コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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;
            }
        }
コード例 #4
0
 internal bool RemoveStream(OggStream stream)
 {
     lock (iterationMutex)
         return(streams.Remove(stream));
 }
コード例 #5
0
 internal bool AddStream(OggStream stream)
 {
     lock (iterationMutex)
         return(streams.Add(stream));
 }