LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Sound code causes code to pause (https://www.linuxquestions.org/questions/programming-9/sound-code-causes-code-to-pause-787051/)

knobby67 02-04-2010 01:18 PM

Sound code causes code to pause
 
Hi all
I'm using alsa libasound to write some embedded code. When I play a sound using snd_pcm_writei it causes the code to pause. Can some one whose done this advise, am I doing something wrong or do I need to set off threads to play sound? I'm not to keen on threads as it's an embedded board. Thanks :)

ta0kira 02-06-2010 05:28 PM

I haven't written sound code, but it might be that the sound driver isn't buffered at the kernel level, causing your process to block while it waits for the driver to read. Do you have access to a file descriptor? If so, set it to non-blocking and see what happens. Otherwise, you might just need to use a separate thread for the sound or regulate the bit-rate manually with nanosleep. You might also ps your process and see what the status is when it's paused. That should tell you if it's blocked for I/O.
Kevin Barry

knobby67 02-07-2010 03:26 AM

I've since found out at this level you have to buffer sound and write chunks on sound interrupts. Unfortunately there's very little documentation on this :s So I'm very slowly working my way into it. I would have thought the web would be full of examples/tutorials on this but it isn't. Lot's show you how to start the card and write a single sound, but few how to use interrupt driven and as far as I can tell none how to use interrupt driven with memmap.


All times are GMT -5. The time now is 08:29 PM.