changeset 31515:823f39ab650b

Clean up #include handling in mplayer.c and mencoder.c. All #includes are moved to the top and grouped alphabetically, system headers before local headers. This avoids some redundant redeclaration warnings that occurred due to some global variables being declared and then (re)declared extern in header files.
author diego
date Mon, 28 Jun 2010 09:39:49 +0000
parents c6195b5575cc
children a80ae9c48a0f
files mencoder.c mplayer.c
diffstat 2 files changed, 141 insertions(+), 196 deletions(-) [+]
line wrap: on
line diff
--- a/mencoder.c	Mon Jun 28 09:35:18 2010 +0000
+++ b/mencoder.c	Mon Jun 28 09:39:49 2010 +0000
@@ -37,69 +37,67 @@
 #define ACODEC_FAAC 6
 #define ACODEC_TWOLAME 7
 
+#ifdef __MINGW32__
+#define SIGHUP   1
+#define SIGQUIT  3
+#define SIGPIPE 13
+#endif
+
+#include "config.h"
+
+#include <inttypes.h>
+#include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <signal.h>
-#include "config.h"
-
-#ifdef __MINGW32__
-#define        SIGHUP 1
-#define        SIGQUIT 3
-#define        SIGPIPE 13
-#endif
+#include <sys/time.h>
 #if defined(__MINGW32__) || defined(__CYGWIN__)
 #include <windows.h>
 #endif
 
-#include <sys/time.h>
-
-#include "mp_msg.h"
-#include "help_mp.h"
-
-#include "codec-cfg.h"
-#include "m_option.h"
-#include "m_config.h"
-#include "parser-mecmd.h"
-#include "parser-cfg.h"
-#include "mp_fifo.h"
-#include "path.h"
-
-#include "stream/stream.h"
+#include "input/input.h"
+#include "libaf/af_format.h"
+#include "libao2/audio_out.h"
+#include "libass/ass_mp.h"
+#include "libavcodec/avcodec.h"
+#include "libmpcodecs/ae.h"
+#include "libmpcodecs/dec_audio.h"
+#include "libmpcodecs/dec_video.h"
+#include "libmpcodecs/mp_image.h"
+#include "libmpcodecs/vd.h"
+#include "libmpcodecs/vf.h"
 #include "libmpdemux/aviprint.h"
 #include "libmpdemux/demuxer.h"
-#include "libmpdemux/stheader.h"
 #include "libmpdemux/mp3_hdr.h"
+#include "libmpdemux/ms_hdr.h"
 #include "libmpdemux/muxer.h"
-
-#include "input/input.h"
+#include "libmpdemux/stheader.h"
+#include "libvo/fastmemcpy.h"
+#include "libvo/font_load.h"
+#include "libvo/sub.h"
 #include "libvo/video_out.h"
-
-#include "libaf/af_format.h"
-
-#include "libmpcodecs/mp_image.h"
-#include "libmpcodecs/dec_audio.h"
-#include "libmpcodecs/dec_video.h"
-#include "libmpcodecs/vf.h"
-#include "libmpcodecs/vd.h"
-
-// for MPEGLAYER3WAVEFORMAT:
-#include "libmpdemux/ms_hdr.h"
-
-#include <inttypes.h>
-
-#include "libvo/fastmemcpy.h"
-
+#include "osdep/priority.h"
 #include "osdep/timer.h"
-
+#include "stream/stream.h"
 #ifdef CONFIG_DVDREAD
 #include "stream/stream_dvd.h"
 #endif
+#include "stream/stream_dvdnav.h"
+#include "codec-cfg.h"
+#include "edl.h"
+#include "help_mp.h"
+#include "m_config.h"
+#include "m_option.h"
+#include "mp_fifo.h"
+#include "mp_msg.h"
+#include "mpcommon.h"
+#include "parser-cfg.h"
+#include "parser-mecmd.h"
+#include "path.h"
+#include "spudec.h"
+#include "vobsub.h"
 
-#include "stream/stream_dvdnav.h"
-#include "libavcodec/avcodec.h"
 
-#include "libmpcodecs/ae.h"
 int vo_doublebuffering=0;
 int vo_directrendering=0;
 int vo_config_count=1;
@@ -147,8 +145,6 @@
 double cur_vout_time_usage=0;
 int benchmark=0;
 
-#include "osdep/priority.h"
-
 // A-V sync:
 int delay_corrected=1;
 static float default_max_pts_correction=-1;//0.01f;
@@ -183,9 +179,6 @@
 static int play_n_frames=-1;
 static int play_n_frames_mf=-1;
 
-#include "libvo/font_load.h"
-#include "libvo/sub.h"
-
 // sub:
 char *font_name=NULL;
 char *sub_font_name=NULL;
@@ -226,9 +219,7 @@
 {
 }
 
-#include "libass/ass_mp.h"
 char *current_module;
