summaryrefslogtreecommitdiffstats
path: root/libmpv
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2018-03-09 06:00:51 +0100
committerKevin Mitchell <kevmitch@gmail.com>2018-03-15 00:00:04 -0700
commita7f3cf473707b19bff9ea80b227490c8b305b601 (patch)
treeb094e1b8237d9ee09770e76809895b5d0e2eceaa /libmpv
parent410a1b49edfbbf7d528fd7dd06b73d06e2f9fce4 (diff)
downloadmpv-a7f3cf473707b19bff9ea80b227490c8b305b601.tar.bz2
mpv-a7f3cf473707b19bff9ea80b227490c8b305b601.tar.xz
client API: add mpv_create_weak_client()
Diffstat (limited to 'libmpv')
-rw-r--r--libmpv/client.h22
-rw-r--r--libmpv/mpv.def1
2 files changed, 20 insertions, 3 deletions
diff --git a/libmpv/client.h b/libmpv/client.h
index 536000229e..335e1417bc 100644
--- a/libmpv/client.h
+++ b/libmpv/client.h
@@ -452,9 +452,11 @@ int mpv_initialize(mpv_handle *ctx);
* API call.
*
* Since mpv client API version 1.29:
- * If the last mpv_handle is detached, the core player is destroyed. Note that
- * internal mpv_handles created due to scripts (e.g. the OSC) will keep the
- * player running. (To be fixed in the following commit.)
+ * If the last mpv_handle is detached, the core player is destroyed. In
+ * addition, if there are only weak mpv_handles (such as created by
+ * mpv_create_weak_client() or internal scripts), these mpv_handles will
+ * be sent MPV_EVENT_SHUTDOWN. This function may block until these clients
+ * have responded to the shutdown event, and the core is finally destroyed.
*
* Before mpv client API version 1.29:
* This left the player running. If you want to be sure that the
@@ -517,6 +519,20 @@ void mpv_terminate_destroy(mpv_handle *ctx);
mpv_handle *mpv_create_client(mpv_handle *ctx, const char *name);
/**
+ * This is the same as mpv_create_client(), but the created mpv_handle is
+ * treated as a weak reference. If all mpv_handles referencing a core are
+ * weak references, the core is automatically destroyed. (This still goes
+ * through normal uninit of course. Effectively, if the last non-weak mpv_handle
+ * is destroyed, then the weak mpv_handles receive MPV_EVENT_SHUTDOWN and are
+ * asked to terminate as well.)
+ *
+ * Note if you want to use this like refcounting: you have to be aware that
+ * mpv_terminate_destroy() _and_ mpv_detach_destroy() for the last non-weak
+ * mpv_handle will block until all weak mpv_handles are destroyed.
+ */
+mpv_handle *mpv_create_weak_client(mpv_handle *ctx, const char *name);
+
+/**
* Load a config file. This loads and parses the file, and sets every entry in
* the config file's default section as if mpv_set_option_string() is called.
*
diff --git a/libmpv/mpv.def b/libmpv/mpv.def
index 5299f69c9a..202f2071f0 100644
--- a/libmpv/mpv.def
+++ b/libmpv/mpv.def
@@ -7,6 +7,7 @@ mpv_command_node_async
mpv_command_string
mpv_create
mpv_create_client
+mpv_create_weak_client
mpv_detach_destroy
mpv_error_string
mpv_event_name