buffer size tweaks

pull/20/head
cosmonaut 2022-08-02 13:50:03 -07:00
parent c5b9ff1677
commit 3e0fcdedb1
3 changed files with 12 additions and 16 deletions

View File

@ -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
);

View File

@ -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)

View File

@ -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;
}
}