private static void CheckError(OpusError error) { if (error < 0) { throw new Exception($"Opus Error: {error}"); } }
protected static void CheckError(OpusError error) { if ((int)error < 0) { throw new Exception($"Opus Error: {error}"); } }
protected void CheckError(OpusError error) { if (error < OpusError.OK) { throw new OpusException(error); } }
private void CheckForError(OpusError err) { if (err < 0) { throw new Exception(string.Concat("Opus returned an error: ", err.ToString())); } }
private static string GetMessage(OpusError error) { switch (error) { case OpusError.BadArg: return("One or more invalid/out of range arguments."); case OpusError.BufferTooSmall: return("Not enough bytes allocated in the buffer."); case OpusError.InternalError: return("An internal error was detected."); case OpusError.InvalidPacket: return("The compressed data passed is corrupted."); case OpusError.Unimplemented: return("Invalid/unsupported request number."); case OpusError.InvalidState: return("An encoder or decoder structure is invalid or already freed."); case OpusError.AllocFail: return("Memory allocation has failed."); default: return("An unknown error has occurred."); } }
// Token: 0x0600015E RID: 350 RVA: 0x0000476C File Offset: 0x0000296C public unsafe static int OpusDecode(IntPtr decoder, int frameSize, Span <byte> pcm) { int num; fixed(byte *pinnableReference = pcm.GetPinnableReference()) { byte *data = pinnableReference; num = Interop._OpusDecode(decoder, null, 0, data, frameSize, 1); } if (num < 0) { OpusError opusError = (OpusError)num; throw new Exception(string.Format("Could not decode PCM data from Opus: {0} ({1}).", opusError, (int)opusError)); } return(num); }
// Token: 0x0600015D RID: 349 RVA: 0x000046FC File Offset: 0x000028FC public unsafe static int OpusDecode(IntPtr decoder, ReadOnlySpan <byte> opus, int frameSize, Span <byte> pcm, bool useFec) { int num; fixed(byte *pinnableReference = opus.GetPinnableReference()) { byte *opusData = pinnableReference; fixed(byte *pinnableReference2 = pcm.GetPinnableReference()) { byte *data = pinnableReference2; num = Interop._OpusDecode(decoder, opusData, opus.Length, data, frameSize, useFec ? 1 : 0); } } if (num < 0) { OpusError opusError = (OpusError)num; throw new Exception(string.Format("Could not decode PCM data from Opus: {0} ({1}).", opusError, (int)opusError)); } return(num); }
// Token: 0x0600015B RID: 347 RVA: 0x00004648 File Offset: 0x00002848 public unsafe static void OpusEncode(IntPtr encoder, ReadOnlySpan <byte> pcm, int frameSize, ref Span <byte> opus) { int num; fixed(byte *pinnableReference = pcm.GetPinnableReference()) { byte *pcmData = pinnableReference; fixed(byte *pinnableReference2 = opus.GetPinnableReference()) { byte *data = pinnableReference2; num = Interop._OpusEncode(encoder, pcmData, frameSize, data, opus.Length); } } if (num < 0) { OpusError opusError = (OpusError)num; throw new Exception(string.Format("Could not encode PCM data to Opus: {0} ({1}).", opusError, (int)opusError)); } opus = opus.Slice(0, num); }
public static extern IntPtr CreateEncoder(int Fs, int channels, int application, out OpusError error);
public static extern IntPtr CreateDecoder(int Fs, int channels, out OpusError error);
private static extern IntPtr _OpusCreateDecoder(int sampleRate, int channels, out OpusError error);
IntPtr IOpusConverter.CreateDecoder(int Fs, int channels, out OpusError error) { return(CreateDecoder(Fs, channels, out error)); }
IntPtr IOpusConverter.CreateEncoder(int Fs, int channels, int application, out OpusError error) { return(CreateEncoder(Fs, channels, application, out error)); }
static extern IntPtr op_open_callbacks(IntPtr source, ref _OpusFileCallbacks cb, IntPtr initial_data, IntPtr initial_bytes, out OpusError error);
private static extern IntPtr CreateEncoder(int Fs, int channels, int application, out OpusError error);
public OpusException(OpusError error) : base(error.ToString()) { }
internal static extern IntPtr opus_encoder_create(int sampleRate, int channels, int application, out OpusError error);
private static extern IntPtr OpusCreateEncoder(int sampleRate, int channels, int application, out OpusError error);
internal static extern IntPtr opus_decoder_create(int sampleRate, int channels, out OpusError error);