public static unsafe WaveFormat MarshalFrom(IntPtr pointer) { if (pointer == IntPtr.Zero) { return((WaveFormat)null); } WaveFormat.__PcmNative @ref = *(WaveFormat.__PcmNative *)(void *) pointer; WaveFormatEncoding waveFormatEncoding = @ref.waveFormatTag; if ((int)@ref.channels <= 2 && (waveFormatEncoding == WaveFormatEncoding.Pcm || waveFormatEncoding == WaveFormatEncoding.IeeeFloat || (waveFormatEncoding == WaveFormatEncoding.Wmaudio2 || waveFormatEncoding == WaveFormatEncoding.Wmaudio3))) { WaveFormat waveFormat = new WaveFormat(); waveFormat.__MarshalFrom(ref @ref); return(waveFormat); } else if (waveFormatEncoding == WaveFormatEncoding.Extensible) { WaveFormatExtensible formatExtensible = new WaveFormatExtensible(); formatExtensible.__MarshalFrom(ref *(WaveFormatExtensible.__Native *)(void *) pointer); return((WaveFormat)formatExtensible); } else { if (waveFormatEncoding != WaveFormatEncoding.Adpcm) { throw new InvalidOperationException(string.Format("Unsupported WaveFormat [{0}]", (object)waveFormatEncoding)); } WaveFormatAdpcm waveFormatAdpcm = new WaveFormatAdpcm(); waveFormatAdpcm.__MarshalFrom(ref *(WaveFormatAdpcm.__Native *)(void *) pointer); return((WaveFormat)waveFormatAdpcm); } }
internal void __MarshalTo(ref WaveFormat.__PcmNative @ref) { @ref.waveFormatTag = this.waveFormatTag; @ref.channels = this.channels; @ref.sampleRate = this.sampleRate; @ref.averageBytesPerSecond = this.averageBytesPerSecond; @ref.blockAlign = this.blockAlign; @ref.bitsPerSample = this.bitsPerSample; }
internal void __MarshalFrom(ref WaveFormat.__PcmNative @ref) { this.waveFormatTag = @ref.waveFormatTag; this.channels = @ref.channels; this.sampleRate = @ref.sampleRate; this.averageBytesPerSecond = @ref.averageBytesPerSecond; this.blockAlign = @ref.blockAlign; this.bitsPerSample = @ref.bitsPerSample; this.extraSize = (short)0; }
internal void __MarshalFree(ref WaveFormat.__PcmNative @ref) { @ref.__MarshalFree(); }