PATCH: dlls/winmm/wineoss/audio.c

Gerald Pfeifer gerald at pfeifer.com
Wed Dec 31 09:53:52 CST 2003


On Tue, 30 Dec 2003, Alexandre Julliard wrote:
>> I'm not sure whether you want to make this change in general, for all
>> platforms, so for now I have embedded it in an #if(n)def.
> I think we should do that on all platforms, yes. And you probably want
> to fix OSS_WaveInInit too.

Good catch!  As promised, please find an updated patch below.

Gerald

ChangeLog:
Improve error messages in OSS_WaveOutInit() and OSS_WaveInInit() and
warn instead of aborting in case of problems reading mixer info.  This
makes sound work on FreeBSD.
Index: audio.c
===================================================================
RCS file: /home/wine/wine/dlls/winmm/wineoss/audio.c,v
retrieving revision 1.108
diff -u -3 -p -r1.108 audio.c
--- audio.c	12 Dec 2003 05:55:26 -0000	1.108
+++ audio.c	31 Dec 2003 15:52:05 -0000
@@ -538,17 +538,18 @@ static BOOL OSS_WaveOutInit(OSS_DEVICE*
         if ((mixer = open(ossdev->mixer_name, O_RDONLY|O_NDELAY)) >= 0) {
             mixer_info info;
             if (ioctl(mixer, SOUND_MIXER_INFO, &info) >= 0) {
-                close(mixer);
                 strncpy(ossdev->ds_desc.szDesc, info.name, sizeof(info.name));
                 strcpy(ossdev->ds_desc.szDrvName, "wineoss.drv");
                 strncpy(ossdev->out_caps.szPname, info.name, sizeof(info.name));
                 TRACE("%s\n", ossdev->ds_desc.szDesc);
             } else {
-                ERR("%s: can't read info!\n", ossdev->mixer_name);
-                OSS_CloseDevice(ossdev);
-                close(mixer);
-                return FALSE;
+                /* FreeBSD up to at least 5.2 provides this ioctl, but does not
+                 * implement it properly, and there are probably similar issues
+                 * on other platforms, so we warn but try to go ahead.
+                 */
+                WARN("%s: cannot read SOUND_MIXER_INFO!\n", ossdev->mixer_name);
             }
+            close(mixer);
         } else {
             ERR("%s: %s\n", ossdev->mixer_name , strerror( errno ));
             OSS_CloseDevice(ossdev);
@@ -680,15 +681,16 @@ static BOOL OSS_WaveInInit(OSS_DEVICE* o
         if ((mixer = open(ossdev->mixer_name, O_RDONLY|O_NDELAY)) >= 0) {
             mixer_info info;
             if (ioctl(mixer, SOUND_MIXER_INFO, &info) >= 0) {
-                close(mixer);
                 strncpy(ossdev->in_caps.szPname, info.name, sizeof(info.name));
                 TRACE("%s\n", ossdev->ds_desc.szDesc);
             } else {
-                ERR("%s: can't read info!\n", ossdev->mixer_name);
-                OSS_CloseDevice(ossdev);
-                close(mixer);
-                return FALSE;
+                /* FreeBSD up to at least 5.2 provides this ioctl, but does not
+                 * implement it properly, and there are probably similar issues
+                 * on other platforms, so we warn but try to go ahead.
+                 */
+                WARN("%s: cannot read SOUND_MIXER_INFO!\n", ossdev->mixer_name);
             }
+            close(mixer);
         } else {
             ERR("%s: %s\n", ossdev->mixer_name, strerror(errno));
             OSS_CloseDevice(ossdev);



More information about the wine-devel mailing list