[vlc-commits] OSS: adapt to hotplug event
Rémi Denis-Courmont
git at videolan.org
Sun Apr 14 10:51:34 CEST 2013
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Apr 14 11:27:18 2013 +0300| [287891031f07e5e1f25804400300e92e23d99bcc] | committer: Rémi Denis-Courmont
OSS: adapt to hotplug event
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=287891031f07e5e1f25804400300e92e23d99bcc
---
modules/audio_output/oss.c | 36 ++++++++++++------------------------
1 file changed, 12 insertions(+), 24 deletions(-)
diff --git a/modules/audio_output/oss.c b/modules/audio_output/oss.c
index c737fe2..8dc4a4a 100644
--- a/modules/audio_output/oss.c
+++ b/modules/audio_output/oss.c
@@ -356,32 +356,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 = aout->sys;
- int fd = sys->fd;
- oss_sysinfo si;
-
+ int fd = vlc_open ("/dev/dsp", O_WRONLY);
if (fd == -1)
- {
- fd = vlc_open ("/dev/dsp", O_WRONLY);
- if (fd == -1)
- return -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 };
@@ -398,16 +390,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;
- if (sys->fd == -1)
- close (fd);
-
+out:
+ close (fd);
return n;
}
@@ -449,8 +436,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;
}
More information about the vlc-commits
mailing list