summaryrefslogtreecommitdiffstats
path: root/player/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'player/main.c')
-rw-r--r--player/main.c77
1 files changed, 37 insertions, 40 deletions
diff --git a/player/main.c b/player/main.c
index 71f5d14b53..48d29b520e 100644
--- a/player/main.c
+++ b/player/main.c
@@ -21,16 +21,19 @@
#include <math.h>
#include <assert.h>
#include <string.h>
-#include <pthread.h>
#include <locale.h>
#include "config.h"
+
+#include <libplacebo/config.h>
+
#include "mpv_talloc.h"
#include "misc/dispatch.h"
#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"
@@ -54,10 +57,8 @@
#include "input/input.h"
#include "audio/out/ao.h"
-#include "demux/demux.h"
#include "misc/thread_tools.h"
#include "sub/osd.h"
-#include "test/tests.h"
#include "video/out/vo.h"
#include "core.h"
@@ -66,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,
@@ -102,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;
}
@@ -133,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);
@@ -143,8 +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);
+ 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);
check_library_versions(log, v);
mp_msg(log, v, "\n");
// Only in verbose mode.
@@ -181,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);
}
@@ -202,17 +206,10 @@ static bool handle_help_options(struct MPContext *mpctx)
{
struct MPOpts *opts = mpctx->opts;
struct mp_log *log = mpctx->log;
- if ((opts->demuxer_name && strcmp(opts->demuxer_name, "help") == 0) ||
- (opts->audio_demuxer_name && strcmp(opts->audio_demuxer_name, "help") == 0) ||
- (opts->sub_demuxer_name && strcmp(opts->sub_demuxer_name, "help") == 0)) {
- demuxer_help(log);
- MP_INFO(mpctx, "\n");
- return true;
- }
if (opts->ao_opts->audio_device &&
strcmp(opts->ao_opts->audio_device, "help") == 0)
{
- ao_print_devices(mpctx->global, log);
+ ao_print_devices(mpctx->global, log, mpctx->ao);
return true;
}
if (opts->property_print_help) {
@@ -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);
@@ -361,7 +358,10 @@ int mp_initialize(struct MPContext *mpctx, char **options)
m_config_set_profile(mpctx->mconfig, "pseudo-gui", 0);
}
- mp_get_resume_defaults(mpctx);
+ // Backup the default settings, which should not be stored in the resume
+ // config files. This explicitly includes values set by config files and
+ // the command line.
+ m_config_backup_watch_later_opts(mpctx->mconfig);
mp_input_load_config(mpctx->input);
@@ -378,12 +378,9 @@ 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) {
+ if (!mpctx->playlist->num_entries && !opts->player_idle_mode &&
+ options)
+ {
// nothing to play
mp_print_version(mpctx->log, true);
MP_INFO(mpctx, "%s", mp_help_text);
@@ -393,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