The attached patch (should) provide(s) a way to select the DirectSound devices on the host for audio input and output for a VM. It uses two environment variables (DEVICE_GUID_OUT and DEVICE_GUID_IN) for this purpose. I would rather allow this to be configurable from the configuration file, but I can not find a (simple) way to get anything from the configuration file to the audio driver. Using an environment variable will work for my usage.

I have not tested this patch, as I have no Windows build environment. Could anyone (try to) build VirtualBox with this patch for Windows (x32)?

Thank you,

Ivo Smits
Index: src/VBox/Devices/Audio/dsoundaudio.c
===================================================================
--- src/VBox/Devices/Audio/dsoundaudio.c        (revision 39122)
+++ src/VBox/Devices/Audio/dsoundaudio.c        (working copy)
@@ -53,6 +53,8 @@
     int bufsize_out;
     audsettings_t settings;
     int latency_millis;
+    const char *device_guid_out;
+    const char *device_guid_in;
 } conf = {
     1,
     1,
@@ -65,7 +67,9 @@
         2,
         AUD_FMT_S16
     },
-    10
+    10,
+    NULL,
+    NULL
 };
 
 typedef struct {
@@ -1016,6 +1020,8 @@
     int err;
     HRESULT hr;
     dsound *s = &glob_dsound;
+    RTUUID devguid;
+    LPCGUID devguidp;
 
     hr = CoInitializeEx (NULL, COINIT_MULTITHREADED);
     if (FAILED (hr)) {
@@ -1046,7 +1052,16 @@
         return NULL;
     }
 
-    hr = IDirectSound_Initialize (s->dsound, NULL);
+    if (conf.device_guid_out) {
+        hr = RTUuidFromStr(&devguid, conf.device_guid_out);
+        if (FAILED (hr)) {
+            LogRel(("DSound: Could not parse DirectSound output device 
GUID\n"));
+        }
+        devguidp = (LPCGUID)&devguid;
+    } else {
+        devguidp = NULL
+    }
+    hr = IDirectSound_Initialize (s->dsound, devguidp);
     if (FAILED (hr)) {
 #ifndef VBOX
         dsound_logerr (hr, "Could not initialize DirectSound\n");
@@ -1080,7 +1095,16 @@
 #endif
     }
     else {
-        hr = IDirectSoundCapture_Initialize (s->dsound_capture, NULL);
+        if (conf.device_guid_in) {
+            hr = RTUuidFromStr(&devguid, conf.device_guid_in);
+            if (FAILED (hr)) {
+                LogRel(("DSound: Could not parse DirectSound input device 
GUID\n"));
+            }
+            devguidp = (LPCGUID)&devguid;
+        } else {
+            devguidp = NULL
+        }
+        hr = IDirectSoundCapture_Initialize (s->dsound_capture, devguidp);
         if (FAILED (hr)) {
 #ifndef VBOX
             dsound_logerr (hr, "Could not initialize DirectSoundCapture\n");
@@ -1128,6 +1152,10 @@
      "(undocumented)", NULL, 0},
     {"BUFSIZE_IN", AUD_OPT_INT, &conf.bufsize_in,
      "(undocumented)", NULL, 0},
+    {"DEVICE_GUID_OUT", AUD_OPT_STR, &conf.device_guid_out,
+     "DirectSound output device GUID", NULL, 0},
+    {"DEVICE_GUID_IN", AUD_OPT_STR, &conf.device_guid_in,
+     "DirectSound input device GUID", NULL, 0},
     {NULL, 0, NULL, NULL, NULL, 0}
 };
 
_______________________________________________
vbox-dev mailing list
[email protected]
https://www.virtualbox.org/mailman/listinfo/vbox-dev

Reply via email to