summaryrefslogtreecommitdiffstats
path: root/audio/out/ao.h
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-02-12 16:53:56 +0100
committerwm4 <wm4@nowhere>2015-02-12 17:17:41 +0100
commitf061befb3338c5cd6837701b4232dad48340ab6c (patch)
tree13d8526248cc5bf68fb5d563fbf4cdd6e5dcc2aa /audio/out/ao.h
parentc152c590843a192761cff585a84ce57385d83d40 (diff)
downloadmpv-f061befb3338c5cd6837701b4232dad48340ab6c.tar.bz2
mpv-f061befb3338c5cd6837701b4232dad48340ab6c.tar.xz
audio: add device change notification for hotplugging
Not very important for the command line player; but GUI applications will want to know about this. This only adds the internal API; support for specific audio outputs comes later. This reuses the ao struct as context for the hotplug event listener, similar to how the "old" device listing API did. This is probably a bit unclean and confusing. One argument got reusing it is that otherwise rewriting parts of ao_pulse would be required (because the PulseAudio API requires so damn much boilerplate). Another is that --ao-defaults is applied to the hotplug dummy ao struct, which automatically applies such defaults even to the hotplug context. Notification works through the property observation mechanism in the client API. The notification chain is a bit complicated: the AO notifies the player, which in turn notifies the clients, which in turn will actually retrieve the device list. (It still has the advantage that it's slightly cleaner, since the AO stuff doesn't need to know about client API issues.) The weird handling of atomic flags in ao.c is because we still don't require real atomics from the compiler. Otherwise we'd just use atomic bitwise operations.
Diffstat (limited to 'audio/out/ao.h')
-rw-r--r--audio/out/ao.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/audio/out/ao.h b/audio/out/ao.h
index dbbed24873..7b85ec80ba 100644
--- a/audio/out/ao.h
+++ b/audio/out/ao.h
@@ -48,6 +48,7 @@ enum aocontrol {
enum {
AO_EVENT_RELOAD = 1,
+ AO_EVENT_HOTPLUG = 2,
};
typedef struct ao_control_vol {
@@ -92,8 +93,15 @@ void ao_drain(struct ao *ao);
bool ao_eof_reached(struct ao *ao);
int ao_query_and_reset_events(struct ao *ao, int events);
void ao_request_reload(struct ao *ao);
+void ao_hotplug_event(struct ao *ao);
+
+struct ao_hotplug;
+struct ao_hotplug *ao_hotplug_create(struct mpv_global *global,
+ struct input_ctx *input_ctx);
+void ao_hotplug_destroy(struct ao_hotplug *hp);
+bool ao_hotplug_check_update(struct ao_hotplug *hp);
+struct ao_device_list *ao_hotplug_get_device_list(struct ao_hotplug *hp);
-struct ao_device_list *ao_get_device_list(struct mpv_global *global);
void ao_print_devices(struct mpv_global *global, struct mp_log *log);
#endif /* MPLAYER_AUDIO_OUT_H */