]> Repos - portaudio/commitdiff
added function to query core audio buffer size range
authorrossb <rossb@0f58301d-fd10-0410-b4af-bbb618454e57>
Wed, 11 Jan 2012 13:03:11 +0000 (13:03 +0000)
committerrossb <rossb@0f58301d-fd10-0410-b4af-bbb618454e57>
Wed, 11 Jan 2012 13:03:11 +0000 (13:03 +0000)
include/pa_mac_core.h
src/hostapi/coreaudio/pa_mac_core.c

index f7a90f08ffea176c12dae4f105ec773c99f1b53c..1d615feed471c111a9fdfbcc6e4adcc78839ab04 100644 (file)
@@ -124,6 +124,19 @@ AudioDeviceID PaMacCore_GetStreamOutputDevice( PaStream* s );
  */
 const char *PaMacCore_GetChannelName( int device, int channelIndex, bool input );
 
+    
+/** Retrieve the range of legal native buffer sizes for the specificed device, in sample frames.
+ @param device The global index of the PortAudio device about which the query is being made.
+ @param minBufferSizeFrames A pointer to the location which will receive the minimum buffer size value.
+ @param maxBufferSizeFrames A pointer to the location which will receive the maximum buffer size value.
+ @see kAudioDevicePropertyBufferFrameSizeRange in the CoreAudio SDK.
+ */
+PaError PaMacCore_GetBufferSizeRange( PaDeviceIndex device,
+                                       long *minBufferSizeFrames, long *maxBufferSizeFrames );
+
+
 /**
  * Flags
  */
index 55ce9f0c0eec9cb9f1418414e7addf125e046d74..7b0d424f6f1d801186414352ee48d1ebb33d10c2 100644 (file)
@@ -204,8 +204,40 @@ const char *PaMacCore_GetChannelName( int device, int channelIndex, bool input )
    return channelName;
 }
 
+    
+PaError PaMacCore_GetBufferSizeRange( PaDeviceIndex device,
+                                      long *minBufferSizeFrames, long *maxBufferSizeFrames )
+{
+    PaError result;
+    PaUtilHostApiRepresentation *hostApi;
+    
+    result = PaUtil_GetHostApiRepresentation( &hostApi, paCoreAudio );
+    
+    if( result == paNoError )
+    {
+        PaDeviceIndex hostApiDeviceIndex;
+        result = PaUtil_DeviceIndexToHostApiDeviceIndex( &hostApiDeviceIndex, device, hostApi );
+        if( result == paNoError )
+        {
+            PaMacAUHAL *macCoreHostApi = (PaMacAUHAL*)hostApi;
+            AudioDeviceID macCoreDeviceId = macCoreHostApi->devIds[hostApiDeviceIndex];
+            AudioValueRange audioRange;
+            UInt32 propSize = sizeof( audioRange );
+            
+            // return the size range for the output scope unless we only have inputs
+            Boolean isInput = 0;
+            if( macCoreHostApi->inheritedHostApiRep.deviceInfos[hostApiDeviceIndex]->maxOutputChannels == 0 )
+                isInput = 1;
+           
+            result = WARNING(AudioDeviceGetProperty( macCoreDeviceId, 0, isInput, kAudioDevicePropertyBufferFrameSizeRange, &propSize, &audioRange ) );
 
-
+            *minBufferSizeFrames = audioRange.mMinimum;
+            *maxBufferSizeFrames = audioRange.mMaximum;
+        }
+    }
+    
+    return result;
+}
 
 
 AudioDeviceID PaMacCore_GetStreamInputDevice( PaStream* s )