summaryrefslogtreecommitdiffstats
path: root/libao2/ao_openal.c
diff options
context:
space:
mode:
Diffstat (limited to 'libao2/ao_openal.c')
-rw-r--r--libao2/ao_openal.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/libao2/ao_openal.c b/libao2/ao_openal.c
index 490aac0eb8..0e04f2cc81 100644
--- a/libao2/ao_openal.c
+++ b/libao2/ao_openal.c
@@ -28,9 +28,11 @@
#ifdef OPENAL_AL_H
#include <OpenAL/alc.h>
#include <OpenAL/al.h>
+#include <OpenAL/alext.h>
#else
#include <AL/alc.h>
#include <AL/al.h>
+#include <AL/alext.h>
#endif
#include "mp_msg.h"
@@ -86,11 +88,27 @@ static int control(int cmd, void *arg) {
static void print_help(void) {
mp_msg(MSGT_AO, MSGL_FATAL,
"\n-ao openal commandline help:\n"
- "Example: mplayer -ao openal\n"
+ "Example: mplayer -ao openal:device=subdevice\n"
"\nOptions:\n"
+ " device=subdevice\n"
+ " Audio device OpenAL should use. Devices can be listed\n"
+ " with -ao openal:device=help\n"
);
}
+static void list_devices(void) {
+ if (alcIsExtensionPresent(NULL, "ALC_ENUMERATE_ALL_EXT") != AL_TRUE) {
+ mp_msg(MSGT_AO, MSGL_FATAL, "Device listing not supported.\n");
+ return;
+ }
+ const char *list = alcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER);
+ mp_msg(MSGT_AO, MSGL_FATAL, "OpenAL devices:\n");
+ while (list && *list) {
+ mp_msg(MSGT_AO, MSGL_FATAL, " '%s'\n", list);
+ list = list + strlen(list) + 1;
+ }
+}
+
static int init(int rate, int channels, int format, int flags) {
float position[3] = {0, 0, 0};
float direction[6] = {0, 0, 1, 0, -1, 0};
@@ -105,7 +123,9 @@ static int init(int rate, int channels, int format, int flags) {
ALCint freq = 0;
ALCint attribs[] = {ALC_FREQUENCY, rate, 0, 0};
int i;
+ char *device = NULL;
const opt_t subopts[] = {
+ {"device", OPT_ARG_MSTRZ, &device, NULL},
{NULL}
};
global_ao->no_persistent_volume = true;
@@ -113,11 +133,15 @@ static int init(int rate, int channels, int format, int flags) {
print_help();
return 0;
}
+ if (device && strcmp(device, "help") == 0) {
+ list_devices();
+ goto err_out;
+ }
if (channels > MAX_CHANS) {
mp_msg(MSGT_AO, MSGL_FATAL, "[OpenAL] Invalid number of channels: %i\n", channels);
goto err_out;
}
- dev = alcOpenDevice(NULL);
+ dev = alcOpenDevice(device);
if (!dev) {
mp_msg(MSGT_AO, MSGL_FATAL, "[OpenAL] could not open device\n");
goto err_out;
@@ -146,9 +170,11 @@ static int init(int rate, int channels, int format, int flags) {
ao_data.buffersize = CHUNK_SIZE * NUM_BUF;
ao_data.outburst = channels * CHUNK_SIZE;
tmpbuf = malloc(CHUNK_SIZE);
+ free(device);
return 1;
err_out:
+ free(device);
return 0;
}