summaryrefslogtreecommitdiffstats
path: root/player/main.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-06-07 15:08:45 +0200
committerwm4 <wm4@nowhere>2014-06-07 15:57:54 +0200
commit500ce69a06be2cb2b79f310e638e4c4ceabe447e (patch)
treea855d9bc2c2be7deaa9db06c787d61ffd1f33136 /player/main.c
parentd64bd9efa13c5e1fc71cfc565950b4afe6e53c8a (diff)
downloadmpv-500ce69a06be2cb2b79f310e638e4c4ceabe447e.tar.bz2
mpv-500ce69a06be2cb2b79f310e638e4c4ceabe447e.tar.xz
client API: add API function that ensures total destruction
mpv_destroy() should perhaps better be called mpv_detach(), because it destroys only the handle, not necessarily the player. The player is only terminated if a quit command is sent. This function quits automatically, and additionally waits until the player is completely destroyed. It removes the possibility that the player core is still uninitializing, while all client handles are already destroyed. (Although in practice, the difference is usually not important.)
Diffstat (limited to 'player/main.c')
-rw-r--r--player/main.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/player/main.c b/player/main.c
index 0bfd25bdd5..d7b34e0ef8 100644
--- a/player/main.c
+++ b/player/main.c
@@ -23,6 +23,7 @@
#include <assert.h>
#include <ctype.h>
#include <string.h>
+#include <pthread.h>
#include "config.h"
#include "talloc.h"
@@ -148,6 +149,9 @@ void mp_destroy(struct MPContext *mpctx)
}
uninit_libav(mpctx->global);
+ if (mpctx->autodetach)
+ pthread_detach(pthread_self());
+
mp_msg_uninit(mpctx->global);
talloc_free(mpctx);
}