[pulseaudio-discuss] [PATCH 1/3] alsa-time-test: Add fillrate parameter
Raymond Yau
superquad.vortex2 at gmail.com
Fri Sep 26 20:21:51 PDT 2014
>
> As a third parameter, add the number of samples to read/write in
> every iteration. This will help slow CPUs.
>
> Signed-off-by: David Henningsson <david.henningsson at canonical.com>
> ---
> src/tests/alsa-time-test.c | 22 +++++++++++++---------
> 1 file changed, 13 insertions(+), 9 deletions(-)
>
> diff --git a/src/tests/alsa-time-test.c b/src/tests/alsa-time-test.c
> index 3c82fdc..5d75756 100644
> --- a/src/tests/alsa-time-test.c
> +++ b/src/tests/alsa-time-test.c
> @@ -27,12 +27,14 @@ int main(int argc, char *argv[]) {
> unsigned periods = 2;
> snd_pcm_uframes_t boundary, buffer_size = 44100/10; /* 100s */
> int dir = 1;
> + int fillrate;
> struct timespec start, last_timestamp = { 0, 0 };
> uint64_t start_us, last_us = 0;
> snd_pcm_sframes_t last_avail = 0, last_delay = 0;
> struct pollfd *pollfds;
> int n_pollfd;
> int64_t sample_count = 0;
> + uint16_t *samples;
> struct sched_param sp;
>
> r = -1;
> @@ -54,6 +56,10 @@ int main(int argc, char *argv[]) {
>
> dev = argc > 1 ? argv[1] : "front:AudioPCI";
> cap = argc > 2 ? atoi(argv[2]) : 0;
> + fillrate = argc > 3 ? atoi(argv[3]) : 1;
> +
> + samples = calloc(fillrate, 2*sizeof(uint16_t));
> + assert(samples);
>
> if (cap == 0)
> r = snd_pcm_open(&pcm, dev, SND_PCM_STREAM_PLAYBACK, 0);
> @@ -108,7 +114,7 @@ int main(int argc, char *argv[]) {
>
> r = snd_pcm_hw_params_get_buffer_size(hwparams, &buffer_size);
> assert(r == 0);
> - r = snd_pcm_sw_params_set_start_threshold(pcm, swparams,
buffer_size);
> + r = snd_pcm_sw_params_set_start_threshold(pcm, swparams, buffer_size
- (buffer_size % fillrate));
Start threshold become zero when fillrate > buffer size
The program abort when fillrate > ( buffer_size / periods)
when drivers have hardware specific constraints (e.g. some hda controllers
have 128 bytes alignment step , periods_mins > 2, or period_bytes_max is
less than 2205 * frame size
The buffer time may not be 1 seconds and 0.05 seconds period time
For sound card which can report DMA residue, when your fillrate are not
multiple of DMA brust size, the elasped time between two successive result
is not exactly the fillrate time but with deviation of DMA brust time
time ,
Do the program want to find out
1) whether driver really support arbitrary period size
2) whether driver reprort DMA residue when the fillrate is less than period
size
Not sure why the program always abort when using pulse plugin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/pulseaudio-discuss/attachments/20140927/5390b84d/attachment-0001.html>
More information about the pulseaudio-discuss
mailing list