public bool FillBuffer(OggStream stream, int bufferId) { int readSamples; lock (readMutex) { readSamples = stream.Reader.ReadSamples(readSampleBuffer, 0, BufferSize); CastBuffer(readSampleBuffer, castBuffer, readSamples); } AL.BufferData(bufferId, stream.Reader.Channels == 1 ? ALFormat.Mono16 : ALFormat.Stereo16, castBuffer, readSamples * sizeof(short), stream.Reader.SampleRate); ALHelper.Check(); return(readSamples != BufferSize); }
public static OggStream StartStream(string file, float volume = 1.0f) { if (Disabled) { return(null); } if (oggStreamer == null) { oggStreamer = new OggStreamer(); } oggStream = new OggStream(file); oggStreamer.AddStream(oggStream); oggStream.Play(volume); ALHelper.Check(); return(oggStream); }
public static void Dispose() { if (Disabled) { return; } if (ALHelper.Efx.IsInitialized) { ALHelper.Efx.DeleteFilter(lowpassFilterId); } for (int i = 0; i < DefaultSourceCount; i++) { var state = OpenTK.Audio.OpenAL.AL.GetSourceState(alSources[i]); if (state == OpenTK.Audio.OpenAL.ALSourceState.Playing || state == OpenTK.Audio.OpenAL.ALSourceState.Paused) { Stop(i); } OpenTK.Audio.OpenAL.AL.DeleteSource(alSources[i]); ALHelper.Check(); } if (oggStream != null) { oggStream.Stop(); oggStream.Dispose(); oggStream = null; } if (oggStreamer != null) { oggStreamer.Dispose(); oggStreamer = null; } }
internal bool RemoveStream(OggStream stream) { lock (iterationMutex) return(streams.Remove(stream)); }
internal bool AddStream(OggStream stream) { lock (iterationMutex) return(streams.Add(stream)); }