static extern int AudioUnitSetProperty(IntPtr inUnit, [MarshalAs(UnmanagedType.U4)] AudioUnitPropertyIDType inID, [MarshalAs(UnmanagedType.U4)] AudioUnitScopeType inScope, [MarshalAs(UnmanagedType.U4)] uint inElement, AURenderCallbackStrct inData, uint inDataSize );
void BrokenSetRender() { var callbackStruct = new AURenderCallbackStrct(); callbackStruct.inputProc = renderCallback; // setting callback function callbackStruct.inputProcRefCon = GCHandle.ToIntPtr(gcHandle); // a pointer that passed to the renderCallback (IntPtr inRefCon) var err = AudioUnitSetProperty(handle, AudioUnitPropertyIDType.SetRenderCallback, AudioUnitScopeType.Input, 0, // 0 == speaker callbackStruct, (uint)Marshal.SizeOf(callbackStruct)); if (err != 0) { throw new AudioUnitException(err); } }
public AudioUnit(AudioComponent component) { if (component == null) { throw new ArgumentNullException("component"); } if (component.Handle == IntPtr.Zero) { throw new ObjectDisposedException("component"); } int err = AudioComponentInstanceNew(component.handle, out handle); if (err != 0) { throw new AudioUnitException(err); } _isPlaying = false; gcHandle = GCHandle.Alloc(this); var callbackStruct = new AURenderCallbackStrct(); callbackStruct.inputProc = renderCallback; // setting callback function callbackStruct.inputProcRefCon = GCHandle.ToIntPtr(gcHandle); // a pointer that passed to the renderCallback (IntPtr inRefCon) err = AudioUnitSetProperty(handle, AudioUnitPropertyIDType.SetRenderCallback, AudioUnitScopeType.Input, 0, // 0 == speaker callbackStruct, (uint)Marshal.SizeOf(callbackStruct)); if (err != 0) { throw new AudioUnitException(err); } }
static extern int AudioUnitSetProperty(IntPtr inUnit, [MarshalAs(UnmanagedType.U4)] AudioUnitPropertyIDType inID, [MarshalAs(UnmanagedType.U4)] AudioUnitScopeType inScope, [MarshalAs(UnmanagedType.U4)] uint inElement, AURenderCallbackStrct inData, uint inDataSize);
public AudioUnit (AudioComponent component) { if (component == null) throw new ArgumentNullException ("component"); if (component.Handle == IntPtr.Zero) throw new ObjectDisposedException ("component"); int err = AudioComponentInstanceNew (component.handle, out handle); if (err != 0) throw new AudioUnitException (err); _isPlaying = false; gcHandle = GCHandle.Alloc(this); var callbackStruct = new AURenderCallbackStrct(); callbackStruct.inputProc = renderCallback; // setting callback function callbackStruct.inputProcRefCon = GCHandle.ToIntPtr(gcHandle); // a pointer that passed to the renderCallback (IntPtr inRefCon) err = AudioUnitSetProperty(handle, AudioUnitPropertyIDType.SetRenderCallback, AudioUnitScopeType.Input, 0, // 0 == speaker callbackStruct, (uint)Marshal.SizeOf(callbackStruct)); if (err != 0) throw new AudioUnitException (err); }
void BrokenSetRender () { var callbackStruct = new AURenderCallbackStrct(); callbackStruct.inputProc = renderCallback; // setting callback function callbackStruct.inputProcRefCon = GCHandle.ToIntPtr(gcHandle); // a pointer that passed to the renderCallback (IntPtr inRefCon) var err = AudioUnitSetProperty(handle, AudioUnitPropertyIDType.SetRenderCallback, AudioUnitScopeType.Input, 0, // 0 == speaker callbackStruct, (uint)Marshal.SizeOf(callbackStruct)); if (err != 0) throw new AudioUnitException (err); }
public AudioUnit (IntPtr handle) { this.handle = handle; _isPlaying = false; gcHandle = GCHandle.Alloc(this); var callbackStruct = new AURenderCallbackStrct(); callbackStruct.inputProc = renderCallback; // setting callback function callbackStruct.inputProcRefCon = GCHandle.ToIntPtr(gcHandle); // a pointer that passed to the renderCallback (IntPtr inRefCon) int err = AudioUnitSetProperty(handle, AudioUnitPropertyIDType.SetRenderCallback, AudioUnitScopeType.Input, 0, // 0 == speaker callbackStruct, (uint)Marshal.SizeOf(callbackStruct)); if (err != 0) throw new AudioUnitException (err); }