mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-11-14 18:05:42 +01:00
axfer: add informative output and an option to suppress it
In current aplay, some informative output is available as a default. This can be suppressed by a quiet option. This commit adds support for it. An original aplay implementation has no effect of this option in a case to handle multiple files. However, in a point of usability, this commit support this case. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
3266d71c0d
commit
2b4d826893
3 changed files with 32 additions and 1 deletions
|
@ -340,6 +340,21 @@ static int context_process_frames(struct context *ctx,
|
||||||
int i;
|
int i;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
|
if (!ctx->xfer.quiet) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"%s: Format '%s', Rate %u Hz, Channels ",
|
||||||
|
snd_pcm_stream_name(direction),
|
||||||
|
snd_pcm_format_description(ctx->xfer.sample_format),
|
||||||
|
ctx->xfer.frames_per_second);
|
||||||
|
if (ctx->xfer.samples_per_frame == 1)
|
||||||
|
fprintf(stderr, "'monaural'");
|
||||||
|
else if (ctx->xfer.samples_per_frame == 2)
|
||||||
|
fprintf(stderr, "'Stereo'");
|
||||||
|
else
|
||||||
|
fprintf(stderr, "%u", ctx->xfer.samples_per_frame);
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
*actual_frame_count = 0;
|
*actual_frame_count = 0;
|
||||||
while (!ctx->interrupted) {
|
while (!ctx->interrupted) {
|
||||||
struct container_context *cntr;
|
struct container_context *cntr;
|
||||||
|
@ -370,6 +385,18 @@ static int context_process_frames(struct context *ctx,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!ctx->xfer.quiet) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"%s: Expected %lu frames, Actual %lu frames\n",
|
||||||
|
snd_pcm_stream_name(direction), expected_frame_count,
|
||||||
|
*actual_frame_count);
|
||||||
|
if (ctx->interrupted) {
|
||||||
|
fprintf(stderr, "Aborted by signal: %s\n",
|
||||||
|
strsignal(ctx->signal));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -227,7 +227,7 @@ int xfer_options_parse_args(struct xfer_context *xfer,
|
||||||
const struct xfer_data *data, int argc,
|
const struct xfer_data *data, int argc,
|
||||||
char *const *argv)
|
char *const *argv)
|
||||||
{
|
{
|
||||||
static const char *short_opts = "CPhvf:c:r:t:I";
|
static const char *short_opts = "CPhvqf:c:r:t:I";
|
||||||
static const struct option long_opts[] = {
|
static const struct option long_opts[] = {
|
||||||
// For generic purposes.
|
// For generic purposes.
|
||||||
{"capture", 0, 0, 'C'},
|
{"capture", 0, 0, 'C'},
|
||||||
|
@ -235,6 +235,7 @@ int xfer_options_parse_args(struct xfer_context *xfer,
|
||||||
{"xfer-type", 1, 0, OPT_XFER_TYPE},
|
{"xfer-type", 1, 0, OPT_XFER_TYPE},
|
||||||
{"help", 0, 0, 'h'},
|
{"help", 0, 0, 'h'},
|
||||||
{"verbose", 0, 0, 'v'},
|
{"verbose", 0, 0, 'v'},
|
||||||
|
{"quiet", 0, 0, 'q'},
|
||||||
// For transfer backend.
|
// For transfer backend.
|
||||||
{"format", 1, 0, 'f'},
|
{"format", 1, 0, 'f'},
|
||||||
{"channels", 1, 0, 'c'},
|
{"channels", 1, 0, 'c'},
|
||||||
|
@ -289,6 +290,8 @@ int xfer_options_parse_args(struct xfer_context *xfer,
|
||||||
xfer->help = true;
|
xfer->help = true;
|
||||||
else if (key == 'v')
|
else if (key == 'v')
|
||||||
++xfer->verbose;
|
++xfer->verbose;
|
||||||
|
else if (key == 'q')
|
||||||
|
xfer->quiet = true;
|
||||||
else if (key == 'f')
|
else if (key == 'f')
|
||||||
xfer->sample_format_literal = arg_duplicate_string(optarg, &err);
|
xfer->sample_format_literal = arg_duplicate_string(optarg, &err);
|
||||||
else if (key == 'c')
|
else if (key == 'c')
|
||||||
|
|
|
@ -33,6 +33,7 @@ struct xfer_context {
|
||||||
unsigned int frames_per_second;
|
unsigned int frames_per_second;
|
||||||
unsigned int samples_per_frame;
|
unsigned int samples_per_frame;
|
||||||
bool help:1;
|
bool help:1;
|
||||||
|
bool quiet:1;
|
||||||
bool multiple_cntrs:1; // For mapper.
|
bool multiple_cntrs:1; // For mapper.
|
||||||
|
|
||||||
snd_pcm_format_t sample_format;
|
snd_pcm_format_t sample_format;
|
||||||
|
|
Loading…
Reference in a new issue