[alsa-devel] callbacks order while capturing from Line-IN

Manu Abraham abraham.manu at gmail.com
Fri Dec 17 07:13:44 CET 2010


On Fri, Dec 17, 2010 at 10:28 AM, Manu Abraham <abraham.manu at gmail.com> wrote:
> Hi,
>
> By now I am a bit confused.
>
> I am seeing a certain pattern in which the callbacks are invoked:
>
> - hw_params()
> - prepare()
> - trigger(); // Start DMA
> - pointer();
>            --> gets data after interrupt is handled
> - trigger(); // Stop DMA
> - prepare();
> - trigger(); // Start DMA
> - pointer();
>           --> gets data after interrupt is handled
>
> ..
> ..
>
> and so on.
>
> Is this the right behaviour that's expected from a function ALSA
> capture driver ?
> I am trying to understand why there is Start DMA, Stop DMA, Start DMA, Stop DMA
> in a cyclic fashion for each of the interrupts in my setup.


To test my theory that a STOP cmd after an interrupt was giving me the
same buffer location, I did commented out the STOP cmd, as well,
allowing the START cmd to run only if the streaming engine has not
START 'ed.

This allows the interrupt handler to fire correctly with the correct
buffer indices, as seen in the following logs.

http://pastebin.ca/2021840

The problem is that,

1. I don't understand why the application issues a CMD to STOP/START,
after each interrupt.
2. The STOP/START cmds reinitializes the Streaming engine to start
with buffer index:0, therefore always buffer position is at the very
beginning of the buffer.

Additionally, I see these lines:

testbox v4l # arecord -D plughw:2,0 --format S16_LE --rate=48000 -c 2
> /tmp/test.wav
Recording WAVE 'stdin' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
overrun!!! (at least 0.002 ms long)
overrun!!! (at least 0.002 ms long)
overrun!!! (at least 0.002 ms long)
overrun!!! (at least 0.002 ms long)
overrun!!! (at least 0.002 ms long)
overrun!!! (at least 0.002 ms long)
overrun!!! (at least 0.002 ms long)
overrun!!! (at least 0.002 ms long)
overrun!!! (at least 0.002 ms long)
overrun!!! (at least 0.002 ms long)
overrun!!! (at least 0.002 ms long)
overrun!!! (at least 0.002 ms long)
overrun!!! (at least 0.002 ms long)
overrun!!! (at least 0.002 ms long)
overrun!!! (at least 0.002 ms long)
overrun!!! (at least 0.002 ms long)
overrun!!! (at least 0.002 ms long)
overrun!!! (at least 0.006 ms long)
overrun!!! (at least 0.002 ms long)
^CAborted by signal Interrupt...


The hardware information definition looks thus:

static struct snd_pcm_hardware saa7231_capture_info = {
	.info			= (SNDRV_PCM_INFO_MMAP		|
				  SNDRV_PCM_INFO_INTERLEAVED	|
				  SNDRV_PCM_INFO_BLOCK_TRANSFER	|
				  SNDRV_PCM_INFO_MMAP_VALID),

	.formats		= SNDRV_PCM_FMTBIT_S16_LE,
	.rates			= SNDRV_PCM_RATE_48000,

	.rate_min		= 48000,
	.rate_max		= 48000,

	.channels_min		= 2,
	.channels_max		= 2,

	.buffer_bytes_max	= XS2D_BUFFERS * PAGE_SIZE * 512, /* 16,777,216 */

	.period_bytes_min	= 4096,
	.period_bytes_max	= 2097152,

	.periods_min		= 8, //8,
	.periods_max		= 4096, //4096,
};

Where XS2D_BUFFERS = 8


Any help is much appreciated.


Thanks,
Manu


More information about the Alsa-devel mailing list