summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-10-13 16:42:56 +0200
committerwm4 <wm4@nowhere>2014-10-13 16:42:56 +0200
commit859d02b40e0399ad8c8db6bc7b6fca53d176d0cc (patch)
tree576abce4d6c92bb18a7db8e8be09fc83eb443710 /audio
parent2e52cc8f2e58bd261586e991adbd0907e4d9ab3d (diff)
downloadmpv-859d02b40e0399ad8c8db6bc7b6fca53d176d0cc.tar.bz2
mpv-859d02b40e0399ad8c8db6bc7b6fca53d176d0cc.tar.xz
ao_openal: implement device listing
Diffstat (limited to 'audio')
-rw-r--r--audio/out/ao_openal.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/audio/out/ao_openal.c b/audio/out/ao_openal.c
index 73ad0857d4..52b94299f0 100644
--- a/audio/out/ao_openal.c
+++ b/audio/out/ao_openal.c
@@ -101,6 +101,17 @@ static int validate_device_opt(struct mp_log *log, const m_option_t *opt,
return 0;
}
+static void list_devs(struct ao *ao, struct ao_device_list *list)
+{
+ if (alcIsExtensionPresent(NULL, "ALC_ENUMERATE_ALL_EXT") != AL_TRUE)
+ return;
+ const char *devs = alcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER);
+ while (devs && *devs) {
+ ao_device_list_add(list, ao, &(struct ao_device_desc){devs, devs});
+ devs = devs + strlen(devs) + 1;
+ }
+}
+
struct speaker {
int id;
float pos[3];
@@ -151,7 +162,10 @@ static int init(struct ao *ao)
goto err_out;
}
}
- dev = alcOpenDevice(p->cfg_device && p->cfg_device[0] ? p->cfg_device : NULL);
+ char *dev_name = p->cfg_device;
+ if (!dev_name || !dev_name[0])
+ dev_name = ao->device;
+ dev = alcOpenDevice(dev_name && dev_name[0] ? dev_name : NULL);
if (!dev) {
MP_FATAL(ao, "could not open device\n");
goto err_out;
@@ -302,6 +316,7 @@ const struct ao_driver audio_out_openal = {
.resume = audio_resume,
.reset = reset,
.drain = drain,
+ .list_devs = list_devs,
.priv_size = sizeof(struct priv),
.options = (const struct m_option[]) {
OPT_STRING_VALIDATE("device", cfg_device, 0, validate_device_opt),