From a1b8092c872977e3289e6cf5232d5b534fbd90b8 Mon Sep 17 00:00:00 2001 From: diego Date: Mon, 28 Jun 2010 08:26:14 +0000 Subject: [PATCH] Factorize MPlayer/MEncoder version string handling. The string now resides in a central object file instead of being duplicated in every file that requires a version string. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@31577 b3059339-0415-0410-9bf9-f77b7e298cf2 --- Makefile | 2 +- libmpdemux/muxer_avi.c | 5 ++--- mpcommon.c | 2 ++ mpcommon.h | 4 ++++ stream/network.c | 10 +++------- stream/stream_cddb.c | 6 +++--- vobsub.c | 7 +++---- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index e20d95495d..5ee3f49f2a 100644 --- a/Makefile +++ b/Makefile @@ -797,7 +797,7 @@ locale/%/LC_MESSAGES/mplayer.mo: po/%.po # Make sure all generated header files are created. codec-cfg.d codec-cfg.o: codecs.conf.h -$(call ADDSUFFIXES,.d .o,mpcommon vobsub stream/stream_cddb stream/network libmpdemux/muxer_avi osdep/mplayer.rc): version.h +$(call ADDSUFFIXES,.d .o,mpcommon osdep/mplayer.rc): version.h # Files that depend on libswscale internals libvo/vo_mga.o libvo/vo_xmga.o libmpcodecs/vf_palette.o: CFLAGS := -I$(FFMPEG_SOURCE_PATH) $(CFLAGS) diff --git a/libmpdemux/muxer_avi.c b/libmpdemux/muxer_avi.c index 74bd019f7c..6428ce86bf 100644 --- a/libmpdemux/muxer_avi.c +++ b/libmpdemux/muxer_avi.c @@ -24,8 +24,7 @@ #include #include "config.h" -#include "version.h" - +#include "mpcommon.h" #include "stream/stream.h" #include "demuxer.h" #include "stheader.h" @@ -501,7 +500,7 @@ static void avifile_write_header(muxer_t *muxer){ // ============= INFO =============== // always include software info info[0].id=mmioFOURCC('I','S','F','T'); // Software: -info[0].text="MEncoder " VERSION; +info[0].text=mencoder_version; // include any optional strings i=1; if(info_name!=NULL){ diff --git a/mpcommon.c b/mpcommon.c index 5756b8ad6a..0b6d95d92b 100644 --- a/mpcommon.c +++ b/mpcommon.c @@ -44,6 +44,8 @@ ASS_Track *ass_track = 0; // current track to render sub_data* subdata = NULL; subtitle* vo_sub_last = NULL; +const char *mencoder_version = "MEncoder " VERSION; +const char *mplayer_version = "MPlayer " VERSION; void print_version(const char* name) { diff --git a/mpcommon.h b/mpcommon.h index 3c35b8221a..b025dcc890 100644 --- a/mpcommon.h +++ b/mpcommon.h @@ -27,7 +27,11 @@ extern double sub_last_pts; extern struct ass_track *ass_track; extern subtitle *vo_sub_last; +extern const char *mencoder_version; +extern const char *mplayer_version; + struct MPContext; + void print_version(const char* name); void update_subtitles(struct MPContext *mpctx, struct MPOpts *opts, sh_video_t *sh_video, double refpts, double sub_offset, diff --git a/stream/network.c b/stream/network.c index cf01bf7144..48d50d5de5 100644 --- a/stream/network.c +++ b/stream/network.c @@ -42,15 +42,13 @@ #include "stream.h" #include "libmpdemux/demuxer.h" #include "m_config.h" - +#include "mpcommon.h" #include "network.h" #include "tcp.h" #include "http.h" #include "cookies.h" #include "url.h" -#include "version.h" - extern int stream_cache_size; /* Variables for the command line option -user, -passwd, -bandwidth, @@ -219,12 +217,10 @@ http_send_request( URL_t *url, off_t pos ) { snprintf(str, 256, "Host: %s", server_url->hostname ); http_set_field( http_hdr, str); if (network_useragent) - { snprintf(str, 256, "User-Agent: %s", network_useragent); - http_set_field(http_hdr, str); - } else - http_set_field( http_hdr, "User-Agent: MPlayer/"VERSION); + snprintf(str, 256, "User-Agent: %s", mplayer_version); + http_set_field(http_hdr, str); if (network_referrer) { char *referrer = NULL; diff --git a/stream/stream_cddb.c b/stream/stream_cddb.c index 24467f13d4..abc6a86966 100644 --- a/stream/stream_cddb.c +++ b/stream/stream_cddb.c @@ -70,7 +70,7 @@ #include "osdep/osdep.h" #include "cdd.h" -#include "version.h" +#include "mpcommon.h" #include "stream.h" #include "network.h" #include "libavutil/common.h" @@ -748,8 +748,8 @@ static void cddb_create_hello(cddb_data_t *cddb_data) } user_name = getenv("LOGNAME"); } - sprintf(cddb_data->cddb_hello, "&hello=%s+%s+%s+%s", - user_name, host_name, "MPlayer", VERSION); + sprintf(cddb_data->cddb_hello, "&hello=%s+%s+%s", + user_name, host_name, mplayer_version); } static int cddb_retrieve(cddb_data_t *cddb_data) diff --git a/vobsub.c b/vobsub.c index f14e72f7d3..f208b7d8de 100644 --- a/vobsub.c +++ b/vobsub.c @@ -32,8 +32,7 @@ #include #include "config.h" -#include "version.h" - +#include "mpcommon.h" #include "vobsub.h" #include "spudec.h" #include "mp_msg.h" @@ -1254,12 +1253,12 @@ static void create_idx(vobsub_out_t *me, const unsigned int *palette, fprintf(me->fidx, "# VobSub index file, v7 (do not modify this line!)\n" "#\n" - "# Generated by MPlayer " VERSION "\n" + "# Generated by %s\n" "# See for more information about MPlayer\n" "# See for more information about Vobsub\n" "#\n" "size: %ux%u\n", - orig_width, orig_height); + mplayer_version, orig_width, orig_height); if (palette) { fputs("palette:", me->fidx); for (i = 0; i < 16; ++i) {