[alsa-devel] big latency and buffering question

Achim Herrmann Achim-Herrmann at t-online.de
Fri Oct 2 15:19:01 CEST 2009


Hi,

think the problem in pcm.c is, that period_time is hardcoded to 100000 (us). 
Thus snd_pcm_hw_params_set_period_time_near() returns a high value for period 
time. If I change period_time to buffer_time>>2, a much smaller value for 
buffer_time is returned and sine signal is fine.

Regards
Achim


> Hi all,
>
> I'm completely new to sound and ALSA development and I have to develop an
> application which is capturing periodically a small amount of audio data
> (e.g. 64 frames), doing some processing and doing playback of the result.
>
> I started with ALSA example "pcm.c" to see if ALSA can meet these
> requirements. During investigation i found out, that up to a choosen buffer
> size of 140ms, generated sine sound is fine. Below 140ms, sound is
> stuttering, independent of call method I'm using.
>
> For buffer size of 140ms I found out, that target buffer size is 6174
> frames (at 44.1kHz sample rate), period size is 3087 frames and loop inside
> write_and_poll function is calculated every 70 ms and 3087 frames are
> written. Think this is doublebuffering then, right?
>
> But if I now choose a buffersize of 139 ms or lower, target buffer size and
> period size are always the same. So no double buffering anymore and sound
> is stuttering.
>
> So, currently I'm far away from goal. I'd like to have a buffer size of
> e.g. 128 frames (2ms). Thus, period size should be 64 frames and loop
> should be calculated every 1ms. (If necessary I would use Linux-RT)
>
> If I choose a buffersize of 2ms, sound is far away from being sine :-)
>
> - Can I use ALSA for a application described in first sentence above?
>
> - What do I have to change in pcm.c to be able to create a sine signal
> using a buffersize of e.g. 128 frames and a period size of 64 frames?
>
> Any hints are appreciated
> Thanks in advance
> Achim
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel at alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel



More information about the Alsa-devel mailing list