summaryrefslogtreecommitdiffstats
path: root/mplayer.c
diff options
context:
space:
mode:
authorUoti Urpala <uau@mplayer2.org>2011-08-07 03:58:12 +0300
committerUoti Urpala <uau@mplayer2.org>2011-08-07 03:58:48 +0300
commit0fd7e6ec93c54b5f22c6e8730448cc9170ae7d99 (patch)
treea43de5cc09677f8f589a6cbaa46495f220e58b67 /mplayer.c
parenta5c642888259112dba9a5b83419ed4a014e97303 (diff)
downloadmpv-0fd7e6ec93c54b5f22c6e8730448cc9170ae7d99.tar.bz2
mpv-0fd7e6ec93c54b5f22c6e8730448cc9170ae7d99.tar.xz
cleanup: reformat mplayer.c
I had delayed reformatting mplayer.c as I wanted to split it, but since I didn't come up with a good way to do that I'll clean up the messy formatting now.
Diffstat (limited to 'mplayer.c')
-rw-r--r--mplayer.c4174
1 files changed, 2174 insertions, 2000 deletions
diff --git a/mplayer.c b/mplayer.c
index bc99557a58..7ddcf48a5c 100644
--- a/mplayer.c
+++ b/mplayer.c
@@ -41,11 +41,11 @@
#include <sys/ioctl.h>
#include <sys/wait.h>
#else
-#define SIGHUP 1 /* hangup */
-#define SIGQUIT 3 /* quit */
-#define SIGKILL 9 /* kill (cannot be caught or ignored) */
-#define SIGBUS 10 /* bus error */
-#define SIGPIPE 13 /* broken pipe */
+#define SIGHUP 1 /* hangup */
+#define SIGQUIT 3 /* quit */
+#define SIGKILL 9 /* kill (cannot be caught or ignored) */
+#define SIGBUS 10 /* bus error */
+#define SIGPIPE 13 /* broken pipe */
#endif
#include <sys/time.h>
@@ -103,8 +103,8 @@
#include "input/input.h"
-int slave_mode=0;
-int enable_mouse_movements=0;
+int slave_mode = 0;
+int enable_mouse_movements = 0;
float start_volume = -1;
#include "osdep/priority.h"
@@ -144,7 +144,11 @@ char *heartbeat_cmd;
// Config file
//**************************************************************************//
-static int cfg_inc_verbose(m_option_t *conf){ ++verbose; return 0;}
+static int cfg_inc_verbose(m_option_t *conf)
+{
+ ++verbose;
+ return 0;
+}
#include "path.h"
@@ -153,7 +157,7 @@ static int cfg_inc_verbose(m_option_t *conf){ ++verbose; return 0;}
// Input media streaming & demultiplexer:
//**************************************************************************//
-static int max_framesize=0;
+static int max_framesize = 0;
#include "stream/stream.h"
#include "libmpdemux/demuxer.h"
@@ -176,7 +180,7 @@ static int max_framesize=0;
#include "options.h"
#include "defaultopts.h"
-static const char help_text[]=_(
+static const char help_text[] = _(
"Usage: mplayer [options] [url|path/]filename\n"
"\n"
"Basic options: (complete list in the man page)\n"
@@ -271,67 +275,67 @@ static const char help_text[]=_(
#include "mp_fifo.h"
// benchmark:
-double video_time_usage=0;
-double vout_time_usage=0;
-static double audio_time_usage=0;
-static int total_time_usage_start=0;
-static int total_frame_cnt=0;
-static int drop_frame_cnt=0; // total number of dropped frames
+double video_time_usage;
+double vout_time_usage;
+static double audio_time_usage;
+static int total_time_usage_start;
+static int total_frame_cnt;
+static int drop_frame_cnt; // total number of dropped frames
// options:
-static int output_quality=0;
+static int output_quality;
// seek:
-static off_t seek_to_byte=0;
-static off_t step_sec=0;
+static off_t seek_to_byte;
+static off_t step_sec;
static m_time_size_t end_at = { .type = END_AT_NONE, .pos = 0 };
// codecs:
-char **audio_codec_list=NULL; // override audio codec
-char **video_codec_list=NULL; // override video codec
-char **audio_fm_list=NULL; // override audio codec family
-char **video_fm_list=NULL; // override video codec family
+char **audio_codec_list; // override audio codec
+char **video_codec_list; // override video codec
+char **audio_fm_list; // override audio codec family
+char **video_fm_list; // override video codec family
// this dvdsub_id was selected via slang
// use this to allow dvdnav to follow -slang across stream resets,
// in particular the subtitle ID for a language changes
int dvdsub_lang_id;
-int vobsub_id=-1;
-static char* spudec_ifo=NULL;
-int forced_subs_only=0;
-int file_filter=1;
+int vobsub_id = -1;
+static char *spudec_ifo = NULL;
+int forced_subs_only = 0;
+int file_filter = 1;
// cache2:
- int stream_cache_size=-1;
+int stream_cache_size = -1;
// dump:
- int stream_dump_type=0;
+int stream_dump_type = 0;
// A-V sync:
-static float default_max_pts_correction=-1;//0.01f;
- float audio_delay=0;
-static int ignore_start=0;
+static float default_max_pts_correction = -1;
+float audio_delay = 0;
+static int ignore_start = 0;
- double force_fps=0;
-static int force_srate=0;
- int frame_dropping=0; // option 0=no drop 1= drop vo 2= drop decode
-static int play_n_frames=-1;
-static int play_n_frames_mf=-1;
+double force_fps = 0;
+static int force_srate = 0;
+int frame_dropping = 0; // option 0=no drop 1= drop vo 2= drop decode
+static int play_n_frames = -1;
+static int play_n_frames_mf = -1;
// sub:
-char *font_name=NULL;
-char *sub_font_name=NULL;
+char *font_name = NULL;
+char *sub_font_name = NULL;
extern int font_fontconfig;
-float font_factor=0.75;
-float sub_delay=0;
-float sub_fps=0;
-int subcc_enabled=0;
+float font_factor = 0.75;
+float sub_delay = 0;
+float sub_fps = 0;
+int subcc_enabled = 0;
int suboverlap_enabled = 1;
#include "sub/ass_mp.h"
-char* current_module=NULL; // for debugging
+char *current_module; // for debugging
// ---
@@ -339,20 +343,20 @@ char* current_module=NULL; // for debugging
#ifdef CONFIG_MENU
#include "m_struct.h"
#include "libmenu/menu.h"
-static const vf_info_t* const libmenu_vfs[] = {
- &vf_info_menu,
- NULL
+static const vf_info_t * const libmenu_vfs[] = {
+ &vf_info_menu,
+ NULL
};
-static vf_instance_t* vf_menu = NULL;
-int use_menu = 0;
-static char* menu_cfg = NULL;
-static char* menu_root = "main";
+static vf_instance_t *vf_menu;
+int use_menu;
+static char *menu_cfg;
+static char *menu_root = "main";
#endif
edl_record_ptr edl_records = NULL; ///< EDL entries memory area
edl_record_ptr next_edl_record = NULL; ///< only for traversing edl_records
-FILE* edl_fd = NULL; ///< fd to write to when in -edlout mode.
+FILE *edl_fd; // file to write to when in -edlout mode.
int use_filedir_conf;
int use_filename_title;
@@ -399,62 +403,57 @@ static float get_relative_time(struct MPContext *mpctx)
return delta * 0.000001;
}
-static int is_valid_metadata_type(struct MPContext *mpctx, metadata_t type) {
- switch (type)
- {
- /* check for valid video stream */
- case META_VIDEO_CODEC:
- case META_VIDEO_BITRATE:
- case META_VIDEO_RESOLUTION:
- {
- if (!mpctx->sh_video)
- return 0;
- break;
- }
-
- /* check for valid audio stream */
- case META_AUDIO_CODEC:
- case META_AUDIO_BITRATE:
- case META_AUDIO_SAMPLES:
- {
- if (!mpctx->sh_audio)
- return 0;
- break;
- }
-
- /* check for valid demuxer */
- case META_INFO_TITLE:
- case META_INFO_ARTIST:
- case META_INFO_ALBUM:
- case META_INFO_YEAR:
- case META_INFO_COMMENT:
- case META_INFO_TRACK:
- case META_INFO_GENRE:
- {
- if (!mpctx->demuxer)
- return 0;
- break;
- }
-
- default:
- break;
- }
-
- return 1;
+static int is_valid_metadata_type(struct MPContext *mpctx, metadata_t type)
+{
+ switch (type) {
+ /* check for valid video stream */
+ case META_VIDEO_CODEC:
+ case META_VIDEO_BITRATE:
+ case META_VIDEO_RESOLUTION:
+ if (!mpctx->sh_video)
+ return 0;
+ break;
+
+ /* check for valid audio stream */
+ case META_AUDIO_CODEC:
+ case META_AUDIO_BITRATE:
+ case META_AUDIO_SAMPLES:
+ if (!mpctx->sh_audio)
+ return 0;
+ break;
+
+ /* check for valid demuxer */
+ case META_INFO_TITLE:
+ case META_INFO_ARTIST:
+ case META_INFO_ALBUM:
+ case META_INFO_YEAR:
+ case META_INFO_COMMENT:
+ case META_INFO_TRACK:
+ case META_INFO_GENRE:
+ if (!mpctx->demuxer)
+ return 0;
+ break;
+
+ default:
+ break;
+ }
+
+ return 1;
}
-static char *get_demuxer_info(struct MPContext *mpctx, char *tag) {
- char **info = mpctx->demuxer->info;
- int n;
+static char *get_demuxer_info(struct MPContext *mpctx, char *tag)
+{
+ char **info = mpctx->demuxer->info;
+ int n;
- if (!info || !tag)
- return talloc_strdup(NULL, "");
+ if (!info || !tag)
+ return talloc_strdup(NULL, "");
- for (n = 0; info[2*n] != NULL ; n++)
- if (!strcasecmp (info[2*n], tag))
- break;
+ for (n = 0; info[2 * n] != NULL; n++)
+ if (!strcasecmp(info[2 * n], tag))
+ break;
- return talloc_strdup(NULL, info[2*n+1] ? info[2*n+1] : "");
+ return talloc_strdup(NULL, info[2 * n + 1] ? info[2 * n + 1] : "");
}
char *get_metadata(struct MPContext *mpctx, metadata_t type)
@@ -493,96 +492,116 @@ char *get_metadata(struct MPContext *mpctx, metadata_t type)
return talloc_strdup(NULL, "");
case META_AUDIO_BITRATE:
return talloc_asprintf(NULL, "%d kbps",
- (int) (sh_audio->i_bps * 8/1000));
+ (int) (sh_audio->i_bps * 8 / 1000));
case META_AUDIO_SAMPLES:
return talloc_asprintf(NULL, "%d Hz, %d ch.", sh_audio->samplerate,
sh_audio->channels);
- /* check for valid demuxer */
- case META_INFO_TITLE:
- return get_demuxer_info(mpctx, "Title");
+ /* check for valid demuxer */
+ case META_INFO_TITLE:
+ return get_demuxer_info(mpctx, "Title");
- case META_INFO_ARTIST:
- return get_demuxer_info(mpctx, "Artist");
+ case META_INFO_ARTIST:
+ return get_demuxer_info(mpctx, "Artist");
- case META_INFO_ALBUM:
- return get_demuxer_info(mpctx, "Album");
+ case META_INFO_ALBUM:
+ return get_demuxer_info(mpctx, "Album");
- case META_INFO_YEAR:
- return get_demuxer_info(mpctx, "Year");
+ case META_INFO_YEAR:
+ return get_demuxer_info(mpctx, "Year");
- case META_INFO_COMMENT:
- return get_demuxer_info(mpctx, "Comment");
+ case META_INFO_COMMENT:
+ return get_demuxer_info(mpctx, "Comment");
- case META_INFO_TRACK:
- return get_demuxer_info(mpctx, "Track");
+ case META_INFO_TRACK:
+ return get_demuxer_info(mpctx, "Track");
- case META_INFO_GENRE:
- return get_demuxer_info(mpctx, "Genre");
+ case META_INFO_GENRE:
+ return get_demuxer_info(mpctx, "Genre");
- default:
- break;
- }
+ default:
+ break;
+ }
return talloc_strdup(NULL, "");
}
static void print_file_properties(struct MPContext *mpctx, const char *filename)
{
- double start_pts = MP_NOPTS_VALUE;
- double video_start_pts = MP_NOPTS_VALUE;
- mp_msg(MSGT_IDENTIFY,MSGL_INFO,"ID_FILENAME=%s\n",
- filename_recode(filename));
- mp_msg(MSGT_IDENTIFY,MSGL_INFO,"ID_DEMUXER=%s\n", mpctx->demuxer->desc->name);
- if (mpctx->sh_video) {
- /* Assume FOURCC if all bytes >= 0x20 (' ') */
- if (mpctx->sh_video->format >= 0x20202020)
- mp_msg(MSGT_IDENTIFY,MSGL_INFO,"ID_VIDEO_FORMAT=%.4s\n", (char *)&mpctx->sh_video->format);
- else
- mp_msg(MSGT_IDENTIFY,MSGL_INFO,"ID_VIDEO_FORMAT=0x%08X\n", mpctx->sh_video->format);
- mp_msg(MSGT_IDENTIFY,MSGL_INFO,"ID_VIDEO_BITRATE=%d\n", mpctx->sh_video->i_bps*8);
- mp_msg(MSGT_IDENTIFY,MSGL_INFO,"ID_VIDEO_WIDTH=%d\n", mpctx->sh_video->disp_w);
- mp_msg(MSGT_IDENTIFY,MSGL_INFO,"ID_VIDEO_HEIGHT=%d\n", mpctx->sh_video->disp_h);
- mp_msg(MSGT_IDENTIFY,MSGL_INFO,"ID_VIDEO_FPS=%5.3f\n", mpctx->sh_video->fps);
- mp_msg(MSGT_IDENTIFY,MSGL_INFO,"ID_VIDEO_ASPECT=%1.4f\n", mpctx->sh_video->aspect);
- video_start_pts = ds_get_next_pts(mpctx->d_video);
- }
- if (mpctx->sh_audio) {
- /* Assume FOURCC if all bytes >= 0x20 (' ') */
- if (mpctx->sh_audio->format >= 0x20202020)
- mp_msg(MSGT_IDENTIFY,MSGL_INFO, "ID_AUDIO_FORMAT=%.4s\n", (char *)&mpctx->sh_audio->format);
+ double start_pts = MP_NOPTS_VALUE;
+ double video_start_pts = MP_NOPTS_VALUE;
+ mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_FILENAME=%s\n",
+ filename_recode(filename));
+ mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_DEMUXER=%s\n",
+ mpctx->demuxer->desc->name);
+ if (mpctx->sh_video) {
+ /* Assume FOURCC if all bytes >= 0x20 (' ') */
+ if (mpctx->sh_video->format >= 0x20202020)
+ mp_msg(MSGT_IDENTIFY, MSGL_INFO,
+ "ID_VIDEO_FORMAT=%.4s\n", (char *)&mpctx->sh_video->format);
+ else
+ mp_msg(MSGT_IDENTIFY, MSGL_INFO,
+ "ID_VIDEO_FORMAT=0x%08X\n", mpctx->sh_video->format);
+ mp_msg(MSGT_IDENTIFY, MSGL_INFO,
+ "ID_VIDEO_BITRATE=%d\n", mpctx->sh_video->i_bps * 8);
+ mp_msg(MSGT_IDENTIFY, MSGL_INFO,
+ "ID_VIDEO_WIDTH=%d\n", mpctx->sh_video->disp_w);
+ mp_msg(MSGT_IDENTIFY, MSGL_INFO,
+ "ID_VIDEO_HEIGHT=%d\n", mpctx->sh_video->disp_h);
+ mp_msg(MSGT_IDENTIFY, MSGL_INFO,
+ "ID_VIDEO_FPS=%5.3f\n", mpctx->sh_video->fps);
+ mp_msg(MSGT_IDENTIFY, MSGL_INFO,
+ "ID_VIDEO_ASPECT=%1.4f\n", mpctx->sh_video->aspect);
+ video_start_pts = ds_get_next_pts(mpctx->d_video);
+ }
+ if (mpctx->sh_audio) {
+ /* Assume FOURCC if all bytes >= 0x20 (' ') */
+ if (mpctx->sh_audio->format >= 0x20202020)
+ mp_msg(MSGT_IDENTIFY, MSGL_INFO,
+ "ID_AUDIO_FORMAT=%.4s\n", (char *)&mpctx->sh_audio->format);
+ else
+ mp_msg(MSGT_IDENTIFY, MSGL_INFO,
+ "ID_AUDIO_FORMAT=%d\n", mpctx->sh_audio->format);
+ mp_msg(MSGT_IDENTIFY, MSGL_INFO,
+ "ID_AUDIO_BITRATE=%d\n", mpctx->sh_audio->i_bps * 8);
+ mp_msg(MSGT_IDENTIFY, MSGL_INFO,
+ "ID_AUDIO_RATE=%d\n", mpctx->sh_audio->samplerate);
+ mp_msg(MSGT_IDENTIFY, MSGL_INFO,
+ "ID_AUDIO_NCH=%d\n", mpctx->sh_audio->channels);
+ start_pts = ds_get_next_pts(mpctx->d_audio);
+ }
+ if (video_start_pts != MP_NOPTS_VALUE) {
+ if (start_pts == MP_NOPTS_VALUE || !mpctx->sh_audio ||
+ (mpctx->sh_video && video_start_pts < start_pts))
+ start_pts = video_start_pts;
+ }
+ if (start_pts != MP_NOPTS_VALUE)
+ mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_START_TIME=%.2f\n", start_pts);
else
- mp_msg(MSGT_IDENTIFY,MSGL_INFO,"ID_AUDIO_FORMAT=%d\n", mpctx->sh_audio->format);
- mp_msg(MSGT_IDENTIFY,MSGL_INFO,"ID_AUDIO_BITRATE=%d\n", mpctx->sh_audio->i_bps*8);
- mp_msg(MSGT_IDENTIFY,MSGL_INFO,"ID_AUDIO_RATE=%d\n", mpctx->sh_audio->samplerate);
- mp_msg(MSGT_IDENTIFY,MSGL_INFO,"ID_AUDIO_NCH=%d\n", mpctx->sh_audio->channels);
- start_pts = ds_get_next_pts(mpctx->d_audio);
- }
- if (video_start_pts != MP_NOPTS_VALUE) {
- if (start_pts == MP_NOPTS_VALUE || !mpctx->sh_audio ||
- (mpctx->sh_video && video_start_pts < start_pts))
- start_pts = video_start_pts;
- }
- if (start_pts != MP_NOPTS_VALUE)
- mp_msg(MSGT_IDENTIFY,MSGL_INFO,"ID_START_TIME=%.2f\n", start_pts);
- else
- mp_msg(MSGT_IDENTIFY,MSGL_INFO,"ID_START_TIME=unknown\n");
- mp_msg(MSGT_IDENTIFY,MSGL_INFO,"ID_LENGTH=%.2f\n", get_time_length(mpctx));
- mp_msg(MSGT_IDENTIFY,MSGL_INFO,"ID_SEEKABLE=%d\n",
- mpctx->stream->seek && (!mpctx->demuxer || mpctx->demuxer->seekable));
- if (mpctx->demuxer) {
- if (mpctx->demuxer->num_chapters == 0)
- stream_control(mpctx->demuxer->stream, STREAM_CTRL_GET_NUM_CHAPTERS, &mpctx->demuxer->num_chapters);
- mp_msg(MSGT_IDENTIFY,MSGL_INFO,"ID_CHAPTERS=%d\n", mpctx->demuxer->num_chapters);
- }
+ mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_START_TIME=unknown\n");
+ mp_msg(MSGT_IDENTIFY, MSGL_INFO,
+ "ID_LENGTH=%.2f\n", get_time_length(mpctx));
+ mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_SEEKABLE=%d\n",
+ mpctx->stream->seek
+ && (!mpctx->demuxer || mpctx->demuxer->seekable));
+ if (mpctx->demuxer) {
+ if (mpctx->demuxer->num_chapters == 0)
+ stream_control(mpctx->demuxer->stream,
+ STREAM_CTRL_GET_NUM_CHAPTERS,
+ &mpctx->demuxer->num_chapters);
+ mp_msg(MSGT_IDENTIFY, MSGL_INFO,
+ "ID_CHAPTERS=%d\n", mpctx->demuxer->num_chapters);
+ }
}
/// step size of mixer changes
int volstep = 3;
#ifdef CONFIG_DVDNAV
-static void mp_dvdnav_context_free(MPContext *ctx){
- if (ctx->nav_smpi) free_mp_image(ctx->nav_smpi);
+static void mp_dvdnav_context_free(MPContext *ctx)
+{
+ if (ctx->nav_smpi)
+ free_mp_image(ctx->nav_smpi);
ctx->nav_smpi = NULL;
free(ctx->nav_buffer);
ctx->nav_buffer = NULL;
@@ -600,199 +619,208 @@ static void uninit_subs(struct demuxer *demuxer)
}
}
-void uninit_player(struct MPContext *mpctx, unsigned int mask){
- mask &= mpctx->initialized_flags;
-
- mp_msg(MSGT_CPLAYER,MSGL_DBG2,"\n*** uninit(0x%X)\n",mask);
-
- if(mask&INITIALIZED_ACODEC){
- mpctx->initialized_flags&=~INITIALIZED_ACODEC;
- current_module="uninit_acodec";
- if(mpctx->sh_audio) uninit_audio(mpctx->sh_audio);
- mpctx->sh_audio=NULL;
- mpctx->mixer.afilter = NULL;
- }
-
- if (mask & INITIALIZED_SUB) {
- mpctx->initialized_flags &= ~INITIALIZED_SUB;
- if (mpctx->d_sub->sh)
- sub_switchoff(mpctx->d_sub->sh, mpctx->osd);
- }
-
- if(mask&INITIALIZED_VCODEC){
- mpctx->initialized_flags&=~INITIALIZED_VCODEC;
- current_module="uninit_vcodec";
- if(mpctx->sh_video) uninit_video(mpctx->sh_video);
- mpctx->sh_video=NULL;
+void uninit_player(struct MPContext *mpctx, unsigned int mask)
+{
+ mask &= mpctx->initialized_flags;
+
+ mp_msg(MSGT_CPLAYER, MSGL_DBG2, "\n*** uninit(0x%X)\n", mask);
+
+ if (mask & INITIALIZED_ACODEC) {
+ mpctx->initialized_flags &= ~INITIALIZED_ACODEC;
+ current_module = "uninit_acodec";
+ if (mpctx->sh_audio)
+ uninit_audio(mpctx->sh_audio);
+ mpctx->sh_audio = NULL;
+ mpctx->mixer.afilter = NULL;
+ }
+
+ if (mask & INITIALIZED_SUB) {
+ mpctx->initialized_flags &= ~INITIALIZED_SUB;
+ if (mpctx->d_sub->sh)
+ sub_switchoff(mpctx->d_sub->sh, mpctx->osd);
+ }
+
+ if (mask & INITIALIZED_VCODEC) {
+ mpctx->initialized_flags &= ~INITIALIZED_VCODEC;
+ current_module = "uninit_vcodec";
+ if (mpctx->sh_video)
+ uninit_video(mpctx->sh_video);
+ mpctx->sh_video = NULL;
#ifdef CONFIG_MENU
- vf_menu=NULL;
+ vf_menu = NULL;
#endif
- }
-
- if(mask&INITIALIZED_DEMUXER){
- mpctx->initialized_flags&=~INITIALIZED_DEMUXER;
- current_module="free_demuxer";
- if (mpctx->num_sources) {
- mpctx->demuxer = mpctx->sources[0].demuxer;
- for (int i = 1; i < mpctx->num_sources; i++) {
- uninit_subs(mpctx->sources[i].demuxer);
- free_stream(mpctx->sources[i].stream);
- free_demuxer(mpctx->sources[i].demuxer);
+ }
+
+ if (mask & INITIALIZED_DEMUXER) {
+ mpctx->initialized_flags &= ~INITIALIZED_DEMUXER;
+ current_module = "free_demuxer";
+ if (mpctx->num_sources) {
+ mpctx->demuxer = mpctx->sources[0].demuxer;
+ for (int i = 1; i < mpctx->num_sources; i++) {
+ uninit_subs(mpctx->sources[i].demuxer);
+ free_stream(mpctx->sources[i].stream);
+ free_demuxer(mpctx->sources[i].demuxer);
+ }
}
+ talloc_free(mpctx->sources);
+ mpctx->sources = NULL;
+ mpctx->num_sources = 0;
+ talloc_free(mpctx->timeline);
+ mpctx->timeline = NULL;
+ mpctx->num_timeline_parts = 0;
+ talloc_free(mpctx->chapters);
+ mpctx->chapters = NULL;
+ mpctx->num_chapters = 0;
+ mpctx->video_offset = 0;
+ if (mpctx->demuxer) {
+ mpctx->stream = mpctx->demuxer->stream;
+ uninit_subs(mpctx->demuxer);
+ free_demuxer(mpctx->demuxer);
+ }
+ mpctx->demuxer = NULL;
}
- talloc_free(mpctx->sources);
- mpctx->sources = NULL;
- mpctx->num_sources = 0;
- talloc_free(mpctx->timeline);
- mpctx->timeline = NULL;
- mpctx->num_timeline_parts = 0;
- talloc_free(mpctx->chapters);
- mpctx->chapters = NULL;
- mpctx->num_chapters = 0;
- mpctx->video_offset = 0;
- if(mpctx->demuxer){
- mpctx->stream=mpctx->demuxer->stream;
- uninit_subs(mpctx->demuxer);
- free_demuxer(mpctx->demuxer);
- }
- mpctx->demuxer=NULL;
- }
-
- // kill the cache process:
- if(mask&INITIALIZED_STREAM){
- mpctx->initialized_flags&=~INITIALIZED_STREAM;
- current_module="uninit_stream";
- if(mpctx->stream) free_stream(mpctx->stream);
- mpctx->stream=NULL;
- }
-
- if(mask&INITIALIZED_VO){
- mpctx->initialized_flags&=~INITIALIZED_VO;
- current_module="uninit_vo";
- vo_destroy(mpctx->video_out);
- mpctx->video_out=NULL;
+
+ // kill the cache process:
+ if (mask & INITIALIZED_STREAM) {
+ mpctx->initialized_flags &= ~INITIALIZED_STREAM;
+ current_module = "uninit_stream";
+ if (mpctx->stream)
+ free_stream(mpctx->stream);
+ mpctx->stream = NULL;
+ }
+
+ if (mask & INITIALIZED_VO) {
+ mpctx->initialized_flags &= ~INITIALIZED_VO;
+ current_module = "uninit_vo";
+ vo_destroy(mpctx->video_out);
+ mpctx->video_out = NULL;
#ifdef CONFIG_DVDNAV
- mp_dvdnav_context_free(mpctx);
+ mp_dvdnav_context_free(mpctx);
#endif
- }
-
- // Must be after libvo uninit, as few vo drivers (svgalib) have tty code.
- if(mask&INITIALIZED_GETCH2){
- mpctx->initialized_flags&=~INITIALIZED_GETCH2;
- current_module="uninit_getch2";
- mp_msg(MSGT_CPLAYER,MSGL_DBG2,"\n[[[uninit getch2]]]\n");
- // restore terminal:
- getch2_disable();
- }
-
- if(mask&INITIALIZED_VOBSUB){
- mpctx->initialized_flags&=~INITIALIZED_VOBSUB;
- current_module="uninit_vobsub";
- if(vo_vobsub) vobsub_close(vo_vobsub);
- vo_vobsub=NULL;
- }
-
- if (mask&INITIALIZED_SPUDEC){
- mpctx->initialized_flags&=~INITIALIZED_SPUDEC;
- current_module="uninit_spudec";
- spudec_free(vo_spudec);
- vo_spudec=NULL;
- }
-
- if(mask&INITIALIZED_AO){
- mpctx->initialized_flags&=~INITIALIZED_AO;
- current_module="uninit_ao";
- if (mpctx->edl_muted) mixer_mute(&mpctx->mixer);
- if (mpctx->ao)
- ao_uninit(mpctx->ao, mpctx->stop_play != AT_END_OF_FILE);
- mpctx->ao = NULL;
- }
-
- current_module=NULL;
+ }
+
+ // Must be after libvo uninit, as few vo drivers (svgalib) have tty code.
+ if (mask & INITIALIZED_GETCH2) {
+ mpctx->initialized_flags &= ~INITIALIZED_GETCH2;
+ current_module = "uninit_getch2";
+ mp_msg(MSGT_CPLAYER, MSGL_DBG2, "\n[[[uninit getch2]]]\n");
+ // restore terminal:
+ getch2_disable();
+ }
+
+ if (mask & INITIALIZED_VOBSUB) {
+ mpctx->initialized_flags &= ~INITIALIZED_VOBSUB;
+ current_module = "uninit_vobsub";
+ if (vo_vobsub)
+ vobsub_close(vo_vobsub);
+ vo_vobsub = NULL;
+ }
+
+ if (mask & INITIALIZED_SPUDEC) {
+ mpctx->initialized_flags &= ~INITIALIZED_SPUDEC;
+ current_module = "uninit_spudec";
+ spudec_free(vo_spudec);
+ vo_spudec = NULL;
+ }
+
+ if (mask & INITIALIZED_AO) {
+ mpctx->initialized_flags &= ~INITIALIZED_AO;
+ current_module = "uninit_ao";
+ if (mpctx->edl_muted)
+ mixer_mute(&mpctx->mixer);
+ if (mpctx->ao)
+ ao_uninit(mpctx->ao, mpctx->stop_play != AT_END_OF_FILE);
+ mpctx->ao = NULL;
+ }
+
+ current_module = NULL;
}
void exit_player_with_rc(struct MPContext *mpctx, enum exit_reason how, int rc)
{
- if (mpctx->user_muted && !mpctx->edl_muted) mixer_mute(&mpctx->mixer);
- uninit_player(mpctx, INITIALIZED_ALL);
+ if (mpctx->user_muted && !mpctx->edl_muted)
+ mixer_mute(&mpctx->mixer);
+ uninit_player(mpctx, INITIALIZED_ALL);
#if defined(__MINGW32__) || defined(__CYGWIN__)
- timeEndPeriod(1);
+ timeEndPeriod(1);
#endif
#ifdef CONFIG_X11
- vo_uninit(mpctx->x11_state); // Close the X11 connection (if any is open).
+ vo_uninit(mpctx->x11_state); // Close the X11 connection (if any is open).
#endif
- current_module="uninit_input";
+ current_module = "uninit_input";
mp_input_uninit(mpctx->input);
#ifdef CONFIG_MENU
if (use_menu)
- menu_uninit();
+ menu_uninit();
#endif
#ifdef CONFIG_FREETYPE
- current_module="uninit_font";
- if (mpctx->osd && mpctx->osd->sub_font != vo_font)
- free_font_desc(mpctx->osd->sub_font);
- free_font_desc(vo_font);
- vo_font = NULL;
- done_freetype();
+ current_module = "uninit_font";
+ if (mpctx->osd && mpctx->osd->sub_font != vo_font)
+ free_font_desc(mpctx->osd->sub_font);
+ free_font_desc(vo_font);
+ vo_font = NULL;
+ done_freetype();
#endif
- osd_free(mpctx->osd);
+ osd_free(mpctx->osd);
#ifdef CONFIG_ASS
- ass_library_done(mpctx->ass_library);
- mpctx->ass_library = NULL;
+ ass_library_done(mpctx->ass_library);
+ mpctx->ass_library = NULL;
#endif
- current_module="exit_player";
-
- if(mpctx->playtree_iter)
- play_tree_iter_free(mpctx->playtree_iter);
- mpctx->playtree_iter = NULL;
- if(mpctx->playtree)
- play_tree_free(mpctx->playtree, 1);
- mpctx->playtree = NULL;
-
- talloc_free(mpctx->key_fifo);
-
- free(edl_records); // free mem allocated for EDL
- edl_records = NULL;
- switch(how) {
- case EXIT_QUIT:
- mp_tmsg(MSGT_CPLAYER,MSGL_INFO,"\nExiting... (%s)\n","Quit");
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_EXIT=QUIT\n");
- break;
- case EXIT_EOF:
- mp_tmsg(MSGT_CPLAYER,MSGL_INFO,"\nExiting... (%s)\n","End of file");
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_EXIT=EOF\n");
- break;
- case EXIT_ERROR:
- mp_tmsg(MSGT_CPLAYER,MSGL_INFO,"\nExiting... (%s)\n","Fatal error");
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_EXIT=ERROR\n");
- break;
- default:
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_EXIT=NONE\n");
- }
- mp_msg(MSGT_CPLAYER,MSGL_DBG2,"max framesize was %d bytes\n",max_framesize);
-
- // must be last since e.g. mp_msg uses option values
- // that will be freed by this.
- if (mpctx->mconfig)
- m_config_free(mpctx->mconfig);
- mpctx->mconfig = NULL;
-
- exit(rc);
+ current_module = "exit_player";
+
+ if (mpctx->playtree_iter)
+ play_tree_iter_free(mpctx->playtree_iter);
+ mpctx->playtree_iter = NULL;
+ if (mpctx->playtree)
+ play_tree_free(mpctx->playtree, 1);
+ mpctx->playtree = NULL;
+
+ talloc_free(mpctx->key_fifo);
+
+ free(edl_records); // free mem allocated for EDL
+ edl_records = NULL;
+ switch (how) {
+ case EXIT_QUIT:
+ mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "\nExiting... (%s)\n", "Quit");
+ mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_EXIT=QUIT\n");
+ break;
+ case EXIT_EOF:
+ mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "\nExiting... (%s)\n", "End of file");
+ mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_EXIT=EOF\n");
+ break;
+ case EXIT_ERROR:
+ mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "\nExiting... (%s)\n", "Fatal error");
+ mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_EXIT=ERROR\n");
+ break;
+ default:
+ mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_EXIT=NONE\n");
+ }
+ mp_msg(MSGT_CPLAYER, MSGL_DBG2,
+ "max framesize was %d bytes\n", max_framesize);
+
+ // must be last since e.g. mp_msg uses option values
+ // that will be freed by this.
+ if (mpctx->mconfig)
+ m_config_free(mpctx->mconfig);
+ mpctx->mconfig = NULL;
+
+ exit(rc);
}
static void exit_player(struct MPContext *mpctx, enum exit_reason how)
{
- exit_player_with_rc(mpctx, how, 1);
+ exit_player_with_rc(mpctx, how, 1);
}
#ifndef __MINGW32__
-static void child_sighandler(int x){
- pid_t pid;
- while((pid=waitpid(-1,NULL,WNOHANG)) > 0);
+static void child_sighandler(int x)
+{
+ pid_t pid;
+ while ((pid = waitpid(-1, NULL, WNOHANG)) > 0) ;
}
#endif
@@ -801,76 +829,77 @@ static char *prog_path;
static int crash_debug = 0;
#endif
-static void exit_sighandler(int x){
- static int sig_count=0;
+static void exit_sighandler(int x)
+{
+ static int sig_count = 0;
#ifdef CONFIG_CRASH_DEBUG
- if (!crash_debug || x != SIGTRAP)
+ if (!crash_debug || x != SIGTRAP)
#endif
- ++sig_count;
- if(sig_count==5)
- {
- /* We're crashing bad and can't uninit cleanly :(
- * by popular request, we make one last (dirty)
- * effort to restore the user's
- * terminal. */
- getch2_disable();
- exit(1);
- }
- if(sig_count==6) exit(1);
- if(sig_count>6){
- // can't stop :(
+ ++sig_count;
+ if (sig_count == 5) {
+ /* We're crashing bad and can't uninit cleanly :(
+ * by popular request, we make one last (dirty)
+ * effort to restore the user's
+ * terminal. */
+ getch2_disable();
+ exit(1);
+ }
+ if (sig_count == 6)
+ exit(1);
+ if (sig_count > 6) {
+ // can't stop :(
#ifndef __MINGW32__
- kill(getpid(),SIGKILL);
+ kill(getpid(), SIGKILL);
#endif
- }
- mp_msg(MSGT_CPLAYER, MSGL_FATAL, "\n");
- mp_tmsg(MSGT_CPLAYER,MSGL_FATAL,
- "\nMPlayer interrupted by signal %d in module: %s\n", x,
- current_module ? current_module : "unknown");
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_SIGNAL=%d\n", x);
- if(sig_count<=1)
- switch(x){
- case SIGINT:
- case SIGPIPE:
- case SIGQUIT:
- case SIGTERM:
- case SIGKILL:
- async_quit_request = 1;
- return; // killed from keyboard (^C) or killed [-9]
- case SIGILL:
+ }
+ mp_msg(MSGT_CPLAYER, MSGL_FATAL, "\n");
+ mp_tmsg(MSGT_CPLAYER, MSGL_FATAL,
+ "\nMPlayer interrupted by signal %d in module: %s\n", x,
+ current_module ? current_module : "unknown");
+ mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_SIGNAL=%d\n", x);
+ if (sig_count <= 1)
+ switch (x) {
+ case SIGINT:
+ case SIGPIPE:
+ case SIGQUIT:
+ case SIGTERM:
+ case SIGKILL:
+ async_quit_request = 1;
+ return; // killed from keyboard (^C) or killed [-9]
+ case SIGILL:
#if CONFIG_RUNTIME_CPUDETECT
- mp_tmsg(MSGT_CPLAYER,MSGL_FATAL,Exit_SIGILL_RTCpuSel);
+ mp_tmsg(MSGT_CPLAYER, MSGL_FATAL, Exit_SIGILL_RTCpuSel);
#else
- mp_tmsg(MSGT_CPLAYER,MSGL_FATAL,Exit_SIGILL);
+ mp_tmsg(MSGT_CPLAYER, MSGL_FATAL, Exit_SIGILL);
#endif
- case SIGFPE:
- case SIGSEGV:
- mp_tmsg(MSGT_CPLAYER,MSGL_FATAL,Exit_SIGSEGV_SIGFPE);
- default:
- mp_tmsg(MSGT_CPLAYER,MSGL_FATAL,Exit_SIGCRASH);
+ case SIGFPE:
+ case SIGSEGV:
+ mp_tmsg(MSGT_CPLAYER, MSGL_FATAL, Exit_SIGSEGV_SIGFPE);
+ default:
+ mp_tmsg(MSGT_CPLAYER, MSGL_FATAL, Exit_SIGCRASH);
#ifdef CONFIG_CRASH_DEBUG
- if (crash_debug) {
- int gdb_pid;
- mp_msg(MSGT_CPLAYER, MSGL_INFO, "Forking...\n");
- gdb_pid = fork();
- mp_msg(MSGT_CPLAYER, MSGL_INFO, "Forked...\n");
- if (gdb_pid == 0) { // We are the child
- char spid[20];
- snprintf(spid, sizeof(spid), "%i", getppid());
- getch2_disable(); // allow terminal to work properly with gdb
- if (execlp("gdb", "gdb", prog_path, spid, "-ex", "bt", NULL) == -1)
- mp_msg(MSGT_CPLAYER, MSGL_ERR, "Couldn't start gdb\n");
- } else if (gdb_pid < 0)
- mp_msg(MSGT_CPLAYER, MSGL_ERR, "Couldn't fork\n");
- else {
- waitpid(gdb_pid, NULL, 0);
- }
- if (x == SIGTRAP) return;
- }
+ if (crash_debug) {
+ int gdb_pid;
+ mp_msg(MSGT_CPLAYER, MSGL_INFO, "Forking...\n");
+ gdb_pid = fork();
+ mp_msg(MSGT_CPLAYER, MSGL_INFO, "Forked...\n");
+ if (gdb_pid == 0) { // We are the child
+ char spid[20];
+ snprintf(spid, sizeof(spid), "%i", getppid());
+ getch2_disable(); // allow terminal to work properly with gdb
+ if (execlp("gdb", "gdb", prog_path, spid, "-ex", "bt", NULL) == -1)
+ mp_msg(MSGT_CPLAYER, MSGL_ERR, "Couldn't start gdb\n");
+ } else if (gdb_pid < 0)
+ mp_msg(MSGT_CPLAYER, MSGL_ERR, "Couldn't fork\n");
+ else
+ waitpid(gdb_pid, NULL, 0);
+ if (x == SIGTRAP)
+ return;
+ }
#endif
- }
- getch2_disable();
- exit(1);
+ }
+ getch2_disable();
+ exit(1);
}
#include "cfg-mplayer.h"
@@ -882,99 +911,101 @@ static int cfg_include(m_option_t *conf, char *filename)
#define DEF_CONFIG "# Write your default config options here!\n\n\n"
-static void parse_cfgfiles(struct MPContext *mpctx, m_config_t* conf)
+static void parse_cfgfiles(struct MPContext *mpctx, m_config_t *conf)
{
struct MPOpts *opts = &mpctx->opts;
-char *conffile;
-int conffile_fd;
- if (!(opts->noconfig & 2) &&
- m_config_parse_config_file(conf, MPLAYER_CONFDIR "/mplayer.conf") < 0)
- exit_player(mpctx, EXIT_NONE);
-if ((conffile = get_path("")) == NULL) {
- mp_tmsg(MSGT_CPLAYER,MSGL_WARN,"Cannot find HOME directory.\n");
-} else {
+ char *conffile;
+ int conffile_fd;
+ if (!(opts->noconfig & 2) &&
+ m_config_parse_config_file(conf, MPLAYER_CONFDIR "/mplayer.conf") < 0)
+ exit_player(mpctx, EXIT_NONE);
+ if ((conffile = get_path("")) == NULL)
+ mp_tmsg(MSGT_CPLAYER, MSGL_WARN, "Cannot find HOME directory.\n");
+ else {
#ifdef __MINGW32__
- mkdir(conffile);
+ mkdir(conffile);
#else
- mkdir(conffile, 0777);
+ mkdir(conffile, 0777);
#endif
- free(conffile);
- if ((conffile = get_path("config")) == NULL) {
- mp_tmsg(MSGT_CPLAYER,MSGL_ERR,"g