summaryrefslogtreecommitdiffstats
path: root/player/main.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2018-03-09 04:46:09 +0100
committerKevin Mitchell <kevmitch@gmail.com>2018-03-15 00:00:04 -0700
commit410a1b49edfbbf7d528fd7dd06b73d06e2f9fce4 (patch)
tree0861a27aa393997ccf02fe4498beff564a1a538b /player/main.c
parent782fa455b54f9153abefb64e26b8a25925118fc9 (diff)
downloadmpv-410a1b49edfbbf7d528fd7dd06b73d06e2f9fce4.tar.bz2
mpv-410a1b49edfbbf7d528fd7dd06b73d06e2f9fce4.tar.xz
client API: cleanup mpv_handle termination
This changes how mpv_terminate_destroy() and mpv_detach_destroy() behave. The doxygen in client.h tries to point out the differences. The goal is to make this more useful to the API user (making it behave like refcounting). This will be refined in follow up commits. Initialization is unfortunately closely tied to termination, so that changes as well. This also removes earlier hacks that make sure that some parts of FFmpeg initialization are run in the playback thread (instead of the user's thread). This does not matter with standard FFmpeg, and I have no reason to care about this anymore.
Diffstat (limited to 'player/main.c')
-rw-r--r--player/main.c16
1 files changed, 3 insertions, 13 deletions
diff --git a/player/main.c b/player/main.c
index bb83accb7e..bb80591220 100644
--- a/player/main.c
+++ b/player/main.c
@@ -154,18 +154,9 @@ void mp_print_version(struct mp_log *log, int always)
}
}
-static void shutdown_clients(struct MPContext *mpctx)
-{
- mp_client_enter_shutdown(mpctx);
- while (mp_clients_num(mpctx) || mpctx->outstanding_async) {
- mp_client_broadcast_event(mpctx, MPV_EVENT_SHUTDOWN, NULL);
- mp_wait_events(mpctx);
- }
-}
-
void mp_destroy(struct MPContext *mpctx)
{
- shutdown_clients(mpctx);
+ mp_shutdown_clients(mpctx);
mp_uninit_ipc(mpctx->ipc_ctx);
mpctx->ipc_ctx = NULL;
@@ -199,9 +190,6 @@ void mp_destroy(struct MPContext *mpctx)
uninit_libav(mpctx->global);
- if (mpctx->autodetach)
- pthread_detach(pthread_self());
-
mp_msg_uninit(mpctx->global);
pthread_mutex_destroy(&mpctx->lock);
talloc_free(mpctx);
@@ -461,6 +449,8 @@ int mpv_main(int argc, char *argv[])
if (!mpctx)
return 1;
+ mpctx->is_cli = true;
+
char **options = argv && argv[0] ? argv + 1 : NULL; // skips program name
int r = mp_initialize(mpctx, options);
if (r == 0)