Fix PcmAudioSampleWrapper namespace

Former-commit-id: fc23456eb1
This commit is contained in:
Malte Rosenbjerg 2021-08-05 13:21:57 +02:00
parent b46fd7b2ad
commit d755c1d526
2 changed files with 22 additions and 18 deletions

View file

@ -8,6 +8,7 @@
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using FFMpegCore.Extend;
namespace FFMpegCore.Test namespace FFMpegCore.Test
{ {

View file

@ -1,27 +1,30 @@
using FFMpegCore.Pipes; using System.IO;
using System.IO;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using FFMpegCore.Pipes;
public class PcmAudioSampleWrapper : IAudioSample namespace FFMpegCore.Extend
{ {
//This could actually be short or int, but copies would be inefficient. public class PcmAudioSampleWrapper : IAudioSample
//Handling bytes lets the user decide on the conversion, and abstract the library
//from handling shorts, unsigned shorts, integers, unsigned integers and floats.
private readonly byte[] _sample;
public PcmAudioSampleWrapper(byte[] sample)
{ {
_sample = sample; //This could actually be short or int, but copies would be inefficient.
} //Handling bytes lets the user decide on the conversion, and abstract the library
//from handling shorts, unsigned shorts, integers, unsigned integers and floats.
private readonly byte[] _sample;
public void Serialize(Stream stream) public PcmAudioSampleWrapper(byte[] sample)
{ {
stream.Write(_sample, 0, _sample.Length); _sample = sample;
} }
public async Task SerializeAsync(Stream stream, CancellationToken token) public void Serialize(Stream stream)
{ {
await stream.WriteAsync(_sample, 0, _sample.Length, token); stream.Write(_sample, 0, _sample.Length);
}
public async Task SerializeAsync(Stream stream, CancellationToken token)
{
await stream.WriteAsync(_sample, 0, _sample.Length, token);
}
} }
} }