internal static IntPtr opus_decoder_create(int sampleRate, int channelCount, out OpusErrors error) { int decoder_size = NativeMethods.opus_decoder_get_size(channelCount); IntPtr ptr = Marshal.AllocHGlobal(decoder_size); error = NativeMethods.opus_decoder_init(ptr, MumbleConstants.SAMPLE_RATE, channelCount); return(ptr); }
internal static IntPtr opus_encoder_create(int sampleRate, int channelCount, OpusApplication application, out OpusErrors error) { int size = opus_encoder_get_size(channelCount); IntPtr ptr = Marshal.AllocHGlobal(size); error = opus_encoder_init(ptr, sampleRate, channelCount, (int)application); if (error != OpusErrors.Ok) { if (ptr != IntPtr.Zero) { destroy_opus(ptr); ptr = IntPtr.Zero; } } return(ptr); }