buffer size tweaks
parent
c5b9ff1677
commit
3e0fcdedb1
|
@ -14,7 +14,7 @@ namespace MoonWorks.Audio
|
||||||
private readonly IntPtr[] buffers;
|
private readonly IntPtr[] buffers;
|
||||||
private int nextBufferIndex = 0;
|
private int nextBufferIndex = 0;
|
||||||
private uint queuedBufferCount = 0;
|
private uint queuedBufferCount = 0;
|
||||||
public abstract int BUFFER_SIZE { get; }
|
protected abstract int BUFFER_SIZE { get; }
|
||||||
|
|
||||||
public unsafe StreamingSound(
|
public unsafe StreamingSound(
|
||||||
AudioDevice device,
|
AudioDevice device,
|
||||||
|
@ -147,8 +147,8 @@ namespace MoonWorks.Audio
|
||||||
|
|
||||||
protected unsafe abstract void FillBuffer(
|
protected unsafe abstract void FillBuffer(
|
||||||
void* buffer,
|
void* buffer,
|
||||||
int bufferLength, /* in bytes */
|
int bufferLengthInBytes, /* in bytes */
|
||||||
out int filledLength, /* in bytes */
|
out int filledLengthInBytes, /* in bytes */
|
||||||
out bool reachedEnd
|
out bool reachedEnd
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,16 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace MoonWorks.Audio
|
namespace MoonWorks.Audio
|
||||||
{
|
{
|
||||||
public class StreamingSoundOgg : StreamingSoundSeekable
|
public class StreamingSoundOgg : StreamingSoundSeekable
|
||||||
{
|
{
|
||||||
// FIXME: what should this value be?
|
|
||||||
public override int BUFFER_SIZE => 1024 * 128;
|
|
||||||
|
|
||||||
private IntPtr VorbisHandle;
|
private IntPtr VorbisHandle;
|
||||||
private IntPtr FileDataPtr;
|
private IntPtr FileDataPtr;
|
||||||
private FAudio.stb_vorbis_info Info;
|
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)
|
public unsafe static StreamingSoundOgg Load(AudioDevice device, string filePath)
|
||||||
{
|
{
|
||||||
|
@ -56,7 +52,6 @@ namespace MoonWorks.Audio
|
||||||
FileDataPtr = fileDataPtr;
|
FileDataPtr = fileDataPtr;
|
||||||
VorbisHandle = vorbisHandle;
|
VorbisHandle = vorbisHandle;
|
||||||
Info = info;
|
Info = info;
|
||||||
buffer = new float[BUFFER_SIZE];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Seek(uint sampleFrame)
|
public override void Seek(uint sampleFrame)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using MoonWorks.Audio;
|
using MoonWorks.Audio;
|
||||||
|
|
||||||
namespace MoonWorks.Video
|
namespace MoonWorks.Video
|
||||||
|
@ -6,8 +6,7 @@ namespace MoonWorks.Video
|
||||||
public unsafe class StreamingSoundTheora : StreamingSound
|
public unsafe class StreamingSoundTheora : StreamingSound
|
||||||
{
|
{
|
||||||
private IntPtr VideoHandle;
|
private IntPtr VideoHandle;
|
||||||
|
protected override int BUFFER_SIZE => 8192;
|
||||||
public override int BUFFER_SIZE => 4096 * 2;
|
|
||||||
|
|
||||||
internal StreamingSoundTheora(
|
internal StreamingSoundTheora(
|
||||||
AudioDevice device,
|
AudioDevice device,
|
||||||
|
@ -27,17 +26,19 @@ namespace MoonWorks.Video
|
||||||
|
|
||||||
protected override unsafe void FillBuffer(
|
protected override unsafe void FillBuffer(
|
||||||
void* buffer,
|
void* buffer,
|
||||||
int bufferLength,
|
int bufferLengthInBytes,
|
||||||
out int filledLength,
|
out int filledLengthInBytes,
|
||||||
out bool reachedEnd
|
out bool reachedEnd
|
||||||
) {
|
) {
|
||||||
|
var lengthInFloats = bufferLengthInBytes / sizeof(float);
|
||||||
|
|
||||||
int samples = Theorafile.tf_readaudio(
|
int samples = Theorafile.tf_readaudio(
|
||||||
VideoHandle,
|
VideoHandle,
|
||||||
(IntPtr) buffer,
|
(IntPtr) buffer,
|
||||||
bufferLength
|
lengthInFloats
|
||||||
);
|
);
|
||||||
|
|
||||||
filledLength = samples * sizeof(float);
|
filledLengthInBytes = samples * sizeof(float);
|
||||||
reachedEnd = Theorafile.tf_eos(VideoHandle) == 1;
|
reachedEnd = Theorafile.tf_eos(VideoHandle) == 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue