summaryrefslogtreecommitdiffstats
path: root/player/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'player/main.c')
-rw-r--r--player/main.c58
1 files changed, 25 insertions, 33 deletions
diff --git a/player/main.c b/player/main.c
index 2f4bede898..48d29b520e 100644
--- a/player/main.c
+++ b/player/main.c
@@ -21,14 +21,11 @@
#include <math.h>
#include <assert.h>
#include <string.h>
-#include <pthread.h>
#include <locale.h>
#include "config.h"
-#if HAVE_LIBPLACEBO
#include <libplacebo/config.h>
-#endif
#include "mpv_talloc.h"
@@ -36,6 +33,7 @@
#include "misc/thread_pool.h"
#include "osdep/io.h"
#include "osdep/terminal.h"
+#include "osdep/threads.h"
#include "osdep/timer.h"
#include "osdep/main-fn.h"
@@ -61,7 +59,6 @@
#include "audio/out/ao.h"
#include "misc/thread_tools.h"
#include "sub/osd.h"
-#include "test/tests.h"
#include "video/out/vo.h"
#include "core.h"
@@ -70,21 +67,17 @@
#include "screenshot.h"
static const char def_config[] =
-#include "generated/etc/builtin.conf.inc"
+#include "etc/builtin.conf.inc"
;
#if HAVE_COCOA
-#include "osdep/macosx_events.h"
+#include "osdep/mac/app_bridge.h"
#endif
#ifndef FULLCONFIG
#define FULLCONFIG "(missing)\n"
#endif
-#if !HAVE_STDATOMIC
-pthread_mutex_t mp_atomic_mutex = PTHREAD_MUTEX_INITIALIZER;
-#endif
-
enum exit_reason {
EXIT_NONE,
EXIT_NORMAL,
@@ -106,16 +99,16 @@ const char mp_help_text[] =
" --h=<string> print options which contain the given string in their name\n"
"\n";
-static pthread_mutex_t terminal_owner_lock = PTHREAD_MUTEX_INITIALIZER;
+static mp_static_mutex terminal_owner_lock = MP_STATIC_MUTEX_INITIALIZER;
static struct MPContext *terminal_owner;
static bool cas_terminal_owner(struct MPContext *old, struct MPContext *new)
{
- pthread_mutex_lock(&terminal_owner_lock);
+ mp_mutex_lock(&terminal_owner_lock);
bool r = terminal_owner == old;
if (r)
terminal_owner = new;
- pthread_mutex_unlock(&terminal_owner_lock);
+ mp_mutex_unlock(&terminal_owner_lock);
return r;
}
@@ -137,8 +130,12 @@ void mp_update_logging(struct MPContext *mpctx, bool preinit)
}
}
- if (mp_msg_has_log_file(mpctx->global) && !had_log_file)
- mp_print_version(mpctx->log, false); // for log-file=... in config files
+ if (mp_msg_has_log_file(mpctx->global) && !had_log_file) {
+ // for log-file=... in config files.
+ // we did flush earlier messages, but they were in a cyclic buffer, so
+ // the version might have been overwritten. ensure we have it.
+ mp_print_version(mpctx->log, false);
+ }
if (enabled && !preinit && mpctx->opts->consolecontrols)
terminal_setup_getch(mpctx->input);
@@ -147,11 +144,10 @@ void mp_update_logging(struct MPContext *mpctx, bool preinit)
void mp_print_version(struct mp_log *log, int always)
{
int v = always ? MSGL_INFO : MSGL_V;
- mp_msg(log, v, "%s %s\n built on %s\n",
- mpv_version, mpv_copyright, mpv_builddate);
-#if HAVE_LIBPLACEBO
+ mp_msg(log, v, "%s %s\n", mpv_version, mpv_copyright);
+ if (strcmp(mpv_builddate, "UNKNOWN"))
+ mp_msg(log, v, " built on %s\n", mpv_builddate);
mp_msg(log, v, "libplacebo version: %s\n", PL_VERSION);
-#endif
check_library_versions(log, v);
mp_msg(log, v, "\n");
// Only in verbose mode.
@@ -188,19 +184,20 @@ void mp_destroy(struct MPContext *mpctx)
cocoa_set_input_context(NULL);
#endif
- if (cas_terminal_owner(mpctx, mpctx)) {
- terminal_uninit();
- cas_terminal_owner(mpctx, NULL);
- }
-
mp_input_uninit(mpctx->input);
uninit_libav(mpctx->global);
mp_msg_uninit(mpctx->global);
+
+ if (cas_terminal_owner(mpctx, mpctx)) {
+ terminal_uninit();
+ cas_terminal_owner(mpctx, NULL);
+ }
+
assert(!mpctx->num_abort_list);
talloc_free(mpctx->abort_list);
- pthread_mutex_destroy(&mpctx->abort_lock);
+ mp_mutex_destroy(&mpctx->abort_lock);
talloc_free(mpctx->mconfig); // destroy before dispatch
talloc_free(mpctx);
}
@@ -228,7 +225,7 @@ static int cfg_include(void *ctx, char *filename, int flags)
{
struct MPContext *mpctx = ctx;
char *fname = mp_get_user_path(NULL, mpctx->global, filename);
- int r = m_config_parse_config_file(mpctx->mconfig, fname, NULL, flags);
+ int r = m_config_parse_config_file(mpctx->mconfig, mpctx->global, fname, NULL, flags);
talloc_free(fname);
return r;
}
@@ -272,7 +269,7 @@ struct MPContext *mp_create(void)
.play_dir = 1,
};
- pthread_mutex_init(&mpctx->abort_lock, NULL);
+ mp_mutex_init(&mpctx->abort_lock);
mpctx->global = talloc_zero(mpctx, struct mpv_global);
@@ -381,11 +378,6 @@ int mp_initialize(struct MPContext *mpctx, char **options)
check_library_versions(mp_null_log, 0);
-#if HAVE_TESTS
- if (opts->test_mode && opts->test_mode[0])
- return run_tests(mpctx) ? 1 : -1;
-#endif
-
if (!mpctx->playlist->num_entries && !opts->player_idle_mode &&
options)
{
@@ -398,7 +390,7 @@ int mp_initialize(struct MPContext *mpctx, char **options)
MP_STATS(mpctx, "start init");
#if HAVE_COCOA
- mpv_handle *ctx = mp_new_client(mpctx->clients, "osx");
+ mpv_handle *ctx = mp_new_client(mpctx->clients, "mac");
cocoa_set_mpv_handle(ctx);
#endif