diff --git a/src/Audio/StreamingSound.cs b/src/Audio/StreamingSound.cs index eac63fd..4982544 100644 --- a/src/Audio/StreamingSound.cs +++ b/src/Audio/StreamingSound.cs @@ -14,7 +14,7 @@ namespace MoonWorks.Audio private readonly IntPtr[] buffers; private int nextBufferIndex = 0; private uint queuedBufferCount = 0; - public abstract int BUFFER_SIZE { get; } + protected abstract int BUFFER_SIZE { get; } public unsafe StreamingSound( AudioDevice device, @@ -147,8 +147,8 @@ namespace MoonWorks.Audio protected unsafe abstract void FillBuffer( void* buffer, - int bufferLength, /* in bytes */ - out int filledLength, /* in bytes */ + int bufferLengthInBytes, /* in bytes */ + out int filledLengthInBytes, /* in bytes */ out bool reachedEnd ); diff --git a/src/Audio/StreamingSoundOgg.cs b/src/Audio/StreamingSoundOgg.cs index d33ce17..1b44e55 100644 --- a/src/Audio/StreamingSoundOgg.cs +++ b/src/Audio/StreamingSoundOgg.cs @@ -1,20 +1,16 @@ using System; using System.IO; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace MoonWorks.Audio { public class StreamingSoundOgg : StreamingSoundSeekable { - // FIXME: what should this value be? - public override int BUFFER_SIZE => 1024 * 128; - private IntPtr VorbisHandle; private IntPtr FileDataPtr; private FAudio.stb_vorbis_info Info; - private readonly float[] buffer; // currently decoded bytes + protected override int BUFFER_SIZE => 32768; public unsafe static StreamingSoundOgg Load(AudioDevice device, string filePath) { @@ -56,7 +52,6 @@ namespace MoonWorks.Audio FileDataPtr = fileDataPtr; VorbisHandle = vorbisHandle; Info = info; - buffer = new float[BUFFER_SIZE]; } public override void Seek(uint sampleFrame) diff --git a/src/Video/StreamingSoundTheora.cs b/src/Video/StreamingSoundTheora.cs index 52a8ac7..a49c939 100644 --- a/src/Video/StreamingSoundTheora.cs +++ b/src/Video/StreamingSoundTheora.cs @@ -1,4 +1,4 @@ -using System; +using System; using MoonWorks.Audio; namespace MoonWorks.Video @@ -6,8 +6,7 @@ namespace MoonWorks.Video public unsafe class StreamingSoundTheora : StreamingSound { private IntPtr VideoHandle; - - public override int BUFFER_SIZE => 4096 * 2; + protected override int BUFFER_SIZE => 8192; internal StreamingSoundTheora( AudioDevice device, @@ -27,17 +26,19 @@ namespace MoonWorks.Video protected override unsafe void FillBuffer( void* buffer, - int bufferLength, - out int filledLength, + int bufferLengthInBytes, + out int filledLengthInBytes, out bool reachedEnd ) { + var lengthInFloats = bufferLengthInBytes / sizeof(float); + int samples = Theorafile.tf_readaudio( VideoHandle, (IntPtr) buffer, - bufferLength + lengthInFloats ); - filledLength = samples * sizeof(float); + filledLengthInBytes = samples * sizeof(float); reachedEnd = Theorafile.tf_eos(VideoHandle) == 1; } }