Sign in to follow this  

[Solved] OpenAL source playing

This topic is 3498 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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]

Share this post


Link to post
Share on other sites
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

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[i] != 0)
{
// Get the number of buffers that have already been processed
alGetSourcei(m_vStreams[i]->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[i]->nSource, 1, &nALbuffer);

// Read in the data for the buffer
while (nReadSoFar < BUFFER_SIZE)
{
nBytesRead = ov_read(&m_vStreams[i]->OggStream, buffer + nReadSoFar, BUFFER_SIZE - nReadSoFar, 0, 2, 1, &bitstream);
if (nBytesRead == 0)
break;
nReadSoFar += nBytesRead;
}
alBufferData(nALbuffer, m_vStreams[i]->nFormat, buffer, nReadSoFar, m_vStreams[i]->nFrequency);

// Put the buffer with the new data on the back of the queue
alSourceQueueBuffers(m_vStreams[i]->nSource, 1, &nALbuffer);
--nProcessedBuffers;
}
}
}



Any assistance with this is greatly appreciated.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

This topic is 3498 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this