From: Chris I. <wil...@us...> - 2003-08-10 02:10:18
|
I am having trouble getting alsa to output clean audio, every thing I have tried so far has resulted in very broken sound. I have attached the latest attempt. What I am trying to do (in write_alsa_output) is wait till the buffer is empty, fill it, and keep doing this till there is no more data. output_data is 16bit signed stereo data, output_size is the count in byte. I do have an oss version of this but it doesn't work with alsa's oss emulation on my stsyem. The oss version has a look at where the driver is reading from in the buffer, and if there is enough space between the read and write poiters it writes the data, without overwriting the drivers read position, and does this till there is no more. I tried a simular thing with alsa but failed misrably. ie: see how many frames are available, write to those frames, commit those frames ... but this was the wrong approach and also resulted in broken audio output. What I need is to know where alsa is reading from in the buffer, so I can write behind it. This needs to be non-blocking and mmap'd due to the whole program taking advantage of the delay between writing to the buffer and actual output to do heavier loads at times and catch up when the load aint so heavey. Please can you point out where I have gone wrong, and possable solutions. ps: I tried that wave generator example in the source, but I ended up getting the same broken sound result. Hope you can help. Thankx in advance Chris Ison |