Ticket #19 (new enhancement)

Opened 2 years ago

Last modified 7 months ago

Patch to expose device "handle" to applications

Reported by: leland_lucius Owned by: rossb
Priority: major Milestone: V19-RC1
Component: host-api-dsound Version: 2.0
Keywords: Cc:

Description

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_win_ds.h audacity/lib-src/portaudio-v19/include/pa_win_ds.h
--- orig/audacity/lib-src/portaudio-v19/include/pa_win_ds.h	1969-12-31 18:00:00.000000000 -0600
+++ audacity/lib-src/portaudio-v19/include/pa_win_ds.h	2006-09-04 05:30:19.000000000 -0500
@@ -0,0 +1,69 @@
+#ifndef PA_WIN_DS_H
+#define PA_WIN_DS_H
+/*
+ * $Id: pa_win_ds.h 1013 2006-05-15 04:01:31Z rossb $
+ * PortAudio Portable Real-Time Audio Library
+ * DirectSound specific extensions
+ *
+ * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * Any person wishing to distribute modifications to the Software is
+ * requested to send the modifications to the original developer so that
+ * they can be incorporated into the canonical version.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+/** @file
+ @brief DirectSound-specific PortAudio API extension header file.
+*/
+
+
+#include "portaudio.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
+
+/** Retrieve the GUID of the input device.
+
+ @param stream The stream to query.
+
+ @return A pointer to the GUID, or NULL if none.
+*/
+LPGUID PaWinDS_GetStreamInputGUID( PaStream* s );
+
+
+/** Retrieve the GUID of the output device.
+
+ @param stream The stream to query.
+
+ @return A pointer to the GUID, or NULL if none.
+*/
+LPGUID PaWinDS_GetStreamOutputGUID( PaStream* s );
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* PA_WIN_DS_H */
diff -wruN orig/audacity/lib-src/portaudio-v19/src/hostapi/dsound/pa_win_ds.c audacity/lib-src/portaudio-v19/src/hostapi/dsound/pa_win_ds.c
--- orig/audacity/lib-src/portaudio-v19/src/hostapi/dsound/pa_win_ds.c	2006-09-04 14:05:59.000000000 -0500
+++ audacity/lib-src/portaudio-v19/src/hostapi/dsound/pa_win_ds.c	2006-09-04 05:30:19.000000000 -0500
@@ -198,6 +198,7 @@
 /* DirectSound specific data. */
 
 /* Output */
+    LPGUID               pOutputGuid;
     LPDIRECTSOUND        pDirectSound;
     LPDIRECTSOUNDBUFFER  pDirectSoundOutputBuffer;
     DWORD                outputBufferWriteOffsetBytes;     /* last write position */
@@ -213,6 +214,7 @@
     double               dsw_framesWritten;
     double               framesPlayed;
 /* Input */
+    LPGUID               pInputGuid;
     LPDIRECTSOUNDCAPTURE pDirectSoundCapture;
     LPDIRECTSOUNDCAPTUREBUFFER   pDirectSoundInputBuffer;
     INT                  bytesPerInputFrame;
@@ -1476,6 +1478,11 @@
                 goto error;
             }
 
+            stream->pOutputGuid = winDsHostApi->winDsDeviceInfos[outputParameters->device].lpGUID;
+            if( stream->pOutputGuid == NULL )
+            {
+               stream->pOutputGuid = (GUID *) &DSDEVID_DefaultPlayback;
+            }
 
             hr = paWinDsDSoundEntryPoints.DirectSoundCreate( winDsHostApi->winDsDeviceInfos[outputParameters->device].lpGUID,
                         &stream->pDirectSound, NULL );
@@ -1522,6 +1529,12 @@
                 goto error;
             }
 
+            stream->pInputGuid = winDsHostApi->winDsDeviceInfos[inputParameters->device].lpGUID;
+            if( stream->pInputGuid == NULL )
+            {
+               stream->pInputGuid = (GUID *)&DSDEVID_DefaultCapture;
+            }
+
             hr = paWinDsDSoundEntryPoints.DirectSoundCaptureCreate( winDsHostApi->winDsDeviceInfos[inputParameters->device].lpGUID,
                         &stream->pDirectSoundCapture,   NULL );
             if( hr != DS_OK )
@@ -2183,4 +2196,19 @@
 }
 
 
+/***********************************************************************************/
+LPGUID PaWinDS_GetStreamInputGUID( PaStream* s )
+{
+    PaWinDsStream *stream = (PaWinDsStream*)s;
 
+   return stream->pInputGuid;
+}
+
+
+/***********************************************************************************/
+LPGUID PaWinDS_GetStreamOutputGUID( PaStream* s )
+{
+    PaWinDsStream *stream = (PaWinDsStream*)s;
+
+    return stream->pOutputGuid;
+}

Attachments

ds.diff (4.9 kB) - added by leland_lucius 2 years ago.

Change History

Changed 2 years ago by leland_lucius

Changed 7 months ago by rossb

  • milestone set to V19-RC1

Changed 7 months ago by rossb

  • priority changed from minor to major
Note: See TracTickets for help on using tickets.