On Fri, 6 Jun 2003, Russell King wrote: > Hi, > > I'm working on some drivers for some custom AC'97 hardware on a > development platform, and am seeing some weird behaviour. > > The development platform is mostly FPGA-based, so it isn't the worlds > most fastest machine. However, running madplay against the OSS > emulation results in the following: > > # time madplay sample.mp3 > ... > 8670 frames decoded (0:03:46.4), +2.2 dB peak amplitude, 3882 clipped samples > 133.99user 19.92system 2:33.95elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k > 0inputs+0outputs (1498major+69minor)pagefaults 0swaps > > Note that the mp3 is 3mins46 long, but we took only 2mins33 to play it! > > When listening to the output, it appears that we're randomly missing > chunks of samples; when I added a printk into my PCM's trigger function, > I noticed that we were frequently calling it with TRIGGER_START/ > TRIGGER_STOP. I suspect this is because the mp3 player can't keep > ALSAs buffers full. > > The driver source can be found at: > > http://patches.arm.linux.org.uk/alsa/aaci.c > > (its not ready for release yet tho. oh, and yes, dma is missing off > the hardware implementation so its currently using PIO, but it is > expected that in real CPUs the device will have DMA available.)
It seems that application is not fast enough to fill the right buffer or the ring buffer pointer is wrong (I think that it is later case because of measured time). I suggest to update ring buffer pointer at the beginning of the interrupt routine to value "just played" rather than "moved to FIFO". Yes, it creates a small window where the samples might be wrong in the ring buffer, but it is better than recover from underruns. Also, FIFO should be pre-filled in trigger-START, too. Jaroslav ----- Jaroslav Kysela <[EMAIL PROTECTED]> Linux Kernel Sound Maintainer ALSA Project, SuSE Labs ------------------------------------------------------- This SF.net email is sponsored by: Etnus, makers of TotalView, The best thread debugger on the planet. Designed with thread debugging features you've never dreamed of, try TotalView 6 free at www.etnus.com. _______________________________________________ Alsa-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/alsa-devel