[vlc-devel] [PATCH] oss: fix device selection

Sean McGovern gseanmcg at gmail.com
Tue Feb 10 03:42:58 CET 2015


---
 modules/audio_output/oss.c |   31 ++++++++++++++++++++-----------
 1 file changed, 20 insertions(+), 11 deletions(-)

diff --git a/modules/audio_output/oss.c b/modules/audio_output/oss.c
index 1afd03d..3803b32 100644
--- a/modules/audio_output/oss.c
+++ b/modules/audio_output/oss.c
@@ -91,20 +91,14 @@ static int Start (audio_output_t *aout, audio_sample_format_t *restrict fmt)
     aout_sys_t* sys = aout->sys;
 
     /* Open the device */
-    const char *device = sys->device;
-    if (device == NULL)
-        device = getenv ("OSS_AUDIODEV");
-    if (device == NULL)
-        device = "/dev/dsp";
-
-    int fd = vlc_open (device, O_WRONLY);
+    int fd = vlc_open (sys->device, O_WRONLY);
     if (fd == -1)
     {
-        msg_Err (aout, "cannot open OSS device %s: %s", device,
+        msg_Err (aout, "cannot open OSS device %s: %s", sys->device,
                  vlc_strerror_c(errno));
         return VLC_EGENERIC;
     }
-    msg_Dbg (aout, "using OSS device: %s", device);
+    msg_Dbg (aout, "using OSS device: %s", sys->device);
 
     /* Select audio format */
     int format;
@@ -352,7 +346,11 @@ static int DevicesEnum (audio_output_t *aout)
         if (!ai.enabled)
             continue;
 
-        aout_HotplugReport (aout, ai.devnode, ai.name);
+        /* the device ID may be a symlink -- canonicalize it */
+        char *devnode = realpath(ai.devnode, NULL);
+        aout_HotplugReport (aout, devnode, ai.name);
+        free (devnode);
+
         n++;
     }
 out:
@@ -388,7 +386,17 @@ static int Open (vlc_object_t *obj)
         return VLC_ENOMEM;
 
     sys->fd = -1;
-    sys->device = var_InheritString (aout, "oss-audio-device");
+    char *device = var_InheritString (aout, "oss-audio-device");
+    if (device == NULL)
+        device = getenv ("OSS_AUDIODEV");
+    if (device == NULL)
+        device = "/dev/dsp";
+
+    /* the device ID may be a symlink -- canonicalize it */
+    sys->device = realpath (device, NULL);
+
+    if (device)
+        free (device);
 
     aout->sys = sys;
     aout->start = Start;
@@ -397,6 +405,7 @@ static int Open (vlc_object_t *obj)
     aout_SoftVolumeInit (aout);
 
     DevicesEnum (aout);
+    aout_DeviceReport (aout, sys->device);
     return VLC_SUCCESS;
 }
 
-- 
1.7.9.2




More information about the vlc-devel mailing list