]> git.sesse.net Git - vlc/blobdiff - modules/audio_output/oss.c
audiounit_ios: merge playback performance improvements from the Mac auhal module
[vlc] / modules / audio_output / oss.c
index 5c98c3017cae329ad90ed3837ade334ae9955292..940718fa7eff2be64cc0b2fcb3dc4d0157c8929e 100644 (file)
@@ -148,8 +148,6 @@ static int Start (audio_output_t *aout, audio_sample_format_t *restrict fmt)
     {
         case AFMT_U8:     fmt->i_format = VLC_CODEC_U8;   break;
         case AFMT_S16_NE: fmt->i_format = VLC_CODEC_S16N; break;
-        //case AFMT_S24_BE:
-        //case AFMT_S24_LE:
         case AFMT_S32_NE: fmt->i_format = VLC_CODEC_S32N; break;
 #ifdef AFMT_FLOAT
         case AFMT_FLOAT:  fmt->i_format = VLC_CODEC_FL32; break;
@@ -210,6 +208,7 @@ static int Start (audio_output_t *aout, audio_sample_format_t *restrict fmt)
         fmt->i_original_channels =
         fmt->i_physical_channels = channels;
     }
+    aout_FormatPrepare (fmt);
 
     VolumeSync (aout);
     sys->starting = true;
@@ -283,7 +282,7 @@ static void Flush (audio_output_t *aout, bool wait)
 
     if (wait)
         return; /* drain is implicit with OSS */
-    ioctl (fd, SNDCTL_DSP_HALT_OUTPUT, NULL);
+    ioctl (fd, SNDCTL_DSP_HALT, NULL);
 }
 
 static int VolumeSync (audio_output_t *aout)
@@ -358,27 +357,24 @@ static int MuteSet (audio_output_t *aout, bool mute)
     return 0;
 }
 
-static int DevicesEnum (audio_output_t *aout, char ***idp, char ***namep)
+static int DevicesEnum (audio_output_t *aout)
 {
-    aout_sys_t *sys = sys;
-    int fd = sys->fd;
-    oss_sysinfo si;
-
+    int fd = vlc_open ("/dev/dsp", O_WRONLY);
     if (fd == -1)
         return -1;
+
+    oss_sysinfo si;
+    int n = -1;
+
     if (ioctl (fd, SNDCTL_SYSINFO, &si) < 0)
     {
         msg_Err (aout, "cannot get system infos: %m");
-        return -1;
+        goto out;
     }
 
     msg_Dbg (aout, "using %s version %s (0x%06X) under %s", si.product,
              si.version, si.versionnum, si.license);
 
-    char **ids = xmalloc (sizeof (*ids) * si.numaudios);
-    char **names = xmalloc (sizeof (*names) * si.numaudios);
-    int n = 0;
-
     for (int i = 0; i < si.numaudios; i++)
     {
         oss_audioinfo ai = { .dev = i };
@@ -395,12 +391,11 @@ static int DevicesEnum (audio_output_t *aout, char ***idp, char ***namep)
         if (!ai.enabled)
             continue;
 
-        ids[n] = xstrdup (ai.devnode);
-        names[n] = xstrdup (ai.name);
+        aout_HotplugReport (aout, ai.devnode, ai.name);
         n++;
     }
-    *idp = ids;
-    *namep = names;
+out:
+    close (fd);
     return n;
 }
 
@@ -442,8 +437,9 @@ static int Open (vlc_object_t *obj)
     aout->stop = Stop;
     aout->volume_set = VolumeSet;
     aout->mute_set = MuteSet;
-    aout->device_enum = DevicesEnum;
     aout->device_select = DeviceSelect;
+
+    DevicesEnum (aout);
     return VLC_SUCCESS;
 }