Commit 28789103 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

OSS: adapt to hotplug event

parent 10605093
...@@ -356,32 +356,24 @@ static int MuteSet (audio_output_t *aout, bool mute) ...@@ -356,32 +356,24 @@ static int MuteSet (audio_output_t *aout, bool mute)
return 0; return 0;
} }
static int DevicesEnum (audio_output_t *aout, char ***idp, char ***namep) static int DevicesEnum (audio_output_t *aout)
{ {
aout_sys_t *sys = aout->sys; int fd = vlc_open ("/dev/dsp", O_WRONLY);
int fd = sys->fd;
oss_sysinfo si;
if (fd == -1) if (fd == -1)
{ return -1;
fd = vlc_open ("/dev/dsp", O_WRONLY);
if (fd == -1) oss_sysinfo si;
return -1; int n = -1;
}
if (ioctl (fd, SNDCTL_SYSINFO, &si) < 0) if (ioctl (fd, SNDCTL_SYSINFO, &si) < 0)
{ {
msg_Err (aout, "cannot get system infos: %m"); 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, msg_Dbg (aout, "using %s version %s (0x%06X) under %s", si.product,
si.version, si.versionnum, si.license); 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++) for (int i = 0; i < si.numaudios; i++)
{ {
oss_audioinfo ai = { .dev = i }; oss_audioinfo ai = { .dev = i };
...@@ -398,16 +390,11 @@ static int DevicesEnum (audio_output_t *aout, char ***idp, char ***namep) ...@@ -398,16 +390,11 @@ static int DevicesEnum (audio_output_t *aout, char ***idp, char ***namep)
if (!ai.enabled) if (!ai.enabled)
continue; continue;
ids[n] = xstrdup (ai.devnode); aout_HotplugReport (aout, ai.devnode, ai.name);
names[n] = xstrdup (ai.name);
n++; n++;
} }
out:
*idp = ids; close (fd);
*namep = names;
if (sys->fd == -1)
close (fd);
return n; return n;
} }
...@@ -449,8 +436,9 @@ static int Open (vlc_object_t *obj) ...@@ -449,8 +436,9 @@ static int Open (vlc_object_t *obj)
aout->stop = Stop; aout->stop = Stop;
aout->volume_set = VolumeSet; aout->volume_set = VolumeSet;
aout->mute_set = MuteSet; aout->mute_set = MuteSet;
aout->device_enum = DevicesEnum;
aout->device_select = DeviceSelect; aout->device_select = DeviceSelect;
DevicesEnum (aout);
return VLC_SUCCESS; return VLC_SUCCESS;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment