Patch to expose device "handle" to applications
[Trac: Originally reported by leland_lucius on 2006-09-14 15:59:00]
Refer to mailing list discussion on PortMixer and exposing devices for a full understanding of the changes.
Related open bugs:
http://www.portaudio.com/trac/ticket/19 (DirectSound)
http://www.portaudio.com/trac/ticket/21 (OSS)
Refer to mailing list discussion on PortMixer and exposing devices for a full understanding of the changes.
Related open bugs:
http://www.portaudio.com/trac/ticket/19 (DirectSound)
http://www.portaudio.com/trac/ticket/21 (OSS)
diff -wruN orig/audacity/lib-src/portaudio-v19/include/portaudio.h audacity/lib-src/portaudio-v19/include/portaudio.h
--- orig/audacity/lib-src/portaudio-v19/include/portaudio.h 2006-09-04 14:05:58.000000000 -0500
+++ audacity/lib-src/portaudio-v19/include/portaudio.h 2006-09-04 05:30:19.000000000 -0500
@@ -1105,6 +1105,15 @@
signed long Pa_GetStreamWriteAvailable( PaStream* stream );
+/** Retrieve the host type handling an open stream.
+
+ @return Returns a non-negative value representing the host API type
+ handling an open stream or, a PaErrorCode (which are always negative)
+ if PortAudio is not initialized or an error is encountered.
+*/
+PaHostApiTypeId Pa_GetStreamHostApiType( PaStream* stream );
+
+
/* Miscellaneous utilities */
diff -wruN orig/audacity/lib-src/portaudio-v19/src/common/pa_front.c audacity/lib-src/portaudio-v19/src/common/pa_front.c
--- orig/audacity/lib-src/portaudio-v19/src/common/pa_front.c 2006-09-04 14:05:59.000000000 -0500
+++ audacity/lib-src/portaudio-v19/src/common/pa_front.c 2006-09-04 05:30:19.000000000 -0500
@@ -1327,8 +1327,10 @@
hostApiInputParametersPtr, hostApiOutputParametersPtr,
sampleRate, framesPerBuffer, streamFlags, streamCallback, userData );
- if( result == paNoError )
+ if( result == paNoError ) {
AddOpenStream( *stream );
+ PA_STREAM_REP(*stream)->hostApiType = hostApi->info.type;
+ }
#ifdef PA_LOG_API_CALLS
@@ -1915,6 +1917,33 @@
}
+PaHostApiTypeId Pa_GetStreamHostApiType( PaStream* stream )
+{
+ PaError error = PaUtil_ValidateStreamPointer( stream );
+ PaHostApiTypeId result;
+
+#ifdef PA_LOG_API_CALLS
+ PaUtil_DebugPrint("Pa_GetStreamHostApiType called:\n" );
+ PaUtil_DebugPrint("\tPaStream* stream: 0x%p\n", stream );
+#endif
+
+ if( error == paNoError )
+ {
+ result = PA_STREAM_REP(stream)->hostApiType;
+ }
+ else
+ {
+ result = (PaHostApiTypeId) error;
+ }
+
+#ifdef PA_LOG_API_CALLS
+ PaUtil_DebugPrint("Pa_GetStreamHostApiType returned:\n" );
+ PaUtil_DebugPrint("\tPaError: %d ( %s )\n\n", result, Pa_GetErrorText( result ) );
+#endif
+
+ return result;
+}
+
PaError Pa_GetSampleSize( PaSampleFormat format )
{
int result;
diff -wruN orig/audacity/lib-src/portaudio-v19/src/common/pa_stream.c audacity/lib-src/portaudio-v19/src/common/pa_stream.c
--- orig/audacity/lib-src/portaudio-v19/src/common/pa_stream.c 2006-09-04 14:05:59.000000000 -0500
+++ audacity/lib-src/portaudio-v19/src/common/pa_stream.c 2006-09-04 05:30:19.000000000 -0500
@@ -93,6 +93,8 @@
streamRepresentation->streamInfo.inputLatency = 0.;
streamRepresentation->streamInfo.outputLatency = 0.;
streamRepresentation->streamInfo.sampleRate = 0.;
+
+ streamRepresentation->hostApiType = 0;
}
diff -wruN orig/audacity/lib-src/portaudio-v19/src/common/pa_stream.h audacity/lib-src/portaudio-v19/src/common/pa_stream.h
--- orig/audacity/lib-src/portaudio-v19/src/common/pa_stream.h 2006-09-04 14:05:59.000000000 -0500
+++ audacity/lib-src/portaudio-v19/src/common/pa_stream.h 2006-09-04 05:30:19.000000000 -0500
@@ -152,6 +152,7 @@
PaStreamFinishedCallback *streamFinishedCallback;
void *userData;
PaStreamInfo streamInfo;
+ PaHostApiTypeId hostApiType;
} PaUtilStreamRepresentation;
Leave a comment