[Solved] OpenAL source playing
I have been trying to use streaming sound in OpenAL and for some reason when I try to load buffers after playing of other files starts, the new sound will not play. Is there a major delay between being able to play a sound and loading data into a buffer?
[Edited by - DarkShogun on May 15, 2008 2:53:09 PM]
Alright I was incorrect about diagnosing the problem. Right now I'm trying to play three different sets of buffers to stream audio. Two buffers are being used in a queued fashion, When I try to play these streams, it will only play one at a time. I'm assuming this would be something wrong with my buffer update function.
This is what I have for my update.
m_vStreams is a vector of pointers to structures I made
OggStream is the OggVorbis_File
nSource is the handle to the source given by OpenAL
Any assistance with this is greatly appreciated.
This is what I have for my update.
m_vStreams is a vector of pointers to structures I made
OggStream is the OggVorbis_File
nSource is the handle to the source given by OpenAL
ALuint nALbuffer; int nProcessedBuffers; int nBytesRead = 0; int nReadSoFar = 0; int bitstream; char buffer[BUFFER_SIZE]; for (unsigned int i = 0; i < m_vStreams.size(); ++i) { if (m_vStreams != 0) { // Get the number of buffers that have already been processed alGetSourcei(m_vStreams->nSource, AL_BUFFERS_PROCESSED, &nProcessedBuffers); // For each processed buffer, replace with new data and add back to the queue while (nProcessedBuffers > 0) { // Take the first processed buffer off the queue alSourceUnqueueBuffers(m_vStreams->nSource, 1, &nALbuffer); // Read in the data for the buffer while (nReadSoFar < BUFFER_SIZE) { nBytesRead = ov_read(&m_vStreams->OggStream, buffer + nReadSoFar, BUFFER_SIZE - nReadSoFar, 0, 2, 1, &bitstream); if (nBytesRead == 0) break; nReadSoFar += nBytesRead; } alBufferData(nALbuffer, m_vStreams->nFormat, buffer, nReadSoFar, m_vStreams->nFrequency); // Put the buffer with the new data on the back of the queue alSourceQueueBuffers(m_vStreams->nSource, 1, &nALbuffer); --nProcessedBuffers; } } }
Any assistance with this is greatly appreciated.
I figured out the problem... i dumbly forgot to reset nReadSoFar to 0 so it wouldnt just keep the same buffer info in there.
Can you post your code?
BTW, I tried to do that few days ago, but I was unsuccesful. When I played some sounds, I could hear a strange sound at the end, sometimes even the beginning of the same sound. I thought it was a problem playing the end of the last buffer, but I couldnt solve it.
Thanks a lot.
BTW, I tried to do that few days ago, but I was unsuccesful. When I played some sounds, I could hear a strange sound at the end, sometimes even the beginning of the same sound. I thought it was a problem playing the end of the last buffer, but I couldnt solve it.
Thanks a lot.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement