mirror of
https://github.com/mpv-player/mpv.git
synced 2026-10-29 15:11:09 +08:00
player: drop explicit exit() calls
The code in main.c calls exit() explicitly, but the code is actually easier to follow by simply exiting from main() instead. The exit() call in av_log.c happens only on severely broken builds, so replace it with abort(). (Shuts up rpmlint warnings.)
This commit is contained in:
+2
-2
@@ -224,8 +224,8 @@ void print_libav_versions(struct mp_log *log, int v)
|
||||
if (broken) {
|
||||
mp_fatal(log, "mpv was compiled and linked against a mixture of Libav "
|
||||
"and FFmpeg versions. This won't work and will most likely "
|
||||
"crash at some point. Exiting.\n");
|
||||
exit(42);
|
||||
"crash at some point. Aborting.\n");
|
||||
abort();
|
||||
}
|
||||
// We don't "really" support mismatched libraries, but if you like to
|
||||
// suffer, you're free to enjoy the terrible aspects of dynamic linking.
|
||||
|
||||
+9
-14
@@ -184,8 +184,7 @@ void mp_destroy(struct MPContext *mpctx)
|
||||
talloc_free(mpctx);
|
||||
}
|
||||
|
||||
static MP_NORETURN void exit_player(struct MPContext *mpctx,
|
||||
enum exit_reason how)
|
||||
static int prepare_exit_cplayer(struct MPContext *mpctx, enum exit_reason how)
|
||||
{
|
||||
#if HAVE_COCOA_APPLICATION
|
||||
cocoa_set_input_context(NULL);
|
||||
@@ -230,13 +229,10 @@ static MP_NORETURN void exit_player(struct MPContext *mpctx,
|
||||
mp_destroy(mpctx);
|
||||
|
||||
#if HAVE_COCOA_APPLICATION
|
||||
// Note: this function never returns due to Cocoa calling exit(0)
|
||||
terminate_cocoa_application();
|
||||
// never reach here:
|
||||
// terminate calls exit itself, just silence compiler warning
|
||||
exit(0);
|
||||
#else
|
||||
exit(rc);
|
||||
#endif
|
||||
return rc;
|
||||
}
|
||||
|
||||
static bool handle_help_options(struct MPContext *mpctx)
|
||||
@@ -507,21 +503,21 @@ int mpv_main(int argc, char *argv[])
|
||||
mpctx->global, argc, argv);
|
||||
if (r < 0) {
|
||||
if (r <= M_OPT_EXIT) {
|
||||
exit_player(mpctx, EXIT_NONE);
|
||||
return prepare_exit_cplayer(mpctx, EXIT_NONE);
|
||||
} else {
|
||||
exit_player(mpctx, EXIT_ERROR);
|
||||
return prepare_exit_cplayer(mpctx, EXIT_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
mp_msg_update_msglevels(mpctx->global);
|
||||
|
||||
if (handle_help_options(mpctx))
|
||||
exit_player(mpctx, EXIT_NONE);
|
||||
return prepare_exit_cplayer(mpctx, EXIT_NONE);
|
||||
|
||||
if (!mpctx->playlist->first && !opts->player_idle_mode) {
|
||||
mp_print_version(mpctx->log, true);
|
||||
MP_INFO(mpctx, "%s", mp_help_text);
|
||||
exit_player(mpctx, EXIT_NONE);
|
||||
return prepare_exit_cplayer(mpctx, EXIT_NONE);
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
@@ -530,9 +526,8 @@ int mpv_main(int argc, char *argv[])
|
||||
#endif
|
||||
|
||||
if (mp_initialize(mpctx) < 0)
|
||||
exit_player(mpctx, EXIT_ERROR);
|
||||
return prepare_exit_cplayer(mpctx, EXIT_ERROR);
|
||||
|
||||
mp_play_files(mpctx);
|
||||
exit_player(mpctx, EXIT_NORMAL);
|
||||
return 1;
|
||||
return prepare_exit_cplayer(mpctx, EXIT_NORMAL);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user