mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-11-10 06:05:43 +01:00
axfer: add an option to dump available hardware parameters
In ALSA PCM interface, before configuring hardware actually, applications can request available set of hardware parameters for runtime of PCM substream. The set of parameters are represented and delivered by a structure. In alsa-lib PCM API, the above design is abstracted by a series of snd_pcm_hw_params_xxx() functions. An actual layout of the structure is hidden from applications by an opaque pointer. In aplay, '--dump-hw-params' option is for this purpose. With this option, the command output available set of the hardware parameters. This commit adds support for the option. Unlike aplay, this commit takes this program to finish after dumping the parameters for simplicity of usage. I note that all of combinations in the set are not necessarily available when the PCM substream includes dependencies of parameters described by constraints and rules. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
2b4d826893
commit
ae378611b7
4 changed files with 16 additions and 1 deletions
|
@ -447,7 +447,7 @@ int subcmd_transfer(int argc, char *const *argv, snd_pcm_stream_t direction)
|
|||
err = context_init(&ctx, direction, argc, argv);
|
||||
if (err < 0)
|
||||
goto end;
|
||||
if (ctx.xfer.help)
|
||||
if (ctx.xfer.help || ctx.xfer.dump_hw_params)
|
||||
goto end;
|
||||
|
||||
err = context_pre_process(&ctx, direction, &expected_frame_count);
|
||||
|
|
|
@ -99,6 +99,15 @@ static int open_handle(struct xfer_context *xfer)
|
|||
|
||||
// TODO: Applying NO_PERIOD_WAKEUP should be done here.
|
||||
|
||||
if (xfer->dump_hw_params) {
|
||||
logging(state, "Available HW Params of node: %s\n",
|
||||
snd_pcm_name(state->handle));
|
||||
snd_pcm_hw_params_dump(state->hw_params, state->log);
|
||||
// TODO: there're more parameters which are not dumped by
|
||||
// alsa-lib.
|
||||
return 0;
|
||||
}
|
||||
|
||||
return set_access_hw_param(state);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
enum no_short_opts {
|
||||
// 128 or later belong to non us-ascii character set.
|
||||
OPT_XFER_TYPE = 128,
|
||||
OPT_DUMP_HW_PARAMS,
|
||||
};
|
||||
|
||||
static int allocate_paths(struct xfer_context *xfer, char *const *paths,
|
||||
|
@ -244,6 +245,8 @@ int xfer_options_parse_args(struct xfer_context *xfer,
|
|||
{"file-type", 1, 0, 't'},
|
||||
// For mapper.
|
||||
{"separate-channels", 0, 0, 'I'},
|
||||
// For debugging.
|
||||
{"dump-hw-params", 0, 0, OPT_DUMP_HW_PARAMS},
|
||||
};
|
||||
char *s_opts;
|
||||
struct option *l_opts;
|
||||
|
@ -302,6 +305,8 @@ int xfer_options_parse_args(struct xfer_context *xfer,
|
|||
xfer->cntr_format_literal = arg_duplicate_string(optarg, &err);
|
||||
else if (key == 'I')
|
||||
xfer->multiple_cntrs = true;
|
||||
else if (key == OPT_DUMP_HW_PARAMS)
|
||||
xfer->dump_hw_params = true;
|
||||
else if (key == '?')
|
||||
return -EINVAL;
|
||||
else {
|
||||
|
|
|
@ -34,6 +34,7 @@ struct xfer_context {
|
|||
unsigned int samples_per_frame;
|
||||
bool help:1;
|
||||
bool quiet:1;
|
||||
bool dump_hw_params:1;
|
||||
bool multiple_cntrs:1; // For mapper.
|
||||
|
||||
snd_pcm_format_t sample_format;
|
||||
|
|
Loading…
Reference in a new issue