summaryrefslogtreecommitdiffstats
path: root/audio/out/ao.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-03-07 15:24:32 +0100
committerwm4 <wm4@nowhere>2014-03-09 00:19:31 +0100
commit41f2b26d11e81095a0d8d370480e0d2459208070 (patch)
tree1b665e392be25795b8fade6d0487609f73ac90d2 /audio/out/ao.c
parent74b7001500c0901b095986fafe7dca3e5c23c7f2 (diff)
downloadmpv-41f2b26d11e81095a0d8d370480e0d2459208070.tar.bz2
mpv-41f2b26d11e81095a0d8d370480e0d2459208070.tar.xz
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.
Diffstat (limited to 'audio/out/ao.c')
-rw-r--r--audio/out/ao.c38
1 files changed, 36 insertions, 2 deletions
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;
+}