示例#1
0
 private static extern int AudioObjectGetPropertyDataSize(
     uint inObjectID,
     ref AudioObjectPropertyAddress inAddress,
     ref uint inQualifierDataSize,
     IntPtr inQualifierData,
     out uint outDataSize
     );
示例#2
0
        public TOut GetAudioObjectPropertyDataDynamic <TOut>(uint deviceObjectID, AudioObjectPropertySelectorExtended selector, AudioObjectPropertyScope scope)
        {
            var    propertyAddress     = new AudioObjectPropertyAddress(selector, scope, AudioObjectPropertyElement.Master);
            uint   inQualifierDataSize = 0;
            IntPtr inQualifierData     = IntPtr.Zero; // aka NULL in obj-c

            uint dataPropertySize;

            var err = AudioObjectGetPropertyDataSize(deviceObjectID, ref propertyAddress, ref inQualifierDataSize, inQualifierData, out dataPropertySize);

            if (err != 0)
            {
                throw new Exception(err.ToString());
            }

            return(GetAudioObjectPropertyDataFixed <TOut>(deviceObjectID, selector, scope, (int)dataPropertySize));
        }
示例#3
0
        public TOut GetAudioObjectPropertyDataFixed <TOut>(uint deviceObjectID, AudioObjectPropertySelectorExtended selector, AudioObjectPropertyScope scope, int size)
        {
            var propertyAddress = new AudioObjectPropertyAddress(selector, scope, AudioObjectPropertyElement.Master);
            var propInfo        = GetUnmanagedPropertyData(deviceObjectID, propertyAddress, size);

            if (typeof(TOut) == typeof(int[]))
            {
                return((TOut)MarshalToIntArray(propInfo));
            }
            else if (typeof(TOut) == typeof(string))
            {
                return((TOut)MarshalToString(propInfo));
            }
            else
            {
                throw new NotSupportedException("Type not yet handled.  Sorry this was built by a lazy engineer.");
            }
        }
示例#4
0
        private PropertyDataPointerInfo GetUnmanagedPropertyData(uint deviceObjectID, AudioObjectPropertyAddress propertyAddress, int size)
        {
            IntPtr resultPtr           = Marshal.AllocHGlobal(size);
            uint   inQualifierDataSize = 0;
            IntPtr inQualifierData     = IntPtr.Zero; // aka NULL in obj-c
            uint   dataPropertySize    = (uint)size;

            var err = AudioObjectGetPropertyData(deviceObjectID, ref propertyAddress, ref inQualifierDataSize, inQualifierData, ref dataPropertySize, resultPtr);

            if (err != 0)
            {
                Marshal.FreeHGlobal(resultPtr);
                throw new Exception(String.Format("AudioUnit error '{0}'", err));
            }

            return(new PropertyDataPointerInfo {
                Ptr = resultPtr, SizeInBytes = (int)dataPropertySize
            });
        }