private unsafe void PutInStreamIfDataAvailable() { AudioBuffer currentBuffer = buffers[nextBufferIndex]; try { var bufferData = new byte[4096]; video.ReadMusicBytes(bufferData, bufferData.Length); fixed(byte *ptr = &bufferData[0]) currentBuffer.AudioDataPointer = (IntPtr)ptr; currentBuffer.AudioBytes = bufferData.Length; int blockAlign = video.Channels * 2; currentBuffer.PlayLength = bufferData.Length / blockAlign; } catch { isAbleToStream = false; return; } isAbleToStream = true; source.SubmitSourceBuffer(currentBuffer, null); nextBufferIndex = (nextBufferIndex + 1) % NumberOfBuffers; }
protected bool Stream(int buffer) { try { byte[] bufferData = new byte[4096]; video.ReadMusicBytes(bufferData, bufferData.Length); openAL.BufferData(buffer, format, bufferData, bufferData.Length, video.Samplerate); openAL.QueueBufferInChannel(buffer, channelHandle); } catch { return(false); } return(true); }
private void PutInStreamIfDataAvailable() { AudioBuffer currentBuffer = buffers[nextBufferIndex]; try { var bufferData = new byte[4096]; video.ReadMusicBytes(bufferData, bufferData.Length); var bufferStream = new MemoryStream(bufferData); currentBuffer.AudioData = bufferStream; currentBuffer.AudioBytes = bufferData.Length; int blockAlign = video.Channels * 2; currentBuffer.PlayLength = bufferData.Length / blockAlign; } catch { isAbleToStream = false; return; } isAbleToStream = true; source.SubmitSourceBuffer(currentBuffer); nextBufferIndex = (nextBufferIndex + 1) % NumberOfBuffers; }