2013-10-29 21:38:29 +00:00
|
|
|
/*
|
|
|
|
* This file is part of MPlayer.
|
|
|
|
*
|
|
|
|
* MPlayer is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* MPlayer is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with MPlayer; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <assert.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "talloc.h"
|
|
|
|
|
|
|
|
#include "osdep/io.h"
|
|
|
|
#include "osdep/priority.h"
|
2013-12-19 20:31:27 +00:00
|
|
|
#include "osdep/terminal.h"
|
2013-10-29 21:38:29 +00:00
|
|
|
#include "osdep/timer.h"
|
|
|
|
|
2013-12-17 01:39:45 +00:00
|
|
|
#include "common/av_log.h"
|
|
|
|
#include "common/codecs.h"
|
|
|
|
#include "common/cpudetect.h"
|
|
|
|
#include "common/encode.h"
|
2013-12-17 01:02:25 +00:00
|
|
|
#include "options/m_config.h"
|
|
|
|
#include "options/m_option.h"
|
|
|
|
#include "options/m_property.h"
|
2013-12-17 01:39:45 +00:00
|
|
|
#include "common/common.h"
|
|
|
|
#include "common/msg.h"
|
|
|
|
#include "common/global.h"
|
2013-12-17 01:02:25 +00:00
|
|
|
#include "options/parse_configfile.h"
|
|
|
|
#include "options/parse_commandline.h"
|
2013-12-17 01:39:45 +00:00
|
|
|
#include "common/playlist.h"
|
|
|
|
#include "common/playlist_parser.h"
|
2013-12-17 01:02:25 +00:00
|
|
|
#include "options/options.h"
|
2013-12-17 00:23:09 +00:00
|
|
|
#include "input/input.h"
|
2013-10-29 21:38:29 +00:00
|
|
|
|
|
|
|
#include "audio/decode/dec_audio.h"
|
|
|
|
#include "audio/out/ao.h"
|
|
|
|
#include "audio/mixer.h"
|
2013-11-23 21:08:42 +00:00
|
|
|
#include "demux/demux.h"
|
2013-10-29 21:38:29 +00:00
|
|
|
#include "stream/stream.h"
|
|
|
|
#include "sub/ass_mp.h"
|
2013-11-24 11:58:06 +00:00
|
|
|
#include "sub/osd.h"
|
2013-10-29 21:38:29 +00:00
|
|
|
#include "video/decode/dec_video.h"
|
|
|
|
#include "video/out/vo.h"
|
|
|
|
|
2013-12-17 00:08:53 +00:00
|
|
|
#include "core.h"
|
2013-12-17 00:15:48 +00:00
|
|
|
#include "lua.h"
|
2013-10-29 21:38:29 +00:00
|
|
|
#include "command.h"
|
|
|
|
#include "screenshot.h"
|
|
|
|
|
2013-07-16 11:28:28 +00:00
|
|
|
#if HAVE_X11
|
2013-10-29 21:38:29 +00:00
|
|
|
#include "video/out/x11_common.h"
|
|
|
|
#endif
|
|
|
|
|
2013-07-16 11:28:28 +00:00
|
|
|
#if HAVE_COCOA
|
2013-10-29 21:38:29 +00:00
|
|
|
#include "osdep/macosx_application.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef PTW32_STATIC_LIB
|
|
|
|
#include <pthread.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__MINGW32__) || defined(__CYGWIN__)
|
|
|
|
#include <windows.h>
|
|
|
|
#endif
|
|
|
|
|
2013-12-18 16:12:07 +00:00
|
|
|
const char mp_help_text[] =
|
2013-10-29 21:38:29 +00:00
|
|
|
"Usage: mpv [options] [url|path/]filename\n"
|
|
|
|
"\n"
|
|
|
|
"Basic options:\n"
|
|
|
|
" --start=<time> seek to given (percent, seconds, or hh:mm:ss) position\n"
|
|
|
|
" --no-audio do not play sound\n"
|
|
|
|
" --no-video do not play video\n"
|
|
|
|
" --fs fullscreen playback\n"
|
|
|
|
" --sub=<file> specify subtitle file to use\n"
|
|
|
|
" --playlist=<file> specify playlist file\n"
|
|
|
|
"\n"
|
|
|
|
" --list-options list all mpv options\n"
|
2013-12-18 16:12:07 +00:00
|
|
|
"\n";
|
2013-10-29 21:38:29 +00:00
|
|
|
|
2013-12-21 18:45:42 +00:00
|
|
|
void mp_print_version(struct mp_log *log, int always)
|
2013-10-29 21:38:29 +00:00
|
|
|
{
|
|
|
|
int v = always ? MSGL_INFO : MSGL_V;
|
2013-12-21 18:45:42 +00:00
|
|
|
mp_msg_log(log, v,
|
2013-10-29 21:38:29 +00:00
|
|
|
"%s (C) 2000-2013 mpv/MPlayer/mplayer2 projects\n built on %s\n", mplayer_version, mplayer_builddate);
|
2013-12-21 18:45:42 +00:00
|
|
|
print_libav_versions(log, v);
|
|
|
|
mp_msg_log(log, v, "\n");
|
2013-10-29 21:38:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static MP_NORETURN void exit_player(struct MPContext *mpctx,
|
|
|
|
enum exit_reason how)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
uninit_player(mpctx, INITIALIZED_ALL);
|
|
|
|
|
2013-07-16 11:28:28 +00:00
|
|
|
#if HAVE_ENCODING
|
2013-10-29 21:38:29 +00:00
|
|
|
encode_lavc_finish(mpctx->encode_lavc_ctx);
|
|
|
|
encode_lavc_free(mpctx->encode_lavc_ctx);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
mpctx->encode_lavc_ctx = NULL;
|
|
|
|
|
2013-07-16 11:28:28 +00:00
|
|
|
#if HAVE_LUA
|
2013-10-29 21:38:29 +00:00
|
|
|
mp_lua_uninit(mpctx);
|
|
|
|
#endif
|
|
|
|
|
2013-11-25 23:31:46 +00:00
|
|
|
#if defined(__MINGW32__)
|
2013-10-29 21:38:29 +00:00
|
|
|
timeEndPeriod(1);
|
|
|
|
#endif
|
|
|
|
|
2013-07-16 11:28:28 +00:00
|
|
|
#if HAVE_COCOA
|
2013-10-29 21:38:29 +00:00
|
|
|
cocoa_set_input_context(NULL);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
command_uninit(mpctx);
|
|
|
|
|
|
|
|
mp_input_uninit(mpctx->input);
|
|
|
|
|
|
|
|
osd_free(mpctx->osd);
|
|
|
|
|
2013-07-16 11:28:28 +00:00
|
|
|
#if HAVE_LIBASS
|
2013-10-29 21:38:29 +00:00
|
|
|
ass_library_done(mpctx->ass_library);
|
|
|
|
mpctx->ass_library = NULL;
|
|
|
|
#endif
|
|
|
|
|
2013-12-15 17:04:13 +00:00
|
|
|
getch2_disable();
|
2013-12-21 19:06:36 +00:00
|
|
|
uninit_libav(mpctx->global);
|
2013-12-15 17:04:13 +00:00
|
|
|
|
2013-10-29 21:38:29 +00:00
|
|
|
if (how != EXIT_NONE) {
|
|
|
|
const char *reason;
|
|
|
|
switch (how) {
|
|
|
|
case EXIT_SOMENOTPLAYED:
|
|
|
|
case EXIT_PLAYED:
|
|
|
|
reason = "End of file";
|
|
|
|
break;
|
|
|
|
case EXIT_NOTPLAYED:
|
|
|
|
reason = "No files played";
|
|
|
|
break;
|
|
|
|
case EXIT_ERROR:
|
|
|
|
reason = "Fatal error";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
reason = "Quit";
|
|
|
|
}
|
|
|
|
MP_INFO(mpctx, "\nExiting... (%s)\n", reason);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mpctx->has_quit_custom_rc) {
|
|
|
|
rc = mpctx->quit_custom_rc;
|
|
|
|
} else {
|
|
|
|
switch (how) {
|
|
|
|
case EXIT_ERROR:
|
|
|
|
rc = 1; break;
|
|
|
|
case EXIT_NOTPLAYED:
|
|
|
|
rc = 2; break;
|
|
|
|
case EXIT_SOMENOTPLAYED:
|
|
|
|
rc = 3; break;
|
|
|
|
default:
|
|
|
|
rc = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// must be last since e.g. mp_msg uses option values
|
|
|
|
// that will be freed by this.
|
|
|
|
|
|
|
|
mp_msg_uninit(mpctx->global);
|
|
|
|
talloc_free(mpctx);
|
|
|
|
|
2013-07-16 11:28:28 +00:00
|
|
|
#if HAVE_COCOA
|
2013-10-29 21:38:29 +00:00
|
|
|
terminate_cocoa_application();
|
|
|
|
// never reach here:
|
|
|
|
// terminate calls exit itself, just silence compiler warning
|
|
|
|
exit(0);
|
|
|
|
#else
|
|
|
|
exit(rc);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool handle_help_options(struct MPContext *mpctx)
|
|
|
|
{
|
|
|
|
struct MPOpts *opts = mpctx->opts;
|
2013-12-21 17:46:24 +00:00
|
|
|
struct mp_log *log = mpctx->log;
|
2013-10-29 21:38:29 +00:00
|
|
|
int opt_exit = 0;
|
|
|
|
if (opts->audio_decoders && strcmp(opts->audio_decoders, "help") == 0) {
|
2013-11-23 20:22:17 +00:00
|
|
|
struct mp_decoder_list *list = audio_decoder_list();
|
2013-12-21 17:46:24 +00:00
|
|
|
mp_print_decoders(log, MSGL_INFO, "Audio decoders:", list);
|
2013-10-29 21:38:29 +00:00
|
|
|
talloc_free(list);
|
|
|
|
opt_exit = 1;
|
|
|
|
}
|
|
|
|
if (opts->video_decoders && strcmp(opts->video_decoders, "help") == 0) {
|
2013-11-23 20:36:20 +00:00
|
|
|
struct mp_decoder_list *list = video_decoder_list();
|
2013-12-21 17:46:24 +00:00
|
|
|
mp_print_decoders(log, MSGL_INFO, "Video decoders:", list);
|
2013-10-29 21:38:29 +00:00
|
|
|
talloc_free(list);
|
|
|
|
opt_exit = 1;
|
|
|
|
}
|
2013-07-16 11:28:28 +00:00
|
|
|
#if HAVE_X11
|
2013-10-29 21:38:29 +00:00
|
|
|
if (opts->vo.fstype_list && strcmp(opts->vo.fstype_list[0], "help") == 0) {
|
2013-12-21 19:11:45 +00:00
|
|
|
fstype_help(log);
|
2013-12-19 20:28:55 +00:00
|
|
|
MP_INFO(mpctx, "\n");
|
2013-10-29 21:38:29 +00:00
|
|
|
opt_exit = 1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
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)) {
|
2013-12-21 19:24:20 +00:00
|
|
|
demuxer_help(log);
|
2013-10-29 21:38:29 +00:00
|
|
|
MP_INFO(mpctx, "\n");
|
|
|
|
opt_exit = 1;
|
|
|
|
}
|
|
|
|
if (opts->list_properties) {
|
2013-12-21 18:36:33 +00:00
|
|
|
property_print_help(log);
|
2013-10-29 21:38:29 +00:00
|
|
|
opt_exit = 1;
|
|
|
|
}
|
2013-07-16 11:28:28 +00:00
|
|
|
#if HAVE_ENCODING
|
2013-12-21 19:11:04 +00:00
|
|
|
if (encode_lavc_showhelp(log, &opts->encode_output))
|
2013-10-29 21:38:29 +00:00
|
|
|
opt_exit = 1;
|
|
|
|
#endif
|
|
|
|
return opt_exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef PTW32_STATIC_LIB
|
|
|
|
static void detach_ptw32(void)
|
|
|
|
{
|
|
|
|
pthread_win32_thread_detach_np();
|
|
|
|
pthread_win32_process_detach_np();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static void osdep_preinit(int *p_argc, char ***p_argv)
|
|
|
|
{
|
|
|
|
char *enable_talloc = getenv("MPV_LEAK_REPORT");
|
|
|
|
if (*p_argc > 1 && (strcmp((*p_argv)[1], "-leak-report") == 0 ||
|
|
|
|
strcmp((*p_argv)[1], "--leak-report") == 0))
|
|
|
|
enable_talloc = "1";
|
|
|
|
if (enable_talloc && strcmp(enable_talloc, "1") == 0)
|
|
|
|
talloc_enable_leak_report();
|
|
|
|
|
|
|
|
#ifdef __MINGW32__
|
|
|
|
mp_get_converted_argv(p_argc, p_argv);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef PTW32_STATIC_LIB
|
|
|
|
pthread_win32_process_attach_np();
|
|
|
|
pthread_win32_thread_attach_np();
|
|
|
|
atexit(detach_ptw32);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__MINGW32__) || defined(__CYGWIN__)
|
|
|
|
// stop Windows from showing all kinds of annoying error dialogs
|
|
|
|
SetErrorMode(0x8003);
|
|
|
|
#endif
|
|
|
|
|
2013-12-18 14:03:08 +00:00
|
|
|
terminal_init();
|
2013-10-29 21:38:29 +00:00
|
|
|
|
|
|
|
mp_time_init();
|
|
|
|
}
|
|
|
|
|
2013-12-21 18:27:19 +00:00
|
|
|
static int cfg_include(void *ctx, char *filename, int flags)
|
2013-10-29 21:38:29 +00:00
|
|
|
{
|
2013-12-21 18:27:19 +00:00
|
|
|
struct MPContext *mpctx = ctx;
|
|
|
|
return m_config_parse_config_file(mpctx->mconfig, filename, flags);
|
2013-10-29 21:38:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int mpv_main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
osdep_preinit(&argc, &argv);
|
|
|
|
|
|
|
|
if (argc >= 1) {
|
|
|
|
argc--;
|
|
|
|
argv++;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct MPContext *mpctx = talloc(NULL, MPContext);
|
|
|
|
*mpctx = (struct MPContext){
|
|
|
|
.last_dvb_step = 1,
|
|
|
|
.terminal_osd_text = talloc_strdup(mpctx, ""),
|
|
|
|
.playlist = talloc_struct(mpctx, struct playlist, {0}),
|
|
|
|
};
|
|
|
|
|
2013-12-21 18:45:42 +00:00
|
|
|
mpctx->global = talloc_zero(mpctx, struct mpv_global);
|
|
|
|
|
|
|
|
// Nothing must call mp_msg*() and related before this
|
|
|
|
mp_msg_init(mpctx->global);
|
|
|
|
mpctx->log = mp_log_new(mpctx, mpctx->global->log, "!cplayer");
|
|
|
|
|
2013-10-29 21:38:29 +00:00
|
|
|
// Create the config context and register the options
|
2013-12-21 18:45:42 +00:00
|
|
|
mpctx->mconfig = m_config_new(mpctx, mpctx->log, sizeof(struct MPOpts),
|
2013-10-29 21:38:29 +00:00
|
|
|
&mp_default_opts, mp_opts);
|
|
|
|
mpctx->opts = mpctx->mconfig->optstruct;
|
|
|
|
mpctx->mconfig->includefunc = cfg_include;
|
2013-12-21 18:27:19 +00:00
|
|
|
mpctx->mconfig->includefunc_ctx = mpctx;
|
2013-10-29 21:38:29 +00:00
|
|
|
mpctx->mconfig->use_profiles = true;
|
2013-11-23 20:35:03 +00:00
|
|
|
mpctx->mconfig->is_toplevel = true;
|
2013-10-29 21:38:29 +00:00
|
|
|
|
|
|
|
struct MPOpts *opts = mpctx->opts;
|
|
|
|
mpctx->global->opts = opts;
|
|
|
|
|
2013-12-21 19:06:36 +00:00
|
|
|
init_libav(mpctx->global);
|
2013-10-29 21:38:29 +00:00
|
|
|
GetCpuCaps(&gCpuCaps);
|
|
|
|
screenshot_init(mpctx);
|
2013-12-21 17:19:47 +00:00
|
|
|
mpctx->mixer = mixer_init(mpctx, mpctx->global);
|
2013-10-29 21:38:29 +00:00
|
|
|
command_init(mpctx);
|
|
|
|
|
|
|
|
// Preparse the command line
|
|
|
|
m_config_preparse_command_line(mpctx->mconfig, argc, argv);
|
2013-12-18 18:04:30 +00:00
|
|
|
mp_msg_update_msglevels(mpctx->global);
|
2013-10-29 21:38:29 +00:00
|
|
|
|
2013-12-21 18:45:42 +00:00
|
|
|
mp_print_version(mpctx->log, false);
|
2013-10-29 21:38:29 +00:00
|
|
|
|
|
|
|
if (!mp_parse_cfgfiles(mpctx))
|
|
|
|
exit_player(mpctx, EXIT_ERROR);
|
|
|
|
|
|
|
|
int r = m_config_parse_mp_command_line(mpctx->mconfig, mpctx->playlist,
|
2013-12-21 19:08:34 +00:00
|
|
|
mpctx->global, argc, argv);
|
2013-10-29 21:38:29 +00:00
|
|
|
if (r < 0) {
|
|
|
|
if (r <= M_OPT_EXIT) {
|
|
|
|
exit_player(mpctx, EXIT_NONE);
|
|
|
|
} else {
|
|
|
|
exit_player(mpctx, EXIT_ERROR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-18 18:04:30 +00:00
|
|
|
mp_msg_update_msglevels(mpctx->global);
|
|
|
|
|
2013-10-29 21:38:29 +00:00
|
|
|
if (handle_help_options(mpctx))
|
|
|
|
exit_player(mpctx, EXIT_NONE);
|
|
|
|
|
|
|
|
MP_VERBOSE(mpctx, "Configuration: " CONFIGURATION "\n");
|
|
|
|
MP_VERBOSE(mpctx, "Command line:");
|
|
|
|
for (int i = 0; i < argc; i++)
|
|
|
|
MP_VERBOSE(mpctx, " '%s'", argv[i]);
|
|
|
|
MP_VERBOSE(mpctx, "\n");
|
|
|
|
|
|
|
|
if (!mpctx->playlist->first && !opts->player_idle_mode) {
|
2013-12-21 18:45:42 +00:00
|
|
|
mp_print_version(mpctx->log, true);
|
2013-12-16 19:40:02 +00:00
|
|
|
MP_INFO(mpctx, "%s", mp_help_text);
|
2013-10-29 21:38:29 +00:00
|
|
|
exit_player(mpctx, EXIT_NONE);
|
|
|
|
}
|
|
|
|
|
2013-07-16 11:28:28 +00:00
|
|
|
#if HAVE_PRIORITY
|
2013-10-29 21:38:29 +00:00
|
|
|
set_priority();
|
|
|
|
#endif
|
|
|
|
|
2013-12-21 18:33:45 +00:00
|
|
|
mpctx->input = mp_input_init(mpctx->global);
|
|
|
|
stream_set_interrupt_callback(mp_input_check_interrupt, mpctx->input);
|
|
|
|
#if HAVE_COCOA
|
|
|
|
cocoa_set_input_context(mpctx->input);
|
|
|
|
#endif
|
2013-10-29 21:38:29 +00:00
|
|
|
|
2013-07-16 11:28:28 +00:00
|
|
|
#if HAVE_ENCODING
|
2013-10-29 21:38:29 +00:00
|
|
|
if (opts->encode_output.file && *opts->encode_output.file) {
|
2013-12-21 19:11:04 +00:00
|
|
|
mpctx->encode_lavc_ctx = encode_lavc_init(&opts->encode_output,
|
|
|
|
mpctx->global);
|
2013-10-29 21:38:29 +00:00
|
|
|
if(!mpctx->encode_lavc_ctx) {
|
2013-12-19 20:28:55 +00:00
|
|
|
MP_INFO(mpctx, "Encoding initialization failed.");
|
2013-10-29 21:38:29 +00:00
|
|
|
exit_player(mpctx, EXIT_ERROR);
|
|
|
|
}
|
|
|
|
m_config_set_option0(mpctx->mconfig, "vo", "lavc");
|
|
|
|
m_config_set_option0(mpctx->mconfig, "ao", "lavc");
|
|
|
|
m_config_set_option0(mpctx->mconfig, "fixed-vo", "yes");
|
|
|
|
m_config_set_option0(mpctx->mconfig, "force-window", "no");
|
|
|
|
m_config_set_option0(mpctx->mconfig, "gapless-audio", "yes");
|
|
|
|
mp_input_enable_section(mpctx->input, "encode", MP_INPUT_EXCLUSIVE);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-12-21 18:33:45 +00:00
|
|
|
if (mpctx->opts->slave_mode)
|
|
|
|
terminal_setup_stdin_cmd_input(mpctx->input);
|
|
|
|
else if (mpctx->opts->consolecontrols)
|
|
|
|
terminal_setup_getch(mpctx->input);
|
|
|
|
|
2013-12-15 17:04:13 +00:00
|
|
|
if (opts->consolecontrols)
|
|
|
|
getch2_enable();
|
|
|
|
|
2013-07-16 11:28:28 +00:00
|
|
|
#if HAVE_LIBASS
|
2013-12-21 18:06:37 +00:00
|
|
|
mpctx->ass_log = mp_log_new(mpctx, mpctx->global->log, "!libass");
|
|
|
|
mpctx->ass_library = mp_ass_init(mpctx->global, mpctx->ass_log);
|
2013-10-29 21:38:29 +00:00
|
|
|
#else
|
|
|
|
MP_WARN(mpctx, "Compiled without libass.\n");
|
2013-10-30 20:55:17 +00:00
|
|
|
MP_WARN(mpctx, "There will be no OSD and no text subtitles.\n");
|
2013-10-29 21:38:29 +00:00
|
|
|
#endif
|
|
|
|
|
2013-12-21 18:06:37 +00:00
|
|
|
mpctx->osd = osd_create(mpctx->global);
|
2013-10-29 21:38:29 +00:00
|
|
|
|
|
|
|
if (opts->force_vo) {
|
|
|
|
opts->fixed_vo = 1;
|
|
|
|
mpctx->video_out = init_best_video_out(mpctx->global, mpctx->input,
|
|
|
|
mpctx->encode_lavc_ctx);
|
|
|
|
if (!mpctx->video_out) {
|
|
|
|
MP_FATAL(mpctx, "Error opening/initializing "
|
|
|
|
"the selected video_out (-vo) device.\n");
|
|
|
|
exit_player(mpctx, EXIT_ERROR);
|
|
|
|
}
|
|
|
|
mpctx->mouse_cursor_visible = true;
|
|
|
|
mpctx->initialized_flags |= INITIALIZED_VO;
|
|
|
|
}
|
|
|
|
|
2013-07-16 11:28:28 +00:00
|
|
|
#if HAVE_LUA
|
2013-10-29 21:38:29 +00:00
|
|
|
// Lua user scripts can call arbitrary functions. Load them at a point
|
|
|
|
// where this is safe.
|
|
|
|
mp_lua_init(mpctx);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (opts->shuffle)
|
|
|
|
playlist_shuffle(mpctx->playlist);
|
|
|
|
|
2013-11-19 21:36:33 +00:00
|
|
|
if (opts->merge_files)
|
|
|
|
merge_playlist_files(mpctx->playlist);
|
|
|
|
|
2013-10-29 21:38:29 +00:00
|
|
|
mpctx->playlist->current = mp_resume_playlist(mpctx->playlist, opts);
|
|
|
|
if (!mpctx->playlist->current)
|
|
|
|
mpctx->playlist->current = mpctx->playlist->first;
|
|
|
|
|
|
|
|
mp_play_files(mpctx);
|
|
|
|
|
|
|
|
exit_player(mpctx, mpctx->stop_play == PT_QUIT ? EXIT_QUIT : mpctx->quit_player_rc);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2013-07-16 11:28:28 +00:00
|
|
|
#if HAVE_COCOA
|
2013-10-29 21:38:29 +00:00
|
|
|
return cocoa_main(mpv_main, argc, argv);
|
|
|
|
#else
|
|
|
|
return mpv_main(argc, argv);
|
|
|
|
#endif
|
|
|
|
}
|