PortAudio / portaudio

PortAudio is a cross-platform, open-source C language library for real-time audio input and output.
Other
1.45k stars 302 forks source link

Patch to expose device "handle" to applications #20

Closed PortAudio-admin closed 12 years ago

PortAudio-admin commented 18 years ago

Issue created by Anonymous on Assembla

[Trac: Originally reported by leland_lucius on 2006-09-14 16:02:36]

Refer to mailing list discussion on PortMixer and exposing devices for a full understanding of the changes:

diff -wruN orig/audacity/lib-src/portaudio-v19/include/pa_mac_core.h audacity/lib-src/portaudio-v19/include/pa_mac_core.h
--- orig/audacity/lib-src/portaudio-v19/include/pa_mac_core.h   2006-09-04 14:05:58.000000000 -0500
+++ audacity/lib-src/portaudio-v19/include/pa_mac_core.h    2006-09-04 05:30:19.000000000 -0500
@@ -58,14 +58,7 @@

 /* Use this function to initialize a paMacCoreStreamInfo struct
    using the requested flags. */
-void paSetupMacCoreStreamInfo( paMacCoreStreamInfo *data, unsigned long flags )
-{
-   bzero( data, sizeof( paMacCoreStreamInfo ) );
-   data->size = sizeof( paMacCoreStreamInfo );
-   data->hostApiType = paCoreAudio;
-   data->version = 0x01;
-   data->flags = flags;
-}
+void paSetupMacCoreStreamInfo( paMacCoreStreamInfo *data, unsigned long flags );

 /*
  * The following flags alter the behaviour of PA on the mac platform.
@@ -76,20 +69,20 @@
  * which allows for much lower latency, but might disrupt the device
  * if other programs are using it, even when you are just Querying
  * the device. */
-const unsigned long paMacCore_ChangeDeviceParameters      = 0x01;
+#define paMacCore_ChangeDeviceParameters        (0x01)

 /* In combination with the above flag,
  * causes the stream opening to fail, unless the exact sample rates
  * are supported by the device. */
-const unsigned long paMacCore_FailIfConversionRequired    = 0x02;
+#define paMacCore_FailIfConversionRequired      (0x02)

 /* These flags set the SR conversion quality, if required. The wierd ordering
  * allows Maximum Quality to be the default.*/
-const unsigned long paMacCore_ConversionQualityMin    = 0x0100;
-const unsigned long paMacCore_ConversionQualityMedium = 0x0200;
-const unsigned long paMacCore_ConversionQualityLow    = 0x0300;
-const unsigned long paMacCore_ConversionQualityHigh   = 0x0400;
-const unsigned long paMacCore_ConversionQualityMax    = 0x0000;
+#define paMacCore_ConversionQualityMin          (0x0100)
+#define paMacCore_ConversionQualityMedium       (0x0200)
+#define paMacCore_ConversionQualityLow          (0x0300)
+#define paMacCore_ConversionQualityHigh         (0x0400)
+#define paMacCore_ConversionQualityMax          (0x0000)

 /*
  * Here are some "preset" combinations of flags (above) to get to some
@@ -98,15 +91,32 @@
  */
 /*This is the default setting: do as much sample rate conversion as possible
  * and as little mucking with the device as possible. */
-const unsigned long paMacCorePlayNice = 0x00;
+#define paMacCorePlayNice                       (0x00)
 /*This setting is tuned for pro audio apps. It allows SR conversion on input
   and output, but it tries to set the appropriate SR on the device.*/
-const unsigned long paMacCorePro      = 0x01;
+#define paMacCorePro                            (0x01)
 /*This is a setting to minimize CPU usage and still play nice.*/
-const unsigned long paMacCoreMinimizeCPUButPlayNice = 0x0100;
+#define paMacCoreMinimizeCPUButPlayNice         (0x0100)
 /*This is a setting to minimize CPU usage, even if that means interrupting the device. */
-const unsigned long paMacCoreMinimizeCPU = 0x0101;
+#define paMacCoreMinimizeCPU                    (0x0101)
+
+/*
+ * Retrieve the AudioDeviceID of the input device assigned to an open stream
+ *
+ * @param s The stream to query.
+ *`
+ * @return A valid AudioDeviceID, or NULL if an error occurred.
+ */
+AudioDeviceID PaMacCore_GetStreamInputDevice( PaStream* s );

+/*
+ * Retrieve the AudioDeviceID of the output device assigned to an open stream
+ *
+ * @param s The stream to query.
+ *
+ * @return A valid AudioDeviceID, or NULL if an error occurred.
+ */
+AudioDeviceID PaMacCore_GetStreamOutputDevice( PaStream* s );

 #ifdef __cplusplus
 }
diff -wruN orig/audacity/lib-src/portaudio-v19/src/hostapi/coreaudio/pa_mac_core.c audacity/lib-src/portaudio-v19/src/hostapi/coreaudio/pa_mac_core.c
--- orig/audacity/lib-src/portaudio-v19/src/hostapi/coreaudio/pa_mac_core.c 2006-09-04 14:05:58.000000000 -0500
+++ audacity/lib-src/portaudio-v19/src/hostapi/coreaudio/pa_mac_core.c  2006-09-04 05:30:19.000000000 -0500
@@ -2038,3 +2038,30 @@

     return PaUtil_GetCpuLoad( &stream->cpuLoadMeasurer );
 }
+
+/* Use this function to initialize a paMacCoreStreamInfo struct
+   using the requested flags. */
+void paSetupMacCoreStreamInfo( paMacCoreStreamInfo *data, unsigned long flags )
+{
+   bzero( data, sizeof( paMacCoreStreamInfo ) );
+   data->size = sizeof( paMacCoreStreamInfo );
+   data->hostApiType = paCoreAudio;
+   data->version = 0x01;
+   data->flags = flags;
+}
+
+AudioDeviceID PaMacCore_GetStreamInputDevice( PaStream* s )
+{
+    PaMacCoreStream *stream = (PaMacCoreStream*)s;
+    VVDBUG(("PaMacCore_GetStreamInputHandle()\n"));
+
+    return ( stream->inputDevice );
+}
+
+AudioDeviceID PaMacCore_GetStreamOutputDevice( PaStream* s )
+{
+    PaMacCoreStream *stream = (PaMacCoreStream*)s;
+    VVDBUG(("PaMacCore_GetStreamOutputHandle()\n"));
+
+    return ( stream->outputDevice );
+}
PortAudio-admin commented 12 years ago

Comment by @RossBencina

TRAC migration: propagating ticket status from TRAC

PortAudio-admin commented 12 years ago

Issue closed by @RossBencina