Exemple #1
0
        public Audio(DisposableI parent)
            : base(parent)
        {
            #if OSX
            component = AudioComponent.FindComponent(AudioTypeOutput.Default);
            #else
            component = AudioComponent.FindComponent(AudioTypeOutput.Remote);
            #endif

            if (component == null) Debug.ThrowError("Audio", "Failed to find AudioComponent");
        }
Exemple #2
0
        public static AudioComponent FindNextComponent(AudioComponent cmp, AudioComponentDescription cd)
        {
            // Getting component hanlder
            IntPtr handle;

            if (cmp == null)
            {
                handle = AudioComponentFindNext(IntPtr.Zero, cd);
            }
            else
            {
                handle = AudioComponentFindNext(cmp.Handle, cd);
            }

            // creating an instance
            if (handle != IntPtr.Zero)
            {
                return(new AudioComponent(handle));
            }
            else
            {
                return(null);
            }
        }
Exemple #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);
            }

            gcHandle = GCHandle.Alloc(this);

#pragma warning disable 612
            BrokenSetRender();
#pragma warning restore 612
        }
Exemple #4
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);
            }
        }