47 lines
996 B
C#
47 lines
996 B
C#
|
using System;
|
||
|
using MoonWorks.Audio;
|
||
|
|
||
|
namespace MoonWorks.Video
|
||
|
{
|
||
|
public unsafe class StreamingSoundTheora : StreamingSound
|
||
|
{
|
||
|
public IntPtr VideoHandle;
|
||
|
|
||
|
public override SoundState State { get => throw new System.NotImplementedException(); protected set => throw new System.NotImplementedException(); }
|
||
|
|
||
|
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 AddBuffer(
|
||
|
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;
|
||
|
}
|
||
|
}
|
||
|
}
|