-
-
Save chamons/0b07314ffcd20734ff09 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Something not null here! | |
AudioConverter a = null; //AudioConverter.Create (srcFormat, dstFormat, out ce); | |
SetProperty (a, 0x73726361, (uint)AudioConverterSampleRateConverterComplexity.Linear);// 'srca' | |
SetProperty (a, 0x73726371, (uint)AudioConverterQuality.Max); // 'srcq' | |
} | |
[DllImport ("/System/Library/Frameworks/AudioToolbox.framework/AudioToolbox")] | |
static extern AudioConverterError AudioConverterSetProperty (IntPtr inAudioConverter, UInt32 inPropertyID, | |
int inPropertyDataSize, ref uint inPropertyData); | |
// This is ghetto | |
void SetProperty (AudioConverter c, UInt32 propertyID, uint value) | |
{ | |
// Unlike the rest of our bindings, we don't make this public for some unknown reason... | |
FieldInfo fi = typeof(AudioConverter).GetField("handle", BindingFlags.NonPublic | BindingFlags.Instance); | |
IntPtr handle = (IntPtr)fi.GetValue (c); | |
var res = AudioConverterSetProperty (handle, propertyID, sizeof (uint), ref value); | |
if (res != AudioConverterError.None) | |
throw new ArgumentException (res.ToString ()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment