diff options
author | wm4 <wm4@nowhere> | 2015-02-02 17:24:33 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-02-02 18:07:37 +0100 |
commit | ef827af06cbf334a497fb0de8c9b75188549d03e (patch) | |
tree | 7d745d909fbeeae7a8466fff32166a723aa72871 /libmpv/client.h | |
parent | 9d8b00f1d6624779ab0db946018042135ef28017 (diff) | |
download | mpv-ef827af06cbf334a497fb0de8c9b75188549d03e.tar.bz2 mpv-ef827af06cbf334a497fb0de8c9b75188549d03e.tar.xz |
client API: add mpv_wait_async_requests()
This does what it's documented to do.
The implementation reuses the code in mpv_detach_destroy(). Due to the
way async requests currently work, just sending a synchronous dummy
request (like a "ignore" command) would be enough to ensure
synchronization, but this code will continue to work even if this
changes.
The line "ctx->event_mask = 0;" is removed, but it shouldn't be needed.
(If a client is somehow very slow to terminate, this could silence an
annoying queue overflow message, but all in all it does nothing.)
Calling mpv_wait_async_requests() and mpv_wait_event() concurrently is
in theory allowed, so change pthread_cond_signal() to
pthread_cond_broadcast() to avoid missed wakeups.
As requested in issue #1542.
Diffstat (limited to 'libmpv/client.h')
-rw-r--r-- | libmpv/client.h | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/libmpv/client.h b/libmpv/client.h index 7208912ee0..500f03cd94 100644 --- a/libmpv/client.h +++ b/libmpv/client.h @@ -167,7 +167,7 @@ extern "C" { * relational operators (<, >, <=, >=). */ #define MPV_MAKE_VERSION(major, minor) (((major) << 16) | (minor) | 0UL) -#define MPV_CLIENT_API_VERSION MPV_MAKE_VERSION(1, 13) +#define MPV_CLIENT_API_VERSION MPV_MAKE_VERSION(1, 14) /** * Return the MPV_CLIENT_API_VERSION the mpv source has been compiled with. @@ -1478,6 +1478,20 @@ void mpv_set_wakeup_callback(mpv_handle *ctx, void (*cb)(void *d), void *d); */ int mpv_get_wakeup_pipe(mpv_handle *ctx); +/** + * Block until all asynchronous requests are done. This affects functions like + * mpv_command_async(), which return immediately and return their result as + * events. + * + * This is a helper, and somewhat equivalent to calling mpv_wait_event() in a + * loop until all known asynchronous requests have sent their reply as event, + * except that the event queue is not emptied. + * + * In case you called mpv_suspend() before, this will also forcibly reset the + * suspend counter of the given handle. + */ +void mpv_wait_async_requests(mpv_handle *ctx); + typedef enum mpv_sub_api { /** * For using mpv's OpenGL renderer on an external OpenGL context. |