Alsa Pulse plugin pcm->ptr initialization problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

By looking through the pcm_pulse.c(1.0.18), I found there is a possible error in initializing the pcm->ptr.

Some background: see update_ptr() function in pcm_pulse.c:
Basically the pcm->ptr is increased when pa_stream_writable_size() increases.  The last pa_stream_writable_size() is saved in pcm->last_size,  so if new pa_stream_writable_size() value is larger than pcm->last_size,  the pcm->ptr is increased.    For example,  the pa_stream_writable_size() increases from 800 to 1400,  then pcm->ptr is increased by 400.   Alsa-lib's snd_pcm_ioplug_hw_ptr_update() function is calling pulse_pointer() to get pcm->ptr,  then pcm_ioplug.c calculates the hw.ptr from the changes of pulse_pointer().  The hw.ptr is used in snd_pcm_mmap_playback_avail().

However, there is an issue that during the pulse is started,  the pcm->last_size jumps from 0 to a positive value, which should not be counted as pcm->ptr increase.  It's causing the hw.ptr wrongly calculated.
Wrong senario
      pa_writable   (N/A)  1000    900      800       1200
           pcm->ptr   0        1000    1000    1000     1400    .....
               hw.ptr   0        1000    1000    1000     1400
Correct scenario:
      pa_writable   (N/A)  1000   900      800       1200
           pcm->ptr   0         0        0          0           400    .....
               hw.ptr   0        0         0          0           400
If hw.ptr is incorrectly set larger than actual size,  it causes avail>"real avail" and client sends more data than pulse can accept.

Dake
_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux