private bool StreamAudio() { // The size of our abstracted buffer. const int BUFFER_SIZE = 4096 * 2; // Store our abstracted buffer into here. List <float> data = new List <float>(); // We'll store this here, so alBufferData can use it too. TheoraPlay.THEORAPLAY_AudioPacket currentAudio; currentAudio.channels = 0; currentAudio.freq = 0; // There might be an initial period of silence, so forcibly push through. while (audioStream.State == SoundState.Stopped && TheoraPlay.THEORAPLAY_availableAudio(Video.theoraDecoder) == 0) { ; } // Add to the buffer from the decoder until it's large enough. while (data.Count < BUFFER_SIZE && TheoraPlay.THEORAPLAY_availableAudio(Video.theoraDecoder) > 0) { IntPtr audioPtr = TheoraPlay.THEORAPLAY_getAudio(Video.theoraDecoder); currentAudio = TheoraPlay.getAudioPacket(audioPtr); data.AddRange( TheoraPlay.getSamples( currentAudio.samples, currentAudio.frames * currentAudio.channels ) ); TheoraPlay.THEORAPLAY_freeAudio(audioPtr); } // If we actually got data, buffer it into OpenAL. if (data.Count > 0) { audioStream.SubmitFloatBuffer( data.ToArray(), currentAudio.channels, currentAudio.freq ); return(true); } return(false); }