Okay, I changed sleep time from 92ms to 20ms, and I don't notice any more CPU usage (program uses 0-3% CPU). I listened to a stream for many minutes and there seemed to be no interrupt.
Maybe that's really the solution now :)
OpenAL Streaming (Queue Buffers)
I had the same problem. When the buffers are depleted it stopped. I solved it by remembering what state it should be in then querying OpenAL for the state it is in. When it should be playing but isn't I just call alSourcePlay again:
if( Stop && BufferQueue.empty() ) { InfoLog << "Stopping sound because we reached end of file" << endl; alSourceStop( Sources[ 0 ] ); State = eStopped; Reset(); } else { ALenum ALState = 0; alGetSourcei( Sources[ 0 ], AL_SOURCE_STATE, &ALState); if( ALState != AL_PLAYING) { InfoLog << "Starting sound (or resuming sound because we ran out of buffers)" << endl; alSourcePlay( Sources[ 0 ] ); } }
Quote:
Original post by coyote-developmentQuote:Original post by KulSeran
There is a really good chance that you are going to miss your window (windows is granular on sleeps with about 15ms of jitter).
What do you mean by that? What does a thread in the background have to do with a window?
I assumed you were working on Windows(tm) the operating system. Linux has similar issues with sleep, but the scheduler is different and so the jitter is different (and I don't recall the average skew on a sleep). On Windows(tm), sleeps tend to skew to the next multiple of 15ms. So, by sleeping for too much time, there is a good chance your app "misses" the opportunity to update the buffers.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement