MoonWorks/src/Video/StreamingSoundTheora.cs

45 lines
846 B
C#

using System;
using MoonWorks.Audio;
namespace MoonWorks.Video
{
public unsafe class StreamingSoundTheora : StreamingSound
{
private IntPtr VideoHandle;
public override int BUFFER_SIZE => 4096 * 2;
internal StreamingSoundTheora(
AudioDevice device,
IntPtr videoHandle,
int channels,
uint sampleRate
) : base(
device,
3, /* float type */
32, /* size of float */
(ushort) (4 * channels),
(ushort) channels,
sampleRate
) {
VideoHandle = videoHandle;
}
protected override unsafe void FillBuffer(
void* buffer,
int bufferLength,
out int filledLength,
out bool reachedEnd
) {
int samples = Theorafile.tf_readaudio(
VideoHandle,
(IntPtr) buffer,
bufferLength
);
filledLength = samples * sizeof(float);
reachedEnd = Theorafile.tf_eos(VideoHandle) == 1;
}
}
}