From 41f2b26d11e81095a0d8d370480e0d2459208070 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 7 Mar 2014 15:24:32 +0100 Subject: audio/out: make ao struct opaque We want to move the AO to its own thread. There's no technical reason for making the ao struct opaque to do this. But it helps us sleep at night, because we can control access to shared state better. --- audio/out/ao.c | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'audio/out/ao.c') diff --git a/audio/out/ao.c b/audio/out/ao.c index 02415b0f2d..b77d401d64 100644 --- a/audio/out/ao.c +++ b/audio/out/ao.c @@ -25,7 +25,9 @@ #include "config.h" #include "ao.h" +#include "internal.h" #include "audio/format.h" +#include "audio/audio.h" #include "options/options.h" #include "options/m_config.h" @@ -231,8 +233,15 @@ int ao_play(struct ao *ao, void **data, int samples, int flags) int ao_control(struct ao *ao, enum aocontrol cmd, void *arg) { - if (ao->driver->control) - return ao->driver->control(ao, cmd, arg); + switch (cmd) { + case AOCONTROL_HAS_TEMP_VOLUME: + return !ao->no_persistent_volume; + case AOCONTROL_HAS_PER_APP_VOLUME: + return !!ao->per_application_mixer; + default: + if (ao->driver->control) + return ao->driver->control(ao, cmd, arg); + } return CONTROL_UNKNOWN; } @@ -307,3 +316,28 @@ bool ao_chmap_sel_get_def(struct ao *ao, const struct mp_chmap_sel *s, { return mp_chmap_sel_get_def(s, map, num); } + +// --- The following functions just return immutable information. + +void ao_get_format(struct ao *ao, struct mp_audio *format) +{ + *format = (struct mp_audio){0}; + mp_audio_set_format(format, ao->format); + mp_audio_set_channels(format, &ao->channels); + format->rate = ao->samplerate; +} + +const char *ao_get_name(struct ao *ao) +{ + return ao->driver->name; +} + +const char *ao_get_description(struct ao *ao) +{ + return ao->driver->description; +} + +bool ao_untimed(struct ao *ao) +{ + return ao->untimed; +} -- cgit v1.2.3