示例#1
0
        bool IAudioStreamProvider.ReadStream(INativeAudioBuffer targetBuffer)
        {
            if (!OggVorbis.IsStreamValid(this.strOvStr))
            {
                return(false);
            }

            AudioData audioDataRes = this.audioData.Res;
            PcmData   pcm;
            bool      eof = !OggVorbis.StreamChunk(this.strOvStr, out pcm);

            if (eof)
            {
                OggVorbis.EndStream(ref this.strOvStr);
                if (this.looped)
                {
                    OggVorbis.BeginStreamFromMemory(audioDataRes.OggVorbisData, out this.strOvStr);
                    if (pcm.DataLength == 0)
                    {
                        eof = !OggVorbis.StreamChunk(this.strOvStr, out pcm);
                    }
                    else
                    {
                        eof = false;
                    }
                }
            }

            if (pcm.DataLength > 0)
            {
                targetBuffer.LoadData(
                    pcm.SampleRate,
                    pcm.Data,
                    pcm.DataLength,
                    pcm.ChannelCount == 1 ? AudioDataLayout.Mono : AudioDataLayout.LeftRight,
                    AudioDataElementType.Short);
            }

            return(pcm.DataLength != 0 && !eof);
        }
示例#2
0
 void IAudioStreamProvider.CloseStream()
 {
     OggVorbis.EndStream(ref this.strOvStr);
 }
示例#3
0
        void IAudioStreamProvider.OpenStream()
        {
            AudioData audioDataRes = this.audioData.Res;

            OggVorbis.BeginStreamFromMemory(audioDataRes.OggVorbisData, out this.strOvStr);
        }