T GetProperty <T> (AudioFileStreamProperty property)
        {
            int size, writable;

            if (AudioFileStreamGetPropertyInfo(handle, property, out size, out writable) != 0)
            {
                return(default(T));
            }
            var buffer = Marshal.AllocHGlobal(size);

            if (buffer == IntPtr.Zero)
            {
                return(default(T));
            }
            try
            {
                var r = AudioFileStreamGetProperty(handle, property, ref size, buffer);
                if (r == 0)
                {
                    return((T)Marshal.PtrToStructure(buffer, typeof(T)));
                }

                return(default(T));
            }
            finally
            {
                Marshal.FreeHGlobal(buffer);
            }
        }
Esempio n. 2
0
        public IntPtr GetProperty(AudioFileStreamProperty property, out int size)
        {
            bool writable;

            LastError = AudioFileStreamGetPropertyInfo(handle, property, out size, out writable);
            if (LastError != 0)
            {
                return(IntPtr.Zero);
            }

            var buffer = Marshal.AllocHGlobal(size);

            if (buffer == IntPtr.Zero)
            {
                return(IntPtr.Zero);
            }

            LastError = AudioFileStreamGetProperty(handle, property, ref size, buffer);
            if (LastError == 0)
            {
                return(buffer);
            }
            Marshal.FreeHGlobal(buffer);
            return(IntPtr.Zero);
        }
Esempio n. 3
0
        unsafe T?GetProperty <T> (AudioFileStreamProperty property) where T : struct
        {
            int  size;
            bool writable;

            LastError = AudioFileStreamGetPropertyInfo(handle, property, out size, out writable);
            if (LastError != 0)
            {
                return(null);
            }
            var buffer = Marshal.AllocHGlobal(size);

            if (buffer == IntPtr.Zero)
            {
                return(null);
            }
            try {
                LastError = AudioFileStreamGetProperty(handle, property, ref size, buffer);
                if (LastError == 0)
                {
                    return((T)Marshal.PtrToStructure(buffer, typeof(T)));
                }

                return(null);
            } finally {
                Marshal.FreeHGlobal(buffer);
            }
        }
Esempio n. 4
0
        unsafe T?GetProperty <T> (AudioFileStreamProperty property) where T : struct
        {
            int size, writable;

            LastError = AudioFileStreamGetPropertyInfo(handle, property, out size, out writable);
            if (LastError != 0)
            {
                return(null);
            }
            var buffer = Marshal.AllocHGlobal(size);

            if (buffer == IntPtr.Zero)
            {
                return(null);
            }
            try {
                LastError = AudioFileStreamGetProperty(handle, property, ref size, buffer);
                if (LastError == 0)
                {
                    T result = *(T *)buffer;
                    return(result);
                }

                return(null);
            } finally {
                Marshal.FreeHGlobal(buffer);
            }
        }
Esempio n. 5
0
 public bool GetProperty(AudioFileStreamProperty property, ref int dataSize, IntPtr outPropertyData)
 {
     if (outPropertyData == IntPtr.Zero)
     {
         throw new ArgumentNullException("outPropertyData");
     }
     return(AudioFileStreamGetProperty(handle, property, ref dataSize, outPropertyData) == 0);
 }
Esempio n. 6
0
 public bool GetProperty(AudioFileStreamProperty property, ref int dataSize, IntPtr outPropertyData)
 {
     if (outPropertyData == IntPtr.Zero)
     {
         ObjCRuntime.ThrowHelper.ThrowArgumentNullException(nameof(outPropertyData));
     }
     return(AudioFileStreamGetProperty(handle, property, ref dataSize, outPropertyData) == 0);
 }
Esempio n. 7
0
 public bool SetProperty(AudioFileStreamProperty property, int dataSize, IntPtr propertyData)
 {
     if (propertyData == IntPtr.Zero)
     {
         ObjCRuntime.ThrowHelper.ThrowArgumentNullException(nameof(propertyData));
     }
     LastError = AudioFileStreamSetProperty(handle, property, dataSize, propertyData);
     return(LastError == 0);
 }
