diff options
author | wm4 <wm4@nowhere> | 2014-11-09 09:58:44 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-11-09 09:58:44 +0100 |
commit | b021d038c2217903e511ca3673d5f2f1b996c4d4 (patch) | |
tree | adc8258d5f8d18f11aa85f72fb6bc34ff62fb33f /audio/out/ao.c | |
parent | 7ee4e533693ee02e660ae0efb2e0e94db8c8c5af (diff) | |
download | mpv-b021d038c2217903e511ca3673d5f2f1b996c4d4.tar.bz2 mpv-b021d038c2217903e511ca3673d5f2f1b996c4d4.tar.xz |
audio/out: make ao_request_reload() idempotent
This is what you would expect. Before this commit, each
ao_request_reload() call would just queue a reload command, and then
recreate the AO for the number of times the function was called.
Instead of sending a command, introduce some sort of event retrieval
mechanism. At least for the reload case, use atomics, because we're too
lazy to setup an extra mutex.
Diffstat (limited to 'audio/out/ao.c')
-rw-r--r-- | audio/out/ao.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/audio/out/ao.c b/audio/out/ao.c index baf6db1e45..b92a78ff26 100644 --- a/audio/out/ao.c +++ b/audio/out/ao.c @@ -397,6 +397,22 @@ bool ao_eof_reached(struct ao *ao) return ao->api->get_eof ? ao->api->get_eof(ao) : true; } +// Query the AO_EVENT_*s as requested by the events parameter, and return them. +int ao_query_and_reset_events(struct ao *ao, int events) +{ + int actual_events = 0; + if (atomic_load(&ao->request_reload)) // don't need to reset it + actual_events |= AO_EVENT_RELOAD; + return actual_events & events; +} + +// Request that the player core destroys and recreates the AO. +void ao_request_reload(struct ao *ao) +{ + atomic_store(&ao->request_reload, true); + mp_input_wakeup(ao->input_ctx); +} + bool ao_chmap_sel_adjust(struct ao *ao, const struct mp_chmap_sel *s, struct mp_chmap *map) { @@ -409,13 +425,6 @@ bool ao_chmap_sel_get_def(struct ao *ao, const struct mp_chmap_sel *s, return mp_chmap_sel_get_def(s, map, num); } -// Request that the player core destroys and recreates the AO. -void ao_request_reload(struct ao *ao) -{ - const char *cmd[] = {"ao_reload", NULL}; - mp_input_run_cmd(ao->input_ctx, cmd); -} - // --- The following functions just return immutable information. void ao_get_format(struct ao *ao, struct mp_audio *format) |