[alsa-devel] Still have choppy audio using 1.0.17

Gustavo da Silva Serra gustavo.serra at tet.com.br
Tue Jul 15 20:40:00 CEST 2008


Gustavo da Silva Serra escreveu:
> stan escreveu:
>   
>> Gustavo da Silva Serra wrote:
>>   
>>     
>>> I have discovered something else. Choppy audio occurs when 
>>> snd_pcm_playback_silence, in pcm_lib.c, will silence the same period 
>>> than the capture pointer is pointing at. I am printing this variables 
>>> "ofs" in snd_pcm_playback_silence and what is returned from 
>>> snd_card_loopback_pointer when the substream is capture.
>>>
>>> How snd_pcm_playback_silence is supposed to work? Must it silence the 
>>> next period from the playback pointer? How is ensured that this 
>>> situation (ofs == capture pointer) does not happen with sound cards?
>>>
>>> Thanks ANY help... any...
>>>
>>>     
>>>       
>> The way the API docs describe it the silence function 
>> fills the play buffer with a set amount of silence when 
>> the buffer has fewer than threshold frames to play. 
>> So, if your playback is running close to that 
>> threshold, it will be continuously injecting chunks of 
>> silence into the stream.  That would certainly sound 
>> choppy.  From the docs it sounds like the silence is 
>> always injected into the existing stream at the current 
>> pointer.
>>
>> Note:  this is just from reading the docs.  I haven't 
>> actually used this.
>>     
>
> I don't know if the silence function snd_pcm_playback_silence is the 
> same from alsa library. It uses the threshold, but it is not clear for 
> me how. It seems that this function clears the buffer for the new stream 
> arriving, because, from time to time, it silences a whole period.
>
> Thanks for the attention :)
> _______________________________________________
>   
It silences a whole period because the pointer inside aloop behaves like 
that. Logging the pointer inside aloop I discovered that it is 
incremented so fast inside timer function that when pointer function is 
called, the pointer is not being incremented anymore. It is like a 
concurrency issue: first the pointer will be incremented many times, 
after that, the pointer function will be called many times with the same 
pointer value. Later, the pointer will be incremented some more, and so 
on...
I wonder if this is not the problem, logging the pointer for my sound 
card I see a different behavior: the pointer function return offset 
between two periods.


More information about the Alsa-devel mailing list