mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-10-29 05:40:25 -04:00
Added verbose flag
This commit is contained in:
parent
77a9f73984
commit
2f1a2513dc
1 changed files with 12 additions and 2 deletions
14
test/pcm.c
14
test/pcm.c
|
|
@ -19,6 +19,7 @@ unsigned int channels = 1; /* count of channels */
|
||||||
unsigned int buffer_time = 500000; /* ring buffer length in us */
|
unsigned int buffer_time = 500000; /* ring buffer length in us */
|
||||||
unsigned int period_time = 100000; /* period time in us */
|
unsigned int period_time = 100000; /* period time in us */
|
||||||
double freq = 440; /* sinusoidal wave frequency in Hz */
|
double freq = 440; /* sinusoidal wave frequency in Hz */
|
||||||
|
int verbose = 0; /* verbose flag */
|
||||||
|
|
||||||
snd_pcm_sframes_t buffer_size;
|
snd_pcm_sframes_t buffer_size;
|
||||||
snd_pcm_sframes_t period_size;
|
snd_pcm_sframes_t period_size;
|
||||||
|
|
@ -148,7 +149,8 @@ static int set_swparams(snd_pcm_t *handle, snd_pcm_sw_params_t *swparams)
|
||||||
printf("Unable to determine current swparams for playback: %s\n", snd_strerror(err));
|
printf("Unable to determine current swparams for playback: %s\n", snd_strerror(err));
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
/* start the transfer when the buffer is almost full */
|
/* start the transfer when the buffer is almost full: */
|
||||||
|
/* (buffer_size / avail_min) * avail_min */
|
||||||
err = snd_pcm_sw_params_set_start_threshold(handle, swparams, (buffer_size / period_size) * period_size);
|
err = snd_pcm_sw_params_set_start_threshold(handle, swparams, (buffer_size / period_size) * period_size);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
printf("Unable to set start threshold mode for playback: %s\n", snd_strerror(err));
|
printf("Unable to set start threshold mode for playback: %s\n", snd_strerror(err));
|
||||||
|
|
@ -698,6 +700,7 @@ static void help(void)
|
||||||
"-b,--buffer ring buffer size in us\n"
|
"-b,--buffer ring buffer size in us\n"
|
||||||
"-p,--period period size in us\n"
|
"-p,--period period size in us\n"
|
||||||
"-m,--method transfer method\n"
|
"-m,--method transfer method\n"
|
||||||
|
"-v,--verbose show the PCM setup parameters\n"
|
||||||
"\n");
|
"\n");
|
||||||
printf("Recognized sample formats are:");
|
printf("Recognized sample formats are:");
|
||||||
for (k = 0; k < SND_PCM_FORMAT_LAST; ++(unsigned long) k) {
|
for (k = 0; k < SND_PCM_FORMAT_LAST; ++(unsigned long) k) {
|
||||||
|
|
@ -724,6 +727,7 @@ int main(int argc, char *argv[])
|
||||||
{"buffer", 1, NULL, 'b'},
|
{"buffer", 1, NULL, 'b'},
|
||||||
{"period", 1, NULL, 'p'},
|
{"period", 1, NULL, 'p'},
|
||||||
{"method", 1, NULL, 'm'},
|
{"method", 1, NULL, 'm'},
|
||||||
|
{"verbose", 1, NULL, 'v'},
|
||||||
{NULL, 0, NULL, 0},
|
{NULL, 0, NULL, 0},
|
||||||
};
|
};
|
||||||
snd_pcm_t *handle;
|
snd_pcm_t *handle;
|
||||||
|
|
@ -741,7 +745,7 @@ int main(int argc, char *argv[])
|
||||||
morehelp = 0;
|
morehelp = 0;
|
||||||
while (1) {
|
while (1) {
|
||||||
int c;
|
int c;
|
||||||
if ((c = getopt_long(argc, argv, "hD:r:c:f:b:p:m:", long_option, NULL)) < 0)
|
if ((c = getopt_long(argc, argv, "hD:r:c:f:b:p:m:v", long_option, NULL)) < 0)
|
||||||
break;
|
break;
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'h':
|
case 'h':
|
||||||
|
|
@ -782,6 +786,9 @@ int main(int argc, char *argv[])
|
||||||
if (transfer_methods[method].name == NULL)
|
if (transfer_methods[method].name == NULL)
|
||||||
method = 0;
|
method = 0;
|
||||||
break;
|
break;
|
||||||
|
case 'v':
|
||||||
|
verbose = 1;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -815,6 +822,9 @@ int main(int argc, char *argv[])
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (verbose > 0)
|
||||||
|
snd_pcm_dump(handle, output);
|
||||||
|
|
||||||
samples = malloc((period_size * channels * snd_pcm_format_width(format)) / 8);
|
samples = malloc((period_size * channels * snd_pcm_format_width(format)) / 8);
|
||||||
if (samples == NULL) {
|
if (samples == NULL) {
|
||||||
printf("No enough memory\n");
|
printf("No enough memory\n");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue