From: James Courtier-D. <Ja...@su...> - 2002-11-27 01:34:36
|
Heiko Schaefer wrote: >Update of /cvsroot/xine/xine-lib/src/xine-engine >In directory sc8-pr-cvs1:/tmp/cvs-serv12622 > >Modified Files: > osd.c >Log Message: >seems the closedir doesn't break passthrough anymore > > Closedir() never was the cause. I suspect that the problem was XRUNs and removing "closedir()" just modified the scheduling enough to fix the apparent problem. As you may have noticed, I rewrote some of "audio_out.c" recently, so that when it is used with alsa, it is actually approximating a "callback" audio model. I also changed the buffer and period setting code a bit. Now, the "audio out loop" will sit waiting blocked by the kernel in the write function. The kernel will only schedule audio out loop when there is free space in the audio buffer. When audio out does get scheduled, it immediately does a write to the audio card, thus reducing the amount of XRUNs as much as possible, it then goes round the loop, and decides which audio samples to use next time, then returns to the blocked state, waiting for the audio buffer to free up enough samples again. The current state of xine audio out (xine-lib CVS) seems to work well, so I don't think I have broken anything. There are some improvements I could still make, like making sure that there are always enough samples waiting to be written to the sound card immeadiately each time it unblocks, instead of the current method of just holding what ever samples are left from the current fifo buffer. At the moment, we can still get XRUNs, because we could have a fifo buffer with 1536 samples in it. The first write could send 1500 samples, leaving only 36 samples to go. So, we sit blocked until the buffer is free enough and then try to write only 36 samples, we then have to go all round the loop again before we can find the other 1464 samples that the sound hardware requires. A better approach would be to make sure that we always have 2*period samples ready to write to the sound card at each "block". This would mean re-writing all the audio out plugins, and change the api a bit there. The api would change the "write" function (e.g. in audio_alsa_out) into a function that makes "callbacks" to xine-engine/audio_out.c I am pretty sure that I could get this working for oss and alsa, but I have no way of testing of even knowing if it is possible to do this with the other audio plugins. Can anyone advise me? Cheers James Cheers James |