Esempio n. 8
0
 public bool SetProperty(AudioFileStreamProperty property, int dataSize, IntPtr propertyData)
 {
     if (propertyData == IntPtr.Zero)
     {
         throw new ArgumentNullException("propertyData");
     }
     LastError = AudioFileStreamSetProperty(handle, property, dataSize, propertyData);
     return(LastError == 0);
 }
Esempio n. 9
0
        protected virtual void OnPropertyFound(AudioFileStreamProperty propertyID, ref AudioFileStreamPropertyFlag ioFlags)
        {
            var p = PropertyFound;

            if (p != null)
            {
                var pf = new PropertyFoundEventArgs(propertyID, ioFlags);
                p(this, pf);
                ioFlags = pf.Flags;
            }
        }
Esempio n. 10
0
 int GetInt(AudioFileStreamProperty property)
 {
     unsafe {
         int val  = 0;
         int size = 4;
         if (AudioFileStreamGetProperty(handle, property, ref size, (IntPtr)(&val)) == 0)
         {
             return(val);
         }
         return(0);
     }
 }
Esempio n. 11
0
 double GetDouble(AudioFileStreamProperty property)
 {
     unsafe {
         double val  = 0;
         int    size = 8;
         if (AudioFileStreamGetProperty(handle, property, ref size, (IntPtr)(&val)) == 0)
         {
             return(val);
         }
         return(0);
     }
 }
Esempio n. 12
0
 long GetLong(AudioFileStreamProperty property)
 {
     unsafe {
         long val  = 0;
         int  size = 8;
         if (AudioFileStreamGetProperty(handle, property, ref size, (IntPtr)(&val)) == 0)
         {
             return(val);
         }
         return(0);
     }
 }
Esempio n. 13
0
 public PropertyFoundEventArgs(AudioFileStreamProperty propertyID, AudioFileStreamPropertyFlag ioFlags)
 {
     Property = propertyID;
     Flags    = ioFlags;
 }
Esempio n. 14
0
 extern static AudioFileStreamStatus AudioFileStreamSetProperty(
     AudioFileStreamID inAudioFileStream,
     AudioFileStreamProperty inPropertyID,
     int inPropertyDataSize,
     IntPtr inPropertyData);
Esempio n. 15
0
 public bool SetProperty(AudioFileStreamProperty property, int dataSize, IntPtr propertyData)
 {
     LastError = AudioFileStreamSetProperty(handle, property, dataSize, propertyData);
     return(LastError == 0);
 }
Esempio n. 16
0
 extern static OSStatus AudioFileStreamGetPropertyInfo(
     AudioFileStreamID inAudioFileStream,
     AudioFileStreamProperty inPropertyID,
     out int outPropertyDataSize,
     out int isWritable);
Esempio n. 17
0
 public bool GetProperty(AudioFileStreamProperty property, ref int dataSize, IntPtr outPropertyData)
 {
     return(AudioFileStreamGetProperty(handle, property, ref dataSize, outPropertyData) == 0);
 }
Esempio n. 18
0
 extern static AudioFileStreamStatus AudioFileStreamGetProperty(
     AudioFileStreamID inAudioFileStream,
     AudioFileStreamProperty inPropertyID,
     ref int ioPropertyDataSize,
     IntPtr outPropertyData);
Esempio n. 19
0
 extern static AudioFileStreamStatus AudioFileStreamGetPropertyInfo(
     AudioFileStreamID inAudioFileStream,
     AudioFileStreamProperty inPropertyID,
     out int outPropertyDataSize,
     [MarshalAs(UnmanagedType.I1)] out bool isWritable);
Esempio n. 20
0
        static void PropertyListener(IntPtr clientData, AudioFileStreamID audioFileStream, AudioFileStreamProperty propertyID, ref AudioFileStreamPropertyFlag ioFlags)
        {
            GCHandle handle = GCHandle.FromIntPtr(clientData);
            var      afs    = handle.Target as AudioFileStream;

            afs.OnPropertyFound(propertyID, ref ioFlags);
        }
Esempio n. 21
0
 public bool SetProperty(AudioFileStreamProperty property, int dataSize, IntPtr propertyData)
 {
     return(AudioFileStreamSetProperty(handle, property, dataSize, propertyData) == 0);
 }