-#include "mpcommon.h"
 
 // Needed by mpcommon.c
 void set_osd_subtitle(subtitle *subs) {
@@ -260,19 +251,16 @@
     int already_read;
 } s_frame_data;
 
-#include "edl.h"
 static edl_record_ptr edl_records = NULL; ///< EDL entries memory area
 static edl_record_ptr next_edl_record = NULL; ///< only for traversing edl_records
 static short edl_muted; ///< Stores whether EDL is currently in muted mode.
 static short edl_seeking; ///< When non-zero, stream is seekable.
 static short edl_seek_type; ///< When non-zero, frames are discarded instead of seeking.
 
+/* This header requires all the global variable declarations. */
 #include "cfg-mencoder.h"
 
-#include "spudec.h"
-#include "vobsub.h"
 
-#include "libao2/audio_out.h"
 /* FIXME */
 static void mencoder_exit(int level, const char *how)
 {
--- a/mplayer.c	Mon Jun 28 09:35:18 2010 +0000
+++ b/mplayer.c	Mon Jun 28 09:39:49 2010 +0000
@@ -19,19 +19,26 @@
 /// \file
 /// \ingroup Properties Command2Property OSDMsgStack
 
+#include "config.h"
+
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include "config.h"
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <sys/types.h>
 
 #if defined(__MINGW32__) || defined(__CYGWIN__)
 #define _UWIN 1  /*disable Non-underscored versions of non-ANSI functions as otherwise int eof would conflict with eof()*/
 #include <windows.h>
 #endif
-#include <string.h>
-#include <unistd.h>
-
-// #include <sys/mman.h>
-#include <sys/types.h>
+
 #ifndef __MINGW32__
 #include <sys/ioctl.h>
 #include <sys/wait.h>
@@ -43,69 +50,6 @@
 #define	SIGPIPE	13	/* broken pipe */
 #endif
 
-#include <sys/time.h>
-#include <sys/stat.h>
-
-#include <signal.h>
-#include <time.h>
-#include <fcntl.h>
-#include <limits.h>
-
-#include <errno.h>
-
-#include "mp_msg.h"
-
-#include "help_mp.h"
-
-#include "m_option.h"
-#include "m_config.h"
-#include "m_property.h"
-#include "mplayer.h"
-#include "access_mpcontext.h"
-
-#include "cfg-mplayer-def.h"
-
-#include "libavutil/intreadwrite.h"
-#include "libavutil/avstring.h"
-
-#include "subreader.h"
-
-#include "libvo/video_out.h"
-
-#include "libvo/font_load.h"
-#include "libvo/sub.h"
-
-#ifdef CONFIG_X11
-#include "libvo/x11_common.h"
-#endif
-
-#include "libao2/audio_out.h"
-
-#include "codec-cfg.h"
-
-#include "edl.h"
-#include "spudec.h"
-#include "vobsub.h"
-
-#include "osdep/getch2.h"
-#include "osdep/timer.h"
-
-#include "gui/interface.h"
-
-#include "input/input.h"
-
-int slave_mode=0;
-int player_idle_mode=0;
-int quiet=0;
-int enable_mouse_movements=0;
-float start_volume = -1;
-
-#include "osdep/priority.h"
-
-char *heartbeat_cmd;
-
-#define ROUND(x) ((int)((x)<0 ? (x)-0.5 : (x)+0.5))
-
 #ifdef HAVE_RTC
 #ifdef __linux__
 #include <linux/rtc.h>
@@ -116,24 +60,91 @@
 #endif /* __linux__ */
 #endif /* HAVE_RTC */
 
+/*
+ * In Mac OS X the SDL-lib is built upon Cocoa. The easiest way to
+ * make it all work is to use the builtin SDL-bootstrap code, which
+ * will be done automatically by replacing our main() if we include SDL.h.
+ */
+#if defined(__APPLE__) && defined(CONFIG_SDL)
+#ifdef CONFIG_SDL_SDL_H
+#include <SDL/SDL.h>
+#else
+#include <SDL.h>
+#endif
+#endif
+
+#include "gui/interface.h"
+#include "input/input.h"
+#include "libao2/audio_out.h"
+#include "libass/ass_mp.h"
+#include "libavutil/avstring.h"
+#include "libavutil/intreadwrite.h"
+#include "libmenu/menu.h"
+#include "libmpcodecs/dec_audio.h"
+#include "libmpcodecs/dec_video.h"
+#include "libmpcodecs/mp_image.h"
+#include "libmpcodecs/vd.h"
+#include "libmpcodecs/vf.h"
+#include "libmpdemux/demuxer.h"
+#include "libmpdemux/stheader.h"
+#include "libvo/font_load.h"
+#include "libvo/sub.h"
+#include "libvo/video_out.h"
+#include "stream/cache2.h"
+#include "stream/stream.h"
+#include "stream/stream_dvdnav.h"
+#include "stream/stream_radio.h"
 #include "stream/tv.h"
-#include "stream/stream_radio.h"
+#include "access_mpcontext.h"
+#include "cfg-mplayer-def.h"
+#include "codec-cfg.h"
+#include "command.h"
+#include "edl.h"
+#include "help_mp.h"
+#include "m_config.h"
+#include "m_option.h"
+#include "m_property.h"
+#include "m_struct.h"
+#include "metadata.h"
+#include "mixer.h"
+#include "mp_core.h"
+#include "mp_fifo.h"
+#include "mp_msg.h"
+#include "mpcommon.h"
+#include "mplayer.h"
+#include "osdep/getch2.h"
+#include "osdep/priority.h"
+#include "osdep/timer.h"
+#include "parser-cfg.h"
+#include "parser-mpcmd.h"
+#include "path.h"
+#include "playtree.h"
+#include "playtreeparser.h"
+#include "spudec.h"
+#include "subreader.h"
+#include "vobsub.h"
+
+#ifdef CONFIG_X11
+#include "libvo/x11_common.h"
+#endif
 #ifdef CONFIG_DVBIN
 #include "stream/dvbin.h"
 #endif
-#include "stream/cache2.h"
-
-//**************************************************************************//
-//             Playtree
-//**************************************************************************//
-#include "playtree.h"
-#include "playtreeparser.h"
-
-//**************************************************************************//
-//             Config
-//**************************************************************************//
-#include "parser-cfg.h"
-#include "parser-mpcmd.h"
+#ifdef CONFIG_DVDREAD
+#include "stream/stream_dvd.h"
+#endif
+
+
+int slave_mode=0;
+int player_idle_mode=0;
+int quiet=0;
+int enable_mouse_movements=0;
+float start_volume = -1;
+
+char *heartbeat_cmd;
+
+#define ROUND(x) ((int)((x)<0 ? (x)-0.5 : (x)+0.5))
+
 
 m_config_t* mconfig;
 
@@ -147,39 +158,8 @@
 	return m_config_parse_config_file(mconfig, filename);
 }
 
