Add support for AUDIODEV and MIXERDEV

Francois Gouget fgouget at codeweavers.com
Tue Aug 31 11:49:11 CDT 2004


A user reported that SunRay terminals used the AUDIODEV and MIXERDEV 
environment variables to tell applications which pseudo-OSS device to 
open for the sound to get to the correct client.

 From what I understand the SunRays are X terminals and these pseudo-OSS 
devices just route the sound data over the network to the proper SunRay 
terminal.

So this patch modifies the wineoss driver to check for these environment 
variables when initialising the OSS_Devices array. If set, then it uses 
the specified device and no other so as not to risk accidentally sending 
sound to other terminals.

This gets wineoss to try to communicate with the device although it does 
not yet seem to get very far as that OSS device is a bit primitive: does 
not support mmap, does not support small fragments, etc.

Note: Maybe we should free the memory we now allocate in OSS_WaveInit() 
but I did not see where that should be done.


Changelog:

  * dlls/winmm/wineoss/audio.c

    Francois Gouget <fgouget at codeweavers.com>
    Add support for the AUDIODEV and MIXERDEV environment variables.


-- 
Francois Gouget
fgouget at codeweavers.com

-------------- next part --------------
Index: dlls/winmm/wineoss/audio.c
===================================================================
RCS file: /var/cvs/wine/dlls/winmm/wineoss/audio.c,v
retrieving revision 1.146
diff -u -r1.146 audio.c
--- dlls/winmm/wineoss/audio.c	23 Aug 2004 19:39:48 -0000	1.146
+++ dlls/winmm/wineoss/audio.c	31 Aug 2004 13:23:33 -0000
@@ -152,9 +152,9 @@
 } OSS_MSG_RING;
 
 typedef struct tagOSS_DEVICE {
-    char                        dev_name[32];
-    char                        mixer_name[32];
-    char                        interface_name[64];
+    char*                       dev_name;
+    char*                       mixer_name;
+    char*                       interface_name;
     unsigned                    open_count;
     WAVEOUTCAPSA                out_caps;
     WAVEOUTCAPSA                duplex_out_caps;
@@ -1161,6 +1161,16 @@
           ossdev->duplex_out_caps.dwFormats, ossdev->duplex_out_caps.dwSupport);
 }
 
+static char* StrDup(const char* str, const char* def)
+{
+    char* dst;
+    if (str==NULL)
+        str=def;
+    dst=HeapAlloc(GetProcessHeap(),0,strlen(str)+1);
+    strcpy(dst, str);
+    return dst;
+}
+
 /******************************************************************
  *		OSS_WaveInit
  *
@@ -1168,26 +1178,45 @@
  */
 LONG OSS_WaveInit(void)
 {
-    int 	i;
+    char* str;
+    int i;
+
     TRACE("()\n");
 
-    for (i = 0; i < MAX_WAVEDRV; ++i)
+    str=getenv("AUDIODEV");
+    if (str!=NULL)
     {
-	if (i == 0) {
-	    sprintf((char *)OSS_Devices[i].dev_name, "/dev/dsp");
-	    sprintf((char *)OSS_Devices[i].mixer_name, "/dev/mixer");
-	} else {
-	    sprintf((char *)OSS_Devices[i].dev_name, "/dev/dsp%d", i);
-	    sprintf((char *)OSS_Devices[i].mixer_name, "/dev/mixer%d", i);
-	}
+        OSS_Devices[0].dev_name=StrDup(str,"");
+        OSS_Devices[0].mixer_name=StrDup(getenv("MIXERDEV"),"/dev/mixer");
+        for (i = 1; i < MAX_WAVEDRV; ++i)
+        {
+            OSS_Devices[i].dev_name=StrDup("",NULL);
+            OSS_Devices[i].mixer_name=StrDup("",NULL);
+        }
+    }
+    else
+    {
+        OSS_Devices[0].dev_name=StrDup("/dev/dsp",NULL);
+        OSS_Devices[0].mixer_name=StrDup("/dev/mixer",NULL);
+        for (i = 1; i < MAX_WAVEDRV; ++i)
+        {
+            OSS_Devices[i].dev_name=HeapAlloc(GetProcessHeap(),0,11);
+            sprintf(OSS_Devices[i].dev_name, "/dev/dsp%d", i);
+            OSS_Devices[i].mixer_name=HeapAlloc(GetProcessHeap(),0,13);
+            sprintf(OSS_Devices[i].mixer_name, "/dev/mixer%d", i);
+        }
+    }
 
+    for (i = 0; i < MAX_WAVEDRV; ++i)
+    {
+        OSS_Devices[i].interface_name=HeapAlloc(GetProcessHeap(),0,9+strlen(OSS_Devices[i].dev_name)+1);
         sprintf(OSS_Devices[i].interface_name, "wineoss: %s", OSS_Devices[i].dev_name);
     }
 
     /* start with output devices */
     for (i = 0; i < MAX_WAVEDRV; ++i)
     {
-        if (OSS_WaveOutInit(&OSS_Devices[i]))
+        if (*OSS_Devices[i].dev_name=='\0' || OSS_WaveOutInit(&OSS_Devices[i]))
         {
             WOutDev[numOutDev].state = WINE_WS_CLOSED;
             WOutDev[numOutDev].ossdev = &OSS_Devices[i];
@@ -1199,7 +1228,7 @@
     /* then do input devices */
     for (i = 0; i < MAX_WAVEDRV; ++i)
     {
-        if (OSS_WaveInInit(&OSS_Devices[i]))
+        if (*OSS_Devices[i].dev_name=='\0' || OSS_WaveInInit(&OSS_Devices[i]))
         {
             WInDev[numInDev].state = WINE_WS_CLOSED;
             WInDev[numInDev].ossdev = &OSS_Devices[i];
@@ -1209,7 +1238,8 @@
 
     /* finish with the full duplex bits */
     for (i = 0; i < MAX_WAVEDRV; i++)
-        OSS_WaveFullDuplexInit(&OSS_Devices[i]);
+        if (*OSS_Devices[i].dev_name!='\0')
+            OSS_WaveFullDuplexInit(&OSS_Devices[i]);
 
     return 0;
 }


More information about the wine-patches mailing list