public void Convert(byte[] sourceBuffer, int count) { if (count % _sourceFormat.BlockAlign != 0 || count == 0) { Debug.WriteLine("No valid number of bytes to convert. Parameter: count"); count -= (count % _sourceFormat.BlockAlign); } Array.Copy(sourceBuffer, _sourceBuffer, count); _header.inputBufferLength = count; _header.inputBufferLengthUsed = count; AcmException.Try(AcmInterop.acmStreamConvert( _handle, _header, _flags), "acmStreamConvert"); _flags = AcmConvertFlags.ACM_STREAMCONVERTF_BLOCKALIGN; }
public byte[] Convert(byte[] source, int offset, int length, bool isEnd) { if (!this.opened) { throw new InvalidOperationException(); } // Copy data to source pointer this.header.cbSrcLength = length; this.header.cbSrcLengthUsed = 0; this.header.cbDstLengthUsed = 0; Marshal.Copy(source, offset, this.header.pbSrc, length); // Convert source AcmConvertFlags flags = AcmConvertFlags.None; if (!isStart && !isEnd) { flags = AcmConvertFlags.BlockAlign; } if (this.isStart) { flags |= AcmConvertFlags.Start; this.isStart = false; } if (isEnd) { flags |= AcmConvertFlags.End; } int mmr = AcmInterop.acmStreamConvert(this.pStream, ref this.header, (int)flags); if (mmr != 0) { throw new SoundException("acmStreamConvert", mmr); } // Copy data from source pointer to byte array int destLength = this.header.cbDstLengthUsed; byte[] dest = new byte[destLength]; Marshal.Copy(this.header.pbDst, dest, 0, destLength); return(dest); }
public static extern MmResult acmStreamConvert( IntPtr acmStreamHandle, [In, Out] NativeAcmHeader header, AcmConvertFlags flags);