-#include "path.h"
-
-//**************************************************************************//
-//**************************************************************************//
-//             Input media streaming & demultiplexer:
-//**************************************************************************//
-
 static int max_framesize=0;
 
-#include "stream/stream.h"
-#include "libmpdemux/demuxer.h"
-#include "libmpdemux/stheader.h"
-
-#ifdef CONFIG_DVDREAD
-#include "stream/stream_dvd.h"
-#endif
-#include "stream/stream_dvdnav.h"
-
-#include "libmpcodecs/dec_audio.h"
-#include "libmpcodecs/dec_video.h"
-#include "libmpcodecs/mp_image.h"
-#include "libmpcodecs/vf.h"
-#include "libmpcodecs/vd.h"
-
-#include "mixer.h"
-
-#include "mp_core.h"
-
-//**************************************************************************//
-//**************************************************************************//
-
-// Common FIFO functions, and keyboard/event FIFO code
-#include "mp_fifo.h"
 int noconsolecontrols=0;
 //**************************************************************************//
 
@@ -324,16 +304,10 @@
 int   subcc_enabled=0;
 int suboverlap_enabled = 1;
 
-#include "libass/ass_mp.h"
-
 char* current_module=NULL; // for debugging
 
 
-// ---
-
 #ifdef CONFIG_MENU
-#include "m_struct.h"
-#include "libmenu/menu.h"
 extern vf_info_t vf_info_menu;
 static vf_info_t* libmenu_vfs[] = {
   &vf_info_menu,
@@ -371,11 +345,9 @@
 /// step size of mixer changes
 int volstep = 3;
 
-
-#include "mpcommon.h"
-#include "command.h"
-
-#include "metadata.h"
+/* This header requires all the global variable declarations. */
+#include "cfg-mplayer.h"
+
 
 #define mp_basename2(s) (strrchr(s,'/')==NULL?(char*)s:(strrchr(s,'/')+1))
 
@@ -898,8 +870,6 @@
   exit(1);
 }
 
-#include "cfg-mplayer.h"
-
 static void parse_cfgfiles( m_config_t* conf )
 {
 char *conffile;
@@ -1231,19 +1201,6 @@
   }
 }
 
-/*
- * In Mac OS X the SDL-lib is built upon Cocoa. The easiest way to
- * make it all work is to use the builtin SDL-bootstrap code, which
- * will be done automatically by replacing our main() if we include SDL.h.
- */
-#if defined(__APPLE__) && defined(CONFIG_SDL)
-#ifdef CONFIG_SDL_SDL_H
-#include <SDL/SDL.h>
-#else
-#include <SDL.h>
-#endif
-#endif
-
 /**
  * \brief append a formatted string
  * \param buf buffer to print into