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
                                        );
Пример #2
0
        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);
            }
        }
Пример #3
0
        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);
            }
        }
Пример #4
0
		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);
Пример #5
0
		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);
		}
Пример #6
0
		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);
		}
Пример #7
0
		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);
		}