I am currently having some issues with OpenAL. I start to stream a sound and then call a function which will try to queue what remains of the sound if it is not loaded on the initial play call. At the moment when a large sound is initially played it doesn't update the data on the source.
Here is the source used to try and fill the channels buffer:
private void EnsureBufferFilled(Int32 sourceId, List<Int32> bufferIds)
{
if(!_Registered || bufferIds.Count == 0) return;
Task t = new Task(() =>
{
List<Int32> loadedIds = new List<Int32>();
foreach (Int32 bufferId in bufferIds)
{
if (AL.IsBuffer(bufferId))
{
AL.SourceQueueBuffer(sourceId, bufferId);
loadedIds.Add(bufferId);
}
else break;
}
bufferIds.RemoveRange(0, loadedIds.Count);
if (bufferIds.Count != 0)
{
EnsureBufferFilled(sourceId, bufferIds);
}
});
t.Start();
}
Any help would be greatly appreciated.
Thanks
I found the issue with this was in the below logic:
if (AL.IsBuffer(bufferId))
This was simply checking to see if the buffer was created and not if all the data had been loaded. This meant that when the checks were being performed I was trying to queue buffers without data.
In order to fix this I added an additional check to see if the data relating to the buffer was loaded (a function I wrote into my own custom audio data class).