[alsa-devel] DMA buffer gets played only once
xyzzy at speakeasy.org
Thu Sep 6 15:39:23 CEST 2007
On Thu, 6 Sep 2007, Markus Franke wrote:
> I just found out that the problem of multiple calls of
> TRIGGER_START/TRIGGER_STOP might be caused by using ossplay (oss
> emulation layer) for testing. If I use aplay, TRIGGER_START gets called
> once but then Alsa goes in a loop continuously calling pcm_pointer().
> Return values of pcm_pointer() look like the following:
I found it very helpful to print timestamps for the various calls (trigger,
pointer, and my IRQ handler). The code inside the #if 0, around lines 53 and
191, is what I wrote to use the time cycle counter for accurate timestamps.
> pcm_pointer returns 0
> pcm_pointer returns 1024
> pcm_pointer returns 2048
> pcm_pointer returns 3072
This is where a timestamp would be nice. Is pcm_pointer getting called after
each period is elapsed, in microseconds? Or is the pointer advancing much too
quickly? It should take about 23220 us for the pointer to increase by 1024
frames at 44.1 kHz.
AFAIK, the only way a driver has to communicate with ALSA during pcm capture
or playback is via the return value of the pointer callback, and when and how
often the driver calls snd_pcm_period_elapsed().
If ALSA is detecting an underrun, it must be something about those two
functions that is causing it.
Be sure to check the period and buffer size from the runtime in your
callbacks, if you haven't already. They might not be what you expected them
to be, which would easily explain the problem.
More information about the Alsa-devel