All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH - dmix v3 0/1] pcm: dmix: Align slave_hw_ptr to slave period boundary
@ 2018-11-06 12:48 Timo Wischer
  2018-11-06 12:52 ` [PATCH - dmix v3 1/1] " twischer
  2018-11-06 14:27 ` [PATCH - dmix v3 0/1] " Takashi Iwai
  0 siblings, 2 replies; 6+ messages in thread
From: Timo Wischer @ 2018-11-06 12:48 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Laxmi Devi, alsa-devel

[-- Attachment #1: Type: text/plain, Size: 1791 bytes --]

On 10/30/18 14:21, Takashi Iwai wrote:
 > Yes, and is this correct?  Suppose you start a stream at the position
 > one sample before the next period (psize * N + (psize-1)). Then
 > slave_hw_ptr is psize * N.  At the next moment, the dpcm->hw.ptr
 > reaches to psize * (N+1), and snd_pcm_dmix_sync_ptr() gets called.
 > Then slave_hw_ptr will be updated to psize * (N+1) although only one
 > sample has been processed?

I have created a spreadsheet to simulate the behavior of dmix (see 
attachment). I used this sheet to test different corner cases with 
different implementations.
Column B-D describes 3 corner cases with the original implementation. 
Column E-H describes the corner cases with patch v2 applied and column 
I-L describes the corner cases with patch v3.
With patch v3 I was not able to find a corner case which would fail. All 
our internal audio test are also passing fine.

The corner cases are described in the form
N*period+period-1
(N+1)period+1
(N+2)period+1

The first line describes the value of dmix->spcm->hw.ptr when 
snd_pcm_dmix_start() will be called.
The second line describes the hw_ptr when poll() returns for the first 
time and the third line describes the hw_ptr when poll() returns for the 
second time.

In column B is the issue case described when the patch is not applied. 
snd_pcm_avail() returns 2 frames only (B27) but the buffer only contains 
3 frames (B18).
Therefore up to 5 frames are available (a buffer size of 8 frames is 
choosen).

The issue case of patch v2 is shown in column H. snd_pcm_avail() returns 
7 frames (H46) but the buffer contains still 3 frames (H37). Therefore 
there are only 5 frames free to overwrite.

Do you see any corner cases which I missed or any other drawbacks?

Best regards and thanks for your time

Timo

[-- Attachment #2: dmix_corner_cases.ods --]
[-- Type: application/vnd.oasis.opendocument.spreadsheet, Size: 19794 bytes --]

[-- Attachment #3: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-11-06 16:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-06 12:48 [PATCH - dmix v3 0/1] pcm: dmix: Align slave_hw_ptr to slave period boundary Timo Wischer
2018-11-06 12:52 ` [PATCH - dmix v3 1/1] " twischer
2018-11-06 13:14   ` Takashi Iwai
2018-11-06 14:27 ` [PATCH - dmix v3 0/1] " Takashi Iwai
2018-11-06 16:15   ` Timo Wischer
2018-11-06 16:32     ` Takashi Iwai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.