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

Jaroslav Kysela perex at perex.cz
Fri Dec 17 09:08:36 CET 2010


On Fri, 17 Dec 2010, Manu Abraham wrote:

> Thanks, that was very helpful. I am looking at it. I did find an issue
> looking at the pointer callback itself straight away.
>
>
> static snd_pcm_uframes_t saa7231_capture_pointer(struct snd_pcm_substream *pcm)
> {
> 	struct saa7231_audio *audio	= snd_pcm_substream_chip(pcm);
> 	struct saa7231_dev *saa7231	= audio->saa7231;
> 	struct snd_pcm_runtime *rt	= pcm->runtime;
>
> 	dprintk(SAA7231_DEBUG, 1, "DEBUG:()");
> 	return bytes_to_frames(rt, audio->index * audio->pages * PAGE_SIZE);
> }
>
> audio->pages is the whole number of pages for all the 8 buffers; Fixed
> that issue, run it again, this time arecord stated just a single
> overrun
>
> static snd_pcm_uframes_t saa7231_capture_pointer(struct snd_pcm_substream *pcm)
> {
> 	struct saa7231_audio *audio	= snd_pcm_substream_chip(pcm);
> 	struct saa7231_dev *saa7231	= audio->saa7231;
> 	struct snd_pcm_runtime *rt	= pcm->runtime;
> 	u32 frames;
>
> 	frames = bytes_to_frames(rt, audio->index * (audio->pages /
> XS2D_BUFFERS) * PAGE_SIZE);
> 	dprintk(SAA7231_DEBUG, 1, "DEBUG:() Index:%d with frames:%d, total %d
> pages", audio->index, frames, audio->pages);
> 	return frames;
> }
>
>
> 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.006 ms long)
> ^CAborted by signal Interrupt...
>
> The logs do look thus now: http://pastebin.ca/2021872

This is your problem (first irq_handler):

saa7231_irq_handler (0): status=0x800 vector=43 event=43 handler:f83b91ff
saa7231_capture_pointer (0): DEBUG:() Index:0 with frames:0, total 48 pages
saa7231_capture_trigger (0): Trying to STOP stream, cmd=0

The pointer should return how many samples are filled (probably value 
6144 in your case). The midlevel code expects that at least one period has 
been recorded, but your pointer() callbacks returned 0 here. It is 
wrong. Ignoring STOP/START is just a bad workaround for the broken 
driver.

> Now, I do get a .wav file The contents of which seems to be junk ??
>
> http://202.88.242.108:8000/test/test.wav
>
> Tried to play it back with alsaplayer and mplyer with no results,
> mplayer shows no issues though.. Maybe PCM corruptions ? But at least
> some noises it should make  ?

Try add some printk directly to the driver to show the few recorded 
samples in the DMA buffers.

 						Jaroslav

-----
Jaroslav Kysela <perex at perex.cz>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.



More information about the Alsa-devel mailing list