Avoiding buffer underruns in the hardware interrupt handler

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi everybody.

Disclaimer: I'm new with ALSA development and I'm trying to digest the large 
amount of information I'm overflowed with, so please bear with possibly stupid 
help requests.

I'm writing an ALSA driver for a playback device. Unlike most sound cards, 
this device uses private memory for its audio buffer. I thus need to manually 
copy data from the ALSA buffer to the device buffer in the driver.

The device audio buffer is quite small, and for this reason I'd rather not use 
the copy/silence callbacks, but copy data from the ALSA buffer to the device 
in interrupt.

The device might generate interrupts a bit faster than what would be expected 
from sampling rate, so I need to check in the interrupt handler how much data 
the ALSA buffer holds. To do so I need to maintain a "hardware pointer" in the 
driver and to access the "user pointer" on the other side of the buffer.

I haven't found a clear API to access that second pointer. What is the 
best/preferred way to find out how much data the ALSA buffer holds ? I suppose 
I will need to perform some locking when accessing the "user pointer", I will 
also appreciate advices regarding which mutex/spinlock I should use for that 
purpose.

Best regards,

Laurent Pinchart

_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux