mplayerxp-cvslog Mailing List for MplayerXP-mplayer with extra performance (Page 2)
Brought to you by:
olov
You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
(53) |
Apr
(142) |
May
(129) |
Jun
(160) |
Jul
(102) |
Aug
(14) |
Sep
(50) |
Oct
(27) |
Nov
(52) |
Dec
(41) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(136) |
Feb
(170) |
Mar
(103) |
Apr
(102) |
May
(44) |
Jun
(25) |
Jul
(2) |
Aug
|
Sep
(6) |
Oct
(1) |
Nov
|
Dec
(4) |
2004 |
Jan
|
Feb
(21) |
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(12) |
Oct
(160) |
Nov
(63) |
Dec
(5) |
2005 |
Jan
(10) |
Feb
(14) |
Mar
(18) |
Apr
(74) |
May
(72) |
Jun
(22) |
Jul
(28) |
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2006 |
Jan
(91) |
Feb
(71) |
Mar
(1) |
Apr
|
May
|
Jun
(4) |
Jul
(3) |
Aug
(4) |
Sep
(21) |
Oct
(42) |
Nov
(9) |
Dec
(26) |
2007 |
Jan
(1) |
Feb
|
Mar
|
Apr
(17) |
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(134) |
Dec
(72) |
2008 |
Jan
(6) |
Feb
(1) |
Mar
|
Apr
|
May
(2) |
Jun
|
Jul
(5) |
Aug
|
Sep
(1) |
Oct
(21) |
Nov
(41) |
Dec
(12) |
2009 |
Jan
(57) |
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
(25) |
Oct
(1) |
Nov
(46) |
Dec
(59) |
2010 |
Jan
(84) |
Feb
(5) |
Mar
|
Apr
(2) |
May
|
Jun
(2) |
Jul
(1) |
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(122) |
Nov
(223) |
Dec
(132) |
2013 |
Jan
|
Feb
|
Mar
|
Apr
(8) |
May
(13) |
Jun
(10) |
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
From: <nic...@us...> - 2013-04-27 17:29:35
|
Revision: 633 http://sourceforge.net/p/mplayerxp/code/633 Author: nickols_k Date: 2013-04-27 17:29:31 +0000 (Sat, 27 Apr 2013) Log Message: ----------- sync with beye Modified Paths: -------------- mplayerxp/libmpcodecs/vd.h mplayerxp/libmpconf/cfgparser.h mplayerxp/libmpdemux/demuxer.h mplayerxp/libmpdemux/demuxer_packet.h mplayerxp/libmpstream2/stream.h mplayerxp/libvo2/video_out.h mplayerxp/xmpcore/xmp_aframe.h mplayerxp/xmpcore/xmp_core.h Modified: mplayerxp/libmpcodecs/vd.h =================================================================== --- mplayerxp/libmpcodecs/vd.h 2013-04-26 06:56:49 UTC (rev 632) +++ mplayerxp/libmpcodecs/vd.h 2013-04-27 17:29:31 UTC (rev 633) @@ -19,9 +19,9 @@ inline video_flags_e operator|(video_flags_e a, video_flags_e b) { return static_cast<video_flags_e>(static_cast<unsigned>(a)|static_cast<unsigned>(b)); } inline video_flags_e operator&(video_flags_e a, video_flags_e b) { return static_cast<video_flags_e>(static_cast<unsigned>(a)&static_cast<unsigned>(b)); } inline video_flags_e operator^(video_flags_e a, video_flags_e b) { return static_cast<video_flags_e>(static_cast<unsigned>(a)^static_cast<unsigned>(b)); } -inline video_flags_e operator|=(video_flags_e a, video_flags_e b) { return (a=static_cast<video_flags_e>(static_cast<unsigned>(a)|static_cast<unsigned>(b))); } -inline video_flags_e operator&=(video_flags_e a, video_flags_e b) { return (a=static_cast<video_flags_e>(static_cast<unsigned>(a)&static_cast<unsigned>(b))); } -inline video_flags_e operator^=(video_flags_e a, video_flags_e b) { return (a=static_cast<video_flags_e>(static_cast<unsigned>(a)^static_cast<unsigned>(b))); } +inline video_flags_e operator|=(video_flags_e& a, video_flags_e b) { return (a=static_cast<video_flags_e>(static_cast<unsigned>(a)|static_cast<unsigned>(b))); } +inline video_flags_e operator&=(video_flags_e& a, video_flags_e b) { return (a=static_cast<video_flags_e>(static_cast<unsigned>(a)&static_cast<unsigned>(b))); } +inline video_flags_e operator^=(video_flags_e& a, video_flags_e b) { return (a=static_cast<video_flags_e>(static_cast<unsigned>(a)^static_cast<unsigned>(b))); } typedef enum { VCodecStatus_Working =3, Modified: mplayerxp/libmpconf/cfgparser.h =================================================================== --- mplayerxp/libmpconf/cfgparser.h 2013-04-26 06:56:49 UTC (rev 632) +++ mplayerxp/libmpconf/cfgparser.h 2013-04-27 17:29:31 UTC (rev 633) @@ -142,9 +142,9 @@ inline M_Config::flags_e operator|(M_Config::flags_e a, M_Config::flags_e b) { return static_cast<M_Config::flags_e>(static_cast<unsigned>(a)|static_cast<unsigned>(b)); } inline M_Config::flags_e operator&(M_Config::flags_e a, M_Config::flags_e b) { return static_cast<M_Config::flags_e>(static_cast<unsigned>(a)&static_cast<unsigned>(b)); } inline M_Config::flags_e operator^(M_Config::flags_e a, M_Config::flags_e b) { return static_cast<M_Config::flags_e>(static_cast<unsigned>(a)^static_cast<unsigned>(b)); } - inline M_Config::flags_e operator|=(M_Config::flags_e a, M_Config::flags_e b) { return (a=static_cast<M_Config::flags_e>(static_cast<unsigned>(a)|static_cast<unsigned>(b))); } - inline M_Config::flags_e operator&=(M_Config::flags_e a, M_Config::flags_e b) { return (a=static_cast<M_Config::flags_e>(static_cast<unsigned>(a)&static_cast<unsigned>(b))); } - inline M_Config::flags_e operator^=(M_Config::flags_e a, M_Config::flags_e b) { return (a=static_cast<M_Config::flags_e>(static_cast<unsigned>(a)^static_cast<unsigned>(b))); } + inline M_Config::flags_e operator|=(M_Config::flags_e& a, M_Config::flags_e b) { return (a=static_cast<M_Config::flags_e>(static_cast<unsigned>(a)|static_cast<unsigned>(b))); } + inline M_Config::flags_e operator&=(M_Config::flags_e& a, M_Config::flags_e b) { return (a=static_cast<M_Config::flags_e>(static_cast<unsigned>(a)&static_cast<unsigned>(b))); } + inline M_Config::flags_e operator^=(M_Config::flags_e& a, M_Config::flags_e b) { return (a=static_cast<M_Config::flags_e>(static_cast<unsigned>(a)^static_cast<unsigned>(b))); } } // namespace mpxp #endif /* __CONFIG_H */ Modified: mplayerxp/libmpdemux/demuxer.h =================================================================== --- mplayerxp/libmpdemux/demuxer.h 2013-04-26 06:56:49 UTC (rev 632) +++ mplayerxp/libmpdemux/demuxer.h 2013-04-27 17:29:31 UTC (rev 633) @@ -147,9 +147,9 @@ inline Demuxer::demuxer_flags_e operator|(Demuxer::demuxer_flags_e a, Demuxer::demuxer_flags_e b) { return static_cast<Demuxer::demuxer_flags_e>(static_cast<unsigned>(a)|static_cast<unsigned>(b)); } inline Demuxer::demuxer_flags_e operator&(Demuxer::demuxer_flags_e a, Demuxer::demuxer_flags_e b) { return static_cast<Demuxer::demuxer_flags_e>(static_cast<unsigned>(a)&static_cast<unsigned>(b)); } inline Demuxer::demuxer_flags_e operator^(Demuxer::demuxer_flags_e a, Demuxer::demuxer_flags_e b) { return static_cast<Demuxer::demuxer_flags_e>(static_cast<unsigned>(a)^static_cast<unsigned>(b)); } - inline Demuxer::demuxer_flags_e operator|=(Demuxer::demuxer_flags_e a, Demuxer::demuxer_flags_e b) { return (a=static_cast<Demuxer::demuxer_flags_e>(static_cast<unsigned>(a)|static_cast<unsigned>(b))); } - inline Demuxer::demuxer_flags_e operator&=(Demuxer::demuxer_flags_e a, Demuxer::demuxer_flags_e b) { return (a=static_cast<Demuxer::demuxer_flags_e>(static_cast<unsigned>(a)&static_cast<unsigned>(b))); } - inline Demuxer::demuxer_flags_e operator^=(Demuxer::demuxer_flags_e a, Demuxer::demuxer_flags_e b) { return (a=static_cast<Demuxer::demuxer_flags_e>(static_cast<unsigned>(a)^static_cast<unsigned>(b))); } + inline Demuxer::demuxer_flags_e operator|=(Demuxer::demuxer_flags_e& a, Demuxer::demuxer_flags_e b) { return (a=static_cast<Demuxer::demuxer_flags_e>(static_cast<unsigned>(a)|static_cast<unsigned>(b))); } + inline Demuxer::demuxer_flags_e operator&=(Demuxer::demuxer_flags_e& a, Demuxer::demuxer_flags_e b) { return (a=static_cast<Demuxer::demuxer_flags_e>(static_cast<unsigned>(a)&static_cast<unsigned>(b))); } + inline Demuxer::demuxer_flags_e operator^=(Demuxer::demuxer_flags_e& a, Demuxer::demuxer_flags_e b) { return (a=static_cast<Demuxer::demuxer_flags_e>(static_cast<unsigned>(a)^static_cast<unsigned>(b))); } Demuxer* new_demuxers_demuxer(Demuxer* vd, Demuxer* ad, Demuxer* sd); }// namespace mpxp Modified: mplayerxp/libmpdemux/demuxer_packet.h =================================================================== --- mplayerxp/libmpdemux/demuxer_packet.h 2013-04-26 06:56:49 UTC (rev 632) +++ mplayerxp/libmpdemux/demuxer_packet.h 2013-04-27 17:29:31 UTC (rev 633) @@ -20,9 +20,9 @@ inline dp_flags_e operator|(dp_flags_e a, dp_flags_e b) { return static_cast<dp_flags_e>(static_cast<unsigned>(a)|static_cast<unsigned>(b)); } inline dp_flags_e operator&(dp_flags_e a, dp_flags_e b) { return static_cast<dp_flags_e>(static_cast<unsigned>(a)&static_cast<unsigned>(b)); } inline dp_flags_e operator^(dp_flags_e a, dp_flags_e b) { return static_cast<dp_flags_e>(static_cast<unsigned>(a)^static_cast<unsigned>(b)); } - inline dp_flags_e operator|=(dp_flags_e a, dp_flags_e b) { return (a=static_cast<dp_flags_e>(static_cast<unsigned>(a)|static_cast<unsigned>(b))); } - inline dp_flags_e operator&=(dp_flags_e a, dp_flags_e b) { return (a=static_cast<dp_flags_e>(static_cast<unsigned>(a)&static_cast<unsigned>(b))); } - inline dp_flags_e operator^=(dp_flags_e a, dp_flags_e b) { return (a=static_cast<dp_flags_e>(static_cast<unsigned>(a)^static_cast<unsigned>(b))); } + inline dp_flags_e operator|=(dp_flags_e& a, dp_flags_e b) { return (a=static_cast<dp_flags_e>(static_cast<unsigned>(a)|static_cast<unsigned>(b))); } + inline dp_flags_e operator&=(dp_flags_e& a, dp_flags_e b) { return (a=static_cast<dp_flags_e>(static_cast<unsigned>(a)&static_cast<unsigned>(b))); } + inline dp_flags_e operator^=(dp_flags_e& a, dp_flags_e b) { return (a=static_cast<dp_flags_e>(static_cast<unsigned>(a)^static_cast<unsigned>(b))); } /** Describes demuxer's packet */ class Demuxer_Packet : public Opaque { Modified: mplayerxp/libmpstream2/stream.h =================================================================== --- mplayerxp/libmpstream2/stream.h 2013-04-26 06:56:49 UTC (rev 632) +++ mplayerxp/libmpstream2/stream.h 2013-04-27 17:29:31 UTC (rev 633) @@ -98,9 +98,9 @@ inline Stream::type_e operator|(Stream::type_e a, Stream::type_e b) { return static_cast<Stream::type_e>(static_cast<unsigned>(a)|static_cast<unsigned>(b)); } inline Stream::type_e operator&(Stream::type_e a, Stream::type_e b) { return static_cast<Stream::type_e>(static_cast<unsigned>(a)&static_cast<unsigned>(b)); } inline Stream::type_e operator^(Stream::type_e a, Stream::type_e b) { return static_cast<Stream::type_e>(static_cast<unsigned>(a)^static_cast<unsigned>(b)); } - inline Stream::type_e operator|=(Stream::type_e a, Stream::type_e b) { return (a=static_cast<Stream::type_e>(static_cast<unsigned>(a)|static_cast<unsigned>(b))); } - inline Stream::type_e operator&=(Stream::type_e a, Stream::type_e b) { return (a=static_cast<Stream::type_e>(static_cast<unsigned>(a)&static_cast<unsigned>(b))); } - inline Stream::type_e operator^=(Stream::type_e a, Stream::type_e b) { return (a=static_cast<Stream::type_e>(static_cast<unsigned>(a)^static_cast<unsigned>(b))); } + inline Stream::type_e operator|=(Stream::type_e& a, Stream::type_e b) { return (a=static_cast<Stream::type_e>(static_cast<unsigned>(a)|static_cast<unsigned>(b))); } + inline Stream::type_e operator&=(Stream::type_e& a, Stream::type_e b) { return (a=static_cast<Stream::type_e>(static_cast<unsigned>(a)&static_cast<unsigned>(b))); } + inline Stream::type_e operator^=(Stream::type_e& a, Stream::type_e b) { return (a=static_cast<Stream::type_e>(static_cast<unsigned>(a)^static_cast<unsigned>(b))); } struct Memory_Stream : public Stream { public: Modified: mplayerxp/libvo2/video_out.h =================================================================== --- mplayerxp/libvo2/video_out.h 2013-04-26 06:56:49 UTC (rev 632) +++ mplayerxp/libvo2/video_out.h 2013-04-27 17:29:31 UTC (rev 633) @@ -70,9 +70,9 @@ inline vo_flags_e operator|(vo_flags_e a, vo_flags_e b) { return static_cast<vo_flags_e>(static_cast<unsigned>(a)|static_cast<unsigned>(b)); } inline vo_flags_e operator&(vo_flags_e a, vo_flags_e b) { return static_cast<vo_flags_e>(static_cast<unsigned>(a)&static_cast<unsigned>(b)); } inline vo_flags_e operator^(vo_flags_e a, vo_flags_e b) { return static_cast<vo_flags_e>(static_cast<unsigned>(a)^static_cast<unsigned>(b)); } - inline vo_flags_e operator|=(vo_flags_e a, vo_flags_e b) { return (a=static_cast<vo_flags_e>(static_cast<unsigned>(a)|static_cast<unsigned>(b))); } - inline vo_flags_e operator&=(vo_flags_e a, vo_flags_e b) { return (a=static_cast<vo_flags_e>(static_cast<unsigned>(a)&static_cast<unsigned>(b))); } - inline vo_flags_e operator^=(vo_flags_e a, vo_flags_e b) { return (a=static_cast<vo_flags_e>(static_cast<unsigned>(a)^static_cast<unsigned>(b))); } + inline vo_flags_e operator|=(vo_flags_e& a, vo_flags_e b) { return (a=static_cast<vo_flags_e>(static_cast<unsigned>(a)|static_cast<unsigned>(b))); } + inline vo_flags_e operator&=(vo_flags_e& a, vo_flags_e b) { return (a=static_cast<vo_flags_e>(static_cast<unsigned>(a)&static_cast<unsigned>(b))); } + inline vo_flags_e operator^=(vo_flags_e& a, vo_flags_e b) { return (a=static_cast<vo_flags_e>(static_cast<unsigned>(a)^static_cast<unsigned>(b))); } /** Request for supported FOURCC by VO-driver */ struct vo_query_fourcc_t { Modified: mplayerxp/xmpcore/xmp_aframe.h =================================================================== --- mplayerxp/xmpcore/xmp_aframe.h 2013-04-26 06:56:49 UTC (rev 632) +++ mplayerxp/xmpcore/xmp_aframe.h 2013-04-27 17:29:31 UTC (rev 633) @@ -45,9 +45,9 @@ inline mpaf_format_e operator|(mpaf_format_e a, mpaf_format_e b) { return static_cast<mpaf_format_e>(static_cast<unsigned>(a)|static_cast<unsigned>(b)); } inline mpaf_format_e operator&(mpaf_format_e a, mpaf_format_e b) { return static_cast<mpaf_format_e>(static_cast<unsigned>(a)&static_cast<unsigned>(b)); } inline mpaf_format_e operator^(mpaf_format_e a, mpaf_format_e b) { return static_cast<mpaf_format_e>(static_cast<unsigned>(a)^static_cast<unsigned>(b)); } - inline mpaf_format_e operator|=(mpaf_format_e a, mpaf_format_e b) { return (a=static_cast<mpaf_format_e>(static_cast<unsigned>(a)|static_cast<unsigned>(b))); } - inline mpaf_format_e operator&=(mpaf_format_e a, mpaf_format_e b) { return (a=static_cast<mpaf_format_e>(static_cast<unsigned>(a)&static_cast<unsigned>(b))); } - inline mpaf_format_e operator^=(mpaf_format_e a, mpaf_format_e b) { return (a=static_cast<mpaf_format_e>(static_cast<unsigned>(a)^static_cast<unsigned>(b))); } + inline mpaf_format_e operator|=(mpaf_format_e& a, mpaf_format_e b) { return (a=static_cast<mpaf_format_e>(static_cast<unsigned>(a)|static_cast<unsigned>(b))); } + inline mpaf_format_e operator&=(mpaf_format_e& a, mpaf_format_e b) { return (a=static_cast<mpaf_format_e>(static_cast<unsigned>(a)&static_cast<unsigned>(b))); } + inline mpaf_format_e operator^=(mpaf_format_e& a, mpaf_format_e b) { return (a=static_cast<mpaf_format_e>(static_cast<unsigned>(a)^static_cast<unsigned>(b))); } /* Decodes the format from mplayer format to libaf format */ mpaf_format_e __FASTCALL__ afmt2mpaf(unsigned format); Modified: mplayerxp/xmpcore/xmp_core.h =================================================================== --- mplayerxp/xmpcore/xmp_core.h 2013-04-26 06:56:49 UTC (rev 632) +++ mplayerxp/xmpcore/xmp_core.h 2013-04-27 17:29:31 UTC (rev 633) @@ -69,9 +69,9 @@ inline xmp_model_e operator|(xmp_model_e a, xmp_model_e b) { return static_cast<xmp_model_e>(static_cast<unsigned>(a)|static_cast<unsigned>(b)); } inline xmp_model_e operator&(xmp_model_e a, xmp_model_e b) { return static_cast<xmp_model_e>(static_cast<unsigned>(a)&static_cast<unsigned>(b)); } inline xmp_model_e operator^(xmp_model_e a, xmp_model_e b) { return static_cast<xmp_model_e>(static_cast<unsigned>(a)^static_cast<unsigned>(b)); } - inline xmp_model_e operator|=(xmp_model_e a, xmp_model_e b) { return (a=static_cast<xmp_model_e>(static_cast<unsigned>(a)|static_cast<unsigned>(b))); } - inline xmp_model_e operator&=(xmp_model_e a, xmp_model_e b) { return (a=static_cast<xmp_model_e>(static_cast<unsigned>(a)&static_cast<unsigned>(b))); } - inline xmp_model_e operator^=(xmp_model_e a, xmp_model_e b) { return (a=static_cast<xmp_model_e>(static_cast<unsigned>(a)^static_cast<unsigned>(b))); } + inline xmp_model_e operator|=(xmp_model_e& a, xmp_model_e b) { return (a=static_cast<xmp_model_e>(static_cast<unsigned>(a)|static_cast<unsigned>(b))); } + inline xmp_model_e operator&=(xmp_model_e& a, xmp_model_e b) { return (a=static_cast<xmp_model_e>(static_cast<unsigned>(a)&static_cast<unsigned>(b))); } + inline xmp_model_e operator^=(xmp_model_e& a, xmp_model_e b) { return (a=static_cast<xmp_model_e>(static_cast<unsigned>(a)^static_cast<unsigned>(b))); } struct mpxp_thread_t { unsigned p_idx; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2013-04-26 06:56:52
|
Revision: 632 http://sourceforge.net/p/mplayerxp/code/632 Author: nickols_k Date: 2013-04-26 06:56:49 +0000 (Fri, 26 Apr 2013) Log Message: ----------- sync with http://beye.sf.bet Modified Paths: -------------- mplayerxp/main.cpp mplayerxp/osdep/mp_malloc.cpp Modified: mplayerxp/main.cpp =================================================================== --- mplayerxp/main.cpp 2013-04-23 12:51:09 UTC (rev 631) +++ mplayerxp/main.cpp 2013-04-26 06:56:49 UTC (rev 632) @@ -2060,6 +2060,27 @@ int main(int argc,char* args[], char *envp[]) { try { + /* init malloc */ + size_t pos; + mp_conf.malloc_debug=0; + mp_malloc_e flg=MPA_FLG_RANDOMIZER; + for(int i=0;i<argc;i++) { + std::string s=args[i]; + if(s.substr(0,18)=="-core.malloc-debug") { + if((pos=s.find('='))!=std::string::npos) { + mp_conf.malloc_debug=::atoi(s.substr(pos+1).c_str()); + } + switch(mp_conf.malloc_debug) { + default: + case 0: flg=MPA_FLG_RANDOMIZER; break; + case 1: flg=MPA_FLG_BOUNDS_CHECK; break; + case 2: flg=MPA_FLG_BEFORE_CHECK; break; + case 3: flg=MPA_FLG_BACKTRACE; break; + } + break; + } + } + mp_init_malloc(args[0],1000,10,flg); std::vector<std::string> argv; std::string str,stmp; for(int i=0;i<argc;i++) { @@ -2069,7 +2090,6 @@ args[argc] = (char*)make_false_pointer((any_t*)antiviral_hole1); std::map<std::string,std::string> envm; unsigned j=0; - size_t pos; while(envp[j]) { str=envp[j++]; pos=str.find('='); @@ -2090,27 +2110,6 @@ return EXIT_FAILURE; } mpxp_ok<<"*** Antiviral protection was inited ***!!!"<<std::endl; - /* init malloc */ - size_t i,sz=argv.size(); - mp_conf.malloc_debug=0; - mp_malloc_e flg=MPA_FLG_RANDOMIZER; - for(i=0;i<sz;i++) { - std::string s=argv[i]; - if(s.substr(0,18)=="-core.malloc-debug") { - if((pos=s.find('='))!=std::string::npos) { - mp_conf.malloc_debug=::atoi(s.substr(pos+1).c_str()); - } - switch(mp_conf.malloc_debug) { - default: - case 0: flg=MPA_FLG_RANDOMIZER; break; - case 1: flg=MPA_FLG_BOUNDS_CHECK; break; - case 2: flg=MPA_FLG_BEFORE_CHECK; break; - case 3: flg=MPA_FLG_BACKTRACE; break; - } - break; - } - } - mp_init_malloc(argv[0],1000,10,flg); /* init structs */ #if defined( ARCH_X86 ) || defined(ARCH_X86_64) memset(&mp_conf.x86,-1,sizeof(x86_features_t)); Modified: mplayerxp/osdep/mp_malloc.cpp =================================================================== --- mplayerxp/osdep/mp_malloc.cpp 2013-04-23 12:51:09 UTC (rev 631) +++ mplayerxp/osdep/mp_malloc.cpp 2013-04-26 06:56:49 UTC (rev 632) @@ -220,7 +220,7 @@ any_t *page_ptr=prot_page_align(ptr); mp_slot_t* slot=prot_find_slot(&priv->mallocs,page_ptr); if(!slot) { - ::printf("[__prot_free_append] suspect call found! Can't find slot for address: %p [aligned: %p]\n",ptr,page_ptr); + mpxp_info<<"[__prot_free_append] suspect call found! Can't find slot for address: "<<ptr<<" [aligned: "<<page_ptr<<"]"<<std::endl; __prot_print_slots(&priv->mallocs); __print_backtrace(Max_BackTraces); ::kill(::getpid(), SIGILL); @@ -236,7 +236,7 @@ if((rp=__prot_malloc_append(size))!=NULL && ptr) { mp_slot_t* slot=prot_find_slot(&priv->mallocs,prot_page_align(ptr)); if(!slot) { - ::printf("[__prot_realloc_append] suspect call found! Can't find slot for address: %p [aligned: %p]\n",ptr,prot_page_align(ptr)); + mpxp_info<<"[__prot_realloc_append] suspect call found! Can't find slot for address: "<<ptr<<" [aligned: "<<prot_page_align(ptr)<<"]"<<std::endl; __prot_print_slots(&priv->mallocs); __print_backtrace(Max_BackTraces); ::kill(::getpid(), SIGILL); @@ -270,7 +270,7 @@ any_t *page_ptr=pre_page_align(ptr); mp_slot_t* slot=prot_find_slot(&priv->mallocs,page_ptr); if(!slot) { - ::printf("[__prot_free_prepend] suspect call found! Can't find slot for address: %p [aligned: %p]\n",ptr,page_ptr); + mpxp_info<<"[__prot_free_prepend] suspect call found! Can't find slot for address: "<<ptr<<" [aligned: "<<page_ptr<<"]"<<std::endl; __prot_print_slots(&priv->mallocs); __print_backtrace(Max_BackTraces); ::kill(::getpid(), SIGILL); @@ -285,7 +285,7 @@ if((rp=__prot_malloc_prepend(size))!=NULL && ptr) { mp_slot_t* slot=prot_find_slot(&priv->mallocs,pre_page_align(ptr)); if(!slot) { - ::printf("[__prot_realloc_prepend] suspect call found! Can't find slot for address: %p [aligned: %p]\n",ptr,pre_page_align(ptr)); + mpxp_info<<"[__prot_realloc_prepend] suspect call found! Can't find slot for address: "<<ptr<<" [aligned: "<<pre_page_align(ptr)<<"]"<<std::endl; __prot_print_slots(&priv->mallocs); __print_backtrace(Max_BackTraces); ::kill(getpid(), SIGILL); @@ -536,7 +536,7 @@ using namespace mpxp; #include <new> -any_t* SECURE_NAME0(_mp_malloc)(size_t size) { +extern "C" any_t* SECURE_NAME0(_mp_malloc)(size_t size) { any_t* ptr; ptr = mp_malloc(size); if(!ptr) { @@ -546,7 +546,7 @@ return ptr; } -any_t* SECURE_NAME1(_mp_mallocz)(size_t size) { +extern "C" any_t* SECURE_NAME1(_mp_mallocz)(size_t size) { any_t* ptr; ptr = mp_mallocz(size); if(!ptr) { @@ -556,7 +556,7 @@ return ptr; } -any_t* SECURE_NAME2(_mp_memalign)(size_t boundary,size_t size) { +extern "C" any_t* SECURE_NAME2(_mp_memalign)(size_t boundary,size_t size) { any_t* ptr; ptr = mp_memalign(boundary,size); if(!ptr) { @@ -566,7 +566,7 @@ return ptr; } -void SECURE_NAME3(_mp_free)(any_t* ptr) { +extern "C" void SECURE_NAME3(_mp_free)(any_t* ptr) { mp_free(ptr); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2013-04-23 12:51:14
|
Revision: 631 http://sourceforge.net/p/mplayerxp/code/631 Author: nickols_k Date: 2013-04-23 12:51:09 +0000 (Tue, 23 Apr 2013) Log Message: ----------- move mallocs into separate header Modified Paths: -------------- mplayerxp/osdep/mplib.h Added Paths: ----------- mplayerxp/osdep/mp_malloc.h Added: mplayerxp/osdep/mp_malloc.h =================================================================== --- mplayerxp/osdep/mp_malloc.h (rev 0) +++ mplayerxp/osdep/mp_malloc.h 2013-04-23 12:51:09 UTC (rev 631) @@ -0,0 +1,98 @@ +/* + * mp_malloc.h - Memory Protected malloc + * + * You can redistribute this file under terms and conditions + * of GNU General Public licence v3. + */ +#ifndef __MP_MALLOC_H_INCLUDED__ +#define __MP_MALLOC_H_INCLUDED__ 1 + +#include <string> + +#include <execinfo.h> +#include <stddef.h> +#include <sys/mman.h> +#include "mpxp_config.h" + +namespace mpxp { + + extern volatile unsigned long long int my_profile_start,my_profile_end,my_profile_total; + +#if defined ( ENABLE_PROFILE ) && (defined ( ARCH_X86 ) || defined( ARCH_X86_64 )) + inline unsigned long long int read_tsc( void ) { + unsigned long long int retval; + __asm __volatile ("rdtsc":"=A"(retval)::"memory"); + return retval; + } +#define PROFILE_RESET() (my_profile_total=0ULL) +#define PROFILE_START() { static int inited=0; if(!inited) { inited=1; my_profile_total=0ULL; } my_profile_start=read_tsc(); } +#define PROFILE_END(your_message) { my_profile_end=read_tsc(); my_profile_total+=(my_profile_end-my_profile_start); printf(your_message" current=%llu total=%llu\n\t",(my_profile_end-my_profile_start),my_profile_total); } +#else +#define PROFILE_RESET() +#define PROFILE_START() +#define PROFILE_END(your_message) +#endif +/** Initializes randomizer for malloc. + * @param rnd_limit upper limit of random generator (recommened: 1000) + * @param every_nth_call how often call randimzer (recommened: 10) + * @note Pseudo-randomizing memory objects makes memory + * exploits harder +*/ + enum mp_malloc_e { + MPA_FLG_RANDOMIZER = 0x00000000, + MPA_FLG_BOUNDS_CHECK = 0x00000001, + MPA_FLG_BEFORE_CHECK = 0x00000002, + MPA_FLG_BACKTRACE = 0x00000004 + }; + void __FASTCALL__ mp_init_malloc(const std::string& argv0,unsigned rnd_limit,unsigned every_nth_call,enum mp_malloc_e flags); + void __FASTCALL__ mp_uninit_malloc(int verbose); + + any_t* __FASTCALL__ mp_malloc(size_t __size); + any_t* __FASTCALL__ mp_mallocz(size_t __size); + any_t* __FASTCALL__ mp_realloc(any_t*__ptr, size_t __size); + inline any_t* mp_calloc (size_t __nelem, size_t __size) { return mp_mallocz(__nelem*__size); } + any_t* __FASTCALL__ mp_memalign (size_t boundary, size_t __size); + void __FASTCALL__ mp_free(any_t*__ptr); + char * __FASTCALL__ mp_strdup(const char *src); + + /* flags: PROT_NONE, PROT_READ, PROT_WRITE, PROT_EXEC */ + enum mp_prot_e { + MP_PROT_READ =0x1, /* Page can be read. */ + MP_PROT_WRITE =0x2, /* Page can be written. */ + MP_PROT_EXEC =0x4, /* Page can be executed. */ + MP_DENY_ALL =0x0, /* Page can not be accessed. */ + }; + int __FASTCALL__ mp_mprotect(any_t* addr,size_t len,enum mp_prot_e flags); + void print_backtrace(const std::string& why,any_t** stack,unsigned num); + + inline void show_backtrace(const std::string& why,unsigned num_calls) { + any_t* stack[num_calls]; + unsigned ncalls; + ncalls=backtrace(stack,num_calls); + print_backtrace(why,stack,ncalls); + } + any_t* __FASTCALL__ rnd_fill(any_t* buffer,size_t size); + any_t* __FASTCALL__ make_false_pointer(any_t* tmplt); + any_t* __FASTCALL__ make_false_pointer_to(any_t* tmplt,unsigned size); + any_t* __FASTCALL__ fill_false_pointers(any_t* buffer,size_t size); + any_t* get_caller_address(unsigned num_caller=0); + +} // namespace mpxp + +/* Note: it seems that compiler cannot distinguish which version of operators + new and delete to use: from global namespace or from user specified */ +#include <new> +enum zeromemory_t{ zeromem=0 }; +enum alignedmemory_t{ alignmem=0 }; +any_t* operator new(size_t size); +any_t* operator new(size_t size,const zeromemory_t&); +any_t* operator new(size_t size,const alignedmemory_t&,size_t boundary); +any_t* operator new(size_t size,const std::nothrow_t&); +any_t* operator new[](size_t size); +any_t* operator new[](size_t size,const zeromemory_t&); +any_t* operator new[](size_t size,const alignedmemory_t&,size_t boundary); +any_t* operator new[](size_t size,const std::nothrow_t&); +void operator delete(any_t* p); +void operator delete[](any_t* p); + +#endif Modified: mplayerxp/osdep/mplib.h =================================================================== --- mplayerxp/osdep/mplib.h 2013-04-17 14:04:33 UTC (rev 630) +++ mplayerxp/osdep/mplib.h 2013-04-23 12:51:09 UTC (rev 631) @@ -15,70 +15,10 @@ #include <stddef.h> #include <sys/mman.h> #include "mpxp_config.h" +#include "mp_malloc.h" namespace mpxp { - extern volatile unsigned long long int my_profile_start,my_profile_end,my_profile_total; - -#if defined ( ENABLE_PROFILE ) && (defined ( ARCH_X86 ) || defined( ARCH_X86_64 )) - inline unsigned long long int read_tsc( void ) { - unsigned long long int retval; - __asm __volatile ("rdtsc":"=A"(retval)::"memory"); - return retval; - } -#define PROFILE_RESET() (my_profile_total=0ULL) -#define PROFILE_START() { static int inited=0; if(!inited) { inited=1; my_profile_total=0ULL; } my_profile_start=read_tsc(); } -#define PROFILE_END(your_message) { my_profile_end=read_tsc(); my_profile_total+=(my_profile_end-my_profile_start); printf(your_message" current=%llu total=%llu\n\t",(my_profile_end-my_profile_start),my_profile_total); } -#else -#define PROFILE_RESET() -#define PROFILE_START() -#define PROFILE_END(your_message) -#endif -/** Initializes randomizer for malloc. - * @param rnd_limit upper limit of random generator (recommened: 1000) - * @param every_nth_call how often call randimzer (recommened: 10) - * @note Pseudo-randomizing memory objects makes memory - * exploits harder -*/ - enum mp_malloc_e { - MPA_FLG_RANDOMIZER = 0x00000000, - MPA_FLG_BOUNDS_CHECK = 0x00000001, - MPA_FLG_BEFORE_CHECK = 0x00000002, - MPA_FLG_BACKTRACE = 0x00000004 - }; - void __FASTCALL__ mp_init_malloc(const std::string& argv0,unsigned rnd_limit,unsigned every_nth_call,enum mp_malloc_e flags); - void __FASTCALL__ mp_uninit_malloc(int verbose); - - any_t* __FASTCALL__ mp_malloc(size_t __size); - any_t* __FASTCALL__ mp_mallocz(size_t __size); - any_t* __FASTCALL__ mp_realloc(any_t*__ptr, size_t __size); - inline any_t* mp_calloc (size_t __nelem, size_t __size) { return mp_mallocz(__nelem*__size); } - any_t* __FASTCALL__ mp_memalign (size_t boundary, size_t __size); - void __FASTCALL__ mp_free(any_t*__ptr); - char * __FASTCALL__ mp_strdup(const char *src); - - /* flags: PROT_NONE, PROT_READ, PROT_WRITE, PROT_EXEC */ - enum mp_prot_e { - MP_PROT_READ =0x1, /* Page can be read. */ - MP_PROT_WRITE =0x2, /* Page can be written. */ - MP_PROT_EXEC =0x4, /* Page can be executed. */ - MP_DENY_ALL =0x0, /* Page can not be accessed. */ - }; - int __FASTCALL__ mp_mprotect(any_t* addr,size_t len,enum mp_prot_e flags); - void print_backtrace(const std::string& why,any_t** stack,unsigned num); - - inline void show_backtrace(const std::string& why,unsigned num_calls) { - any_t* stack[num_calls]; - unsigned ncalls; - ncalls=backtrace(stack,num_calls); - print_backtrace(why,stack,ncalls); - } - any_t* __FASTCALL__ rnd_fill(any_t* buffer,size_t size); - any_t* __FASTCALL__ make_false_pointer(any_t* tmplt); - any_t* __FASTCALL__ make_false_pointer_to(any_t* tmplt,unsigned size); - any_t* __FASTCALL__ fill_false_pointers(any_t* buffer,size_t size); - any_t* get_caller_address(unsigned num_caller=0); - template <typename T> class LocalPtr { public: LocalPtr(T* value):ptr(value) {} @@ -102,21 +42,4 @@ any_t* unusable; }; } // namespace mpxp - -/* Note: it seems that compiler cannot distinguish which version of operators - new and delete to use: from global namespace or from user specified */ -#include <new> -enum zeromemory_t{ zeromem=0 }; -enum alignedmemory_t{ alignmem=0 }; -any_t* operator new(size_t size); -any_t* operator new(size_t size,const zeromemory_t&); -any_t* operator new(size_t size,const alignedmemory_t&,size_t boundary); -any_t* operator new(size_t size,const std::nothrow_t&); -any_t* operator new[](size_t size); -any_t* operator new[](size_t size,const zeromemory_t&); -any_t* operator new[](size_t size,const alignedmemory_t&,size_t boundary); -any_t* operator new[](size_t size,const std::nothrow_t&); -void operator delete(any_t* p); -void operator delete[](any_t* p); - #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2013-04-17 14:04:39
|
Revision: 630 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=630&view=rev Author: nickols_k Date: 2013-04-17 14:04:33 +0000 (Wed, 17 Apr 2013) Log Message: ----------- impove informativeness. Really: after migrating on archlinux with precompiled gcc-4.8.0 illegal patch still exists on the development computer: main.cpp:2081 doesn't modify environment variables and env[j+1] still points on ELF Modified Paths: -------------- mplayerxp/libmpconf/cfgparser.cpp mplayerxp/main.cpp Modified: mplayerxp/libmpconf/cfgparser.cpp =================================================================== --- mplayerxp/libmpconf/cfgparser.cpp 2013-04-17 13:05:49 UTC (rev 629) +++ mplayerxp/libmpconf/cfgparser.cpp 2013-04-17 14:04:33 UTC (rev 630) @@ -112,7 +112,7 @@ if (lopt==lname) goto option_found; } } - mpxp_err<<"invalid option: "<<opt<<std::endl; + mpxp_err<<"read_option: invalid option: "<<opt<<std::endl; ret = ERR_NOT_AN_OPTION; goto out; option_found : @@ -124,7 +124,7 @@ goto out; } if (conf[i].flags & CONF_NOCMD && parser_mode == M_Config::CmdLine) { - mpxp_err<<"this option can only be used in config file:"<<opt<<std::endl; + mpxp_err<<"read_option: this option can only be used in config file:"<<opt<<std::endl; ret = ERR_NOT_AN_OPTION; goto out; } @@ -156,14 +156,14 @@ lparm=="0") *((int *) conf[i].p) = conf[i].min; else { - mpxp_err<<"invalid parameter for flag: "<<param<<std::endl; + mpxp_err<<"read_option: invalid parameter for flag: "<<param<<std::endl; ret = ERR_OUT_OF_RANGE; goto out; } ret = 1; } else { /* parser_mode == COMMAND_LINE */ *((int *) conf[i].p) = conf[i].max; - mpxp_dbg3<<"assigning "<<conf[i].name<<"="<<conf[i].max<<" as flag value"<<std::endl; + mpxp_dbg3<<"read_option: assigning "<<conf[i].name<<"="<<conf[i].max<<" as flag value"<<std::endl; ret = 0; } break; @@ -173,27 +173,27 @@ tmp_int = ::strtol(param.c_str(), &endptr, 0); if (*endptr) { - mpxp_err<<"parameter must be an integer: "<<param<<std::endl; + mpxp_err<<"read_option: parameter must be an integer: "<<param<<std::endl; ret = ERR_OUT_OF_RANGE; goto out; } if (conf[i].flags & CONF_MIN) if (tmp_int < conf[i].min) { - mpxp_err<<"parameter must be >= "<<(int) conf[i].min<<": "<<param<<std::endl; + mpxp_err<<"read_option: parameter must be >= "<<(int) conf[i].min<<": "<<param<<std::endl; ret = ERR_OUT_OF_RANGE; goto out; } if (conf[i].flags & CONF_MAX) if (tmp_int > conf[i].max) { - mpxp_err<<"parameter must be <= "<<(int) conf[i].max<<": "<<param<<std::endl; + mpxp_err<<"read_option: parameter must be <= "<<(int) conf[i].max<<": "<<param<<std::endl; ret = ERR_OUT_OF_RANGE; goto out; } *((int *) conf[i].p) = tmp_int; - mpxp_dbg3<<"assigning "<<conf[i].name<<"="<<tmp_int<<" as int value"<<std::endl; + mpxp_dbg3<<"read_option: assigning "<<conf[i].name<<"="<<tmp_int<<" as int value"<<std::endl; ret = 1; break; case CONF_TYPE_FLOAT: @@ -206,27 +206,27 @@ tmp_float /= ::strtod(endptr+1, &endptr); if (*endptr) { - mpxp_err<<"parameter must be a floating point number or a ratio (numerator[:/]denominator): "<<param<<std::endl; + mpxp_err<<"read_option: parameter must be a floating point number or a ratio (numerator[:/]denominator): "<<param<<std::endl; ret = ERR_MISSING_PARAM; goto out; } if (conf[i].flags & CONF_MIN) if (tmp_float < conf[i].min) { - mpxp_err<<"parameter must be >= "<<(float)conf[i].min<<": "<<param<<std::endl; + mpxp_err<<"read_option: parameter must be >= "<<(float)conf[i].min<<": "<<param<<std::endl; ret = ERR_OUT_OF_RANGE; goto out; } if (conf[i].flags & CONF_MAX) if (tmp_float > conf[i].max) { - mpxp_err<<"parameter must be <= "<<(float)conf[i].max<<": "<<param<<std::endl; + mpxp_err<<"read_option: parameter must be <= "<<(float)conf[i].max<<": "<<param<<std::endl; ret = ERR_OUT_OF_RANGE; goto out; } *((float *) conf[i].p) = tmp_float; - mpxp_dbg3<<"assigning "<<conf[i].name<<"="<<tmp_float<<" as float value"<<std::endl; + mpxp_dbg3<<"read_option: assigning "<<conf[i].name<<"="<<tmp_float<<" as float value"<<std::endl; ret = 1; break; case CONF_TYPE_STRING: @@ -235,19 +235,19 @@ if (conf[i].flags & CONF_MIN) if (param.length() < conf[i].min) { - mpxp_err<<"parameter must be >= "<<(int) conf[i].min<<" chars: "<<param<<std::endl; + mpxp_err<<"read_option: parameter must be >= "<<(int) conf[i].min<<" chars: "<<param<<std::endl; ret = ERR_OUT_OF_RANGE; goto out; } if (conf[i].flags & CONF_MAX) if (param.length() > conf[i].max) { - mpxp_err<<"parameter must be <= "<<(int) conf[i].max<<" chars: "<<param<<std::endl; + mpxp_err<<"read_option: parameter must be <= "<<(int) conf[i].max<<" chars: "<<param<<std::endl; ret = ERR_OUT_OF_RANGE; goto out; } *((char **) conf[i].p) = mp_strdup(param.c_str()); - mpxp_dbg3<<"assigning "<<conf[i].name<<"="<<param<<" as string value"<<std::endl; + mpxp_dbg3<<"read_option: assigning "<<conf[i].name<<"="<<param<<" as string value"<<std::endl; ret = 1; break; case CONF_TYPE_INC: @@ -267,7 +267,7 @@ mpxp_info<<(char *)conf[i].p; exit(1); default: - mpxp_err<<"Unknown config type specified in conf-mplayerxp.h!"<<std::endl; + mpxp_err<<"read_option: Unknown config type specified in conf-mplayerxp.h!"<<std::endl; break; } out: @@ -279,7 +279,7 @@ } return ret; err_missing_param: - mpxp_err<<"missing parameter for option: "<<opt<<std::endl; + mpxp_err<<"read_option: missing parameter for option: "<<opt<<std::endl; ret = ERR_MISSING_PARAM; goto out; } Modified: mplayerxp/main.cpp =================================================================== --- mplayerxp/main.cpp 2013-04-17 13:05:49 UTC (rev 629) +++ mplayerxp/main.cpp 2013-04-17 14:04:33 UTC (rev 630) @@ -2078,6 +2078,7 @@ str=str.substr(0,pos); envm[str]=stmp; } + envp[j+1] = NULL; /* init antiviral protection */ int rc; rc=mp_mprotect((any_t*)antiviral_hole1,sizeof(antiviral_hole1),MP_DENY_ALL); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2013-04-17 13:05:56
|
Revision: 629 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=629&view=rev Author: nickols_k Date: 2013-04-17 13:05:49 +0000 (Wed, 17 Apr 2013) Log Message: ----------- restore -vo fbdev efficiency Modified Paths: -------------- mplayerxp/libvo2/vo_fbdev.cpp mplayerxp/main.cpp Modified: mplayerxp/libvo2/vo_fbdev.cpp =================================================================== --- mplayerxp/libvo2/vo_fbdev.cpp 2013-04-17 09:54:29 UTC (rev 628) +++ mplayerxp/libvo2/vo_fbdev.cpp 2013-04-17 13:05:49 UTC (rev 629) @@ -252,6 +252,7 @@ } fb_preinit_done = 1; + pre_init_err= MPXP_Ok; fb_works = MPXP_Ok; return MPXP_Ok; err_out_tty_fd: @@ -263,6 +264,7 @@ err_out: fb_preinit_done = 1; fb_works = MPXP_False; + pre_init_err= MPXP_Error; return MPXP_False; } @@ -889,7 +891,10 @@ mpxp_err<<FBDEV<< "Internal fatal error: init() was called before preinit()"<<std::endl; return MPXP_False; } - if (pre_init_err!=MPXP_Ok) return MPXP_False; + if (pre_init_err!=MPXP_Ok) { + mpxp_err<<FBDEV<<"fb_prenit() was failed"<<std::endl; + return MPXP_False; + } if (priv_conf.mode_name && !flags&VOFLAG_MODESWITCHING) { mpxp_err<<FBDEV<< "-fbmode can only be used with -vm"<<std::endl; Modified: mplayerxp/main.cpp =================================================================== --- mplayerxp/main.cpp 2013-04-17 09:54:29 UTC (rev 628) +++ mplayerxp/main.cpp 2013-04-17 13:05:49 UTC (rev 629) @@ -2078,7 +2078,6 @@ str=str.substr(0,pos); envm[str]=stmp; } - envp[j+1] = NULL; /* init antiviral protection */ int rc; rc=mp_mprotect((any_t*)antiviral_hole1,sizeof(antiviral_hole1),MP_DENY_ALL); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2013-04-17 09:54:35
|
Revision: 628 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=628&view=rev Author: nickols_k Date: 2013-04-17 09:54:29 +0000 (Wed, 17 Apr 2013) Log Message: ----------- fixed compilation with gcc-4.8.0 Modified Paths: -------------- mplayerxp/configure mplayerxp/osdep/mp_malloc.cpp mplayerxp/osdep/mplib.h Modified: mplayerxp/configure =================================================================== --- mplayerxp/configure 2013-04-12 07:48:43 UTC (rev 627) +++ mplayerxp/configure 2013-04-17 09:54:29 UTC (rev 628) @@ -644,7 +644,7 @@ fi if enabled png; then -require2 png png.h PNG_LIBPNG_VER_STRING -lpng +require3 png png.h Z_BEST_SPEED PNG_LIBPNG_VER_STRING -lpng print_config HAVE_ mpxp_config.h mpxp_config.mak png disabled png && require2 libpng_png libpng/png.h PNG_LIBPNG_VER_STRING -lpng -lm print_config HAVE_ mpxp_config.h mpxp_config.mak libpng_png Modified: mplayerxp/osdep/mp_malloc.cpp =================================================================== --- mplayerxp/osdep/mp_malloc.cpp 2013-04-12 07:48:43 UTC (rev 627) +++ mplayerxp/osdep/mp_malloc.cpp 2013-04-17 09:54:29 UTC (rev 628) @@ -570,13 +570,13 @@ mp_free(ptr); } -any_t *operator new(size_t size) { return SECURE_NAME0(_mp_malloc)(size); } -any_t *operator new(size_t size,const zeromemory_t&) { return SECURE_NAME1(_mp_mallocz)(size); } -any_t *operator new(size_t size,const alignedmemory_t&,size_t boundary) { return SECURE_NAME2(_mp_memalign)(boundary,size); } -any_t *operator new(size_t size,const std::nothrow_t&) { return mp_malloc(size); } -any_t *operator new[](size_t size) { return SECURE_NAME0(_mp_malloc)(size); } -any_t *operator new[](size_t size,const zeromemory_t&) { return SECURE_NAME1(_mp_mallocz)(size); } -any_t *operator new[](size_t size,const alignedmemory_t&,size_t boundary) { return SECURE_NAME2(_mp_memalign)(boundary,size); } -any_t *operator new[](size_t size,const std::nothrow_t&) { return mp_malloc(size); } -void operator delete(any_t* p) { SECURE_NAME3(_mp_free)(p); } -void operator delete[](any_t* p) { SECURE_NAME3(_mp_free)(p); } +any_t* operator new(size_t size) throw(std::bad_alloc) { return SECURE_NAME0(_mp_malloc)(size); } +any_t* operator new(size_t size,const zeromemory_t&) { return SECURE_NAME1(_mp_mallocz)(size); } +any_t* operator new(size_t size,const alignedmemory_t&,size_t boundary) { return SECURE_NAME2(_mp_memalign)(boundary,size); } +any_t* operator new(size_t size,const std::nothrow_t&) { return mp_malloc(size); } +any_t* operator new[](size_t size) throw(std::bad_alloc) { return SECURE_NAME0(_mp_malloc)(size); } +any_t* operator new[](size_t size,const zeromemory_t&) { return SECURE_NAME1(_mp_mallocz)(size); } +any_t* operator new[](size_t size,const alignedmemory_t&,size_t boundary) { return SECURE_NAME2(_mp_memalign)(boundary,size); } +any_t* operator new[](size_t size,const std::nothrow_t&) { return mp_malloc(size); } +void operator delete(any_t* p) throw() { SECURE_NAME3(_mp_free)(p); } +void operator delete[](any_t* p) throw() { SECURE_NAME3(_mp_free)(p); } Modified: mplayerxp/osdep/mplib.h =================================================================== --- mplayerxp/osdep/mplib.h 2013-04-12 07:48:43 UTC (rev 627) +++ mplayerxp/osdep/mplib.h 2013-04-17 09:54:29 UTC (rev 628) @@ -108,14 +108,14 @@ #include <new> enum zeromemory_t{ zeromem=0 }; enum alignedmemory_t{ alignmem=0 }; -any_t *operator new(size_t size); -any_t *operator new(size_t size,const zeromemory_t&); -any_t *operator new(size_t size,const alignedmemory_t&,size_t boundary); -any_t *operator new(size_t size,const std::nothrow_t&); -any_t *operator new[](size_t size); -any_t *operator new[](size_t size,const zeromemory_t&); -any_t *operator new[](size_t size,const alignedmemory_t&,size_t boundary); -any_t *operator new[](size_t size,const std::nothrow_t&); +any_t* operator new(size_t size); +any_t* operator new(size_t size,const zeromemory_t&); +any_t* operator new(size_t size,const alignedmemory_t&,size_t boundary); +any_t* operator new(size_t size,const std::nothrow_t&); +any_t* operator new[](size_t size); +any_t* operator new[](size_t size,const zeromemory_t&); +any_t* operator new[](size_t size,const alignedmemory_t&,size_t boundary); +any_t* operator new[](size_t size,const std::nothrow_t&); void operator delete(any_t* p); void operator delete[](any_t* p); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2013-04-12 07:48:59
|
Revision: 627 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=627&view=rev Author: nickols_k Date: 2013-04-12 07:48:43 +0000 (Fri, 12 Apr 2013) Log Message: ----------- restore efficiency Modified Paths: -------------- mplayerxp/Makefile mplayerxp/libmpdemux/demuxer.cpp Added Paths: ----------- mplayerxp/main.cpp Removed Paths: ------------- mplayerxp/mplayerxp.cpp Modified: mplayerxp/Makefile =================================================================== --- mplayerxp/Makefile 2012-12-29 17:26:32 UTC (rev 626) +++ mplayerxp/Makefile 2013-04-12 07:48:43 UTC (rev 627) @@ -21,7 +21,7 @@ MANDIR = ${prefix}/man LDFLAGS += -Wl,-rpath,${CODECDIR}/codecs -SRCS = mplayerxp.cpp dump.cpp mpxp_msg.cpp +SRCS = main.cpp dump.cpp mpxp_msg.cpp OBJS = $(SRCS:.cpp=.o) Modified: mplayerxp/libmpdemux/demuxer.cpp =================================================================== --- mplayerxp/libmpdemux/demuxer.cpp 2012-12-29 17:26:32 UTC (rev 626) +++ mplayerxp/libmpdemux/demuxer.cpp 2013-04-12 07:48:43 UTC (rev 627) @@ -347,8 +347,10 @@ // Real Media { "audio/x-pn-realaudio", &demux_realaud }, // OGG Streaming +#ifdef HAVE_LIBVORBIS { "application/ogg", &demux_ogg }, { "application/x-ogg", &demux_ogg }, +#endif // NullSoft Streaming Video { "video/nsv", &demux_nsv}, { "misc/ultravox", &demux_nsv}, Copied: mplayerxp/main.cpp (from rev 626, mplayerxp/mplayerxp.cpp) =================================================================== --- mplayerxp/main.cpp (rev 0) +++ mplayerxp/main.cpp 2013-04-12 07:48:43 UTC (rev 627) @@ -0,0 +1,2124 @@ +#include "mpxp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; +/* MplayerXP (C) 2000-2002. by A'rpi/ESP-team (C) 2002. by Nickols_K */ +#include <algorithm> +#include <iostream> +#include <iomanip> +#include <map> + +#include <ctype.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <limits.h> +#ifdef _OPENMP +#include <omp.h> +#endif +#define __USE_ISOC99 1 /* for lrint */ +#include <math.h> +#include <errno.h> +#include <sys/mman.h> +#include <sys/types.h> +#include <sys/wait.h> +#include <sys/time.h> +#include <sys/stat.h> +#include <signal.h> +#include <time.h> +#include <fcntl.h> + +#include "version.h" +#include "mplayerxp.h" +#include "xmpcore/sig_hand.h" + +#include "postproc/af.h" +#include "postproc/vf.h" +#define HELP_MPXP_DEFINE_STATIC +#include "mpxp_help.h" + +#include "libmpstream2/stream.h" +#include "libmpdemux/demuxer.h" + +#include "libmpconf/codec-cfg.h" +#include "libplaytree2/playtree.h" + +#include "libmpcodecs/dec_video.h" +#include "libmpcodecs/dec_audio.h" + +#include "libmpsub/spudec.h" +#include "libmpsub/vobsub.h" + +#include "osdep/get_path.h" +#include "osdep/cpudetect.h" +#include "osdep/mm_accel.h" +#include "osdep/timer.h" + +#include "nls/nls.h" +#include "postproc/libmenu/menu.h" + +#include "input2/input.h" +#include "player_msg.h" +#include "xmpcore/xmp_core.h" +#include "xmpcore/xmp_vplayer.h" +#include "xmpcore/xmp_adecoder.h" +#include "xmpcore/xmp_context.h" +#include "xmpcore/PointerProtector.h" +#include "dump.h" + +namespace mpxp { +/************************************************************************** + Private data +**************************************************************************/ +static volatile char antiviral_hole1[__VM_PAGE_SIZE__] __PAGE_ALIGNED__; +/************************************************************************** + Config file +**************************************************************************/ +enum { + INITED_VO =0x00000001, + INITED_AO =0x00000002, + INITED_RESERVED =0x00000004, + INITED_LIRC =0x00000008, + INITED_SPUDEC =0x00000010, + INITED_STREAM =0x00000020, + INITED_INPUT =0x00000040, + INITED_DEMUXER =0x00000080, + INITED_ACODEC =0x00000100, + INITED_VCODEC =0x00000200, + INITED_VOBSUB =0x00000400, + INITED_SUBTITLE =0x10000000, + INITED_XMP =0x80000000, + INITED_ALL =0xFFFFFFFF +}; + +enum { + PT_NEXT_ENTRY =1, + PT_PREV_ENTRY =-1, + PT_NEXT_SRC =2, + PT_PREV_SRC =-2, + PT_UP_NEXT =3, + PT_UP_PREV =-3 +}; + +struct osd_args_t { + int visible; + int info_factor; +}; + +struct input_state_t { + int need_repaint; + int after_dvdmenu; + int next_file; +}; + +struct MPXPSystem : public Opaque { + public: + MPXPSystem(const std::map<std::string,std::string>& _envm):inited_flags(0),osd_function(OSD_PLAY),envm(_envm),_libinput(mp_input_open(_envm)) { } + virtual ~MPXPSystem() {} + + void uninit_player(unsigned int mask); + Demuxer* demuxer() const { return _demuxer; } + Demuxer* assign_demuxer(Demuxer* _d) { uninit_demuxer(); _demuxer=_d; if(_d) inited_flags|=INITED_DEMUXER; return _demuxer; } + libinput_t& libinput() const { return _libinput; } + void uninit_demuxer(); + void uninit_input(); + + int libmpdemux_was_interrupted(int eof) const; + void seek(osd_args_t *osd,const seek_args_t* seek) const; + void init_keyboard_fifo(); + char* init_output_subsystems(); + int init_vobsub(const std::string& filename); + void init_dvd_nls() const; + + int handle_playlist(const std::string& filename) const; + + void print_stream_formats() const; + void print_audio_status() const; + void read_video_properties() const; + void read_subtitles(const std::string& filename,int forced_subs_only,int stream_dump_type); + + void find_acodec(const char *ao_subdevice); + int configure_audio(); + + MPXP_Rc find_vcodec(); + + void run_ahead_engine(); + +#ifdef USE_OSD + int paint_osd(int* osd_visible,int* in_pause); +#endif + int handle_input(seek_args_t* seek,osd_args_t* osd,input_state_t* state); + + unsigned inited_flags; + MPXP_Rc vo_inited; + MPXP_Rc ao_inited; + int osd_show_framedrop; + int osd_function; + PlayTree* playtree; + // for multifile support: + PlayTree_Iter* playtree_iter; + const std::map<std::string,std::string>& envm; + private: + Opaque unusable; + Demuxer* _demuxer; + libinput_t& _libinput; +}; + +struct MPXPSecureKeys { +public: + MPXPSecureKeys(unsigned _nkeys):nkeys(_nkeys) { keys = new unsigned [nkeys]; for(unsigned i=0;i<nkeys;i++) keys[i]=rand()%UINT_MAX; } + ~MPXPSecureKeys() { delete [] keys; } +private: + unsigned nkeys; + unsigned* keys; +}; + +MP_Config::MP_Config() { + memset(&has_video,0,reinterpret_cast<long>(&monitor_pixel_aspect)-reinterpret_cast<long>(&has_video)); + xp=get_number_cpu(); + audio_id=-1; + video_id=-1; + dvdsub_id=-1; + vobsub_id=-1; + audio_lang=I18N_LANGUAGE; + dvdsub_lang=I18N_LANGUAGE; + av_sync_pts=-1; + frame_reorder=1; + av_force_pts_fix2=-1; + loop_times=-1; + play_n_frames=-1; + font_factor=0.75; + sub_auto=1; + has_audio=1; + has_video=1; + has_dvdsub=1; + osd_level=2; + playbackspeed_factor=1.0; + ao_channels=2; + monitor_pixel_aspect=1; + msg_filter=0xFFFFFFFF; + max_trace=10; +} +MP_Config mp_conf; + +MPXPContext::MPXPContext() + :_engine(new(zeromem) mpxp_engine_t), + _audio(new(zeromem) audio_processing_t), + _video(new(zeromem) video_processing_t) +{ + seek_time=-1; + bench=new(zeromem) time_usage_t; + use_pts_fix2=-1; + rtc_fd=-1; +} + +MPXPContext::~MPXPContext() +{ + delete _engine->MPXPSys; + delete bench; +} + +static volatile char antiviral_hole2[__VM_PAGE_SIZE__] __PAGE_ALIGNED__; +static LocalPtr<MPXPContext> MPXPCtx(new(zeromem) MPXPContext); +static volatile char antiviral_hole3[__VM_PAGE_SIZE__] __PAGE_ALIGNED__; +volatile MPXPSecureKeys* secure_keys; +/************************************************************************** + Decoding ahead +**************************************************************************/ +static volatile char antiviral_hole4[__VM_PAGE_SIZE__] __PAGE_ALIGNED__; +/**************************************************************************/ +MPXPContext& mpxp_context() { return *MPXPCtx; } + +static MPXP_Rc mpxp_test_antiviral_protection(int* verbose) +{ + if(*verbose) mpxp_info<<"Your've specified test-av option!\nRight now MPlayerXP should make coredump!"<<std::endl; + *verbose=antiviral_hole1[0]|antiviral_hole2[0]|antiviral_hole3[0]|antiviral_hole4[0]; + mpxp_err<<"Antiviral protection of MPlayerXP doesn't work!"<<std::endl; + return MPXP_Virus; +} + +static void __attribute__ ((noinline)) mpxp_test_backtrace(void) { + goto *(reinterpret_cast<any_t*>(get_caller_address())); + kill(getpid(), SIGILL); +} + +unsigned xp_num_cpu; +unsigned get_number_cpu(void) { +#ifdef _OPENMP + return omp_get_num_procs(); +#else + /* TODO ? */ + return 1; +#endif +} + +static void mpxp_uninit_structs(void) { +#ifdef ENABLE_WIN32LOADER + free_codec_cfg(); +#endif + if(mpxp_context().video().output) delete mpxp_context().video().output; + if(mpxp_context().audio().output) delete mpxp_context().audio().output; + xmp_uninit(); + mp_uninit_malloc(mp_conf.verbose); +} + +void MPXPSystem::uninit_demuxer() { + if(inited_flags&INITED_DEMUXER) { + inited_flags&=~INITED_DEMUXER; + MP_UNIT("free_priv->demuxer"); + delete _demuxer; + _demuxer=NULL; + } +} + +void MPXPSystem::uninit_input() { + if(inited_flags&INITED_INPUT) { + inited_flags&=~INITED_INPUT; + MP_UNIT("uninit_input"); + mp_input_close(_libinput); + } +} +void MPXPSystem::uninit_player(unsigned int mask){ + Stream* stream=NULL; + sh_audio_t* sh_audio=NULL; + sh_video_t* sh_video=NULL; + if(_demuxer) { + stream=static_cast<Stream*>(_demuxer->stream); + sh_audio=reinterpret_cast<sh_audio_t*>(_demuxer->audio->sh); + sh_video=reinterpret_cast<sh_video_t*>(_demuxer->video->sh); + } + fflush(stdout); + fflush(stderr); + mask=inited_flags&mask; + + MP_UNIT("uninit_xp"); + if(mask&INITED_XMP) { + inited_flags&=~INITED_XMP; + MP_UNIT("uninit_xmp"); + xmp_uninit_engine(0); + } + + if (mask&INITED_SPUDEC){ + inited_flags&=~INITED_SPUDEC; + MP_UNIT("uninit_spudec"); + spudec_free(mpxp_context().video().output->spudec); + mpxp_context().video().output->spudec=NULL; + } + + if (mask&INITED_VOBSUB){ + inited_flags&=~INITED_VOBSUB; + MP_UNIT("uninit_vobsub"); + vobsub_close(mpxp_context().video().output->vobsub); + mpxp_context().video().output->vobsub=NULL; + } + + if(mask&INITED_VCODEC){ + inited_flags&=~INITED_VCODEC; + MP_UNIT("uninit_vcodec"); + mpcv_uninit(*mpxp_context().video().decoder); + sh_video=NULL; + } + + if(mask&INITED_VO){ + inited_flags&=~INITED_VO; + MP_UNIT("uninit_vo"); + delete mpxp_context().video().output; + mpxp_context().video().output=NULL; + vo_inited=MPXP_False; + } + + if(mask&INITED_ACODEC){ + inited_flags&=~INITED_ACODEC; + MP_UNIT("uninit_acodec"); + mpca_uninit(*mpxp_context().audio().decoder); + sh_audio=NULL; + } + + if(mask&INITED_AO){ + inited_flags&=~INITED_AO; + MP_UNIT("uninit_ao"); + delete mpxp_context().audio().output; + mpxp_context().audio().output=NULL; + ao_inited=MPXP_False; + } + + if(mask&INITED_DEMUXER) uninit_demuxer(); + + if(mask&INITED_STREAM){ + inited_flags&=~INITED_STREAM; + MP_UNIT("uninit_stream"); + if(stream) delete stream; + stream=NULL; + } + + if(mask&INITED_INPUT) uninit_input(); +#ifdef USE_SUB + if(mask&INITED_SUBTITLE){ + inited_flags&=~INITED_SUBTITLE; + MP_UNIT("sub_free"); + sub_free( mpxp_context().subtitles ); + mp_conf.sub_name=NULL; + mpxp_context().video().output->sub=NULL; + mpxp_context().subtitles=NULL; + } +#endif + MP_UNIT(NULL); +} + +void exit_player(const std::string& why){ + + fflush(stdout); + fflush(stderr); + mpxp_context().engine().MPXPSys->uninit_player(INITED_ALL); + + MP_UNIT("exit_player"); + + if(!why.empty()) mpxp_hint<<std::endl<<MSGTR_Exiting<<"...("<<why<<")"<<std::endl; + if(mpxp_context().mconfig) delete mpxp_context().mconfig; + mpxp_print_uninit(); + mpxp_uninit_structs(); + if(!why.empty()) ::exit(0); + return; /* Still try coredump!!!*/ +} + +void __exit_sighandler(void) +{ + static int sig_count=0; + ++sig_count; +// return; + if(sig_count==2) return; + if(sig_count>2){ + // can't stop :( + kill(getpid(),SIGKILL); + return; + } + exit_player(""); +} + + +void exit_sighandler(void) +{ + xmp_killall_threads(pthread_self()); + __exit_sighandler(); +} + +// When libmpdemux perform a blocking operation (network connection or cache filling) +// if the operation fail we use this function to check if it was interrupted by the user. +// The function return a new value for eof. +int MPXPSystem::libmpdemux_was_interrupted(int eof) const +{ + mp_cmd_t* cmd; + if((cmd = mp_input_get_cmd(_libinput,0,0,0)) != NULL) { + switch(cmd->id) { + case MP_CMD_QUIT: + case MP_CMD_SOFT_QUIT: // should never happen + exit_player(MSGTR_Exit_quit); + case MP_CMD_PLAY_TREE_STEP: { + eof = (cmd->args[0].v.i > 0) ? PT_NEXT_ENTRY : PT_PREV_ENTRY; + } break; + case MP_CMD_PLAY_TREE_UP_STEP: { + eof = (cmd->args[0].v.i > 0) ? PT_UP_NEXT : PT_UP_PREV; + } break; + case MP_CMD_PLAY_ALT_SRC_STEP: { + eof = (cmd->args[0].v.i > 0) ? PT_NEXT_SRC : PT_PREV_SRC; + } break; + } + mp_cmd_free(cmd); + } + return eof; +} + +#if defined( ARCH_X86 ) || defined(ARCH_X86_64) +static void get_mmx_optimizations( void ) +{ + GetCpuCaps(&gCpuCaps); + + if(mp_conf.x86.simd) { + if(mp_conf.x86.mmx != -1) gCpuCaps.hasMMX=mp_conf.x86.mmx; + if(mp_conf.x86.mmx2 != -1) gCpuCaps.hasMMX2=mp_conf.x86.mmx2; + if(mp_conf.x86._3dnow != -1) gCpuCaps.has3DNow=mp_conf.x86._3dnow; + if(mp_conf.x86._3dnow2 != -1) gCpuCaps.has3DNowExt=mp_conf.x86._3dnow2; + if(mp_conf.x86.sse != -1) gCpuCaps.hasSSE=mp_conf.x86.sse; + if(mp_conf.x86.sse2 != -1) gCpuCaps.hasSSE2=mp_conf.x86.sse2; + if(mp_conf.x86.sse3 != -1) gCpuCaps.hasSSE2=mp_conf.x86.sse3; + if(mp_conf.x86.ssse3 != -1) gCpuCaps.hasSSSE3=mp_conf.x86.ssse3; + if(mp_conf.x86.sse41 != -1) gCpuCaps.hasSSE41=mp_conf.x86.sse41; + if(mp_conf.x86.sse42 != -1) gCpuCaps.hasSSE42=mp_conf.x86.sse42; + if(mp_conf.x86.aes != -1) gCpuCaps.hasAES=mp_conf.x86.aes; + if(mp_conf.x86.avx != -1) gCpuCaps.hasAVX=mp_conf.x86.avx; + if(mp_conf.x86.fma != -1) gCpuCaps.hasFMA=mp_conf.x86.fma; + } else { + gCpuCaps.hasMMX= + gCpuCaps.hasMMX2= + gCpuCaps.has3DNow= + gCpuCaps.has3DNowExt= + gCpuCaps.hasSSE= + gCpuCaps.hasSSE2= + gCpuCaps.hasSSE3= + gCpuCaps.hasSSSE3= + gCpuCaps.hasSSE41= + gCpuCaps.hasSSE42= + gCpuCaps.hasAES= + gCpuCaps.hasAVX= + gCpuCaps.hasFMA=0; + } + mpxp_v<<"User corrected CPU flags: MMX="<<gCpuCaps.hasMMX + <<" MMX2="<<gCpuCaps.hasMMX2 + <<" 3DNow="<<gCpuCaps.has3DNow + <<" 3DNow2="<<gCpuCaps.has3DNowExt + <<" SSE="<<gCpuCaps.hasSSE + <<" SSE2="<<gCpuCaps.hasSSE2 + <<" SSE3="<<gCpuCaps.hasSSE3 + <<" SSSE3="<<gCpuCaps.hasSSSE3 + <<" SSE41="<<gCpuCaps.hasSSE41 + <<" SSE42="<<gCpuCaps.hasSSE42 + <<" AES="<<gCpuCaps.hasAES + <<" AVX="<<gCpuCaps.hasAVX + <<" FMA="<<gCpuCaps.hasFMA + <<std::endl; + if(gCpuCaps.hasMMX) mpxp_context().mplayer_accel |= MM_ACCEL_X86_MMX; + if(gCpuCaps.hasMMX2) mpxp_context().mplayer_accel |= MM_ACCEL_X86_MMXEXT; + if(gCpuCaps.hasSSE) mpxp_context().mplayer_accel |= MM_ACCEL_X86_SSE; + if(gCpuCaps.has3DNow) mpxp_context().mplayer_accel |= MM_ACCEL_X86_3DNOW; + if(gCpuCaps.has3DNowExt) mpxp_context().mplayer_accel |= MM_ACCEL_X86_3DNOWEXT; + mpxp_v<<"mpxp_context().mplayer_accel="<<mpxp_context().mplayer_accel<<std::endl; +} +#endif + + +static void init_player(const std::map<std::string,std::string>& envm) +{ + if(mp_conf.video_driver && strcmp(mp_conf.video_driver,"help")==0) { + mpxp_context().video().output->print_help(); + mpxp_uninit_structs(); + exit(0); + } + if(mp_conf.audio_driver && strcmp(mp_conf.audio_driver,"help")==0) { + mpxp_context().audio().output->print_help(); + mpxp_uninit_structs(); + exit(0); + } + if(mp_conf.video_family && strcmp(mp_conf.video_family,"help")==0) { + vfm_help(); + mpxp_uninit_structs(); + exit(0); + } + if(mp_conf.audio_family && strcmp(mp_conf.audio_family,"help")==0) { + afm_help(); + mpxp_uninit_structs(); + exit(0); + } + if(vf_cfg.list && strcmp(vf_cfg.list,"help")==0) { + vf_help(); + mpxp_uninit_structs(); + exit(0); + } + if(af_cfg.list && strcmp(af_cfg.list,"help")==0) { + af_help(); + mpxp_uninit_structs(); + exit(0); + } + +#ifdef ENABLE_WIN32LOADER + /* check codec.conf*/ + if(!parse_codec_cfg(get_path(envm,"win32codecs.conf").c_str())) { + if(!parse_codec_cfg(CONFDIR"/win32codecs.conf")) { + mpxp_hint<<MSGTR_CopyCodecsConf<<std::endl; + mpxp_uninit_structs(); + exit(0); + } + } +#endif + if(mp_conf.audio_codec && strcmp(mp_conf.audio_codec,"help")==0) { +#ifdef ENABLE_WIN32LOADER + list_codecs(1); +#endif + mpxp_uninit_structs(); + exit(0); + } + if(mp_conf.video_codec && strcmp(mp_conf.video_codec,"help")==0) { +#ifdef ENABLE_WIN32LOADER + list_codecs(0); +#endif + mpxp_uninit_structs(); + exit(0); + } +} + +void show_help(void) { + // no file/vcd/dvd -> show HELP: + for(unsigned j=0;help_text[j];j++) mpxp_info<<help_text[j]<<std::endl; + Stream::print_drivers(); + mpxp_info<<std::endl; + mpxp_info<<"Example: mplayerxp -ao alsa:hw:0 -vo x11 your.avi"<<std::endl; + mpxp_info<<"Use --long-help option for full help"<<std::endl; +} + +void show_long_help(const M_Config& cfg,const std::map<std::string,std::string>& envm) { + MPXPSystem& MPXPSys=*mpxp_context().engine().MPXPSys; + cfg.show_options(); + mp_input_print_binds(MPXPSys.libinput()); + Stream::print_drivers(); + Video_Output::print_help(); + Audio_Output::print_help(); + vf_help(); + af_help(); + vfm_help(); + afm_help(); +#ifdef ENABLE_WIN32LOADER + /* check codec.conf*/ + if(!parse_codec_cfg(get_path(envm,"win32codecs.conf").c_str())){ + if(!parse_codec_cfg(CONFDIR"/win32codecs.conf")){ + mpxp_hint<<MSGTR_CopyCodecsConf<<std::endl; + mpxp_uninit_structs(); + exit(0); + } + } + list_codecs(0); + list_codecs(1); +#endif +} + +#ifdef USE_OSD + +//================= Update OSD ==================== +void update_osd( float v_pts ) +{ + MPXPSystem& MPXPSys=*mpxp_context().engine().MPXPSys; + static char osd_text_buffer[64]; + static int osd_last_pts=-303; +//================= Update OSD ==================== + if(mp_conf.osd_level>=2){ + int pts=(mp_conf.osd_level==3&&MPXPSys.demuxer()->movi_length!=UINT_MAX)?MPXPSys.demuxer()->movi_length-v_pts:v_pts; + int addon=(mp_conf.osd_level==3&&MPXPSys.demuxer()->movi_length!=UINT_MAX)?-1:1; + char osd_text_tmp[64]; + if(pts==osd_last_pts-addon) + { + if(mp_conf.osd_level==3&&MPXPSys.demuxer()->movi_length!=UINT_MAX) ++pts; + else --pts; + } + else osd_last_pts=pts; + mpxp_context().video().output->osd_text=osd_text_buffer; + if (MPXPSys.osd_show_framedrop) { + sprintf(osd_text_tmp, "Framedrop: %s",mp_conf.frame_dropping>1?"hard":mp_conf.frame_dropping?"vo":"none"); + MPXPSys.osd_show_framedrop--; + } else +#ifdef ENABLE_DEC_AHEAD_DEBUG + if(mp_conf.verbose) sprintf(osd_text_tmp,"%c %02d:%02d:%02d",MPXPSys.osd_function,pts/3600,(pts/60)%60,pts%60); + else sprintf(osd_text_tmp,"%c %02d:%02d:%02d",MPXPSys.osd_function,pts/3600,(pts/60)%60,pts%60); +#else + sprintf(osd_text_tmp,"%c %02d:%02d:%02d",MPXPSys.osd_function,pts/3600,(pts/60)%60,pts%60); +#endif + if(strcmp(mpxp_context().video().output->osd_text, osd_text_tmp)) { + strcpy(mpxp_context().video().output->osd_text, osd_text_tmp); + vo_osd_changed(OSDTYPE_OSD); + } + } else { + if(mpxp_context().video().output->osd_text) { + mpxp_context().video().output->osd_text=NULL; + vo_osd_changed(OSDTYPE_OSD); + } + } +} +#endif + +void MPXPSystem::seek( osd_args_t *osd,const seek_args_t* _seek) const +{ + sh_audio_t* sh_audio=reinterpret_cast<sh_audio_t*>(_demuxer->audio->sh); + sh_video_t* sh_video=reinterpret_cast<sh_video_t*>(_demuxer->video->sh); + Demuxer_Stream *d_dvdsub=_demuxer->sub; + int seek_rval=1; + mpxp_context().engine().xp_core->audio->eof=0; + if(_seek->secs || _seek->flags&DEMUX_SEEK_SET) { + seek_rval=demux_seek_r(*_demuxer,_seek); + mpxp_context().mpxp_after_seek=25; /* 1 sec delay */ + } + if(seek_rval){ + mpxp_context().seek_time = GetTimerMS(); + + // success: + /* FIXME there should be real seeking for vobsub */ + if (mpxp_context().video().output->vobsub) vobsub_reset(mpxp_context().video().output->vobsub); + if (mpxp_context().video().output->spudec) spudec_reset(mpxp_context().video().output->spudec); + + if(sh_audio){ + sh_audio->chapter_change=0; + sh_audio->a_pts=HUGE; + } + fflush(stdout); + + if(sh_video){ + MP_UNIT("seek_video_reset"); + mpcv_resync_stream(*mpxp_context().video().decoder); + mpxp_context().video().output->reset(); + sh_video->chapter_change=-1; + } + + if(sh_audio){ + MP_UNIT("seek_audio_reset"); + mpca_resync_stream(*mpxp_context().audio().decoder); + mpxp_context().audio().output->reset(); // stop audio, throwing away buffered data + } + + if (mpxp_context().video().output->vobsub) { + MP_UNIT("seek_vobsub_reset"); + vobsub_seek_r(mpxp_context().video().output->vobsub, _seek); + } + +#ifdef USE_OSD + // Set OSD: + if(mp_conf.osd_level){ + int len=((_demuxer->movi_end-_demuxer->movi_start)>>8); + if (len>0){ + if(osd) osd->visible=sh_video->fps<=60?sh_video->fps:25; + mpxp_context().video().output->osd_progbar_type=0; + mpxp_context().video().output->osd_progbar_value=(_demuxer->filepos-_demuxer->movi_start)/len; + vo_osd_changed(OSDTYPE_PROGBAR); + } + } +#endif + if(sh_video) { + max_pts_correction=0.1; + if(osd) osd->visible=sh_video->fps<=60?sh_video->fps:25; // to rewert to PLAY pointer after 1 sec + mpxp_context().bench->audio=0; mpxp_context().bench->audio_decode=0; mpxp_context().bench->video=0; mpxp_context().bench->vout=0; + if(mpxp_context().video().output->spudec) { + unsigned char* packet=NULL; + while(ds_get_packet_sub_r(*d_dvdsub,&packet)>0) ; // Empty stream + spudec_reset(mpxp_context().video().output->spudec); + } + } + } + + if(sh_video) dae_wait_decoder_outrun(mpxp_context().engine().xp_core->video); +} + +void mpxp_reset_vcache(void) +{ + MPXPSystem& MPXPSys=*mpxp_context().engine().MPXPSys; + sh_video_t* sh_video=reinterpret_cast<sh_video_t*>(MPXPSys.demuxer()->video->sh); + seek_args_t _seek = { 0, DEMUX_SEEK_CUR|DEMUX_SEEK_SECONDS }; + if(sh_video) MPXPSys.seek(NULL,&_seek); + return; +} + +void mpxp_resync_audio_stream(void) +{ + mpca_resync_stream(*mpxp_context().audio().decoder); +} + +static void init_benchmark(void) +{ + mpxp_context().bench->max_audio=0; mpxp_context().bench->max_video=0; mpxp_context().bench->max_vout=0; + mpxp_context().bench->min_audio=HUGE; mpxp_context().bench->min_video=HUGE; mpxp_context().bench->min_vout=HUGE; + + mpxp_context().bench->min_audio_decode=HUGE; + mpxp_context().bench->max_audio_decode=0; + + mpxp_context().bench->max_demux=0; + mpxp_context().bench->demux=0; + mpxp_context().bench->min_demux=HUGE; + + mpxp_context().bench->cur_video=0; + mpxp_context().bench->cur_vout=0; + mpxp_context().bench->cur_audio=0; +} + +static void show_benchmark(void) +{ + double tot=(mpxp_context().bench->video+mpxp_context().bench->vout+mpxp_context().bench->audio+mpxp_context().bench->audio_decode+mpxp_context().bench->demux+mpxp_context().bench->c2); + double total_time_usage; + + mpxp_context().bench->total_start=GetTimer()-mpxp_context().bench->total_start; + total_time_usage = (float)mpxp_context().bench->total_start*0.000001; + + mpxp_info<<std::endl<<std::setprecision(3) + <<"AVE BENCHMARKs: VC:"<<mpxp_context().bench->video<<"s" + <<" VO:"<<mpxp_context().bench->vout<<"s" + <<" A:"<<mpxp_context().bench->audio+mpxp_context().bench->audio_decode<<"s" + <<" D:"<<mpxp_context().bench->demux<<"s="<<mpxp_context().bench->c2<<"s" + <<" C:"<<tot<<"s"<<std::endl; + if(total_time_usage>0.0) + mpxp_info<<std::setprecision(4) + <<"AVE BENCHMARK%: VC:"<<100.0*mpxp_context().bench->video/total_time_usage<<"%" + <<" VO:"<<100.0*mpxp_context().bench->vout/total_time_usage<<"%" + <<" A:"<<100.0*(mpxp_context().bench->audio+mpxp_context().bench->audio_decode)/total_time_usage<<"%" + <<" D:"<<100.0*mpxp_context().bench->demux/total_time_usage<<"%" + <<" C:"<<100.0*mpxp_context().bench->c2/total_time_usage<<"%" + <<" = "<<100.0*tot/total_time_usage<<"%"<<std::endl; + unsigned nframes=mpxp_context().engine().xp_core->video->num_played_frames; + mpxp_info<<std::endl<<"REAL RESULTS: from "<<nframes<<"was dropped="<<mpxp_context().engine().xp_core->video->num_dropped_frames<<std::endl; +} + +static void show_benchmark_status(void) +{ + MPXPSystem& MPXPSys=*mpxp_context().engine().MPXPSys; + sh_audio_t* sh_audio=reinterpret_cast<sh_audio_t*>(MPXPSys.demuxer()->audio->sh); + float rev_time=(sh_audio->timer>0.5)?100.0*(mpxp_context().bench->audio+mpxp_context().bench->audio_decode)/(double)sh_audio->timer:0; + if(xmp_test_model(XMP_Run_AudioPlayback)) + mpxp_status<<std::setprecision(1) + <<"A:"<<sh_audio->timer-mpxp_context().audio().output->get_delay() + <<" "<<rev_time + <<"\r"; + else + mpxp_status<<std::setprecision(1) + <<"A:"<<sh_audio->timer-mpxp_context().audio().output->get_delay() + <<" "<<rev_time + <<" B:"<<get_delay_audio_buffer() + <<"\r"; + mpxp_status.flush(); +} + +void MPXPSystem::init_keyboard_fifo() +{ +#ifdef HAVE_TERMCAP + load_termcap(NULL); // load key-codes +#endif +} + +void mplayer_put_key(int code){ + MPXPSystem& MPXPSys=*mpxp_context().engine().MPXPSys; + mp_cmd_t* cmd; + cmd=mp_input_get_cmd_from_keys(MPXPSys.libinput(),1,&code); + mp_input_queue_cmd(MPXPSys.libinput(),cmd); +} + + +static void mpxp_init_osd(const std::map<std::string,std::string>& envm) { +// check font +#ifdef USE_OSD + if(mp_conf.font_name){ + mpxp_context().video().output->font=read_font_desc(mp_conf.font_name,mp_conf.font_factor,mp_conf.verbose>1); + if(!mpxp_context().video().output->font) + mpxp_err<<MSGTR_CantLoadFont<<": "<<mp_conf.font_name<<std::endl; + } else { + // try default: + mpxp_context().video().output->font=read_font_desc(get_path(envm,"font/font.desc").c_str(),mp_conf.font_factor,mp_conf.verbose>1); + if(!mpxp_context().video().output->font) + mpxp_context().video().output->font=read_font_desc(DATADIR"/font/font.desc",mp_conf.font_factor,mp_conf.verbose>1); + } +#endif + /* Configure menu here */ + { + std::string menu_cfg; + menu_cfg = get_path(envm,"menu.conf"); + if(menu_init(NULL, menu_cfg.c_str())) + mpxp_info<<"Menu initialized: "<<menu_cfg<<std::endl; + else { + menu_cfg="/etc/menu.conf"; + if(menu_init(NULL, menu_cfg.c_str())) + mpxp_info<<"Menu initialized: "<<menu_cfg<<std::endl; + else + mpxp_warn<<"Menu init failed"<<std::endl; + } + } + MP_UNIT("init_osd"); + vo_init_osd(); +} + +char* MPXPSystem::init_output_subsystems() { + char* rs=NULL; + unsigned i; + // check video_out driver name: + MP_UNIT("vo_init"); + if(vo_inited==MPXP_False) { + if(!mpxp_context().video().output) mpxp_context().video().output=new(zeromem) Video_Output; + vo_inited = mpxp_context().video().output->init(mp_conf.video_driver?mp_conf.video_driver:""); + } + + if(vo_inited==MPXP_False){ + mpxp_fatal<<MSGTR_InvalidVOdriver<<": "<<(mp_conf.video_driver?mp_conf.video_driver:"?")<<std::endl; + exit_player(MSGTR_Fatal_error); + } + +// check audio_out driver name: + MP_UNIT("ao_init"); + if (mp_conf.audio_driver) + if ((i=strcspn(mp_conf.audio_driver, ":")) > 0) + { + size_t i2 = strlen(mp_conf.audio_driver); + + if (mp_conf.audio_driver[i] == ':') + { + rs = new char [i2-i]; + if (rs != NULL) strncpy(rs, (char *)(mp_conf.audio_driver+i+1), i2-i); + mp_conf.audio_driver[i] = '\0'; + } + } + return rs; +} + +int MPXPSystem::init_vobsub(const std::string& filename) { + int forced_subs_only=0; + MP_UNIT("vobsub"); + if (mp_conf.vobsub_name){ + mpxp_context().video().output->vobsub=vobsub_open(mp_conf.vobsub_name,mp_conf.spudec_ifo,1,&mpxp_context().video().output->spudec); + if(mpxp_context().video().output->vobsub==NULL) + mpxp_err<<MSGTR_CantLoadSub<<": "<<mp_conf.vobsub_name<<std::endl; + else { + inited_flags|=INITED_VOBSUB; + vobsub_set_from_lang(mpxp_context().video().output->vobsub, mp_conf.dvdsub_lang); + // check if vobsub requested only to display forced subtitles + forced_subs_only=vobsub_get_forced_subs_flag(mpxp_context().video().output->vobsub); + } + }else if(mp_conf.sub_auto && !filename.empty() && filename.length()>=5){ + /* try to autodetect vobsub from movie filename ::atmos */ + std::string buf = filename.substr(0,filename.length()-4); + mpxp_context().video().output->vobsub=vobsub_open(buf,mp_conf.spudec_ifo,0,&mpxp_context().video().output->spudec); + } + if(mpxp_context().video().output->vobsub) { + mp_conf.sub_auto=0; // don't do autosub for textsubs if vobsub found + inited_flags|=INITED_VOBSUB; + } + return forced_subs_only; +} + +int MPXPSystem::handle_playlist(const std::string& filename) const { + Stream* stream=static_cast<Stream*>(_demuxer->stream); + int eof=0; + PlayTree* entry; + // Handle playlist + MP_UNIT("handle_playlist"); + mpxp_v<<"Parsing playlist "<<filename<<"..."<<std::endl; + entry = PlayTree::parse_playtree(_libinput,stream); + if(!entry) { + entry = playtree_iter->get_tree(); + if(playtree_iter->step(1,0) != PLAY_TREE_ITER_ENTRY) { + eof = PT_NEXT_ENTRY; + return eof; + } + if(playtree_iter->get_tree() == entry ) { // Loop with a single file + if(playtree_iter->up_step(1,0) != PLAY_TREE_ITER_ENTRY) { + eof = PT_NEXT_ENTRY; + return eof; + } + } + entry->remove(1,1); + eof = PT_NEXT_SRC; + return eof; + } + playtree_iter->get_tree()->insert_entry(entry); + entry = playtree_iter->get_tree(); + if(playtree_iter->step(1,0) != PLAY_TREE_ITER_ENTRY) { + eof = PT_NEXT_ENTRY; + return eof; + } + entry->remove(1,1); + eof = PT_NEXT_SRC; + return eof; +} + +void MPXPSystem::init_dvd_nls() const { +/* Add NLS support here */ + Stream* stream=static_cast<Stream*>(_demuxer->stream); + char *lang; + if(!mp_conf.audio_lang) mp_conf.audio_lang=nls_get_screen_cp(envm); + MP_UNIT("dvd lang->id"); + if(mp_conf.audio_lang) { + lang=new char [std::max(strlen(mp_conf.audio_lang)+1,size_t(4))]; + strcpy(lang,mp_conf.audio_lang); + if(mp_conf.audio_id==-1 && stream->ctrl(SCTRL_LNG_GET_AID,lang)==MPXP_Ok) { + mp_conf.audio_id=*(int *)lang; + } + delete lang; + } + if(mp_conf.dvdsub_lang) { + lang=new char [std::max(strlen(mp_conf.dvdsub_lang)+1,size_t(4))]; + strcpy(lang,mp_conf.dvdsub_lang); + if(mp_conf.dvdsub_id==-1 && stream->ctrl(SCTRL_LNG_GET_SID,lang)==MPXP_Ok) { + mp_conf.dvdsub_id=*(int *)lang; + } + delete lang; + } +} + +void MPXPSystem::print_stream_formats() const { + sh_audio_t* sh_audio=reinterpret_cast<sh_audio_t*>(_demuxer->audio->sh); + sh_video_t* sh_video=reinterpret_cast<sh_video_t*>(_demuxer->video->sh); + int fmt; + mpxp_info<<"[Stream]:"; + if(sh_video) { + mpxp_info<<"Video="; + if(sh_video->bih)fmt=sh_video->bih->biCompression; + else fmt=sh_video->fourcc; + fourcc(mpxp_info,fmt); + } + if(sh_audio) { + mpxp_info<<" Audio="; + fmt=sh_audio->wtag; + fourcc(mpxp_info,fmt); + } + mpxp_info<<std::endl; +} + +void MPXPSystem::read_video_properties() const { + sh_video_t* sh_video=reinterpret_cast<sh_video_t*>(_demuxer->video->sh); + Demuxer_Stream *d_video=_demuxer->video; + MP_UNIT("video_read_properties"); + if(!sh_video->read_properties()) { + mpxp_err<<"Video: can't read properties"<<std::endl; + d_video->sh=NULL; + sh_video=reinterpret_cast<sh_video_t*>(d_video->sh); + } else { + mpxp_v<<"[V] filefmt:"<<_demuxer->file_format + <<"fourcc:0x"<<std::hex<<sh_video->fourcc + <<" size:"<<sh_video->src_w<<"x"<<sh_video->src_h + <<" fps:"<<std::setprecision(2)<<sh_video->fps + <<" ftime:="<<1/sh_video->fps<<std::endl; + /* need to set fps here for output encoders to pick it up in their init */ + if(mp_conf.force_fps){ + sh_video->fps=mp_conf.force_fps; + } + + if(!sh_video->fps && !mp_conf.force_fps){ + mpxp_err<<MSGTR_FPSnotspecified<<std::endl; + d_video->sh=NULL; + sh_video=reinterpret_cast<sh_video_t*>(d_video->sh); + } + } +} + +void MPXPSystem::read_subtitles(const std::string& filename,int forced_subs_only,int stream_dump_type) { + sh_video_t* sh_video=reinterpret_cast<sh_video_t*>(_demuxer->video->sh); + Stream* stream=static_cast<Stream*>(_demuxer->stream); + if (mp_conf.spudec_ifo) { + unsigned int palette[16], width, height; + MP_UNIT("spudec_init_vobsub"); + std::string buf=""; + if (vobsub_parse_ifo(NULL,mp_conf.spudec_ifo, palette, &width, &height, 1, -1, buf) >= 0) + mpxp_context().video().output->spudec=spudec_new_scaled(palette, sh_video->src_w, sh_video->src_h); + } + + if (mpxp_context().video().output->spudec==NULL) { + unsigned *pal; + MP_UNIT("spudec_init"); + if(stream->ctrl(SCTRL_VID_GET_PALETTE,&pal)==MPXP_Ok) + mpxp_context().video().output->spudec=spudec_new_scaled(pal,sh_video->src_w, sh_video->src_h); + } + + if (mpxp_context().video().output->spudec==NULL) { + MP_UNIT("spudec_init_normal"); + mpxp_context().video().output->spudec=spudec_new_scaled(NULL, sh_video->src_w, sh_video->src_h); + spudec_set_font_factor(mpxp_context().video().output->spudec,mp_conf.font_factor); + } + + if (mpxp_context().video().output->spudec!=NULL) { + inited_flags|=INITED_SPUDEC; + // Apply current settings for forced subs + spudec_set_forced_subs_only(mpxp_context().video().output->spudec,forced_subs_only); + } + +#ifdef USE_SUB +// after reading video params we should load subtitles because +// we know fps so now we can adjust subtitles time to ~6 seconds AST +// check .sub + MP_UNIT("read_subtitles_file"); + if(mp_conf.sub_name){ + mpxp_context().subtitles=sub_read_file(mp_conf.sub_name, sh_video->fps); + if(!mpxp_context().subtitles) mpxp_err<<MSGTR_CantLoadSub<<": "<<mp_conf.sub_name<<std::endl; + } else if(mp_conf.sub_auto) { // auto load sub file ... + mpxp_context().subtitles=sub_read_file( !filename.empty() ? sub_filename(get_path(envm,"sub/").c_str(), filename.c_str() ) + : "default.sub", sh_video->fps ); + } + if(mpxp_context().subtitles) { + inited_flags|=INITED_SUBTITLE; + if(stream_dump_type>1) list_sub_file(mpxp_context().subtitles); + } +#endif +} + +void MPXPSystem::find_acodec(const char *ao_subdevice) { + int found=0; + audio_decoder_t* mpca=0; + sh_audio_t* sh_audio=reinterpret_cast<sh_audio_t*>(_demuxer->audio->sh); + Demuxer_Stream *d_audio=_demuxer->audio; + sh_audio->codec=NULL; + mpca=mpca_init(sh_audio); // try auto-probe first + if(mpca) { mpxp_context().audio().decoder=mpca; found=1; } +#ifdef ENABLE_WIN32LOADER + if(!found) { +// Go through the codec.conf and find the best codec... + if(mp_conf.audio_family) mpxp_info<<MSGTR_TryForceAudioFmt<<": "<<mp_conf.audio_family<<std::endl; + while(1) { + sh_audio->codec=find_codec(sh_audio->wtag,NULL,sh_audio->codec,1); + if(!sh_audio->codec) { + if(mp_conf.audio_family) { + sh_audio->codec=NULL; /* re-search */ + mpxp_err<<MSGTR_CantFindAfmtFallback<<std::endl; + mp_conf.audio_family=NULL; + continue; + } + break; + } + if(mp_conf.audio_codec && strcmp(sh_audio->codec->codec_name,mp_conf.audio_codec)) continue; + else if(mp_conf.audio_family && strcmp(sh_audio->codec->driver_name,mp_conf.audio_family)) continue; + if(afm_find_driver(sh_audio->codec->driver_name)) { + mpxp_v<<(mp_conf.audio_codec?"Forcing":"Detected") + <<" audio codec: ["<<std::string(sh_audio->codec->codec_name) + <<"] drv:"<<std::string(sh_audio->codec->driver_name) + <<" ("<<std::string(sh_audio->codec->s_info)<<")"<<std::endl; + found=1; + break; + } + } + if(!found) { + sh_audio->codec=find_lavc_audio(sh_audio); + if(sh_audio->codec) found=1; + } + } +#endif + if(!found) { + mpxp_err<<MSGTR_CantFindAudioCodec<<std::endl; + fourcc(mpxp_err,sh_audio->wtag); + mpxp_hint<<get_path(envm,"win32codecs.conf")<<":"<<MSGTR_TryUpgradeCodecsConfOrRTFM<<std::endl; + d_audio->sh=NULL; + sh_audio=reinterpret_cast<sh_audio_t*>(d_audio->sh); + } else { + if(!(mpxp_context().audio().output=new(zeromem) Audio_Output(ao_subdevice?ao_subdevice:""))) { + mpxp_err<<MSGTR_CannotInitAO<<std::endl; + d_audio->sh=NULL; + sh_audio=reinterpret_cast<sh_audio_t*>(d_audio->sh); + } + if(ao_subdevice) delete ao_subdevice; + ao_inited=mpxp_context().audio().output->_register(mp_conf.audio_driver?mp_conf.audio_driver:"",0); + if (ao_inited!=MPXP_Ok){ + mpxp_fatal<<MSGTR_InvalidAOdriver<<": "<<mp_conf.audio_driver<<std::endl; + exit_player(MSGTR_Fatal_error); + } + } +} + +MPXP_Rc MPXPSystem::find_vcodec() { + Demuxer_Stream *d_video=_demuxer->video; + sh_video_t* sh_video=reinterpret_cast<sh_video_t*>(_demuxer->video->sh); + MPXP_Rc rc=MPXP_Ok; + MP_UNIT("init_video_codec"); + sh_video->inited=0; + mpxp_context().video().output->flags=VOFLAG_NONE; + /* configure flags */ + if(vo_conf.fullscreen) mpxp_context().video().output->FS_SET(); + if(vo_conf.softzoom) mpxp_context().video().output->ZOOM_SET(); + if(vo_conf.flip>0) mpxp_context().video().output->FLIP_SET(); + if(vo_conf.vidmode) mpxp_context().video().output->VM_SET(); + if((mpxp_context().video().decoder=mpcv_init(sh_video,mp_conf.video_codec?mp_conf.video_codec:"",mp_conf.video_family?mp_conf.video_family:"",-1,_libinput))) sh_video->inited=1; +#ifdef ENABLE_WIN32LOADER + if(!sh_video->inited) { +/* Go through the codec.conf and find the best codec...*/ + codecs_reset_selection(0); + if(mp_conf.video_codec) { + /* forced codec by name: */ + mpxp_info<<"Forced video codec: "<<mp_conf.video_codec<<std::endl; + mpxp_context().video().decoder=mpcv_init(sh_video,video_codec?mp_conf.video_codec:"","",-1,_libinput); + } else { + int status; + /* try in stability order: UNTESTED, WORKING, BUGGY, BROKEN */ + if(mp_conf.video_family) mpxp_info<<MSGTR_TryForceVideoFmt<<": "<<mp_conf.video_family<<std::endl; + for(status=CODECS_STATUS__MAX;status>=CODECS_STATUS__MIN;--status){ + if(mp_conf.video_family) /* try first the preferred codec family:*/ + if((mpxp_context().video().decoder=mpcv_init(sh_video,"",mp_conf.video_family?mp_conf.video_family:"",status,_libinput))) break; + if((mpxp_context().video().decoder=mpcv_init(sh_video,"","",status,_libinput))) break; + } + } + } + /* Use lavc decoders as last hope */ + if(!sh_video->inited) mpxp_context().video().decoder=mpcv_lavc_init(sh_video,_libinput); +#endif + + if(!sh_video->inited) { + mpxp_err<<MSGTR_CantFindVideoCodec<<std::endl; + fourcc(mpxp_err,sh_video->fourcc); + mpxp_hint<<get_path(envm,"win32codecs.conf")<<":"<<MSGTR_TryUpgradeCodecsConfOrRTFM<<std::endl; + d_video->sh = NULL; + sh_video = reinterpret_cast<sh_video_t*>(d_video->sh); + rc=MPXP_False; + } else inited_flags|=INITED_VCODEC; + + if(sh_video) + mpxp_v<<(mp_conf.video_codec?"Forcing":"Detected") + <<" video codec: ["<<std::string(sh_video->codec->codec_name) + <<"] vfm:"<<std::string(sh_video->codec->driver_name) + <<" ("<<std::string(sh_video->codec->s_info)<<std::endl; + return rc; +} + +int MPXPSystem::configure_audio() { + sh_audio_t* sh_audio=reinterpret_cast<sh_audio_t*>(_demuxer->audio->sh); + sh_video_t* sh_video=reinterpret_cast<sh_video_t*>(_demuxer->video->sh); + Demuxer_Stream *d_audio=_demuxer->audio; + int rc=0; + const ao_info_t *info=mpxp_context().audio().output->get_info(); + MP_UNIT("setup_audio"); + mpxp_v<<"AO: ["<<info->short_name<<"] " + <<(mp_conf.force_srate?mp_conf.force_srate:sh_audio->rate)<<"Hz " + <<(sh_audio->nch>7?"surround71": + sh_audio->nch>6?"surround61": + sh_audio->nch>5?"surround51": + sh_audio->nch>4?"surround41": + sh_audio->nch>3?"surround40": + sh_audio->nch>2?"stereo2.1": + sh_audio->nch>1?"Stereo":"Mono") + <<ao_format_name(sh_audio->afmt)<<std::endl; + mpxp_v<<"AO: Description: "<<info->name<<std::endl; + mpxp_v<<"AO: Author: "<<info->author<<std::endl; + if(strlen(info->comment) > 0) mpxp_v<<"AO: Comment: "<<info->comment<<std::endl; + + MP_UNIT("af_preinit"); + unsigned samplerate,channels,format; + samplerate=mp_conf.force_srate?mp_conf.force_srate:sh_audio->rate; + channels=mp_conf.ao_channels?mp_conf.ao_channels:sh_audio->nch; + format=sh_audio->afmt; + + if(mpca_preinit_filters(*mpxp_context().audio().decoder, + // input: + (int)(sh_audio->rate), + sh_audio->nch, sh_audio->afmt, + // output: + samplerate, channels, format)!=MPXP_Ok){ + mpxp_err<<"Audio filter chain preinit failed"<<std::endl; + } else { + mpxp_v<<"AF_pre: "<<samplerate<<"Hz "<<channels<<"ch (" + <<ao_format_name(format)<< + ") afmt="<<std::hex<<std::setfill('0')<<std::setw(8)<<format + <<" sh_audio_min="<<sh_audio->audio_out_minsize<<std::endl; + } + + if(MPXP_Ok!=mpxp_context().audio().output->configure( + samplerate, + channels, + format)) { + mpxp_err<<"Can't configure audio device"<<std::endl; + d_audio->sh=NULL; + sh_audio=reinterpret_cast<sh_audio_t*>(d_audio->sh); + if(sh_video == NULL) rc=-1; + } else { + inited_flags|=INITED_AO; + MP_UNIT("af_init"); + if(mpca_init_filters(*mpxp_context().audio().decoder, + sh_audio->rate, + sh_audio->nch, mpaf_format_e(sh_audio->afmt), + mpxp_context().audio().output->samplerate(), + mpxp_context().audio().output->channels(), + mpaf_format_e(mpxp_context().audio().output->format()), + mpxp_context().audio().output->outburst()*4, + mpxp_context().audio().output->buffersize())!=MPXP_Ok) { + mpxp_err<<"No matching audio filter found!"<<std::endl; + } + } + return rc; +} + +void MPXPSystem::run_ahead_engine() { + sh_audio_t* sh_audio=reinterpret_cast<sh_audio_t*>(_demuxer->audio->sh); + sh_video_t* sh_video=reinterpret_cast<sh_video_t*>(_demuxer->video->sh); + MP_UNIT("init_xp"); + if(sh_video && mpxp_context().engine().xp_core->num_v_buffs < 3) {/* we need at least 3 buffers to suppress screen judering */ + mpxp_fatal<<"Not enough buffers for DECODING AHEAD!"<<std::endl; + mpxp_fatal<<"Need 3 buffers but exist only " + <<mpxp_context().engine().xp_core->num_v_buffs<<std::endl; + exit_player("Try other '-vo' driver.\n"); + } + if(xmp_init_engine(sh_video,sh_audio)!=0) + exit_player("Can't initialize decoding ahead!\n"); + if(xmp_run_decoders()!=0) + exit_player("Can't run decoding ahead!\n"); + if(sh_video) + mpxp_ok<<"Using DECODING AHEAD mplayer's core with "<<mpxp_context().engine().xp_core->num_v_buffs<<" video buffers"<<std::endl; + else + mpxp_ok<<"Using DECODING AHEAD mplayer's core with "<<mpxp_context().engine().xp_core->num_a_buffs<<" audio buffers"<<std::endl; +/* reset counters */ + if(sh_video) mpxp_context().engine().xp_core->video->num_dropped_frames=0; + inited_flags|=INITED_XMP; +} + +void MPXPSystem::print_audio_status() const { + sh_audio_t* sh_audio=reinterpret_cast<sh_audio_t*>(_demuxer->audio->sh); + /* PAINT audio OSD */ + unsigned ipts,rpts; + unsigned h,m,s,rh,rm,rs; + static unsigned ph=0,pm=0,ps=0; + ipts=(unsigned)(sh_audio->timer-mpxp_context().audio().output->get_delay()); + rpts=_demuxer->movi_length-ipts; + h = ipts/3600; + m = (ipts/60)%60; + s = ipts%60; + if(_demuxer->movi_length!=UINT_MAX) { + rh = rpts/3600; + rm = (rpts/60)%60; + rs = rpts%60; + } else rh=rm=rs=0; + if(h != ph || m != pm || s != ps) { + mpxp_status<<">"<<std::setfill('0')<<std::setw(2)<<h<<":" + <<std::setfill('0')<<std::setw(2)<<m<<":" + <<std::setfill('0')<<std::setw(2)<<s<<"(" + <<std::setfill('0')<<std::setw(2)<<rh<<":" + <<std::setfill('0')<<std::setw(2)<<rm<<":" + <<std::setfill('0')<<std::setw(2)<<rs<<")\r"; + mpxp_status.flush(); + ph = h; + pm = m; + ps = s; + } +} + +#ifdef USE_OSD +int MPXPSystem::paint_osd(int* osd_visible,int* in_pause) { + Stream* stream=static_cast<Stream*>(_demuxer->stream); + sh_audio_t* sh_audio=reinterpret_cast<sh_audio_t*>(_demuxer->audio->sh); + sh_video_t* sh_video=reinterpret_cast<sh_video_t*>(_demuxer->video->sh); + int rc=0; + if(*osd_visible) { + if (!--(*osd_visible)) { + mpxp_context().video().output->osd_progbar_type=-1; // disable + vo_osd_changed(OSDTYPE_PROGBAR); + if (!((osd_function == OSD_PAUSE)||(osd_function==OSD_DVDMENU))) + osd_function = OSD_PLAY; + } + } + if(osd_function==OSD_DVDMENU) { + rect_highlight_t hl; + if(stream->ctrl(SCTRL_VID_GET_HILIGHT,&hl)==MPXP_Ok) { + osd_set_nav_box (hl.sx, hl.sy, hl.ex, hl.ey); + mpxp_v<<"Set nav box: "<<hl.sx<<" "<<hl.sy<<" "<<hl.ex<<" "<<hl.ey<<std::endl; + vo_osd_changed (OSDTYPE_DVDNAV); + } + } + if(osd_function==OSD_PAUSE||osd_function==OSD_DVDMENU) { + mp_cmd_t* cmd; + if (vo_inited && sh_video) { + if(mp_conf.osd_level>1 && !*in_pause) { + *in_pause = 1; + return -1; + } + mpxp_context().video().output->pause(); + } + if(mp_conf.verbose) { + mpxp_status<<std::endl<<"------ PAUSED -------\r"; + mpxp_status.flush(); + } + + if (ao_inited==MPXP_Ok && sh_audio) { + if(xmp_test_model(XMP_Run_AudioPlayer)) { + mpxp_context().engine().xp_core->in_pause=1; + while( !dec_ahead_can_aseek ) yield_timeslice(); + } + mpxp_context().audio().output->pause(); // pause audio, keep data if possible + } + + while( (cmd = mp_input_get_cmd(_libinput,20,1,1)) == NULL) { + if(sh_video && vo_inited) mpxp_context().video().output->check_events(); + yield_timeslice(); + } + + if (cmd && cmd->id == MP_CMD_PAUSE) { + cmd = mp_input_get_cmd(_libinput,0,1,0); + mp_cmd_free(cmd); + } + + if(osd_function==OSD_PAUSE) osd_function=OSD_PLAY; + if (ao_inited==MPXP_Ok && sh_audio) { + mpxp_context().audio().output->resume(); // resume audio + if(xmp_test_model(XMP_Run_AudioPlayer)) { + mpxp_context().engine().xp_core->in_pause=0; + __MP_SYNCHRONIZE(audio_play_mutex,pthread_cond_signal(&audio_play_cond)); + } + } + if (vo_inited && sh_video) + mpxp_context().video().output->resume(); // resume video + *in_pause=0; + (void)GetRelativeTime(); // keep TF around FT in next cycle + } + return rc; +} +#endif + +int MPXPSystem::handle_input(seek_args_t* _seek,osd_args_t* osd,input_state_t* state) { + Stream* stream=static_cast<Stream*>(_demuxer->stream); + sh_video_t* sh_video=reinterpret_cast<sh_video_t*>(_demuxer->video->sh); + int v_bright=0; + int v_cont=0; + int v_hue=0; + int v_saturation=0; +/* +For future: + int v_red_intensity=0; + int v_green_intensity=0; + int v_blue_intensity=0; +*/ + int eof=0; + mp_cmd_t* cmd; + while( (cmd = mp_input_get_cmd(_libinput,0,0,0)) != NULL) { + switch(cmd->id) { + case MP_CMD_SEEK : { + int v,i_abs; + v = cmd->args[0].v.i; + i_abs = (cmd->nargs > 1) ? cmd->args[1].v.i : 0; + if(i_abs) { + _seek->flags = DEMUX_SEEK_SET|DEMUX_SEEK_PERCENTS; + if(sh_video) osd_function= (v > dae_played_frame(mpxp_context().engine().xp_core->video).v_pts) ? OSD_FFW : OSD_REW; + _seek->secs = v/100.; + } else { + _seek->flags = DEMUX_SEEK_CUR|DEMUX_SEEK_SECONDS; + if(sh_video) osd_function= (v > 0) ? OSD_FFW : OSD_REW; + _seek->secs+= v; + } + } break; + case MP_CMD_SPEED_INCR : + case MP_CMD_SPEED_MULT : + case MP_CMD_SPEED_SET : + mpxp_warn<<"Speed adjusting is not implemented yet!"<<std::endl; + break; + case MP_CMD_SWITCH_AUDIO : + mpxp_info<<"ID_AUDIO_TRACK="<<demuxer_switch_audio_r(*_demuxer, _demuxer->audio->id+1)<<std::endl; + break; + case MP_CMD_SWITCH_VIDEO : + mpxp_info<<"ID_VIDEO_TRACK="<<demuxer_switch_video_r(*_demuxer, _demuxer->video->id+1)<<std::endl; + break; + case MP_CMD_SWITCH_SUB : + mpxp_info<<"ID_SUB_TRACK="<<demuxer_switch_subtitle_r(*_demuxer, _demuxer->sub->id+1)<<std::endl; + break; + case MP_CMD_FRAME_STEP : + case MP_CMD_PAUSE : + osd_function=OSD_PAUSE; + break; + case MP_CMD_SOFT_QUIT : + exit_player(MSGTR_Exit_quit); + case MP_CMD_QUIT : + exit_player(MSGTR_Exit_quit); + case MP_CMD_PLAY_TREE_STEP : { + int n = cmd->args[0].v.i > 0 ? 1 : -1; + PlayTree_Iter* it = new PlayTree_Iter(*playtree_iter); + + if(it->step(n,0) == PLAY_TREE_ITER_ENTRY) + eof = (n > 0) ? PT_NEXT_ENTRY : PT_PREV_ENTRY; + delete it; + } break; + case MP_CMD_PLAY_TREE_UP_STEP : { + int n = cmd->args[0].v.i > 0 ? 1 : -1; + PlayTree_Iter* it = new PlayTree_Iter(*playtree_iter); + if(it->up_step(n,0) == PLAY_TREE_ITER_ENTRY) + eof = (n > 0) ? PT_UP_NEXT : PT_UP_PREV; + delete it; + } break; + case MP_CMD_PLAY_ALT_SRC_STEP : + if(playtree_iter->get_num_files() > 1) { + int v = cmd->args[0].v.i; + if(v > 0 && playtree_iter->get_file() < playtree_iter->get_num_files()) + eof = PT_NEXT_SRC; + else if(v < 0 && playtree_iter->get_file() > 1) + eof = PT_PREV_SRC; + } + break; + case MP_CMD_OSD : + if(sh_video) { + int v = cmd->args[0].v.i; + if(v < 0) mp_conf.osd_level=(mp_conf.osd_level+1)%4; + else mp_conf.osd_level= v > 3 ? 3 : v; + } + break; + case MP_CMD_MUTE: + mpxp_context().audio().output->mixer_mute(); + break; + case MP_CMD_VOLUME : { + int v = cmd->args[0].v.i; + if(v > 0) mpxp_context().audio().output->mixer_incvolume(); + else mpxp_context().audio().output->mixer_decvolume(); +#ifdef USE_OSD + if(mp_conf.osd_level){ + osd->visible=sh_video->fps; // 1 sec + mpxp_context().video().output->osd_progbar_type=OSD_VOLUME; + mpxp_context().video().output->osd_progbar_value=(mpxp_context().audio().output->mixer_getbothvolume()*256.0)/100.0; + vo_osd_changed(OSDTYPE_PROGBAR); + } +#endif + } break; + case MP_CMD_CONTRAST : { + int v = cmd->args[0].v.i, i_abs = cmd->args[1].v.i; + if(i_abs) v_cont=v; + else v_cont+=v; + if(v_cont > 100) v_cont=100; + if(v_cont < -100) v_cont = -100; + if(mpcv_set_colors(*mpxp_context().video().decoder,VO_EC_CONTRAST,v_cont)==MPXP_Ok) { +#ifdef USE_OSD + if(mp_conf.osd_level){ + osd->visible=sh_video->fps; // 1 sec + mpxp_context().video().output->osd_progbar_type=OSD_CONTRAST; + mpxp_context().video().output->osd_progbar_value=((v_cont)<<8)/100; + mpxp_context().video().output->osd_progbar_value = ((v_cont+100)<<8)/200; + vo_osd_changed(OSDTYPE_PROGBAR); + } +#endif + } + } break; + case MP_CMD_BRIGHTNESS : { + int v = cmd->args[0].v.i, i_abs = cmd->args[1].v.i; + if(i_abs) v_bright=v; + else v_bright+=v; + if(v_bright > 100) v_bright = 100; + if(v_bright < -100) v_bright = -100; + if(mpcv_set_colors(*mpxp_context().video().decoder,VO_EC_BRIGHTNESS,v_bright)==MPXP_Ok) { +#ifdef USE_OSD + if(mp_conf.osd_level){ + osd->visible=sh_video->fps; // 1 sec + mpxp_context().video().output->osd_progbar_type=OSD_BRIGHTNESS; + mpxp_context().video().output->osd_progbar_value=((v_bright)<<8)/100; + mpxp_context().video().output->osd_progbar_value = ((v_bright+100)<<8)/200; + vo_osd_changed(OSDTYPE_PROGBAR); + } +#endif + } + } break; + case MP_CMD_HUE : { + int v = cmd->args[0].v.i, i_abs = cmd->args[1].v.i; + if(i_abs) v_hue=v; + else v_hue+=v; + if(v_hue > 100) v_hue = 100; + if(v_hue < -100) v_hue = -100; + if(mpcv_set_colors(*mpxp_context().video().decoder,VO_EC_HUE,v_hue)==MPXP_Ok) { +#ifdef USE_OSD + if(mp_conf.osd_level){ + osd->visible=sh_video->fps; // 1 sec + mpxp_context().video().output->osd_progbar_type=OSD_HUE; + mpxp_context().video().output->osd_progbar_value=((v_hue)<<8)/100; + mpxp_context().video().output->osd_progbar_value = ((v_hue+100)<<8)/200; + vo_osd_changed(OSDTYPE_PROGBAR); + } +#endif + } + } break; + case MP_CMD_SATURATION : { + int v = cmd->args[0].v.i, i_abs = cmd->args[1].v.i; + if(i_abs) v_saturation=v; + else v_saturation+=v; + if(v_saturation > 100) v_saturation = 100; + if(v_saturation < -100) v_saturation = -100; + if(mpcv_set_colors(*mpxp_context().video().decoder,VO_EC_SATURATION,v_saturation)==MPXP_Ok) { +#ifdef USE_OSD + if(mp_conf.osd_level){ + osd->visible=sh_video->fps; // 1 sec + mpxp_context().video().output->osd_progbar_type=OSD_SATURATION; + mpxp_context().video().output->osd_progbar_value=((v_saturation)<<8)/100; + mpxp_context().video().output->osd_progbar_value = ((v_saturation+100)<<8)/200; + vo_osd_changed(OSDTYPE_PROGBAR); + } +#endif + } + } break; + case MP_CMD_FRAMEDROPPING : { + int v = cmd->args[0].v.i; + if(v < 0) mp_conf.frame_dropping = (mp_conf.frame_dropping+1)%3; + else mp_conf.frame_dropping = v > 2 ? 2 : v; + osd_show_framedrop = osd->info_factor; + } break; + case MP_CMD_TV_STEP_CHANNEL: + if(cmd->args[0].v.i > 0)cmd->id=MP_CMD_TV_STEP_CHANNEL_UP; + else cmd->id=MP_CMD_TV_STEP_CHANNEL_DOWN; + case MP_CMD_TV_STEP_NORM: + case MP_CMD_TV_STEP_CHANNEL_LIST: + stream->ctrl(SCRTL_MPXP_CMD,(any_t*)cmd->id); + break; + case MP_CMD_DVDNAV: + if(stream->ctrl(SCRTL_MPXP_CMD,(any_t*)cmd->args[0].v.i)==MPXP_Ok) { + if(cmd->args[0].v.i!=MP_CMD_DVDNAV_SELECT) { + stream->type(Stream::Type_Menu); + state->need_repaint=1; + } + osd_function=OSD_DVDMENU; + if(cmd->args[0].v.i==MP_CMD_DVDNAV_SELECT) { + osd_function=0; + state->need_repaint=1; + state->after_dvdmenu=1; + state->next_file=1; + return eof; + } + } + break; + case MP_CMD_VO_FULLSCREEN: + mpxp_context().video().output->fullscreen(); + break; + case MP_CMD_VO_SCREENSHOT: + mpxp_context().video().output->screenshot(dae_curr_vplayed(mpxp_context().engine().xp_core)); + break; + case MP_CMD_SUB_POS: { + int v; + v = cmd->args[0].v.i; + + sub_data.pos+=v; + if(sub_data.pos >100) sub_data.pos=100; + if(sub_data.pos <0) sub_data.pos=0; + vo_osd_changed(OSDTYPE_SUBTITLE); + } break; + default : + mpxp_err<<"Received unknow cmd "<<cmd->name<<std::endl; + } + mp_cmd_free(cmd); + } + return eof; +} + +PlayTree_Iter& mpxp_get_playtree_iter() { return *(mpxp_context().engine().MPXPSys->playtree_iter); } +const std::map<std::string,std::string>& mpxp_get_environment() { return mpxp_context().engine().MPXPSys->envm; } +/******************************************\ +* MAIN MPLAYERXP FUNCTION !!! * +\******************************************/ +int MPlayerXP(const std::vector<std::string>& argv, const std::map<std::string,std::string>& envm){ +// mpxp_test_backtrace(); + Stream* stream=NULL; + int stream_dump_type=0; + input_state_t input_state = { 0, 0, 0 }; + const char *ao_subdevice; + std::string filename=""; //"MI2-Trailer.avi"; + int file_format=Demuxer::Type_UNKNOWN; + +// movie info: + int eof=0; + osd_args_t osd = { 100, 9 }; + int forced_subs_only=0; + seek_args_t seek_args = { 0, DEMUX_SEEK_CUR|DEMUX_SEEK_SECONDS }; + + // Yes, it really must be placed in stack or in very secret place + PointerProtector<MPXPSecureKeys> ptr_protector; + secure_keys=ptr_protector.protect(new(zeromem) MPXPSecureKeys(10)); + + init_signal_handling(); + + xmp_init(); + xmp_register_main(exit_sighandler); + + mpxp_print_init(mp_conf.verbose+MSGL_STATUS); + for(unsigned j=0;banner_text[j];j++) mpxp_info<<banner_text[j]<<std::endl; + + /* currently it's lowest point of MPXPSystem initialization */ + mpxp_context().engine().MPXPSys = new(zeromem) MPXPSystem(envm); + MPXPSystem& MPXPSys=*mpxp_context().engine().MPXPSys; + MPXPSys.init_keyboard_fifo(); + + MPXPSys.playtree = new(zeromem) PlayTree(); + + M_Config& m_config=*new(zeromem) M_Config(MPXPSys.playtree,MPXPSys.libinput()); + mpxp_context().mconfig = &m_config; + m_config.register_options(mplayerxp_opts); + // TODO : add something to let modules register their options + mp_register_options(m_config); + m_config.parse_cfgfiles(envm); + + if(m_config.parse_command_line(argv,envm)!=MPXP_Ok) + exit_player("Error parse command line"); // error parsing cmdline + + if(!mp_conf.xp) { + mpxp_err<<"Error: detected option: -core.xp=0"<<std::endl; + mpxp_err<<"Note! Single-thread mode is not longer supported by MPlayerXP"<<std::endl; + exit_player(MSGTR_Exit_quit); + } + if(mp_conf.test_av) { + int verb=1; + if(mpxp_test_antiviral_protection(&verb)==MPXP_Virus) + exit_player("Bad test of antiviral protection"); + } + + xp_num_cpu=get_number_cpu(); +#if defined( ARCH_X86 ) || defined(ARCH_X86_64) + get_mmx_optimizations(); +#endif + if(mp_conf.shuffle_playback) MPXPSys.playtree->set_flags(MPXPSys.playtree->get_flags()|PLAY_TREE_RND); + else MPXPSys.playtree->set_flags(MPXPSys.playtree->get_flags()&~PLAY_TREE_RND); + +// MPXPSys.playtree = play_tree_cleanup(MPXPSys.playtree); + if(MPXPSys.playtree) { + MPXPSys.playtree_iter = new PlayTree_Iter(MPXPSys.playtree,m_config); + if(MPXPSys.playtree_iter) { + if(MPXPSys.playtree_iter->step(0,0) != PLAY_TREE_ITER_ENTRY) { + delete MPXPSys.playtree_iter; + MPXPSys.playtree_iter = NULL; + } + else filename = MPXPSys.playtree_iter->get_playable_source_name(1); + } + } + + mpxp_context().engine().xp_core->num_a_buffs = vo_conf.xp_buffs; + + init_player(envm); + + if(filename.empty()){ + show_help(); + exit_player(MSGTR_Exit_quit); + } + + // Many users forget to include command line in bugreports... + if(mp_conf.verbose){ + std::map<std::string,std::string>::const_iterator it; + mpxp_info<<"Environment:"<<std::endl; + for(it=envm.begin();it!=envm.end();it++) + mpxp_info<<(*it).first<<" => "<<(*it).second<<std::endl; + size_t i,sz=argv.size(); + mpxp_info<<"CommandLine:"; + for(i=1;i<sz;i++) mpxp_info<<" '"<<argv[i]<<"'"; + mpxp_info<<std::endl; + } + + mpxp_context().video().output=new(zeromem) Video_Output; +//------ load global data first ------ + mpxp_init_osd(envm); +// ========== Init keyboard FIFO (connection to libvo) ============ + + MP_UNIT(NULL); + + +// ******************* Now, let's see the per-file stuff ******************** +play_next_file: + + ao_subdevice=MPXPSys.init_output_subsystems(); + if(!filename.empty()) mpxp_ok<<MSGTR_Playing<<" "<<filename<<std::endl; + + forced_subs_only=MPXPSys.init_vobsub(filename); + + MP_UNIT("mplayer"); + if(!input_state.after_dvdmenu && MPXPSys.demuxer()) { + delete MPXPSys.demuxer()->stream; + MPXPSys.demuxer()->stream=NULL; + MPXPSys.inited_flags&=~INITED_STREAM; + MPXPSys.uninit_demuxer(); + } + if(MPXPSys.demuxer()) { + MPXPSys.demuxer()->audio=NULL; + MPXPSys.demuxer()->video=NULL; + MPXPSys.demuxer()->sub=NULL; + MPXPSys.demuxer()->audio->sh=NULL; + MPXPSys.demuxer()->video->sh=NULL; + } +//============ Open & Sync STREAM --- fork cache2 ==================== + stream_dump_type=0; + if(mp_conf.stream_dump) + if((stream_dump_type=dump_parse(mp_conf.stream_dump))==0) { + mpxp_err<<"Wrong dump parameters! Unable to continue"<<std::endl; + exit_player(MSGTR_Fatal_error); + } + + if(stream_dump_type) mp_conf.s_cache_size=0; + MP_UNIT("open_stream"); + // CACHE2: initial prefill: 20% later: 5% (should be set by -cacheopts) + if(!input_state.after_dvdmenu) + stream=(mp_conf.s_cache_size && !stream_dump_type)? + new(zeromem) Cached_Stream(MPXPSys.libinput(),mp_conf.s_cache_size*1024,mp_conf.s_cache_size*1024/5,mp_conf.s_cache_size*1024/20): + new(zeromem) Stream; + if(stream->open(MPXPSys.libinput(),filename,&file_format)!=MPXP_Ok) { // error... + mpxp_err<<"Can't open: "<<filename<<std::endl; + eof = MPXPSys.libmpdemux_was_interrupted(PT_NEXT_ENTRY); + goto goto_next_file; + } + MPXPSys.inited_flags|=INITED_STREAM; + + if(stream->type() & Stream::Type_Text) { + eof=MPXPSys.handle_playlist(filename); + goto goto_next_file; + } + + MP_UNIT(NULL); + + // DUMP STREAMS: + if(stream_dump_type==1) dump_stream(stream); + +//============ Open MPXPSys.demuxer()S --- DETECT file type ======================= + if(mp_conf.playb... [truncated message content] |
From: <nic...@us...> - 2012-12-29 17:26:40
|
Revision: 626 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=626&view=rev Author: nickols_k Date: 2012-12-29 17:26:32 +0000 (Sat, 29 Dec 2012) Log Message: ----------- *** This is the last message (at least in this year!) *** Comments about illegal-patch: changeset[580]: gdb shows that copy g++ which i use for developemnt has been hacked by malefactor(s) for their dark deals. Furthermore, any copy of gcc, which i had, ignored: #ifdef NDEBUG directive exactly for mplayer* projects. That happens since my participation in mplayerhq development. changeset[611]: gdb shows that real segfault has been happened within of illegal patch, but malefactor(s) have masked its sources by legal sources of the project. Else impossibly to explain how instruction pointer have jumped from: /usr/lib/gcc/x86_64-unknown-linux-gnu/4.5.4/../../../../include/c++/4.5.4/bits/vector.tcc:159 to: cfgparser.cpp:160 Reading this log above: warning: Could not load shared library symbols for linux-vdso.so.1 it's strange that gdb attempts to read symbols from pure virtual object. May it exists in form of real object on HDD? $ldconfig -p | grep vdso shows empty result. But my doubts about vdso are explainted below. changeset[623]: It's clear that malefactor(s) substituted context of glibc. Else impossibly to explain how these logic errors never throw segfaults early. changeset[625]: It's clear that illegal-patch receives control before main() function. Else impossibly to explain why environment contains additional 0x21 (33) arguments (if i correctly understand the ?read-only? value of envp[j+1] which comes right after official NULL in envp[j]). Well, where exist the illegal-patch since it can't exist in air? Most probably, it exists on the HDD where i perform development of the project. In this case, the system contains hacked linux-kernel with other illegal-patch which hides from me some files and directories (including so far non-virtual linux-vdso.so.1). Moreover, the system contains hacked 'make' utility which hides from me viral subfolder with illegal-patch. My current environment: Linux kas-wifi.ap 3.6.6 #1 SMP PREEMPT Fri Nov 9 19:27:30 MSK 2012 x86_64 GNU/Linux g++ (GCC) 4.5.4 GNU ld (GNU Binutils) 2.23 ldd (GNU libc) 2.16 GNU gdb (GDB) 7.5 GNU Make 3.81 After all i would say that development of the project has been turned into war between malefactor(s) and me. I'm spending much more my efforts not for improvements but for rewritting some places of the project in way of simplification to make them unusable for illegal-patch. (Fresh example: struct config_save_t + m_config_t.config_stack + m_config_t.cs_level m_config_t.dynamics + m_config_t.dynasize m_config_t.sub_conf which were tear out in changeset[617-618] and contained unreal, at least for this project, code: if(sub_conf) o=std::string(sub_conf)+":"+opt; else o=opt; Could illegal-patch to use this pieces of code for own dark deals, considering that removal this stuff much improved the project? Noter: early changesets contains removal of other unused and specially badly coded places which did the project non-workable without illegal-patch.) Do i need to continue this project when exists whole world of commercially available media-players? Total price of development so-called free software disproportionally superior the price of any commercial product (if we will at least count the money which were spent for internet) not counting spent time which could be spent for commerce. For all who are interested with quality of this project: HAPPY NEW YEAR!!! Modified Paths: -------------- mplayerxp/libmpdemux/demux_mp3.cpp mplayerxp/mplayerxp.cpp Modified: mplayerxp/libmpdemux/demux_mp3.cpp =================================================================== --- mplayerxp/libmpdemux/demux_mp3.cpp 2012-12-29 12:10:43 UTC (rev 625) +++ mplayerxp/libmpdemux/demux_mp3.cpp 2012-12-29 17:26:32 UTC (rev 626) @@ -525,7 +525,7 @@ sh_audio->rate=mp3_samplerate; sh_audio->nch=mp3_channels; demuxer->movi_start-=HDR_SIZE; - if(!read_mp3v1_tags(demuxer,hdr,pos)) return 0; /* id3v1 may coexist with id3v2 */ + read_mp3v1_tags(demuxer,hdr,pos); /* id3v1 may coexist with id3v2 */ break; case RAW_MP3: sh_audio->wtag = 0x55; @@ -533,7 +533,7 @@ sh_audio->rate=mp3_samplerate; sh_audio->nch=mp3_channels; demuxer->movi_start-=HDR_SIZE; - if(!read_mp3v1_tags(demuxer,hdr,pos)) return 0; /* id3v1 may coexist with id3v2 */ + read_mp3v1_tags(demuxer,hdr,pos); /* id3v1 may coexist with id3v2 */ break; } Modified: mplayerxp/mplayerxp.cpp =================================================================== --- mplayerxp/mplayerxp.cpp 2012-12-29 12:10:43 UTC (rev 625) +++ mplayerxp/mplayerxp.cpp 2012-12-29 17:26:32 UTC (rev 626) @@ -150,7 +150,7 @@ int handle_input(seek_args_t* seek,osd_args_t* osd,input_state_t* state); unsigned inited_flags; - int vo_inited; + MPXP_Rc vo_inited; MPXP_Rc ao_inited; int osd_show_framedrop; int osd_function; @@ -324,6 +324,7 @@ MP_UNIT("uninit_vo"); delete mpxp_context().video().output; mpxp_context().video().output=NULL; + vo_inited=MPXP_False; } if(mask&INITED_ACODEC){ @@ -338,6 +339,7 @@ MP_UNIT("uninit_ao"); delete mpxp_context().audio().output; mpxp_context().audio().output=NULL; + ao_inited=MPXP_False; } if(mask&INITED_DEMUXER) uninit_demuxer(); @@ -818,9 +820,12 @@ unsigned i; // check video_out driver name: MP_UNIT("vo_init"); - vo_inited = (mpxp_context().video().output->init(mp_conf.video_driver?mp_conf.video_driver:"")==MPXP_Ok)?1:0; + if(vo_inited==MPXP_False) { + if(!mpxp_context().video().output) mpxp_context().video().output=new(zeromem) Video_Output; + vo_inited = mpxp_context().video().output->init(mp_conf.video_driver?mp_conf.video_driver:""); + } - if(!vo_inited){ + if(vo_inited==MPXP_False){ mpxp_fatal<<MSGTR_InvalidVOdriver<<": "<<(mp_conf.video_driver?mp_conf.video_driver:"?")<<std::endl; exit_player(MSGTR_Fatal_error); } @@ -860,8 +865,7 @@ std::string buf = filename.substr(0,filename.length()-4); mpxp_context().video().output->vobsub=vobsub_open(buf,mp_conf.spudec_ifo,0,&mpxp_context().video().output->spudec); } - if(mpxp_context().video().output->vobsub) - { + if(mpxp_context().video().output->vobsub) { mp_conf.sub_auto=0; // don't do autosub for textsubs if vobsub found inited_flags|=INITED_VOBSUB; } @@ -1574,7 +1578,6 @@ PointerProtector<MPXPSecureKeys> ptr_protector; secure_keys=ptr_protector.protect(new(zeromem) MPXPSecureKeys(10)); - mpxp_context().video().output=new(zeromem) Video_Output; init_signal_handling(); xmp_init(); @@ -1651,6 +1654,7 @@ mpxp_info<<std::endl; } + mpxp_context().video().output=new(zeromem) Video_Output; //------ load global data first ------ mpxp_init_osd(envm); // ========== Init keyboard FIFO (connection to libvo) ============ @@ -1923,6 +1927,7 @@ MP_UNIT("Update timers"); if(sh_audio) eof = mpxp_context().engine().xp_core->audio->eof; if(sh_video) eof|=dae_played_eof(mpxp_context().engine().xp_core->video); + if(eof) break; if(!sh_video) { if(mp_conf.benchmark && mp_conf.verbose) show_benchmark_status(); else MPXPSys.print_audio_status(); @@ -2038,19 +2043,16 @@ int flg; flg=INITED_ALL; if(input_state.after_dvdmenu) flg &=~(INITED_STREAM|INITED_DEMUXER); - MPXPSys.uninit_player(flg&(~INITED_INPUT)); /* TODO: |(~INITED_AO)|(~INITED_VO) */ - MPXPSys.vo_inited=0; - MPXPSys.ao_inited=MPXP_False; + MPXPSys.uninit_player(flg&(~(INITED_INPUT|INITED_VO|INITED_SPUDEC))); /* TODO: |(~INITED_AO)|(~INITED_VO) */ eof = 0; - mpxp_context().engine().xp_core->audio->eof=0; goto play_next_file; } if(stream_dump_type>1) dump_mux_close(MPXPSys.demuxer()); - exit_player(MSGTR_Exit_eof); mpxp_uninit_structs(); delete ptr_protector.unprotect(secure_keys); + exit_player(MSGTR_Exit_eof); return EXIT_SUCCESS; } } // namespace mpxp This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2012-12-29 12:10:50
|
Revision: 625 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=625&view=rev Author: nickols_k Date: 2012-12-29 12:10:43 +0000 (Sat, 29 Dec 2012) Log Message: ----------- segfault-- and attempt to defect environment! Note about illegal-patch: No comments: listing of gdb tells even more that i'm able to say. $gdb --args ./ffmpeg -ao alsa:hw:0 -vo x11 M/l.avi -vf menu=main GNU gdb (GDB) 7.5 Copyright (C) 2012 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-unknown-linux-gnu". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>... Reading symbols from /Data/-SF.NET-/MPXP/mplayerxp/mplayerxp/ffmpeg...done. (gdb) break mplayerxp.cpp:2079 Breakpoint 1 at 0x4585cc: file mplayerxp.cpp, line 2079. (gdb) run Starting program: /Data/-SF.NET-/MPXP/mplayerxp/mplayerxp/ffmpeg -ao alsa:hw:0 -vo x11 M/l.avi -vf menu=main warning: Could not load shared library symbols for linux-vdso.so.1. Do you need "set solib-search-path" or "set sysroot"? [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". Breakpoint 1, main (argc=<optimized out>, args=<optimized out>, envp= 0x7fffffffdae0) at mplayerxp.cpp:2079 2079 envp[j+1] = NULL; (gdb) print args[argc] value has been optimized out (gdb) print envp[j+1] $1 = 0x21 <Address 0x21 out of bounds> (gdb) n 2082 rc=mp_mprotect((any_t*)antiviral_hole1,sizeof(antiviral_hole1),MP_DENY_ALL); (gdb) print envp[j+1] $2 = 0x21 <Address 0x21 out of bounds> (gdb) print envp[j+2] $3 = 0x7ffff7ffb000 "\177ELF\002\001\001" (gdb) print envp[j+3] $4 = 0x10 <Address 0x10 out of bounds> (gdb) print envp[j+4] $5 = 0x178bfbff <Address 0x178bfbff out of bounds> (gdb) print envp[j+5] $6 = 0x6 <Address 0x6 out of bounds> (gdb) print envp[j+6] $7 = 0x1000 <Address 0x1000 out of bounds> (gdb) print envp[j+7] $8 = 0x11 <Address 0x11 out of bounds> (gdb) print envp[j+8] $9 = 0x64 <Address 0x64 out of bounds> (gdb) print envp[j+9] $10 = 0x3 <Address 0x3 out of bounds> (gdb) print envp[j+10] $11 = 0x400040 "\006" (gdb) print envp[j+11] $12 = 0x4 <Address 0x4 out of bounds> (gdb) print envp[j+12] $13 = 0x38 <Address 0x38 out of bounds> (gdb) print envp[j+13] $14 = 0x5 <Address 0x5 out of bounds> (gdb) print envp[j+14] $15 = 0x8 <Address 0x8 out of bounds> (gdb) print envp[j+15] $16 = 0x7 <Address 0x7 out of bounds> Modified Paths: -------------- mplayerxp/libvo2/x11_system.cpp mplayerxp/mplayerxp.cpp mplayerxp/osdep/mplib.cpp mplayerxp/osdep/mplib.h Modified: mplayerxp/libvo2/x11_system.cpp =================================================================== --- mplayerxp/libvo2/x11_system.cpp 2012-12-29 10:39:06 UTC (rev 624) +++ mplayerxp/libvo2/x11_system.cpp 2012-12-29 12:10:43 UTC (rev 625) @@ -1021,8 +1021,10 @@ ::shmctl(Shminfo[idx].shmid, IPC_RMID, 0); } void Xv_System::freeMyXImage(unsigned idx) { - ::XShmDetach( get_display(),&Shminfo[idx]); - ::shmdt( Shminfo[idx].shmaddr ); + if(Shminfo[idx].shmid) { + ::XShmDetach( get_display(),&Shminfo[idx]); + ::shmdt( Shminfo[idx].shmaddr ); + } } void Xv_System::put_image(XvImage*image,const vo_rect_t& r) const { Modified: mplayerxp/mplayerxp.cpp =================================================================== --- mplayerxp/mplayerxp.cpp 2012-12-29 10:39:06 UTC (rev 624) +++ mplayerxp/mplayerxp.cpp 2012-12-29 12:10:43 UTC (rev 625) @@ -2064,6 +2064,7 @@ str=args[i]; argv.push_back(str); } + args[argc] = (char*)make_false_pointer((any_t*)antiviral_hole1); std::map<std::string,std::string> envm; unsigned j=0; size_t pos; @@ -2075,6 +2076,7 @@ str=str.substr(0,pos); envm[str]=stmp; } + envp[j+1] = NULL; /* init antiviral protection */ int rc; rc=mp_mprotect((any_t*)antiviral_hole1,sizeof(antiviral_hole1),MP_DENY_ALL); Modified: mplayerxp/osdep/mplib.cpp =================================================================== --- mplayerxp/osdep/mplib.cpp 2012-12-29 10:39:06 UTC (rev 624) +++ mplayerxp/osdep/mplib.cpp 2012-12-29 12:10:43 UTC (rev 625) @@ -27,16 +27,28 @@ return buffer; } +any_t* make_false_pointer(any_t* tmplt) { + long lo_mask=(sizeof(any_t*)*8/2)-1; + long hi_mask=~lo_mask; + long false_pointer; + false_pointer=::rand()&lo_mask; + false_pointer|=(reinterpret_cast<long>(tmplt)&hi_mask); + return reinterpret_cast<any_t*>(false_pointer); +} + +any_t* __FASTCALL__ make_false_pointer_to(any_t* tmplt,unsigned size) { + long false_pointer=reinterpret_cast<long>(tmplt); + false_pointer+=::rand()%size; + return reinterpret_cast<any_t*>(false_pointer); +} + any_t* fill_false_pointers(any_t* buffer,size_t size) { unsigned i,psize=(size/sizeof(any_t*))*sizeof(any_t*); - long lo_mask=(sizeof(any_t*)*8/2)-1; - long hi_mask=~lo_mask; - long filler; + any_t* filler; for(i=0;i<psize/sizeof(long);i++) { - filler=::rand()&lo_mask; - filler|=(reinterpret_cast<long>(buffer)&hi_mask); - ((long *)buffer)[i]=::rand()%2?filler:0; + filler=make_false_pointer(buffer); + ((long *)buffer)[i]=::rand()%2?reinterpret_cast<long>(filler):0; } ::memset(&((char *)buffer)[psize],0,size-psize); return buffer; Modified: mplayerxp/osdep/mplib.h =================================================================== --- mplayerxp/osdep/mplib.h 2012-12-29 10:39:06 UTC (rev 624) +++ mplayerxp/osdep/mplib.h 2012-12-29 12:10:43 UTC (rev 625) @@ -74,6 +74,8 @@ print_backtrace(why,stack,ncalls); } any_t* __FASTCALL__ rnd_fill(any_t* buffer,size_t size); + any_t* __FASTCALL__ make_false_pointer(any_t* tmplt); + any_t* __FASTCALL__ make_false_pointer_to(any_t* tmplt,unsigned size); any_t* __FASTCALL__ fill_false_pointers(any_t* buffer,size_t size); any_t* get_caller_address(unsigned num_caller=0); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2012-12-29 10:39:14
|
Revision: 624 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=624&view=rev Author: nickols_k Date: 2012-12-29 10:39:06 +0000 (Sat, 29 Dec 2012) Log Message: ----------- remove dependencies from ::getenv() Note about illegal-patch: binary of project still contains getenv in list of imported names. Therefore project still has illegal patch with viral nature. Modified Paths: -------------- mplayerxp/libao3/ao_nas.cpp mplayerxp/libmpcodecs/vd_xanim.cpp mplayerxp/libmpdemux/demux_mpxp64.cpp mplayerxp/libmpstream2/cddb.cpp mplayerxp/libmpstream2/cookies.cpp mplayerxp/libmpstream2/url.cpp mplayerxp/libvo2/vo_fbdev.cpp mplayerxp/libvo2/vo_opengl.cpp mplayerxp/libvo2/vo_sdl.cpp mplayerxp/libvo2/vo_x11.cpp mplayerxp/libvo2/vo_xv.cpp mplayerxp/libvo2/x11_system.cpp mplayerxp/libvo2/x11_system.h mplayerxp/mplayerxp.cpp mplayerxp/mpxp_msg.cpp mplayerxp/nls/nls.h mplayerxp/nls/recode.cpp mplayerxp/osdep/get_path.cpp mplayerxp/osdep/getch2.cpp mplayerxp/osdep/getch2.h Modified: mplayerxp/libao3/ao_nas.cpp =================================================================== --- mplayerxp/libao3/ao_nas.cpp 2012-12-28 17:27:59 UTC (rev 623) +++ mplayerxp/libao3/ao_nas.cpp 2012-12-29 10:39:06 UTC (rev 624) @@ -435,7 +435,7 @@ unsigned char auformat = nas_aformat_to_auformat(&f); unsigned bytes_per_sample = _channels * AuSizeofFormat(auformat); unsigned buffer_size; - char *server; + std::string server; _format = f; _samplerate = r; @@ -462,15 +462,22 @@ return MPXP_False; } - if (!(server = ::getenv("AUDIOSERVER")) && - !(server = ::getenv("DISPLAY"))) { + const std::map<std::string,std::string>& envm=mpxp_get_environment(); + std::map<std::string,std::string>::const_iterator it; + it = envm.find("AUDIOSERVER"); + if(it!=envm.end()) server = (*it).second; + if(server.empty()) { + it = envm.find("DISPLAY"); + if(it!=envm.end()) server = (*it).second; + } + if (server.empty()) { mpxp_err<<"ao_nas: init(): AUDIOSERVER environment variable not set -> nosound"<<std::endl; return MPXP_False; } mpxp_v<<"ao_nas: init(): Using audioserver "<<server<<std::endl; - aud = AuOpenServer(server, 0, NULL, 0, NULL, NULL); + aud = AuOpenServer(server.c_str(), 0, NULL, 0, NULL, NULL); if (!aud) { mpxp_err<<"ao_nas: init(): Can't open nas audio server -> nosound"<<std::endl; return MPXP_False; Modified: mplayerxp/libmpcodecs/vd_xanim.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_xanim.cpp 2012-12-28 17:27:59 UTC (rev 623) +++ mplayerxp/libmpcodecs/vd_xanim.cpp 2012-12-29 10:39:06 UTC (rev 624) @@ -365,7 +365,7 @@ } } -const char *xacodec_def_path = "/usr/lib/xanim/mods"; +static std::string xacodec_def_path = "/usr/lib/xanim/mods"; static int xacodec_init_video(xa_private_t& priv, int out_format) { @@ -387,10 +387,12 @@ for (i=0; i < XA_CLOSE_FUNCS; i++) priv.xacodec_driver->close_func[i] = NULL; - if (getenv("XANIM_MOD_DIR")) - xacodec_def_path = ::getenv("XANIM_MOD_DIR"); + const std::map<std::string,std::string>& envm=mpxp_get_environment(); + std::map<std::string,std::string>::const_iterator it; + it = envm.find("XANIM_MOD_DIR"); + if(it!=envm.end()) xacodec_def_path = (*it).second; - snprintf(dll, 1024, "%s/%s", xacodec_def_path, sh_video->codec->dll_name); + snprintf(dll, 1024, "%s/%s", xacodec_def_path.c_str(), sh_video->codec->dll_name); if (xacodec_init(dll, priv.xacodec_driver) == 0) return 0; Modified: mplayerxp/libmpdemux/demux_mpxp64.cpp =================================================================== --- mplayerxp/libmpdemux/demux_mpxp64.cpp 2012-12-28 17:27:59 UTC (rev 623) +++ mplayerxp/libmpdemux/demux_mpxp64.cpp 2012-12-29 10:39:06 UTC (rev 624) @@ -410,7 +410,7 @@ { str=new char [len]; s->read(str,len); - sub_data.cp=nls_get_screen_cp(); + sub_data.cp=nls_get_screen_cp(mpxp_get_environment()); demuxer->info().add(infot,nls_recode2screen_cp(codepage,str,len)); delete str; } Modified: mplayerxp/libmpstream2/cddb.cpp =================================================================== --- mplayerxp/libmpstream2/cddb.cpp 2012-12-28 17:27:59 UTC (rev 623) +++ mplayerxp/libmpstream2/cddb.cpp 2012-12-29 10:39:06 UTC (rev 624) @@ -46,6 +46,7 @@ #include "cdd.h" #include "tcp.h" #include "version.h" +#include "osdep/get_path.h" #include "network.h" #include "stream_msg.h" @@ -467,7 +468,7 @@ static void __FASTCALL__ cddb_create_hello(cddb_data_t *cddb_data) { char host_name[51]; - const char *user_name; + std::string user_name; if( cddb_data->anonymous ) { // Default is anonymous /* Note from Eduardo P\xE9rez Ureta <ep...@it...> : @@ -481,7 +482,10 @@ if( gethostname(host_name, 50)<0 ) { strcpy(host_name, "localhost"); } - user_name = getenv("LOGNAME"); + const std::map<std::string,std::string>& envm=mpxp_get_environment(); + std::map<std::string,std::string>::const_iterator it; + it = envm.find("LOGNAME"); + if(it!=envm.end()) user_name = (*it).second; } cddb_data->cddb_hello=std::string("&hello=")+user_name+"+"+host_name+"+"+"MPlayerXP"+"+"+VERSION; } @@ -526,11 +530,7 @@ cddb_data.disc_id = cddb_discid(cddb_data.tracks); cddb_data.anonymous = 1; // Don't send user info by default - const std::map<std::string,std::string>& envm=mpxp_get_environment(); - std::map<std::string,std::string>::const_iterator it; - it = envm.find("HOME"); - home_dir = (*it).second; - if( !home_dir.empty() ) cddb_data.cache_dir=home_dir+cddb_cache_dir; + cddb_data.cache_dir=get_path(mpxp_get_environment(),cddb_cache_dir); // Check for a cached file if( cddb_read_cache(&cddb_data)<0 ) { // No Cache found Modified: mplayerxp/libmpstream2/cookies.cpp =================================================================== --- mplayerxp/libmpstream2/cookies.cpp 2012-12-28 17:27:59 UTC (rev 623) +++ mplayerxp/libmpstream2/cookies.cpp 2012-12-29 10:39:06 UTC (rev 624) @@ -95,55 +95,55 @@ } /* Loads a file into RAM */ -static char *load_file(const char *filename, off_t * length) +static char *load_file(const std::string& filename, off_t * length) { int fd; char *buffer; mpxp_v<<"Loading cookie file: "<<filename<<std::endl; - fd = open(filename, O_RDONLY); + fd = ::open(filename.c_str(), O_RDONLY); if (fd < 0) { mpxp_v<<"Could not open"<<std::endl; return NULL; } - *length = lseek(fd, 0, SEEK_END); + *length = ::lseek(fd, 0, SEEK_END); if (*length < 0) { mpxp_v<<"Could not find EOF"<<std::endl; - close(fd); + ::close(fd); return NULL; } if (unsigned(*length) > std::numeric_limits<size_t>::max() - 1) { mpxp_v<<"File too big, could not mp_malloc"<<std::endl; - close(fd); + ::close(fd); return NULL; } - lseek(fd, SEEK_SET, 0); + ::lseek(fd, SEEK_SET, 0); if (!(buffer = new char [*length + 1])) { mpxp_v<<"Could not mp_malloc"<<std::endl; - close(fd); + ::close(fd); return NULL; } - if (read(fd, buffer, *length) != *length) { + if (::read(fd, buffer, *length) != *length) { delete buffer; mpxp_v<<"Read is behaving funny"<<std::endl; - close(fd); + ::close(fd); return NULL; } - close(fd); + ::close(fd); buffer[*length] = 0; return buffer; } /* Loads a cookies.txt file into a linked list. */ -static struct cookie_list_type *load_cookies_from(const char *filename, +static struct cookie_list_type *load_cookies_from(const std::string& filename, struct cookie_list_type *list) { @@ -179,42 +179,33 @@ DIR *dir; struct dirent *ent; struct cookie_list_type *list = NULL; - char *buf; + std::string homedir,buf; - char *homedir; - if (net_conf.cookies_file) return load_cookies_from(net_conf.cookies_file, list); - homedir = getenv("HOME"); - if (!homedir) - return list; + const std::map<std::string,std::string>& envm=mpxp_get_environment(); + std::map<std::string,std::string>::const_iterator it; + it = envm.find("HOME"); + if(it==envm.end()) throw "No 'HOME' environment found"; + homedir = (*it).second; + buf=homedir+"/.mozilla/default"; + dir = ::opendir(buf.c_str()); - buf = new char [strlen(homedir) + sizeof("/.mozilla/default") + 1]; - sprintf(buf, "%s/.mozilla/default", homedir); - dir = opendir(buf); - delete buf; - if (dir) { - while ((ent = readdir(dir)) != NULL) { + while ((ent = ::readdir(dir)) != NULL) { if ((ent->d_name)[0] != '.') { - buf = new char [strlen(getenv("HOME")) + - sizeof("/.mozilla/default/") + - strlen(ent->d_name) + sizeof("cookies.txt") + 1]; - sprintf(buf, "%s/.mozilla/default/%s/cookies.txt", - getenv("HOME"), ent->d_name); - list = load_cookies_from(buf, list); - delete buf; + std::string buf2; + buf2=buf+"/"+std::string(ent->d_name)+"/cookies.txt"; + list = load_cookies_from(buf2, list); } } - closedir(dir); + ::closedir(dir); } - buf = new char [strlen(homedir) + sizeof("/.netscape/cookies.txt") + 1]; - sprintf(buf, "%s/.netscape/cookies.txt", homedir); + buf=homedir+"/.netscape/cookies.txt"; list = load_cookies_from(buf, list); - delete buf; return list; } Modified: mplayerxp/libmpstream2/url.cpp =================================================================== --- mplayerxp/libmpstream2/url.cpp 2012-12-28 17:27:59 UTC (rev 623) +++ mplayerxp/libmpstream2/url.cpp 2012-12-29 10:39:06 UTC (rev 624) @@ -170,10 +170,14 @@ } // Check if the http_proxy environment variable is set. if( protocol2lower()=="http") { - const char *proxy; - proxy = getenv("http_proxy"); - if( proxy!=NULL ) { + std::string proxy; + const std::map<std::string,std::string>& envm=mpxp_get_environment(); + std::map<std::string,std::string>::const_iterator it; + it = envm.find("http_proxy"); + if(it!=envm.end()) proxy = (*it).second; + if( !proxy.empty() ) { std::string new_url=proxy; + mpxp_v<<"Using "<<proxy<<" as http_proxy"<<std::endl; URL proxy_url(new_url); #ifdef HAVE_AF_INET6 if (net_conf.ipv4_only_proxy && (::gethostbyname(_host.c_str())==NULL)) { Modified: mplayerxp/libvo2/vo_fbdev.cpp =================================================================== --- mplayerxp/libvo2/vo_fbdev.cpp 2012-12-28 17:27:59 UTC (rev 623) +++ mplayerxp/libvo2/vo_fbdev.cpp 2012-12-29 10:39:06 UTC (rev 624) @@ -183,6 +183,7 @@ #endif int fb_preinit_done; MPXP_Rc fb_works; + std::string dev_name; }; std::string FBDev_VO_Interface::parse_sub_device(const std::string& sd) @@ -207,8 +208,14 @@ if (fb_preinit_done) return fb_works; - if (!priv_conf.dev_name && !(priv_conf.dev_name = getenv("FRAMEBUFFER"))) - priv_conf.dev_name = (char *)"/dev/fb0"; + dev_name=""; + const std::map<std::string,std::string>& envm=mpxp_get_environment(); + std::map<std::string,std::string>::const_iterator it; + it = envm.find("FRAMEBUFFER"); + if(it!=envm.end()) dev_name = (*it).second; + + if(dev_name.empty()) dev_name = "/dev/fb0"; + priv_conf.dev_name = const_cast<char*>(dev_name.c_str()); mpxp_dbg2<<FBDEV<< "using "<<priv_conf.dev_name<<std::endl; if ((dev_fd = ::open(priv_conf.dev_name, O_RDWR)) == -1) { Modified: mplayerxp/libvo2/vo_opengl.cpp =================================================================== --- mplayerxp/libvo2/vo_opengl.cpp 2012-12-28 17:27:59 UTC (rev 623) +++ mplayerxp/libvo2/vo_opengl.cpp 2012-12-29 10:39:06 UTC (rev 624) @@ -96,7 +96,7 @@ OpenGL_VO_Interface::OpenGL_VO_Interface(const std::string& arg) :VO_Interface(arg), aspect(new(zeromem) Aspect(mp_conf.monitor_pixel_aspect)), - glx(new(zeromem) GLX_System(vo_conf.mDisplayName,vo_conf.xinerama_screen)) + glx(new(zeromem) GLX_System(vo_conf.mDisplayName?vo_conf.mDisplayName:"",vo_conf.xinerama_screen)) { num_buffers=1; glx->saver_off(); Modified: mplayerxp/libvo2/vo_sdl.cpp =================================================================== --- mplayerxp/libvo2/vo_sdl.cpp 2012-12-28 17:27:59 UTC (rev 623) +++ mplayerxp/libvo2/vo_sdl.cpp 2012-12-29 10:39:06 UTC (rev 624) @@ -266,7 +266,7 @@ :VO_Interface(arg), aspect(new(zeromem) Aspect(mp_conf.monitor_pixel_aspect)) #ifdef HAVE_X11 - ,x11(new(zeromem) X11_System(vo_conf.mDisplayName,vo_conf.xinerama_screen)) + ,x11(new(zeromem) X11_System(vo_conf.mDisplayName?vo_conf.mDisplayName:"",vo_conf.xinerama_screen)) #endif { std::string vidix_name; Modified: mplayerxp/libvo2/vo_x11.cpp =================================================================== --- mplayerxp/libvo2/vo_x11.cpp 2012-12-28 17:27:59 UTC (rev 623) +++ mplayerxp/libvo2/vo_x11.cpp 2012-12-29 10:39:06 UTC (rev 624) @@ -130,7 +130,7 @@ X11_VO_Interface::X11_VO_Interface(const std::string& arg) :VO_Interface(arg), aspect(new(zeromem) Aspect(mp_conf.monitor_pixel_aspect)), - x11(new(zeromem) X11_System(vo_conf.mDisplayName,vo_conf.xinerama_screen)) + x11(new(zeromem) X11_System(vo_conf.mDisplayName?vo_conf.mDisplayName:"",vo_conf.xinerama_screen)) { std::string vidix_name; num_buffers=1; Modified: mplayerxp/libvo2/vo_xv.cpp =================================================================== --- mplayerxp/libvo2/vo_xv.cpp 2012-12-28 17:27:59 UTC (rev 623) +++ mplayerxp/libvo2/vo_xv.cpp 2012-12-29 10:39:06 UTC (rev 624) @@ -86,7 +86,7 @@ Xv_VO_Interface::Xv_VO_Interface(const std::string& arg) :VO_Interface(arg), aspect(new(zeromem) Aspect(mp_conf.monitor_pixel_aspect)), - xv(new(zeromem) Xv_System(vo_conf.mDisplayName,vo_conf.xinerama_screen)) + xv(new(zeromem) Xv_System(vo_conf.mDisplayName?vo_conf.mDisplayName:"",vo_conf.xinerama_screen)) { num_buffers=1; if(!arg.empty()) { Modified: mplayerxp/libvo2/x11_system.cpp =================================================================== --- mplayerxp/libvo2/x11_system.cpp 2012-12-28 17:27:59 UTC (rev 623) +++ mplayerxp/libvo2/x11_system.cpp 2012-12-29 10:39:06 UTC (rev 624) @@ -44,7 +44,7 @@ return 0; } -X11_System::X11_System(const char* DisplayName,int xinerama_screen) +X11_System::X11_System(const std::string& DisplayName,int xinerama_screen) :screenwidth(0), screenheight(0) { @@ -53,7 +53,7 @@ // char * DisplayName = ":0.0"; ::XImage * mXImage = NULL; ::XWindowAttributes attribs; - const char* dispName; + std::string dispName; MotifHints = None; @@ -62,14 +62,19 @@ #endif ::XSetErrorHandler(x11_errorhandler); - if (!DisplayName) - if (!(DisplayName=getenv("DISPLAY"))) - DisplayName=":0.0"; - dispName = ::XDisplayName(DisplayName); + dispName=DisplayName; + if (dispName.empty()) { + const std::map<std::string,std::string>& envm=mpxp_get_environment(); + std::map<std::string,std::string>::const_iterator it; + it = envm.find("DISPLAY"); + if(it!=envm.end()) dispName = (*it).second; + if(dispName.empty()) dispName =":0.0"; + } + dispName = ::XDisplayName(dispName.c_str()); mpxp_v<<"X11 opening display: "<<dispName<<std::endl; - if(!(mDisplay=::XOpenDisplay(dispName))) { + if(!(mDisplay=::XOpenDisplay(dispName.c_str()))) { mpxp_err<<"X11_System: couldn't open the X11 display: "<<dispName<<std::endl; exit_player("X11_System error"); } @@ -141,9 +146,10 @@ else if(mask==0xFFFF) _depth=16; } /* slightly improved local display detection AST */ - if ( strncmp(dispName, "unix:", 5) == 0) dispName += 4; - else if ( strncmp(dispName, "localhost:", 10) == 0) dispName += 9; - if (*dispName==':') mLocalDisplay=1; + char ch=dispName[0]; + if ( dispName.substr(0,5)=="unix:") ch=dispName[4]; + else if ( dispName.substr(0,10)=="localhost:") ch=dispName[9]; + if (ch==':') mLocalDisplay=1; else mLocalDisplay=0; XA_NET_WM_STATE=::XInternAtom(mDisplay,"_NET_WM_STATE",0 ); XA_NET_WM_STATE_FULLSCREEN=::XInternAtom(mDisplay,"_NET_WM_STATE_FULLSCREEN",0 ); @@ -153,7 +159,7 @@ X11_System::~X11_System() { ::XSetErrorHandler(NULL); /* and -wid is set */ - ::XDestroyWindow(mDisplay, window); + if(window) ::XDestroyWindow(mDisplay, window); ::XCloseDisplay(mDisplay); } @@ -950,7 +956,7 @@ #ifdef HAVE_XV #include "img_format.h" -Xv_System::Xv_System(const char* DisplayName,int xinerama_screen) +Xv_System::Xv_System(const std::string& DisplayName,int xinerama_screen) :X11_System(DisplayName,xinerama_screen) {} Xv_System::~Xv_System() {} @@ -1166,7 +1172,7 @@ #endif #ifdef HAVE_OPENGL -GLX_System::GLX_System(const char* DisplayName,int xinerama_screen) +GLX_System::GLX_System(const std::string& DisplayName,int xinerama_screen) :X11_System(DisplayName,xinerama_screen) { static int visual_attribs[] = { Modified: mplayerxp/libvo2/x11_system.h =================================================================== --- mplayerxp/libvo2/x11_system.h 2012-12-28 17:27:59 UTC (rev 623) +++ mplayerxp/libvo2/x11_system.h 2012-12-29 10:39:06 UTC (rev 624) @@ -1,6 +1,8 @@ #ifndef X11_COMMON_H #define X11_COMMON_H +#include <string> + #include <X11/Xlib.h> #include <X11/Xutil.h> #ifdef HAVE_SHM @@ -31,7 +33,7 @@ class X11_System { public: - X11_System(const char* DisplayName,int ximerama_screen); + X11_System(const std::string& DisplayName,int ximerama_screen); virtual ~X11_System(); unsigned screen_width() const; @@ -121,7 +123,7 @@ #include <sys/shm.h> class Xv_System : public X11_System { public: - Xv_System(const char* DisplayName,int ximerama_screen); + Xv_System(const std::string& DisplayName,int ximerama_screen); virtual ~Xv_System(); unsigned query_port(uint32_t fourcc); @@ -150,7 +152,7 @@ #include <GL/glut.h> class GLX_System : public X11_System { public: - GLX_System(const char* DisplayName,int ximerama_screen); + GLX_System(const std::string& DisplayName,int ximerama_screen); virtual ~GLX_System(); virtual void create_window(const XSizeHints& hint,XVisualInfo* visual,unsigned flags,unsigned depth,const std::string& title); Modified: mplayerxp/mplayerxp.cpp =================================================================== --- mplayerxp/mplayerxp.cpp 2012-12-28 17:27:59 UTC (rev 623) +++ mplayerxp/mplayerxp.cpp 2012-12-29 10:39:06 UTC (rev 624) @@ -907,7 +907,7 @@ /* Add NLS support here */ Stream* stream=static_cast<Stream*>(_demuxer->stream); char *lang; - if(!mp_conf.audio_lang) mp_conf.audio_lang=nls_get_screen_cp(); + if(!mp_conf.audio_lang) mp_conf.audio_lang=nls_get_screen_cp(envm); MP_UNIT("dvd lang->id"); if(mp_conf.audio_lang) { lang=new char [std::max(strlen(mp_conf.audio_lang)+1,size_t(4))]; Modified: mplayerxp/mpxp_msg.cpp =================================================================== --- mplayerxp/mpxp_msg.cpp 2012-12-28 17:27:59 UTC (rev 623) +++ mplayerxp/mpxp_msg.cpp 2012-12-29 10:39:06 UTC (rev 624) @@ -237,7 +237,7 @@ va_start(va, format); ssize=vsprintf(sbuf,format.c_str(), va); va_end(va); - if(strcmp(nls_get_screen_cp(),"UTF-8")!=0) { + if(strcmp(nls_get_screen_cp(mpxp_get_environment()),"UTF-8")!=0) { char *obuf; obuf=nls_recode2screen_cp("UTF-8",sbuf,ssize); rc=fputs(obuf,stderr); Modified: mplayerxp/nls/nls.h =================================================================== --- mplayerxp/nls/nls.h 2012-12-28 17:27:59 UTC (rev 623) +++ mplayerxp/nls/nls.h 2012-12-29 10:39:06 UTC (rev 624) @@ -1,28 +1,32 @@ #ifndef __NLS_NLS_H #define __NLS_NLS_H 1 +#include "mpxp_config.h" +#include <map> -/** Returns pointer to screen's codepage - * @return pointer into environment. -**/ -extern char *nls_get_screen_cp(void); +namespace mpxp { + /** Returns pointer to screen's codepage + * @return pointer into environment. + **/ + extern char *nls_get_screen_cp(const std::map<std::string,std::string>& envm); -/** Recodes from given codepage into screen's codepage - * @param src_cp decribes source codepage - * @param param points buffer to be converted - * @param len length of buffer to be converted - * @return allocated buffer with result or performs mp_strdup() function - * if convertion was failed. -**/ -extern char *nls_recode2screen_cp(const char *src_cp,const char *param,unsigned len); + /** Recodes from given codepage into screen's codepage + * @param src_cp decribes source codepage + * @param param points buffer to be converted + * @param len length of buffer to be converted + * @return allocated buffer with result or performs mp_strdup() function + * if convertion was failed. + **/ + extern char *nls_recode2screen_cp(const char *src_cp,const char *param,unsigned len); -/** Recodes to given codepage from screen's codepage - * @param to_cp decribes given codepage - * @param param points buffer to be converted - * @param size points buffer where size of resulting buffer will be stored - * @return allocated buffer with result or performs mp_strdup() function - * if convertion was failed. -**/ -extern char *nls_recode_from_screen_cp(const char *to_cp,const char *param,size_t *size); + /** Recodes to given codepage from screen's codepage + * @param to_cp decribes given codepage + * @param param points buffer to be converted + * @param size points buffer where size of resulting buffer will be stored + * @return allocated buffer with result or performs mp_strdup() function + * if convertion was failed. + **/ + extern char *nls_recode_from_screen_cp(const char *to_cp,const char *param,size_t *size); -extern unsigned utf8_get_char(const char **str); + extern unsigned utf8_get_char(const char **str); +} // namespace mpxp #endif Modified: mplayerxp/nls/recode.cpp =================================================================== --- mplayerxp/nls/recode.cpp 2012-12-28 17:27:59 UTC (rev 623) +++ mplayerxp/nls/recode.cpp 2012-12-29 10:39:06 UTC (rev 624) @@ -16,6 +16,7 @@ #include "nls.h" #include "nls_msg.h" +namespace mpxp { /* *We have to proceed with the POSIX methods of looking to `LANG'. On some systems this can be done by the `setlocale' function itself. @@ -28,20 +29,21 @@ LINGUAS=ru Output of locale program contains `LANG' variable only! */ -static const char * langs[] = { "LANG", "LANGUAGE", "LINGUAS" }; +static const char* langs[] = { "LANG", "LANGUAGE", "LINGUAS" }; -char *nls_get_screen_cp(void) +char *nls_get_screen_cp(const std::map<std::string,std::string>& envm) { unsigned i; - char *nls; + std::string nls; static char to_cp[256]; strcpy(to_cp,"UTF-8"); - for(i=0;i<sizeof(langs)/sizeof(char *);i++) - { - if((nls=getenv(langs[i]))!=NULL) - { - nls=strchr(nls,'.'); - if(nls) strcpy(to_cp,nls+1); + for(i=0;i<sizeof(langs)/sizeof(char *);i++) { + std::map<std::string,std::string>::const_iterator it; + it = envm.find(langs[i]); + if(it!=envm.end()) { + nls = (*it).second; + nls=nls.substr(nls.find('.')+1); + if(!nls.empty()) strcpy(to_cp,nls.c_str()); break; } } @@ -58,7 +60,7 @@ const char *ibuff,*ib; char *ob,*to_cp; size_t inb,outb; - to_cp=nls_get_screen_cp(); + to_cp=nls_get_screen_cp(mpxp_get_environment()); errno=0; ic=iconv_open(to_cp,src_cp); if(errno) @@ -133,7 +135,7 @@ const char *ibuff,*ib; char *ob,*src_cp; size_t inb; - src_cp=nls_get_screen_cp(); + src_cp=nls_get_screen_cp(mpxp_get_environment()); errno=0; ic=iconv_open(to_cp,src_cp); if(errno) @@ -175,3 +177,4 @@ #endif return obuff; } +} // namespace mpxp Modified: mplayerxp/osdep/get_path.cpp =================================================================== --- mplayerxp/osdep/get_path.cpp 2012-12-28 17:27:59 UTC (rev 623) +++ mplayerxp/osdep/get_path.cpp 2012-12-29 10:39:06 UTC (rev 624) @@ -6,9 +6,10 @@ namespace mpxp { std::string get_path(const std::map<std::string,std::string>& envm,const std::string& filename) { + std::string homedir; std::map<std::string,std::string>::const_iterator it; it = envm.find("HOME"); - const std::string homedir = (*it).second; + if(it!=envm.end()) homedir = (*it).second; std::string rs; std::string config_dir = std::string("/.")+PROGNAME; Modified: mplayerxp/osdep/getch2.cpp =================================================================== --- mplayerxp/osdep/getch2.cpp 2012-12-28 17:27:59 UTC (rev 623) +++ mplayerxp/osdep/getch2.cpp 2012-12-29 10:39:06 UTC (rev 624) @@ -69,51 +69,57 @@ static char *term_p=term_buffer2; static void termcap_add(char *id,int code){ -char *p=tgetstr(id,&term_p); - if(!p) return; - if(getch2_key_db>=MAX_KEYS) return; - getch2_keys[getch2_key_db].len=strlen(p); - strncpy(getch2_keys[getch2_key_db].chars,p,8); - getch2_keys[getch2_key_db].code=code; - ++getch2_key_db; + char *p=::tgetstr(id,&term_p); + if(!p) return; + if(getch2_key_db>=MAX_KEYS) return; + getch2_keys[getch2_key_db].len=strlen(p); + strncpy(getch2_keys[getch2_key_db].chars,p,8); + getch2_keys[getch2_key_db].code=code; + ++getch2_key_db; } static int success=0; -int load_termcap(const char *termtype){ - if(!termtype) termtype=getenv("TERM"); - success=tgetent(term_buffer, termtype); - if(success<0){ mpxp_err<<"Could not access the 'termcap' data base"<<std::endl; return 0; } - if(success==0){ mpxp_err<<"Terminal type `"<<termtype<<"' is not defined"<<std::endl; return 0;} +int load_termcap(const std::string& _termtype,const std::map<std::string,std::string>& envm){ + std::string termtype=_termtype; + if(termtype.empty()) { + std::map<std::string,std::string>::const_iterator it; + it = envm.find("TERM"); + if(it!=envm.end()) termtype = (*it).second; + } - screen_width=tgetnum("co"); - screen_height=tgetnum("li"); - if(screen_width<1 || screen_width>255) screen_width=80; - if(screen_height<1 || screen_height>255) screen_height=24; + success=::tgetent(term_buffer, termtype); + if(success<0){ mpxp_err<<"Could not access the 'termcap' data base"<<std::endl; return 0; } + if(success==0){ mpxp_err<<"Terminal type `"<<termtype<<"' is not defined"<<std::endl; return 0;} - termcap_add("kP",KEY_PGUP); - termcap_add("kN",KEY_PGDWN); - termcap_add("kh",KEY_HOME); - termcap_add("kH",KEY_END); - termcap_add("kI",KEY_INS); - termcap_add("kD",KEY_DEL); - termcap_add("kb",KEY_BS); - termcap_add("kl",KEY_LEFT); - termcap_add("kd",KEY_DOWN); - termcap_add("ku",KEY_UP); - termcap_add("kr",KEY_RIGHT); - termcap_add("k0",KEY_F+0); - termcap_add("k1",KEY_F+1); - termcap_add("k2",KEY_F+2); - termcap_add("k3",KEY_F+3); - termcap_add("k4",KEY_F+4); - termcap_add("k5",KEY_F+5); - termcap_add("k6",KEY_F+6); - termcap_add("k7",KEY_F+7); - termcap_add("k8",KEY_F+8); - termcap_add("k9",KEY_F+9); - termcap_add("k;",KEY_F+10); - return getch2_key_db; + screen_width=::tgetnum("co"); + screen_height=::tgetnum("li"); + if(screen_width<1 || screen_width>255) screen_width=80; + if(screen_height<1 || screen_height>255) screen_height=24; + + termcap_add("kP",KEY_PGUP); + termcap_add("kN",KEY_PGDWN); + termcap_add("kh",KEY_HOME); + termcap_add("kH",KEY_END); + termcap_add("kI",KEY_INS); + termcap_add("kD",KEY_DEL); + termcap_add("kb",KEY_BS); + termcap_add("kl",KEY_LEFT); + termcap_add("kd",KEY_DOWN); + termcap_add("ku",KEY_UP); + termcap_add("kr",KEY_RIGHT); + termcap_add("k0",KEY_F+0); + termcap_add("k1",KEY_F+1); + termcap_add("k2",KEY_F+2); + termcap_add("k3",KEY_F+3); + termcap_add("k4",KEY_F+4); + termcap_add("k5",KEY_F+5); + termcap_add("k6",KEY_F+6); + termcap_add("k7",KEY_F+7); + termcap_add("k8",KEY_F+8); + termcap_add("k9",KEY_F+9); + termcap_add("k;",KEY_F+10); + return getch2_key_db; } #endif Modified: mplayerxp/osdep/getch2.h =================================================================== --- mplayerxp/osdep/getch2.h 2012-12-28 17:27:59 UTC (rev 623) +++ mplayerxp/osdep/getch2.h 2012-12-29 10:39:06 UTC (rev 624) @@ -4,7 +4,7 @@ /* GyS-TermIO v2.0 (for GySmail v3) (C) 1999 A'rpi/ESP-team */ /* a very small replacement of ncurses library */ /* Load key definitions from the TERMCAP database. 'termtype' can be NULL */ - int load_termcap(const char *termtype); + int load_termcap(const std::string& termtype,const std::map<std::string,std::string>& envm); /* Enable and disable STDIN line-buffering */ void getch2_enable(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2012-12-28 17:28:06
|
Revision: 623 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=623&view=rev Author: nickols_k Date: 2012-12-28 17:27:59 +0000 (Fri, 28 Dec 2012) Log Message: ----------- fixed SIGPIPE during tcp.write Modified Paths: -------------- mplayerxp/libmpstream2/tcp.cpp Modified: mplayerxp/libmpstream2/tcp.cpp =================================================================== --- mplayerxp/libmpstream2/tcp.cpp 2012-12-28 17:03:09 UTC (rev 622) +++ mplayerxp/libmpstream2/tcp.cpp 2012-12-28 17:27:59 UTC (rev 623) @@ -99,6 +99,8 @@ case Tcp::IP6: our_s_addr = (any_t*) &server_address.six.sin6_addr; break; default: mpxp_err<<"[tcp"<<af2String(af)<<"] UnknownAF: "<<af<<std::endl; + ::closesocket(_fd); + _fd=-1; _error=Tcp::Err_Fatal; return; } @@ -125,6 +127,8 @@ #endif if( hp==NULL ) { mpxp_v<<"[tcp"<<af2String(af)<<"] Can't resolv: "<<_url.host()<<std::endl; + ::closesocket(_fd); + _fd=-1; _error=Tcp::Err_Fatal; return; } @@ -151,6 +155,8 @@ break; default: mpxp_err<<"[tcp"<<af2String(af)<<"] UnknownAF: "<<af<<std::endl; + ::closesocket(_fd); + _fd=-1; _error = Tcp::Err_Fatal; return; } @@ -216,6 +222,8 @@ ret = ::getsockopt(_fd,SOL_SOCKET,SO_ERROR,&_error,&err_len); if(ret < 0) { mpxp_err<<"[tcp"<<af2String(af)<<"] Get socket option failed: "<<strerror(errno)<<std::endl; + ::closesocket(_fd); + _fd=-1; _error=Tcp::Err_Fatal; return; } @@ -267,7 +275,7 @@ int Tcp::read(uint8_t* buf,unsigned len,int flags) { return ::recv(_fd,buf,len,flags); } int Tcp::write(const uint8_t* buf,unsigned len,int flags) const { return ::send(_fd,buf,len,flags); } -int Tcp::established() const { return _fd > 0; } +int Tcp::established() const { return _fd > 0 && _error==Tcp::Err_None; } Tcp::tcp_error_e Tcp::error() const { return _error; } libinput_t& Tcp::get_libinput() const { return libinput; } const URL& Tcp::url() const { return _url; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2012-12-28 17:03:20
|
Revision: 622 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=622&view=rev Author: nickols_k Date: 2012-12-28 17:03:09 +0000 (Fri, 28 Dec 2012) Log Message: ----------- use new version of get_path() + cleanups + fixes Modified Paths: -------------- mplayerxp/dump.cpp mplayerxp/input2/input.cpp mplayerxp/input2/input.h mplayerxp/libao3/ao_alsa.cpp mplayerxp/libao3/ao_arts.cpp mplayerxp/libao3/ao_esd.cpp mplayerxp/libao3/ao_jack.cpp mplayerxp/libao3/ao_nas.cpp mplayerxp/libao3/ao_null.cpp mplayerxp/libao3/ao_openal.cpp mplayerxp/libao3/ao_sdl.cpp mplayerxp/libao3/ao_wav.cpp mplayerxp/libao3/audio_out.cpp mplayerxp/libmpconf/cfgparser.cpp mplayerxp/libmpdemux/asf.h mplayerxp/libmpdemux/demux_ac3.cpp mplayerxp/libmpdemux/demux_avi.cpp mplayerxp/libmpdemux/demux_dca.cpp mplayerxp/libmpdemux/demux_dv.cpp mplayerxp/libmpdemux/demux_film.cpp mplayerxp/libmpdemux/demux_flac.cpp mplayerxp/libmpdemux/demux_lavf.cpp mplayerxp/libmpdemux/demux_mkv.cpp mplayerxp/libmpdemux/demux_mov.cpp mplayerxp/libmpdemux/demux_mp3.cpp mplayerxp/libmpdemux/demux_mpg.cpp mplayerxp/libmpdemux/demux_mpxp64.cpp mplayerxp/libmpdemux/demux_musepack.cpp mplayerxp/libmpdemux/demux_nuv.cpp mplayerxp/libmpdemux/demux_ogg.cpp mplayerxp/libmpdemux/demux_pva.cpp mplayerxp/libmpdemux/demux_real.cpp mplayerxp/libmpdemux/demux_realaud.cpp mplayerxp/libmpdemux/demux_roq.cpp mplayerxp/libmpdemux/demux_snd_au.cpp mplayerxp/libmpdemux/demux_ts.cpp mplayerxp/libmpdemux/demux_ty.cpp mplayerxp/libmpdemux/demux_viv.cpp mplayerxp/libmpdemux/demux_voc.cpp mplayerxp/libmpdemux/demux_vqf.cpp mplayerxp/libmpdemux/demux_wav.cpp mplayerxp/libmpdemux/mux_mpxp64.cpp mplayerxp/libmpdemux/muxer.h mplayerxp/libmpdemux/stheader.cpp mplayerxp/libmpdemux/sub_cc.cpp mplayerxp/libmpdemux/sub_ty.cpp mplayerxp/libmpdemux/yuv4mpeg_intern.h mplayerxp/libmpstream2/cdd.h mplayerxp/libmpstream2/cddb.cpp mplayerxp/libmpstream2/cookies.cpp mplayerxp/libmpstream2/librtsp/rtsp.h mplayerxp/libmpstream2/librtsp/rtsp_rtp.h mplayerxp/libmpstream2/mrl.cpp mplayerxp/libmpstream2/network.h mplayerxp/libmpstream2/network_asf_mmst.cpp mplayerxp/libmpstream2/pnm.cpp mplayerxp/libmpstream2/realrtsp/real.h mplayerxp/libmpstream2/rtp_cache.cpp mplayerxp/libmpstream2/rtp_cache.h mplayerxp/libmpstream2/s_dvdnav.cpp mplayerxp/libmpstream2/s_dvdread.cpp mplayerxp/libmpstream2/s_ftp.cpp mplayerxp/libmpsub/subreader.cpp mplayerxp/libplaytree2/playtree.cpp mplayerxp/libplaytree2/playtree.h mplayerxp/mplayerxp.cpp mplayerxp/mplayerxp.h mplayerxp/osdep/cpudetect.cpp mplayerxp/osdep/get_path.cpp mplayerxp/osdep/get_path.h mplayerxp/postproc/af_export.cpp mplayerxp/postproc/libmenu/menu_filesel.cpp Modified: mplayerxp/dump.cpp =================================================================== --- mplayerxp/dump.cpp 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/dump.cpp 2012-12-28 17:03:09 UTC (rev 622) @@ -71,9 +71,11 @@ exit_player(MSGTR_Exit_eof); } -#define MUX_HAVE_AUDIO 0x01 -#define MUX_HAVE_VIDEO 0x02 -#define MUX_HAVE_SUBS 0x04 +enum { + MUX_HAVE_AUDIO=0x01, + MUX_HAVE_VIDEO=0x02, + MUX_HAVE_SUBS=0x04 +}; struct dump_priv_t : public Opaque { public: dump_priv_t(libinput_t& l):libinput(l) {} Modified: mplayerxp/input2/input.cpp =================================================================== --- mplayerxp/input2/input.cpp 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/input2/input.cpp 2012-12-28 17:03:09 UTC (rev 622) @@ -39,22 +39,19 @@ namespace mpxp { -#ifndef MP_MAX_KEY_FD -#define MP_MAX_KEY_FD 10 -#endif +static const int MP_MAX_KEY_FD=10; +static const int MP_MAX_CMD_FD=10; -#ifndef MP_MAX_CMD_FD -#define MP_MAX_CMD_FD 10 -#endif +enum { + MP_FD_EOF=(1<<0), + MP_FD_DROP=(1<<1), + MP_FD_DEAD=(1<<2), + MP_FD_GOT_CMD=(1<<3), + MP_FD_NO_SELECT=(1<<4) +}; -#define MP_FD_EOF (1<<0) -#define MP_FD_DROP (1<<1) -#define MP_FD_DEAD (1<<2) -#define MP_FD_GOT_CMD (1<<3) -#define MP_FD_NO_SELECT (1<<4) +static const int CMD_QUEUE_SIZE=100; -#define CMD_QUEUE_SIZE 100 - typedef int (*mp_key_func_t)(any_t* ctx); // These functions should return the key code or one of the error code typedef int (*mp_cmd_func_t)(any_t* ctx,char* dest,int size); // These functions should act like read but they must use our error code (if needed ;-) typedef void (*mp_close_func_t)(any_t* ctx); // These are used to close the driver @@ -90,7 +87,7 @@ }; struct libinput_t : public Opaque { - libinput_t() {} + libinput_t(const std::map<std::string,std::string>& _envm):envm(_envm) {} virtual ~libinput_t() {} Opaque unusable; @@ -115,6 +112,7 @@ int in_file_fd; int tim; //for getch2 char key_str[12]; + const std::map<std::string,std::string>& envm; }; struct input_conf_t { @@ -656,7 +654,7 @@ return code; } -#define MP_CMD_MAX_SIZE 256 +static const int MP_CMD_MAX_SIZE=256; static int mp_input_read_cmd(mp_input_fd_t* mp_fd, char** ret) { char* end; (*ret) = NULL; @@ -1124,8 +1122,8 @@ delete binds; } -#define BS_MAX 256 -#define SPACE_CHAR " \n\r\t" +static const int BS_MAX=256; +static const char* SPACE_CHAR=" \n\r\t"; static int mp_input_parse_config(libinput_t& priv,const std::string& file) { int fd; @@ -1268,7 +1266,7 @@ static void mp_input_init(libinput_t& priv) { std::string file; - file = config_file[0] != '/' ? get_path(config_file) : config_file; + file = config_file[0] != '/' ? get_path(priv.envm,config_file) : config_file; if(file.empty()) return; if(! mp_input_parse_config(priv,file)) { @@ -1334,8 +1332,8 @@ if(priv.in_file_fd==0) getch2_disable(); } -libinput_t& mp_input_open() { - libinput_t& priv=*new(zeromem) libinput_t; +libinput_t& mp_input_open(const std::map<std::string,std::string>& envm) { + libinput_t& priv=*new(zeromem) libinput_t(envm); priv.ar_state=-1; priv.in_file_fd=-1; mp_input_init(priv); Modified: mplayerxp/input2/input.h =================================================================== --- mplayerxp/input2/input.h 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/input2/input.h 2012-12-28 17:03:09 UTC (rev 622) @@ -4,6 +4,8 @@ #include "osdep/mplib.h" using namespace mpxp; +#include <map> + #include "xmpcore/xmp_enums.h" namespace mpxp { @@ -155,7 +157,7 @@ extern void mp_cmd_free(mp_cmd_t* cmd); // When you create a new driver you should add it in this 2 functions. - extern libinput_t& mp_input_open(); + extern libinput_t& mp_input_open(const std::map<std::string,std::string>& envm); extern void mp_input_close(libinput_t& handle); extern void mp_input_print_keys(libinput_t& handle); Modified: mplayerxp/libao3/ao_alsa.cpp =================================================================== --- mplayerxp/libao3/ao_alsa.cpp 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/libao3/ao_alsa.cpp 2012-12-28 17:03:09 UTC (rev 622) @@ -107,7 +107,7 @@ snd_pcm_sw_params_free(swparams); } -#define ALSA_DEVICE_SIZE 48 +static const int ALSA_DEVICE_SIZE=48; #define BUFFERTIME // else SET_CHUNK_SIZE #undef USE_POLL Modified: mplayerxp/libao3/ao_arts.cpp =================================================================== --- mplayerxp/libao3/ao_arts.cpp 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/libao3/ao_arts.cpp 2012-12-28 17:03:09 UTC (rev 622) @@ -34,8 +34,8 @@ namespace mpxp { /* Feel mp_free to experiment with the following values: */ -#define ARTS_PACKETS 10 /* Number of audio packets */ -#define ARTS_PACKET_SIZE_LOG2 11 /* Log2 of audio packet size */ +static const int ARTS_PACKETS=10; /* Number of audio packets */ +static const int ARTS_PACKET_SIZE_LOG2=11; /* Log2 of audio packet size */ class Arts_AO_Interface : public AO_Interface { public: Modified: mplayerxp/libao3/ao_esd.cpp =================================================================== --- mplayerxp/libao3/ao_esd.cpp 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/libao3/ao_esd.cpp 2012-12-28 17:03:09 UTC (rev 622) @@ -58,7 +58,7 @@ namespace mpxp { -#define ESD_RESAMPLES 0 +static const int ESD_RESAMPLES=0; #define ESD_DEBUG 0 #if ESD_DEBUG @@ -67,8 +67,8 @@ #define dprintf(...) /**/ #endif -#define ESD_CLIENT_NAME "MPlayerXP" -#define ESD_MAX_DELAY (1.0f) /* max amount of data buffered in esd (#sec) */ +static const char* ESD_CLIENT_NAME="MPlayerXP"; +static const float ESD_MAX_DELAY=1.0f; /* max amount of data buffered in esd (#sec) */ class Esd_AO_Interface : public AO_Interface { public: Modified: mplayerxp/libao3/ao_jack.cpp =================================================================== --- mplayerxp/libao3/ao_jack.cpp 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/libao3/ao_jack.cpp 2012-12-28 17:03:09 UTC (rev 622) @@ -42,7 +42,7 @@ namespace mpxp { //! maximum number of channels supported, avoids lots of mallocs -#define MAX_CHANS 6 +static const int MAX_CHANS=6; class Jack_AO_Interface : public AO_Interface { public: Jack_AO_Interface(const std::string& subdevice); @@ -90,10 +90,10 @@ }; //! size of one chunk, if this is too small MPlayer will start to "stutter" //! after a short time of playback -#define CHUNK_SIZE (16 * 1024) +static const int CHUNK_SIZE=(16 * 1024); //! number of "virtual" chunks the priv->buffer consists of -#define NUM_CHUNKS 8 -#define BUFFSIZE (NUM_CHUNKS * CHUNK_SIZE) +static const int NUM_CHUNKS=8; +static const int BUFFSIZE=(NUM_CHUNKS * CHUNK_SIZE); Jack_AO_Interface::Jack_AO_Interface(const std::string& _subdevice) :AO_Interface(_subdevice) {} Jack_AO_Interface::~Jack_AO_Interface() { Modified: mplayerxp/libao3/ao_nas.cpp =================================================================== --- mplayerxp/libao3/ao_nas.cpp 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/libao3/ao_nas.cpp 2012-12-28 17:03:09 UTC (rev 622) @@ -64,7 +64,7 @@ namespace mpxp { /* NAS_FRAG_SIZE must be a power-of-two value */ -#define NAS_FRAG_SIZE 4096 +static const int NAS_FRAG_SIZE=4096; static const char * const nas_event_types[] = { "Undefined", Modified: mplayerxp/libao3/ao_null.cpp =================================================================== --- mplayerxp/libao3/ao_null.cpp 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/libao3/ao_null.cpp 2012-12-28 17:03:09 UTC (rev 622) @@ -19,11 +19,11 @@ #include "ao_msg.h" namespace mpxp { -#define WAV_ID_RIFF FOURCC_TAG(0x46,0x46,0x49,0x52) /* "RIFF" */ -#define WAV_ID_WAVE FOURCC_TAG(0x45,0x56,0x41,0x57) /* "WAVE" */ -#define WAV_ID_FMT FOURCC_TAG(0x20,0x74,0x6d,0x66) /* "fmt " */ -#define WAV_ID_DATA FOURCC_TAG(0x61,0x74,0x61,0x64) /* "data" */ -#define WAV_ID_PCM TWOCC_TAG (0x00,0x01) +static const uint32_t WAV_ID_RIFF=FOURCC_TAG(0x46,0x46,0x49,0x52); /* "RIFF" */ +static const uint32_t WAV_ID_WAVE=FOURCC_TAG(0x45,0x56,0x41,0x57); /* "WAVE" */ +static const uint32_t WAV_ID_FMT =FOURCC_TAG(0x20,0x74,0x6d,0x66); /* "fmt " */ +static const uint32_t WAV_ID_DATA=FOURCC_TAG(0x61,0x74,0x61,0x64); /* "data" */ +static const uint32_t WAV_ID_PCM =TWOCC_TAG (0x00,0x01); struct WaveHeader { uint32_t riff; uint32_t file_length; Modified: mplayerxp/libao3/ao_openal.cpp =================================================================== --- mplayerxp/libao3/ao_openal.cpp 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/libao3/ao_openal.cpp 2012-12-28 17:03:09 UTC (rev 622) @@ -37,9 +37,9 @@ #include "ao_msg.h" namespace mpxp { -#define MAX_CHANS 8 -#define NUM_BUF 128 -#define CHUNK_SIZE 512 +static const int MAX_CHANS=8; +static const int NUM_BUF=128; +static const int CHUNK_SIZE=512; class OpenAL_AO_Interface : public AO_Interface { public: OpenAL_AO_Interface(const std::string& subdevice); Modified: mplayerxp/libao3/ao_sdl.cpp =================================================================== --- mplayerxp/libao3/ao_sdl.cpp 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/libao3/ao_sdl.cpp 2012-12-28 17:03:09 UTC (rev 622) @@ -28,12 +28,12 @@ namespace mpxp { // Samplesize used by the SDLlib AudioSpec struct -#define SAMPLESIZE 1024 +static const int SAMPLESIZE=1024; // General purpose Ring-buffering routines -#define BUFFSIZE 4096 -#define NUM_BUFS 16 +static const int BUFFSIZE=4096; +static const int NUM_BUFS=16; class SDL_AO_Interface : public AO_Interface { public: SDL_AO_Interface(const std::string& subdevice); Modified: mplayerxp/libao3/ao_wav.cpp =================================================================== --- mplayerxp/libao3/ao_wav.cpp 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/libao3/ao_wav.cpp 2012-12-28 17:03:09 UTC (rev 622) @@ -40,12 +40,12 @@ #endif namespace mpxp { -#define WAV_ID_RIFF 0x46464952 /* "RIFF" */ -#define WAV_ID_WAVE 0x45564157 /* "WAVE" */ -#define WAV_ID_FMT 0x20746d66 /* "fmt " */ -#define WAV_ID_DATA 0x61746164 /* "data" */ -#define WAV_ID_PCM 0x0001 -#define WAV_ID_FLOAT_PCM 0x0003 +static const uint32_t WAV_ID_RIFF=0x46464952; /* "RIFF" */ +static const uint32_t WAV_ID_WAVE=0x45564157; /* "WAVE" */ +static const uint32_t WAV_ID_FMT =0x20746d66; /* "fmt " */ +static const uint32_t WAV_ID_DATA=0x61746164; /* "data" */ +static const uint32_t WAV_ID_PCM =0x0001; +static const uint32_t WAV_ID_FLOAT_PCM=0x0003; struct WaveHeader { Modified: mplayerxp/libao3/audio_out.cpp =================================================================== --- mplayerxp/libao3/audio_out.cpp 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/libao3/audio_out.cpp 2012-12-28 17:03:09 UTC (rev 622) @@ -327,7 +327,7 @@ ctrl(AOCONTROL_SET_VOLUME,(long)&vol); } -#define MIXER_CHANGE 3 +static const int MIXER_CHANGE=3; void Audio_Output::mixer_incvolume() const { float mixer_l, mixer_r; Modified: mplayerxp/libmpconf/cfgparser.cpp =================================================================== --- mplayerxp/libmpconf/cfgparser.cpp 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/libmpconf/cfgparser.cpp 2012-12-28 17:03:09 UTC (rev 622) @@ -26,6 +26,7 @@ #include "cfgparser.h" #include "libplaytree2/playtree.h" #include "parser_msg.h" +#include "osdep/get_path.h" namespace mpxp { static const int MAX_RECURSION_DEPTH=8; @@ -86,7 +87,7 @@ int M_Config::cfg_inc_int(int value){ return ++value; } int M_Config::read_option(const std::vector<const mpxp_option_t*>& conf_list,const std::string& opt,const std::string& param) { - int i=0,nconf = 0; + int i=0; long tmp_int; double tmp_float; int ret = -1; @@ -96,7 +97,8 @@ mpxp_dbg3<<"read_option: opt='"<<opt<<"' param='"<<param<<"'"<<std::endl; std::string lopt=opt; std::transform(lopt.begin(),lopt.end(),lopt.begin(), ::tolower); - for(nconf = 0 ; conf_list[nconf] != NULL; nconf++) { + size_t nconf,sz = conf_list.size(); + for(nconf = 0 ; nconf<sz ; nconf++) { conf = conf_list[nconf]; for (i = 0; conf[i].name != NULL; i++) { std::string lname=conf[i].name; @@ -629,12 +631,13 @@ } const mpxp_option_t* M_Config::find_option(const std::vector<const mpxp_option_t*>& list,const std::string& name) const { - unsigned i,j; + unsigned i; const mpxp_option_t *conf; if(!list.empty()) { std::string ln=name; std::transform(ln.begin(),ln.end(),ln.begin(), ::tolower); - for(j = 0; list[j] != NULL ; j++) { + size_t j,sz=list.size(); + for(j = 0; j<sz ; j++) { conf = list[j]; for(i=0; conf[i].name != NULL; i++) { std::string lcn=conf[i].name; @@ -860,20 +863,6 @@ //"nosound=nein" "\n"; -__always_inline std::string get_path(const std::map<std::string,std::string>& envm,const std::string& filename="") { - std::map<std::string,std::string>::const_iterator it; - it = envm.find("HOME"); - const std::string homedir = (*it).second; - std::string rs; - std::string config_dir = std::string("/.")+PROGNAME; - - if (homedir.empty()) throw "No 'HOME' environment found"; - rs=homedir+config_dir; - if (!filename.empty()) rs+="/"+filename; - mpxp_v<<"get_path('"<<homedir<<":"<<filename<<"') -> "<<rs<<std::endl; - return rs; -} - void M_Config::parse_cfgfiles(const std::map<std::string,std::string>& envm) { std::string conffile; Modified: mplayerxp/libmpdemux/asf.h =================================================================== --- mplayerxp/libmpdemux/asf.h 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/libmpdemux/asf.h 2012-12-28 17:03:09 UTC (rev 622) @@ -8,10 +8,6 @@ #include "win32loader/wine/vfw.h" #include "osdep/bswap.h" -#ifndef MIN -#define MIN(a,b) ((a<b)?a:b) -#endif - /////////////////////// // MS GUID definition /////////////////////// Modified: mplayerxp/libmpdemux/demux_ac3.cpp =================================================================== --- mplayerxp/libmpdemux/demux_ac3.cpp 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/libmpdemux/demux_ac3.cpp 2012-12-28 17:03:09 UTC (rev 622) @@ -22,7 +22,7 @@ #include "mp3_hdr.h" #include "demux_msg.h" -#define HDR_SIZE 4 +static const int HDR_SIZE=4; struct ac3_priv_t : public Opaque { public: @@ -43,20 +43,22 @@ unsigned char toc[100]; /* like AVI's indexes */ }; -#define AC3_CHANNEL 0 -#define AC3_MONO 1 -#define AC3_STEREO 2 -#define AC3_3F 3 -#define AC3_2F1R 4 -#define AC3_3F1R 5 -#define AC3_2F2R 6 -#define AC3_3F2R 7 -#define AC3_CHANNEL1 8 -#define AC3_CHANNEL2 9 -#define AC3_DOLBY 10 -#define AC3_CHANNEL_MASK 15 -#define AC3_LFE 16 -#define AC3_ADJUST_LEVEL 32 +enum { + AC3_CHANNEL=0, + AC3_MONO=1, + AC3_STEREO=2, + AC3_3F=3, + AC3_2F1R=4, + AC3_3F1R=5, + AC3_2F2R=6, + AC3_3F2R=7, + AC3_CHANNEL1=8, + AC3_CHANNEL2=9, + AC3_DOLBY=10, + AC3_CHANNEL_MASK=15, + AC3_LFE=16, + AC3_ADJUST_LEVEL=32 +}; static int ac3_decode_header (const uint8_t * buf,unsigned* sample_rate,unsigned* bit_rate,unsigned* channels) { static int rate[] = { 32, 40, 48, 56, 64, 80, 96, 112, Modified: mplayerxp/libmpdemux/demux_avi.cpp =================================================================== --- mplayerxp/libmpdemux/demux_avi.cpp 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/libmpdemux/demux_avi.cpp 2012-12-28 17:03:09 UTC (rev 622) @@ -59,7 +59,7 @@ if(idx_size > 0) delete idx; } -#define MAX_PACKS 4096 +static const int MAX_PACKS=4096; inline uint64_t avi_idx_offset(AVIINDEXENTRY* x) { return ((x->dwFlags&0xffff0000)<<16)+x->dwChunkOffset; } static int odml_get_vstream_id(int id, unsigned char res[]) @@ -815,15 +815,14 @@ return NULL; } +static int FCC_CHR_CHECK(char x) { return (x<48 || x>=96); } static int valid_fourcc(unsigned int id){ unsigned char* fcc=(unsigned char*)(&id); -#define FCC_CHR_CHECK(x) (x<48 || x>=96) if(FCC_CHR_CHECK(fcc[0])) return 0; if(FCC_CHR_CHECK(fcc[1])) return 0; if(FCC_CHR_CHECK(fcc[2])) return 0; if(FCC_CHR_CHECK(fcc[3])) return 0; return 1; -#undef FCC_CHR_CHECK } static int choose_chunk_len(unsigned int len1,unsigned int len2){ @@ -1339,7 +1338,7 @@ d_video->pts=priv->avi_video_pts; // OSD } -#define formtypeON2 mmioFOURCC('O', 'N', '2', 'f') +static const uint32_t formtypeON2=mmioFOURCC('O', 'N', '2', 'f'); static MPXP_Rc avi_probe(Demuxer *demuxer) { uint32_t riff,id; Modified: mplayerxp/libmpdemux/demux_dca.cpp =================================================================== --- mplayerxp/libmpdemux/demux_dca.cpp 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/libmpdemux/demux_dca.cpp 2012-12-28 17:03:09 UTC (rev 622) @@ -22,7 +22,7 @@ #include "mp3_hdr.h" #include "demux_msg.h" -#define HDR_SIZE 4 +static const int HDR_SIZE=4; struct dca_priv_t : public Opaque { public: @@ -43,27 +43,28 @@ unsigned char toc[100]; /* like AVI's indexes */ }; -#define DDCA_MONO 0 -#define DDCA_CHANNEL 1 -#define DDCA_STEREO 2 -#define DDCA_STEREO_SUMDIFF 3 -#define DDCA_STEREO_TOTAL 4 -#define DDCA_3F 5 -#define DDCA_2F1R 6 -#define DDCA_3F1R 7 -#define DDCA_2F2R 8 -#define DDCA_3F2R 9 -#define DDCA_4F2R 10 +enum { + DDCA_MONO=0, + DDCA_CHANNEL=1, + DDCA_STEREO=2, + DDCA_STEREO_SUMDIFF=3, + DDCA_STEREO_TOTAL=4, + DDCA_3F=5, + DDCA_2F1R=6, + DDCA_3F1R=7, + DDCA_2F2R=8, + DDCA_3F2R=9, + DDCA_4F2R=10, + DDCA_DOLBY=101, /* FIXME */ + DDCA_CHANNEL_MAX=DDCA_3F2R /* We don't handle anything above that */ +}; -#define DDCA_DOLBY 101 /* FIXME */ +static const int DDCA_CHANNEL_BITS=6; +static const int DDCA_CHANNEL_MASK=0x3F; -#define DDCA_CHANNEL_MAX DDCA_3F2R /* We don't handle anything above that */ -#define DDCA_CHANNEL_BITS 6 -#define DDCA_CHANNEL_MASK 0x3F +static const int DDCA_LFE=0x80; +static const int DDCA_ADJUST_LEVEL=0x100; -#define DDCA_LFE 0x80 -#define DDCA_ADJUST_LEVEL 0x100 - typedef struct ddca_state_s { const uint32_t *buffer_start; Modified: mplayerxp/libmpdemux/demux_dv.cpp =================================================================== --- mplayerxp/libmpdemux/demux_dv.cpp 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/libmpdemux/demux_dv.cpp 2012-12-28 17:03:09 UTC (rev 622) @@ -37,8 +37,8 @@ #include "demuxer_internal.h" #include "stheader.h" -#define DV_PAL_FRAME_SIZE 144000 -#define DV_NTSC_FRAME_SIZE 122000 +static const int DV_PAL_FRAME_SIZE =144000; +static const int DV_NTSC_FRAME_SIZE=122000; struct rawdv_frames_t : public Opaque { Modified: mplayerxp/libmpdemux/demux_film.cpp =================================================================== --- mplayerxp/libmpdemux/demux_film.cpp 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/libmpdemux/demux_film.cpp 2012-12-28 17:03:09 UTC (rev 622) @@ -28,9 +28,9 @@ #include "demux_msg.h" // chunk types found in a FILM file -#define CHUNK_FILM mmioFOURCC('F', 'I', 'L', 'M') -#define CHUNK_FDSC mmioFOURCC('F', 'D', 'S', 'C') -#define CHUNK_STAB mmioFOURCC('S', 'T', 'A', 'B') +static const uint32_t CHUNK_FILM=mmioFOURCC('F', 'I', 'L', 'M'); +static const uint32_t CHUNK_FDSC=mmioFOURCC('F', 'D', 'S', 'C'); +static const uint32_t CHUNK_STAB=mmioFOURCC('S', 'T', 'A', 'B'); typedef struct _film_chunk_t { Modified: mplayerxp/libmpdemux/demux_flac.cpp =================================================================== --- mplayerxp/libmpdemux/demux_flac.cpp 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/libmpdemux/demux_flac.cpp 2012-12-28 17:03:09 UTC (rev 622) @@ -22,7 +22,7 @@ #include "mp3_hdr.h" #include "demux_msg.h" -#define HDR_SIZE 4 +static const int HDR_SIZE=4; struct flac_priv_t : public Opaque { public: Modified: mplayerxp/libmpdemux/demux_lavf.cpp =================================================================== --- mplayerxp/libmpdemux/demux_lavf.cpp 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/libmpdemux/demux_lavf.cpp 2012-12-28 17:03:09 UTC (rev 622) @@ -35,10 +35,9 @@ #include "libao3/afmt.h" #include "demux_msg.h" -#define PROBE_BUF_SIZE 2048 +static const int PROBE_BUF_SIZE=2048; +static const int BIO_BUFFER_SIZE=32768; -#define BIO_BUFFER_SIZE 32768 - struct lavf_priv_t : public Opaque { public: lavf_priv_t() {} Modified: mplayerxp/libmpdemux/demux_mkv.cpp =================================================================== --- mplayerxp/libmpdemux/demux_mkv.cpp 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/libmpdemux/demux_mkv.cpp 2012-12-28 17:03:09 UTC (rev 622) @@ -55,64 +55,63 @@ #define EBML_UINT_INVALID std::numeric_limits<uint64_t>::max() #define EBML_INT_INVALID std::numeric_limits<int64_t>::max() -#define EBML_FLOAT_INVALID -1000000000.0 +static const float EBML_FLOAT_INVALID=-1000000000.0f; -#define MKV_A_AAC_2MAIN "A_AAC/MPEG2/MAIN" -#define MKV_A_AAC_2LC "A_AAC/MPEG2/LC" -#define MKV_A_AAC_2SBR "A_AAC/MPEG2/LC/SBR" -#define MKV_A_AAC_2SSR "A_AAC/MPEG2/SSR" -#define MKV_A_AAC_4MAIN "A_AAC/MPEG4/MAIN" -#define MKV_A_AAC_4LC "A_AAC/MPEG4/LC" -#define MKV_A_AAC_4SBR "A_AAC/MPEG4/LC/SBR" -#define MKV_A_AAC_4SSR "A_AAC/MPEG4/SSR" -#define MKV_A_AAC_4LTP "A_AAC/MPEG4/LTP" -#define MKV_A_AAC "A_AAC" -#define MKV_A_AC3 "A_AC3" -#define MKV_A_DTS "A_DTS" -#define MKV_A_MP2 "A_MPEG/L2" -#define MKV_A_MP3 "A_MPEG/L3" -#define MKV_A_PCM "A_PCM/INT/LIT" -#define MKV_A_PCM_BE "A_PCM/INT/BIG" -#define MKV_A_VORBIS "A_VORBIS" -#define MKV_A_ACM "A_MS/ACM" -#define MKV_A_REAL28 "A_REAL/28_8" -#define MKV_A_REALATRC "A_REAL/ATRC" -#define MKV_A_REALCOOK "A_REAL/COOK" -#define MKV_A_REALDNET "A_REAL/DNET" -#define MKV_A_REALSIPR "A_REAL/SIPR" -#define MKV_A_QDMC "A_QUICKTIME/QDMC" -#define MKV_A_QDMC2 "A_QUICKTIME/QDM2" -#define MKV_A_FLAC "A_FLAC" -#define MKV_A_WAVPACK "A_WAVPACK4" +static const char* MKV_A_AAC_2MAIN ="A_AAC/MPEG2/MAIN"; +static const char* MKV_A_AAC_2LC ="A_AAC/MPEG2/LC"; +static const char* MKV_A_AAC_2SBR ="A_AAC/MPEG2/LC/SBR"; +static const char* MKV_A_AAC_2SSR ="A_AAC/MPEG2/SSR"; +static const char* MKV_A_AAC_4MAIN ="A_AAC/MPEG4/MAIN"; +static const char* MKV_A_AAC_4LC ="A_AAC/MPEG4/LC"; +static const char* MKV_A_AAC_4SBR ="A_AAC/MPEG4/LC/SBR"; +static const char* MKV_A_AAC_4SSR ="A_AAC/MPEG4/SSR"; +static const char* MKV_A_AAC_4LTP ="A_AAC/MPEG4/LTP"; +static const char* MKV_A_AAC ="A_AAC"; +static const char* MKV_A_AC3 ="A_AC3"; +static const char* MKV_A_DTS ="A_DTS"; +static const char* MKV_A_MP2 ="A_MPEG/L2"; +static const char* MKV_A_MP3 ="A_MPEG/L3"; +static const char* MKV_A_PCM ="A_PCM/INT/LIT"; +static const char* MKV_A_PCM_BE ="A_PCM/INT/BIG"; +static const char* MKV_A_VORBIS ="A_VORBIS"; +static const char* MKV_A_ACM ="A_MS/ACM"; +static const char* MKV_A_REAL28 ="A_REAL/28_8"; +static const char* MKV_A_REALATRC ="A_REAL/ATRC"; +static const char* MKV_A_REALCOOK ="A_REAL/COOK"; +static const char* MKV_A_REALDNET ="A_REAL/DNET"; +static const char* MKV_A_REALSIPR ="A_REAL/SIPR"; +static const char* MKV_A_QDMC ="A_QUICKTIME/QDMC"; +static const char* MKV_A_QDMC2 ="A_QUICKTIME/QDM2"; +static const char* MKV_A_FLAC ="A_FLAC"; +static const char* MKV_A_WAVPACK ="A_WAVPACK4"; -#define MKV_V_MSCOMP "V_MS/VFW/FOURCC" -#define MKV_V_REALV10 "V_REAL/RV10" -#define MKV_V_REALV20 "V_REAL/RV20" -#define MKV_V_REALV30 "V_REAL/RV30" -#define MKV_V_REALV40 "V_REAL/RV40" -#define MKV_V_SORENSONV1 "V_SORENSON/V1" -#define MKV_V_SORENSONV2 "V_SORENSON/V2" -#define MKV_V_SORENSONV3 "V_SORENSON/V3" -#define MKV_V_CINEPAK "V_CINEPAK" -#define MKV_V_QUICKTIME "V_QUICKTIME" -#define MKV_V_MPEG1 "V_MPEG1" -#define MKV_V_MPEG2 "V_MPEG2" -#define MKV_V_MPEG4_SP "V_MPEG4/ISO/SP" -#define MKV_V_MPEG4_ASP "V_MPEG4/ISO/ASP" -#define MKV_V_MPEG4_AP "V_MPEG4/ISO/AP" -#define MKV_V_MPEG4_AVC "V_MPEG4/ISO/AVC" -#define MKV_V_THEORA "V_THEORA" +static const char* MKV_V_MSCOMP ="V_MS/VFW/FOURCC"; +static const char* MKV_V_REALV10 ="V_REAL/RV10"; +static const char* MKV_V_REALV20 ="V_REAL/RV20"; +static const char* MKV_V_REALV30 ="V_REAL/RV30"; +static const char* MKV_V_REALV40 ="V_REAL/RV40"; +static const char* MKV_V_SORENSONV1 ="V_SORENSON/V1"; +static const char* MKV_V_SORENSONV2 ="V_SORENSON/V2"; +static const char* MKV_V_SORENSONV3 ="V_SORENSON/V3"; +static const char* MKV_V_CINEPAK ="V_CINEPAK"; +static const char* MKV_V_QUICKTIME ="V_QUICKTIME"; +static const char* MKV_V_MPEG1 ="V_MPEG1"; +static const char* MKV_V_MPEG2 ="V_MPEG2"; +static const char* MKV_V_MPEG4_SP ="V_MPEG4/ISO/SP"; +static const char* MKV_V_MPEG4_ASP ="V_MPEG4/ISO/ASP"; +static const char* MKV_V_MPEG4_AP ="V_MPEG4/ISO/AP"; +static const char* MKV_V_MPEG4_AVC ="V_MPEG4/ISO/AVC"; +static const char* MKV_V_THEORA ="V_THEORA"; -#define MKV_S_TEXTASCII "S_TEXT/ASCII" -#define MKV_S_TEXTUTF8 "S_TEXT/UTF8" -#define MKV_S_TEXTSSA "S_TEXT/SSA" -#define MKV_S_TEXTASS "S_TEXT/ASS" -#define MKV_S_VOBSUB "S_VOBSUB" -#define MKV_S_SSA "S_SSA" // Deprecated -#define MKV_S_ASS "S_ASS" // Deprecated +static const char* MKV_S_TEXTASCII ="S_TEXT/ASCII"; +static const char* MKV_S_TEXTUTF8 ="S_TEXT/UTF8"; +static const char* MKV_S_TEXTSSA ="S_TEXT/SSA"; +static const char* MKV_S_TEXTASS ="S_TEXT/ASS"; +static const char* MKV_S_VOBSUB ="S_VOBSUB"; +static const char* MKV_S_SSA ="S_SSA"; // Deprecated +static const char* MKV_S_ASS ="S_ASS"; // Deprecated - static uint32_t ebml_read_id (Stream *s, int *length) { @@ -466,9 +465,11 @@ {77,80} }; // Map flavour to bytes per second -#define SIPR_FLAVORS 4 -#define ATRC_FLAVORS 8 -#define COOK_FLAVORS 34 +enum { + SIPR_FLAVORS=4, + ATRC_FLAVORS=8, + COOK_FLAVORS=34 +}; static int sipr_fl2bps[SIPR_FLAVORS] = {813, 1062, 625, 2000}; static int atrc_fl2bps[ATRC_FLAVORS] = {8269, 11714, 13092, 16538, 18260, 22050, 33075, 44100}; static int cook_fl2bps[COOK_FLAVORS] = {1000, 1378, 2024, 2584, 4005, 5513, 8010, 4005, 750, 2498, @@ -676,10 +677,10 @@ static int dvd_last_chapter; static int dvd_chapter; -#define REALHEADER_SIZE 16 -#define RVPROPERTIES_SIZE 34 -#define RAPROPERTIES4_SIZE 56 -#define RAPROPERTIES5_SIZE 70 +static const int REALHEADER_SIZE =16; +static const int RVPROPERTIES_SIZE =34; +static const int RAPROPERTIES4_SIZE =56; +static const int RAPROPERTIES5_SIZE =70; /** * \brief ensures there is space for at least one additional element @@ -739,9 +740,8 @@ } -#define AAC_SYNC_EXTENSION_TYPE 0x02b7 -static int -aac_get_sample_rate_index (uint32_t sample_rate) +static const int AAC_SYNC_EXTENSION_TYPE=0x02b7; +static int aac_get_sample_rate_index (uint32_t sample_rate) { if (92017 <= sample_rate) return 0; Modified: mplayerxp/libmpdemux/demux_mov.cpp =================================================================== --- mplayerxp/libmpdemux/demux_mov.cpp 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/libmpdemux/demux_mov.cpp 2012-12-28 17:03:09 UTC (rev 622) @@ -54,8 +54,8 @@ inline uint16_t BE_16(uint16_t x) { return be2me_16(x); } inline uint32_t BE_32(uint32_t x) { return be2me_32(x); } -#define char2short(x,y) BE_16(*((uint16_t *)&(((unsigned char *)(x))[(y)]))) -#define char2int(x,y) BE_32(*((uint32_t *)&(((unsigned char *)(x))[(y)]))) +static uint16_t char2short(unsigned char* x,int y) { return BE_16(*((uint16_t *)&x[y])); } +static uint32_t char2int(unsigned char* x, int y) { return BE_32(*((uint32_t *)&x[y])); } typedef struct { unsigned int pts; // duration @@ -92,12 +92,14 @@ int pts_offset; } mov_editlist_t; -#define MOV_TRAK_UNKNOWN 0 -#define MOV_TRAK_VIDEO 1 -#define MOV_TRAK_AUDIO 2 -#define MOV_TRAK_FLASH 3 -#define MOV_TRAK_GENERIC 4 -#define MOV_TRAK_CODE 5 +enum { + MOV_TRAK_UNKNOWN=0, + MOV_TRAK_VIDEO=1, + MOV_TRAK_AUDIO=2, + MOV_TRAK_FLASH=3, + MOV_TRAK_GENERIC=4, + MOV_TRAK_CODE=5 +}; typedef struct { int id; @@ -281,11 +283,10 @@ (float)(el->dur)/(float)timescale, el->pts_offset); } } - } -#define MOV_MAX_TRACKS 256 -#define MOV_MAX_SUBLEN 1024 +static const int MOV_MAX_TRACKS=256; +static const int MOV_MAX_SUBLEN=1024; struct mov_priv_t : public Opaque { public: Modified: mplayerxp/libmpdemux/demux_mp3.cpp =================================================================== --- mplayerxp/libmpdemux/demux_mp3.cpp 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/libmpdemux/demux_mp3.cpp 2012-12-28 17:03:09 UTC (rev 622) @@ -23,10 +23,12 @@ #include "mp3_hdr.h" #include "demux_msg.h" -#define RAW_MP1 1 -#define RAW_MP2 2 -#define RAW_MP3 3 -#define HDR_SIZE 4 +enum { + RAW_MP1=1, + RAW_MP2=2, + RAW_MP3=3, + HDR_SIZE=4 +}; struct mp3_priv_t : public Opaque { public: @@ -121,21 +123,22 @@ } /* id3v2 */ -#define FOURCC_TAG BE_FOURCC -#define ID3V22_TAG FOURCC_TAG('I', 'D', '3', 2) /* id3 v2.2 tags */ -#define ID3V23_TAG FOURCC_TAG('I', 'D', '3', 3) /* id3 v2.3 tags */ -#define ID3V24_TAG FOURCC_TAG('I', 'D', '3', 4) /* id3 v2.4 tags */ +static const uint32_t ID3V22_TAG=FOURCC_TAG('I', 'D', '3', 2); /* id3 v2.2 tags */ +static const uint32_t ID3V23_TAG=FOURCC_TAG('I', 'D', '3', 3); /* id3 v2.3 tags */ +static const uint32_t ID3V24_TAG=FOURCC_TAG('I', 'D', '3', 4); /* id3 v2.4 tags */ /* * ID3 v2.2 */ /* tag header */ -#define ID3V22_UNSYNCH_FLAG 0x80 -#define ID3V22_COMPRESS_FLAG 0x40 -#define ID3V22_ZERO_FLAG 0x3F +enum { + ID3V22_UNSYNCH_FLAG=0x80, + ID3V22_COMPRESS_FLAG=0x40, + ID3V22_ZERO_FLAG=0x3F +}; /* frame header */ -#define ID3V22_FRAME_HEADER_SIZE 6 +static const int ID3V22_FRAME_HEADER_SIZE=6; static int read_id3v22_tags(Demuxer *demuxer,unsigned flags,unsigned hsize) { off_t pos,epos; @@ -186,20 +189,24 @@ * ID3 v2.3 */ /* tag header */ -#define ID3V23_UNSYNCH_FLAG 0x80 -#define ID3V23_EXT_HEADER_FLAG 0x40 -#define ID3V23_EXPERIMENTAL_FLAG 0x20 -#define ID3V23_ZERO_FLAG 0x1F +enum { + ID3V23_UNSYNCH_FLAG=0x80, + ID3V23_EXT_HEADER_FLAG=0x40, + ID3V23_EXPERIMENTAL_FLAG=0x20, + ID3V23_ZERO_FLAG=0x1F +}; /* frame header */ -#define ID3V23_FRAME_HEADER_SIZE 10 -#define ID3V23_FRAME_TAG_PRESERV_FLAG 0x8000 -#define ID3V23_FRAME_FILE_PRESERV_FLAG 0x4000 -#define ID3V23_FRAME_READ_ONLY_FLAG 0x2000 -#define ID3V23_FRAME_COMPRESS_FLAG 0x0080 -#define ID3V23_FRAME_ENCRYPT_FLAG 0x0040 -#define ID3V23_FRAME_GROUP_ID_FLAG 0x0020 -#define ID3V23_FRAME_ZERO_FLAG 0x1F1F +enum { + ID3V23_FRAME_HEADER_SIZE =10, + ID3V23_FRAME_TAG_PRESERV_FLAG=0x8000, + ID3V23_FRAME_FILE_PRESERV_FLAG=0x4000, + ID3V23_FRAME_READ_ONLY_FLAG =0x2000, + ID3V23_FRAME_COMPRESS_FLAG =0x0080, + ID3V23_FRAME_ENCRYPT_FLAG =0x0040, + ID3V23_FRAME_GROUP_ID_FLAG =0x0020, + ID3V23_FRAME_ZERO_FLAG =0x1F1F +}; static int read_id3v23_tags(Demuxer *demuxer,unsigned flags,unsigned hsize) { @@ -259,23 +266,27 @@ * ID3 v2.4 */ /* tag header */ -#define ID3V24_UNSYNCH_FLAG 0x80 -#define ID3V24_EXT_HEADER_FLAG 0x40 -#define ID3V24_EXPERIMENTAL_FLAG 0x20 -#define ID3V24_FOOTER_FLAG 0x10 -#define ID3V24_ZERO_FLAG 0x0F +enum { + ID3V24_UNSYNCH_FLAG=0x80, + ID3V24_EXT_HEADER_FLAG=0x40, + ID3V24_EXPERIMENTAL_FLAG=0x20, + ID3V24_FOOTER_FLAG=0x10, + ID3V24_ZERO_FLAG=0x0F +}; /* frame header */ -#define ID3V24_FRAME_HEADER_SIZE 10 -#define ID3V24_FRAME_TAG_PRESERV_FLAG 0x4000 -#define ID3V24_FRAME_FILE_PRESERV_FLAG 0x2000 -#define ID3V24_FRAME_READ_ONLY_FLAG 0x1000 -#define ID3V24_FRAME_GROUP_ID_FLAG 0x0040 -#define ID3V24_FRAME_COMPRESS_FLAG 0x0008 -#define ID3V24_FRAME_ENCRYPT_FLAG 0x0004 -#define ID3V24_FRAME_UNSYNCH_FLAG 0x0002 -#define ID3V24_FRAME_DATA_LEN_FLAG 0x0001 -#define ID3V24_FRAME_ZERO_FLAG 0x8FB0 +enum { + ID3V24_FRAME_HEADER_SIZE =10, + ID3V24_FRAME_TAG_PRESERV_FLAG=0x4000, + ID3V24_FRAME_FILE_PRESERV_FLAG=0x2000, + ID3V24_FRAME_READ_ONLY_FLAG =0x1000, + ID3V24_FRAME_GROUP_ID_FLAG =0x0040, + ID3V24_FRAME_COMPRESS_FLAG =0x0008, + ID3V24_FRAME_ENCRYPT_FLAG =0x0004, + ID3V24_FRAME_UNSYNCH_FLAG =0x0002, + ID3V24_FRAME_DATA_LEN_FLAG =0x0001, + ID3V24_FRAME_ZERO_FLAG =0x8FB0 +}; static int read_id3v24_tags(Demuxer *demuxer,unsigned flags,unsigned hsize) { @@ -392,12 +403,14 @@ return MPXP_False; } -#define FRAMES_FLAG 0x0001 -#define BYTES_FLAG 0x0002 -#define TOC_FLAG 0x0004 -#define VBR_SCALE_FLAG 0x0008 -#define FRAMES_AND_BYTES (FRAMES_FLAG | BYTES_FLAG) -#define MPG_MD_MONO 3 +enum { + FRAMES_FLAG =0x0001, + BYTES_FLAG =0x0002, + TOC_FLAG =0x0004, + VBR_SCALE_FLAG=0x0008, + FRAMES_AND_BYTES=(FRAMES_FLAG | BYTES_FLAG) +}; +static const int MPG_MD_MONO=3; static void Xing_test(Stream *s,uint8_t *hdr,mp3_priv_t *priv) { Modified: mplayerxp/libmpdemux/demux_mpg.cpp =================================================================== --- mplayerxp/libmpdemux/demux_mpg.cpp 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/libmpdemux/demux_mpg.cpp 2012-12-28 17:03:09 UTC (rev 622) @@ -27,23 +27,23 @@ #include "libmpcodecs/dec_audio.h" #include "demux_msg.h" -//#define MAX_PS_PACKETSIZE 2048 -#define MAX_PS_PACKETSIZE (224*1024) +static const int MAX_PS_PACKETSIZE=(224*1024); -#define UNKNOWN 0 -#define VIDEO_MPEG1 0x10000001 -#define VIDEO_MPEG2 0x10000002 -#define VIDEO_MPEG4 0x10000004 -#define VIDEO_H264 0x10000005 -#define AUDIO_MP2 0x50 -#define AUDIO_MP3 0x55 -#define AUDIO_A52 0x2000 -#define AUDIO_DTS 0x2001 -#define AUDIO_LPCM_BE 0x10001 -#define AUDIO_AAC mmioFOURCC('M', 'P', '4', 'A') +enum { + UNKNOWN =0, + VIDEO_MPEG1 =0x10000001, + VIDEO_MPEG2 =0x10000002, + VIDEO_MPEG4 =0x10000004, + VIDEO_H264 =0x10000005, + AUDIO_MP2 =0x50, + AUDIO_MP3 =0x55, + AUDIO_A52 =0x2000, + AUDIO_DTS =0x2001, + AUDIO_LPCM_BE =0x10001, + AUDIO_AAC =mmioFOURCC('M', 'P', '4', 'A') +}; +static const int MPGPES_BAD_PTS=-1; -#define MPGPES_BAD_PTS -1 - typedef int (*alt_demuxer_t)(Demuxer *demux,Demuxer_Stream *__ds); struct mpg_demuxer_t : public Opaque { public: Modified: mplayerxp/libmpdemux/demux_mpxp64.cpp =================================================================== --- mplayerxp/libmpdemux/demux_mpxp64.cpp 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/libmpdemux/demux_mpxp64.cpp 2012-12-28 17:03:09 UTC (rev 622) @@ -29,7 +29,7 @@ #include "mpxpav64.h" #include "demux_msg.h" -#define MAX_AV_STREAMS MAX_V_STREAMS+MAX_A_STREAMS+MAX_S_STREAMS +static const int MAX_AV_STREAMS=MAX_V_STREAMS+MAX_A_STREAMS+MAX_S_STREAMS; struct mpxpav64_priv_t : public Opaque { public: @@ -71,7 +71,7 @@ h->clutID = le2me_16(h->clutID); } -#define MAX_PACKS 4096 +static const int MAX_PACKS=4096; static void print_FileProp(mpxpav64FileProperties_t *fp) { @@ -773,7 +773,7 @@ return 0; } -#define USE_INDEXES 1 +static const int USE_INDEXES=1; static void mpxpav64_seek(Demuxer *demuxer,const seek_args_t* seeka){ mpxpav64_priv_t *priv=static_cast<mpxpav64_priv_t*>(demuxer->priv); float brate=priv->fprop.AveBitrate; Modified: mplayerxp/libmpdemux/demux_musepack.cpp =================================================================== --- mplayerxp/libmpdemux/demux_musepack.cpp 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/libmpdemux/demux_musepack.cpp 2012-12-28 17:03:09 UTC (rev 622) @@ -22,7 +22,7 @@ #include "mp3_hdr.h" #include "demux_msg.h" -#define HDR_SIZE 4 +static const int HDR_SIZE=4; struct musepack_priv_t : public Opaque { public: Modified: mplayerxp/libmpdemux/demux_nuv.cpp =================================================================== --- mplayerxp/libmpdemux/demux_nuv.cpp 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/libmpdemux/demux_nuv.cpp 2012-12-28 17:03:09 UTC (rev 622) @@ -64,9 +64,9 @@ /** * Seek to a position relative to the current position, indicated in time. */ +static const int MAX_TIME=1000000; static void nuv_seek ( Demuxer *demuxer, const seek_args_t* seeka ) { -#define MAX_TIME 1000000 nuv_priv_t* priv = static_cast<nuv_priv_t*>(demuxer->priv); struct rtframeheader rtjpeg_frameheader; off_t orig_pos; Modified: mplayerxp/libmpdemux/demux_ogg.cpp =================================================================== --- mplayerxp/libmpdemux/demux_ogg.cpp 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/libmpdemux/demux_ogg.cpp 2012-12-28 17:03:09 UTC (rev 622) @@ -29,9 +29,9 @@ #include "libao3/afmt.h" #include "demux_msg.h" -#define BLOCK_SIZE 4096 -#define FOURCC_VORBIS mmioFOURCC('v', 'r', 'b', 's') -#define FOURCC_THEORA mmioFOURCC('t', 'h', 'e', 'o') +static const int BLOCK_SIZE=4096; +static const uint32_t FOURCC_VORBIS=mmioFOURCC('v', 'r', 'b', 's'); +static const uint32_t FOURCC_THEORA=mmioFOURCC('t', 'h', 'e', 'o'); /// Vorbis decoder context : we need the vorbis_info for vorbis timestamping /// Shall we put this struct def in a common header ? @@ -163,21 +163,22 @@ delete ov; } -#define NUM_VORBIS_HDR_PACKETS 3 +static const int NUM_VORBIS_HDR_PACKETS=3; /// Some defines from OggDS -#define PACKET_TYPE_HEADER 0x01 -#define PACKET_TYPE_BITS 0x07 -#define PACKET_LEN_BITS01 0xc0 -#define PACKET_LEN_BITS2 0x02 -#define PACKET_IS_SYNCPOINT 0x08 - +enum { + PACKET_TYPE_HEADER =0x01, + PACKET_TYPE_BITS =0x07, + PACKET_LEN_BITS01 =0xc0, + PACKET_LEN_BITS2 =0x02, + PACKET_IS_SYNCPOINT =0x08 +}; //-------- subtitle support - should be moved to decoder layer, and queue // - subtitles up in demuxer buffer... #include "libmpsub/subreader.h" #include "libvo2/sub.h" -#define OGG_SUB_MAX_LINE 128 +static const int OGG_SUB_MAX_LINE=128; static subtitle ogg_sub; static float clear_sub; Modified: mplayerxp/libmpdemux/demux_pva.cpp =================================================================== --- mplayerxp/libmpdemux/demux_pva.cpp 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/libmpdemux/demux_pva.cpp 2012-12-28 17:03:09 UTC (rev 622) @@ -43,10 +43,12 @@ * #defines below taken from PVA spec (see URL above) */ -#define PVA_MAX_VIDEO_PACK_LEN 6*1024 +static const int PVA_MAX_VIDEO_PACK_LEN=6*1024; -#define VIDEOSTREAM 0x01 -#define MAINAUDIOSTREAM 0x02 +enum { + VIDEOSTREAM=0x01, + MAINAUDIOSTREAM=0x02 +}; typedef struct { off_t offset; Modified: mplayerxp/libmpdemux/demux_real.cpp =================================================================== --- mplayerxp/libmpdemux/demux_real.cpp 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/libmpdemux/demux_real.cpp 2012-12-28 17:03:09 UTC (rev 622) @@ -40,7 +40,7 @@ #define MKTAG(a, b, c, d) (a | (b << 8) | (c << 16) | (d << 24)) -#define MAX_STREAMS 32 +static const int MAX_STREAMS=32; typedef struct { int timestamp; Modified: mplayerxp/libmpdemux/demux_realaud.cpp =================================================================== --- mplayerxp/libmpdemux/demux_realaud.cpp 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/libmpdemux/demux_realaud.cpp 2012-12-28 17:03:09 UTC (rev 622) @@ -22,11 +22,11 @@ #include "aviprint.h" #include "demux_msg.h" -#define FOURCC_DOTRA mmioFOURCC('.','r','a', 0xfd) -#define FOURCC_144 mmioFOURCC('1','4','_','4') -#define FOURCC_288 mmioFOURCC('2','8','_','8') -#define FOURCC_DNET mmioFOURCC('d','n','e','t') -#define FOURCC_LPCJ mmioFOURCC('l','p','c','J') +static const uint32_t FOURCC_DOTRA=mmioFOURCC('.','r','a', 0xfd); +static const uint32_t FOURCC_144=mmioFOURCC('1','4','_','4'); +static const uint32_t FOURCC_288=mmioFOURCC('2','8','_','8'); +static const uint32_t FOURCC_DNET=mmioFOURCC('d','n','e','t'); +static const uint32_t FOURCC_LPCJ=mmioFOURCC('l','p','c','J'); struct realaud_priv_t : public Opaque { public: Modified: mplayerxp/libmpdemux/demux_roq.cpp =================================================================== --- mplayerxp/libmpdemux/demux_roq.cpp 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/libmpdemux/demux_roq.cpp 2012-12-28 17:03:09 UTC (rev 622) @@ -23,14 +23,18 @@ #include "stheader.h" #include "demux_msg.h" -#define RoQ_INFO 0x1001 -#define RoQ_QUAD_CODEBOOK 0x1002 -#define RoQ_QUAD_VQ 0x1011 -#define RoQ_SOUND_MONO 0x1020 -#define RoQ_SOUND_STEREO 0x1021 +enum { + RoQ_INFO =0x1001, + RoQ_QUAD_CODEBOOK =0x1002, + RoQ_QUAD_VQ =0x1011, + RoQ_SOUND_MONO =0x1020, + RoQ_SOUND_STEREO =0x1021 +}; -#define CHUNK_TYPE_AUDIO 0 -#define CHUNK_TYPE_VIDEO 1 +enum { + CHUNK_TYPE_AUDIO=0, + CHUNK_TYPE_VIDEO=1 +}; typedef struct roq_chunk_t { Modified: mplayerxp/libmpdemux/demux_snd_au.cpp =================================================================== --- mplayerxp/libmpdemux/demux_snd_au.cpp 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/libmpdemux/demux_snd_au.cpp 2012-12-28 17:03:09 UTC (rev 622) @@ -22,7 +22,7 @@ #include "mp3_hdr.h" #include "demux_msg.h" -#define HDR_SIZE 4 +static const int HDR_SIZE=4; struct snd_au_priv_t : public Opaque { public: Modified: mplayerxp/libmpdemux/demux_ts.cpp =================================================================== --- mplayerxp/libmpdemux/demux_ts.cpp 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/libmpdemux/demux_ts.cpp 2012-12-28 17:03:09 UTC (rev 622) @@ -43,22 +43,23 @@ #include "mpeg_hdr.h" #include "demux_msg.h" +static const int TS_PH_PACKET_SIZE=192; +static const int TS_FEC_PACKET_SIZE=204; +static const int TS_PACKET_SIZE=188; +static const int NB_PID_MAX=8192; -#define TS_PH_PACKET_SIZE 192 -#define TS_FEC_PACKET_SIZE 204 -#define TS_PACKET_SIZE 188 -#define NB_PID_MAX 8192 +static const int MAX_HEADER_SIZE=6; /* enough for PES header + length */ +static const int MAX_CHECK_SIZE=65535; +static const int TS_MAX_PROBE_SIZE=2000000; /* dont forget to change this in cfg-common.h too */ +static const int NUM_CONSECUTIVE_TS_PACKETS=32; +static const int NUM_CONSECUTIVE_AUDIO_PACKETS=348; +static const int MAX_A52_FRAME_SIZE=3840; -#define MAX_HEADER_SIZE 6 /* enough for PES header + length */ -#define MAX_CHECK_SIZE 65535 -#define TS_MAX_PROBE_SIZE 2000000 /* dont forget to change this in cfg-common.h too */ -#define NUM_CONSECUTIVE_TS_PACKETS 32 -#define NUM_CONSECUTIVE_AUDIO_PACKETS 348 -#define MAX_A52_FRAME_SIZE 3840 +enum { + TYPE_AUDIO=1, + TYPE_VIDEO=2 +}; -#define TYPE_AUDIO 1 -#define TYPE_VIDEO 2 - int ts_prog; int ts_keep_broken=0; off_t _ts_probe = TS_MAX_PROBE_SIZE; @@ -127,7 +128,7 @@ int offset, buffer_size; } av_fifo_t; -#define MAX_EXTRADATA_SIZE 64*1024 +static const int MAX_EXTRADATA_SIZE=64*1024; typedef struct { int32_t object_type; //aka codec used int32_t stream_type; //video, audio etc. Modified: mplayerxp/libmpdemux/demux_ty.cpp =================================================================== --- mplayerxp/libmpdemux/demux_ty.cpp 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/libmpdemux/demux_ty.cpp 2012-12-28 17:03:09 UTC (rev 622) @@ -72,14 +72,16 @@ // e/02: Extended data services data -#define TIVO_PES_FILEID 0xf5467abd -#define TIVO_PART_LENGTH 0x20000000 +static const int TIVO_PES_FILEID=0xf5467abd; +static const int TIVO_PART_LENGTH=0x20000000; -#define CHUNKSIZE ( 128 * 1024 ) -#define MAX_AUDIO_BUFFER ( 16 * 1024 ) +static const int CHUNKSIZE =( 128 * 1024 ); +static const int MAX_AUDIO_BUFFER =( 16 * 1024 ); -#define TY_V 1 -#define TY_A 2 +enum { + TY_V=1, + TY_A=2 +}; typedef struct { @@ -88,7 +90,7 @@ int chunks; } tmf_fileParts; -#define MAX_TMF_PARTS 16 +static const int MAX_TMF_PARTS=16; struct TiVoInfo : public Opaque { public: @@ -112,7 +114,7 @@ void ty_ClearOSD( int start ); // =========================================================================== -#define TMF_SIG "showing.xml" +static const char* TMF_SIG="showing.xml"; // =========================================================================== static int ty_tmf_filetoparts( Demuxer *demux, TiVoInfo *tivo ) @@ -228,12 +230,12 @@ // SA TiVo 864 // DTiVo AC-3 1550 // -#define SERIES1_PTS_LENGTH 11 -#define SERIES1_PTS_OFFSET 6 -#define SERIES2_PTS_LENGTH 16 -#define SERIES2_PTS_OFFSET 9 -#define AC3_PTS_LENGTH 16 -#define AC3_PTS_OFFSET 9 +static const int SERIES1_PTS_LENGTH=11; +static const int SERIES1_PTS_OFFSET=6; +static const int SERIES2_PTS_LENGTH=16; +static const int SERIES2_PTS_OFFSET=9; +static const int AC3_PTS_LENGTH=16; +static const int AC3_PTS_OFFSET=9; static int IsValidAudioPacket( int size, int *ptsOffset, int *ptsLen ) { @@ -332,9 +334,11 @@ *esOffset2 += *esOffset1 + 1; } -#define VIDEO_NAL 0xe0 -#define AUDIO_NAL 0xc0 -#define AC3_NAL 0xbd +enum { + VIDEO_NAL=0xe0, + AUDIO_NAL=0xc0, + AC3_NAL=0xbd +}; static int ty_demux( Demuxer *demux, Demuxer_Stream *dsds ) { Modified: mplayerxp/libmpdemux/demux_viv.cpp =================================================================== --- mplayerxp/libmpdemux/demux_viv.cpp 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/libmpdemux/demux_viv.cpp 2012-12-28 17:03:09 UTC (rev 622) @@ -69,8 +69,10 @@ //enum { VIVO_AUDIO_G723, VIVO_AUDIO_SIREN }; -#define VIVO_AUDIO_G723 1 -#define VIVO_AUDIO_SIREN 2 +enum { + VIVO_AUDIO_G723=1, + VIVO_AUDIO_SIREN +}; struct vivo_priv_t : public Opaque { public: @@ -126,8 +128,8 @@ /* parse all possible extra headers */ /* (audio headers are seperate - mostly with recordtype=3 or 4) */ -#define TEXTPARSE_ALL 1 +#define TEXTPARSE_ALL static void vivo_parse_text_header(Demuxer *demux, int header_len) { vivo_priv_t* priv = static_cast<vivo_priv_t*>(demux->priv); Modified: mplayerxp/libmpdemux/demux_voc.cpp =================================================================== --- mplayerxp/libmpdemux/demux_voc.cpp 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/libmpdemux/demux_voc.cpp 2012-12-28 17:03:09 UTC (rev 622) @@ -22,7 +22,7 @@ #include "mp3_hdr.h" #include "demux_msg.h" -#define HDR_SIZE 4 +static const int HDR_SIZE=4; struct voc_priv_t : public Opaque { public: Modified: mplayerxp/libmpdemux/demux_vqf.cpp =================================================================== --- mplayerxp/libmpdemux/demux_vqf.cpp 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/libmpdemux/demux_vqf.cpp 2012-12-28 17:03:09 UTC (rev 622) @@ -16,9 +16,9 @@ #include "libao3/afmt.h" #include "demux_msg.h" -#define KEYWORD_BYTES 4 -#define VERSION_BYTES 8 -#define ELEM_BYTES sizeof(unsigned long) +static const int KEYWORD_BYTES=4; +static const int VERSION_BYTES=8; +static const int ELEM_BYTES=sizeof(unsigned long); typedef struct{ char ID[KEYWORD_BYTES+VERSION_BYTES+1]; int size; Modified: mplayerxp/libmpdemux/demux_wav.cpp =================================================================== --- mplayerxp/libmpdemux/demux_wav.cpp 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/libmpdemux/demux_wav.cpp 2012-12-28 17:03:09 UTC (rev 622) @@ -22,7 +22,7 @@ #include "mp3_hdr.h" #include "demux_msg.h" -#define HDR_SIZE 4 +static const int HDR_SIZE=4; struct da_priv_t : public Opaque { public: Modified: mplayerxp/libmpdemux/mux_mpxp64.cpp =================================================================== --- mplayerxp/libmpdemux/mux_mpxp64.cpp 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/libmpdemux/mux_mpxp64.cpp 2012-12-28 17:03:09 UTC (rev 622) @@ -52,8 +52,8 @@ float prev_xpts; }priv_mpxpav64_stream_t; -#define SEEKPOINT_THRESHOLD 1.0 -#define PTS2INT(pts) (lrint(pts*1000)) +static const float SEEKPOINT_THRESHOLD=1.0f; +static int PTS2INT(float pts) { return lrint(pts*1000); } typedef struct priv_mpxpav64_s { @@ -270,28 +270,28 @@ return MAKE_AVI_ASPECT(x, y); } -#define le2me_ImageDesc(h) { \ - (h)->idSize = le2me_32((h)->idSize); \ - (h)->cType = le2me_32((h)->cType); \ - (h)->resvd1 = le2me_32((h)->resvd1); \ - (h)->resvd2 = le2me_16((h)->resvd2); \ - (h)->dataRefIndex = le2me_16((h)->dataRefIndex); \ - (h)->version = le2me_16((h)->version); \ - (h)->revisionLevel = le2me_16((h)->revisionLevel); \ - (h)->vendor = le2me_32((h)->vendor); \ - (h)->temporalQuality = le2me_32((h)->temporalQuality); \ - (h)->spatialQuality = le2me_32((h)->spatialQuality); \ - (h)->width = le2me_16((h)->width); \ - (h)->height = le2me_16((h)->height); \ - (h)->vRes = le2me_32((h)->vRes); \ - (h)->hRes = le2me_32((h)->hRes); \ - (h)->dataSize = le2me_32((h)->dataSize); \ - (h)->frameCount = le2me_16((h)->frameCount); \ - (h)->depth = le2me_16((h)->depth); \ - (h)->clutID = le2me_16((h)->clutID); \ +static void le2me_ImageDesc(ImageDescription* h) { + h->idSize = le2me_32(h->idSize); + h->cType = le2me_32(h->cType); + h->resvd1 = le2me_32(h->resvd1); + h->resvd2 = le2me_16(h->resvd2); + h->dataRefIndex = le2me_16(h->dataRefIndex); + h->version = le2me_16(h->version); + h->revisionLevel = le2me_16(h->revisionLevel); + h->vendor = le2me_32(h->vendor); + h->temporalQuality = le2me_32(h->temporalQuality); + h->spatialQuality = le2me_32(h->spatialQuality); + h->width = le2me_16(h->width); + h->height = le2me_16(h->height); + h->vRes = le2me_32(h->vRes); + h->hRes = le2me_32(h->hRes); + h->dataSize = le2me_32(h->dataSize); + h->frameCount = le2me_16(h->frameCount); + h->depth = le2me_16(h->depth); + h->clutID = le2me_16(h->clutID); } -#define WFSIZE(wf) (sizeof(WAVEFORMATEX)+(((wf)->cbSize)?((wf)->cbSize):0)) +static int WFSIZE(WAVEFORMATEX* wf) { return sizeof(WAVEFORMATEX)+(wf->cbSize?wf->cbSize:0); } static void mpxpav64_put_st64(muxer_t *muxer,muxer_stream_t* s) { priv_mpxpav64_stream_t *privs=(priv_mpxpav64_stream_t *)s->priv; Modified: mplayerxp/libmpdemux/muxer.h =================================================================== --- mplayerxp/libmpdemux/muxer.h 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/libmpdemux/muxer.h 2012-12-28 17:03:09 UTC (rev 622) @@ -76,11 +76,11 @@ }; muxer_t *muxer_new_muxer(const char *type,const char *subtype,FILE *f); -#define muxer_new_stream(muxer,a) muxer->cont_new_stream(muxer,a) -#define muxer_write_chunk(a,b,c,d) a->muxer->cont_write_chunk(a,b,c,d) -#define muxer_write_header(muxer,info) if(muxer->cont_write_header) muxer->cont_write_header(muxer,info) -#define muxer_write_index(muxer) if(muxer->cont_write_index) muxer->cont_write_index(muxer) -#define muxer_fix_parameters(muxer) if(muxer->fix_parameters) muxer->fix_parameters(muxer) +inline muxer_stream_t* muxer_new_stream(muxer_t* muxer,int a) { return muxer->cont_new_stream(muxer,a); } +inline void muxer_write_chunk(muxer_stream_t* a,size_t b,unsigned c,float d) { a->muxer->cont_write_chunk(a,b,c,d); } +inline void muxer_write_header(muxer_t* muxer,Demuxer* info) { if(muxer->cont_write_header) muxer->cont_write_header(muxer,info); } +inline void muxer_write_index(muxer_t* muxer) { if(muxer->cont_write_index) muxer->cont_write_index(muxer); } +inline void muxer_fix_parameters(muxer_t* muxer) { if(muxer->fix_parameters) muxer->fix_parameters(muxer); } extern void muxer_init_muxer_raw(muxer_t *); extern void muxer_init_muxer_mpxp64(muxer_t *); extern int muxer_init_muxer_lavf(muxer_t *,const char *); Modified: mplayerxp/libmpdemux/stheader.cpp =================================================================== --- mplayerxp/libmpdemux/stheader.cpp 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/libmpdemux/stheader.cpp 2012-12-28 17:03:09 UTC (rev 622) @@ -33,7 +33,7 @@ } /* biCompression constant */ -#define BI_RGB 0L +static const int BI_RGB=0L; static mp_mpeg_header_t picture; static int telecine=0; Modified: mplayerxp/libmpdemux/sub_cc.cpp =================================================================== --- mplayerxp/libmpdemux/sub_cc.cpp 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/libmpdemux/sub_cc.cpp 2012-12-28 17:03:09 UTC (rev 622) @@ -28,7 +28,7 @@ #include "libvo2/video_out.h" #include "libvo2/sub.h" -#define CC_MAX_LINE_LENGTH 64 +static const int CC_MAX_LINE_LENGTH=64; static char chartbl[128]; @@ -39,8 +39,10 @@ static int inited=0; -#define CC_ROLLON 1 -#define CC_ROLLUP 2 +enum { + CC_ROLLON=1, + CC_ROLLUP=2 +}; static int cc_mode=CC_ROLLON; static int cc_lines=4; ///< number of visible rows in CC roll-up mode, not used in CC roll-on mode Modified: mplayerxp/libmpdemux/sub_ty.cpp =================================================================== --- mplayerxp/libmpdemux/sub_ty.cpp 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/libmpdemux/sub_ty.cpp 2012-12-28 17:03:09 UTC (rev 622) @@ -25,8 +25,10 @@ extern int sub_justify; -#define TY_TEXT_MODE ( 1 << 0 ) -#define TY_OSD_MODE ( 1 << 1 ) +enum { + TY_TEXT_MODE=( 1 << 0 ), + TY_OSD_MODE =( 1 << 1 ) +}; static int TY_OSD_flags = TY_TEXT_MODE | TY_OSD_MODE; static int TY_OSD_debug = 0; @@ -34,13 +36,13 @@ // =========================================================================== // Closed Caption Decoding and OSD Presentation // =========================================================================== -#define TY_CCNONE ( -3 ) -#define TY_CCTEXTMODE ( -2 ) -#define TY_CCPOPUPNB ( -1 ) -#define TY_CCPOPUP ( 0 ) -#define TY_CCPAINTON ( 1 ) +static const int TY_CCNONE =( -3 ); +static const int TY_CCTEXTMODE =( -2 ); +static const int TY_CCPOPUPNB =( -1 ); +static const int TY_CCPOPUP =( 0 ); +static const int TY_CCPAINTON =( 1 ); -#define TY_CC_MAX_X ( 45 ) +static const int TY_CC_MAX_X =( 45 ); static int TY_CC_CUR_X; static int TY_CC_CUR_Y; @@ -182,6 +184,7 @@ // char specialchar[] = { '®', '°', '½', '¿', '*', '¢', '£', 14, 'à', ' ', 'è', 'â', 'ê', 'î', 'ô', 'û' }; +#define CURRENT ((b1&0x08)>>3) static int ty_CCdecode( char b1, char b2 ) { int x; @@ -201,7 +204,6 @@ } else if ( ( b1 & 0x10 ) && ( b2 > 0x1F ) && ( data != CC_last ) ) { -#define CURRENT ( ( b1 & 0x08 ) >> 3 ) if ( CC_mode != CURRENT && TY_CC_stat != TY_CCNONE ) { @@ -465,13 +467,12 @@ // =========================================================================== // Extended Data Service Decoding and OSD Presentation // =========================================================================== -#define XDS_BUFFER_LENGTH ( 16 ) -#define XDS_DISPLAY_FRAMES ( 120 ) +static const int XDS_BUFFER_LENGTH=( 16 ); +static const int XDS_DISPLAY_FRAMES=( 120 ); static char *ty_XDS_Display[ XDS_BUFFER_LENGTH ]; static int ty_XDSAddLine = -1; static int ty_XDSDisplayCount = -1; - static void ty_AddXDSToDisplay( const char *format, ... ) { char line[ 80 ]; Modified: mplayerxp/libmpdemux/yuv4mpeg_intern.h =================================================================== --- mplayerxp/libmpdemux/yuv4mpeg_intern.h 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/libmpdemux/yuv4mpeg_intern.h 2012-12-28 17:03:09 UTC (rev 622) @@ -23,12 +23,12 @@ #define __YUV4MPEG_INTERN_H__ -#define Y4M_MAGIC "YUV4MPEG2" -#define Y4M_FRAME_MAGIC "FRAME" +static const char* Y4M_MAGIC="YUV4MPEG2"; +static const char* Y4M_FRAME_MAGIC="FRAME"; -#define Y4M_DELIM " " /* single-character(space) separating tagged fields */ +static const char* Y4M_DELIM=" "; /* single-character(space) separating tagged fields */ -#define Y4M_LINE_MAX 256 /* max number of characters in a header line +static const int Y4M_LINE_MAX=256; /* max number of characters in a header line (including the '\n', but not the '\0') */ Modified: mplayerxp/libmpstream2/cdd.h =================================================================== --- mplayerxp/libmpstream2/cdd.h 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/libmpstream2/cdd.h 2012-12-28 17:03:09 UTC (rev 622) @@ -13,7 +13,7 @@ std::string cddb_hello; unsigned long disc_id; unsigned int tracks; - char* cache_dir; + std::string cache_dir; const char* freedb_server; int freedb_proto_level; int anonymous; Modified: mplayerxp/libmpstream2/cddb.cpp =================================================================== --- mplayerxp/libmpstream2/cddb.cpp 2012-12-28 14:18:34 UTC (rev 621) +++ mplayerxp/libmpstream2/cddb.cpp 2012-12-28 17:03:09 UTC (rev 622) @@ -51,8 +51,8 @@ namespace mpxp { -#define DEFAULT_FREEDB_SERVER "freedb.freedb.org" -#define DEFAULT_CACHE_DIR "/.cddb/" +static const char* DEFAULT_FREEDB_SERVER="freedb.freedb.org"; +static const char* DEFAULT_CACHE_DIR ="/.cddb/"; static cd_toc_t cdtoc[100]; @@ -193,9 +193,9 @@ int file_fd, ret; size_t file_size; - if( cddb_data==NULL || cddb_data->cache_dir==NULL ) return -1; + if( cddb_data==NULL || cddb_data->cache_dir.empty()) return -1; - sprintf( file_name, "%s%08lx", cddb_data->cache_dir, cddb_data->disc_id); + sprintf( file_name, "%s%08lx", cddb_data->cache_dir.c_str(), cddb_data->disc_id); file_fd = ::open(file_name, O_RDONLY); if( file_fd<0 ) { @@ -233,9 +233,9 @@ int file_fd; int wrote=0; - if( cddb_data==NULL || cddb_data->cache_dir==NULL ) return -1; + if( cddb_data==NULL || cddb_data->cache_dir.empty... [truncated message content] |
From: <nic...@us...> - 2012-12-28 14:18:42
|
Revision: 621 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=621&view=rev Author: nickols_k Date: 2012-12-28 14:18:34 +0000 (Fri, 28 Dec 2012) Log Message: ----------- rename libplaytree -> libplaytree2 (TRANSACTION END) Modified Paths: -------------- mplayerxp/Makefile mplayerxp/libmpconf/cfgparser.cpp mplayerxp/libplaytree2/Makefile mplayerxp/mplayerxp.cpp mplayerxp/postproc/libmenu/menu.cpp mplayerxp/postproc/libmenu/menu_cmdlist.cpp mplayerxp/postproc/libmenu/menu_param.cpp mplayerxp/postproc/libmenu/menu_pt.cpp Modified: mplayerxp/Makefile =================================================================== --- mplayerxp/Makefile 2012-12-28 14:12:56 UTC (rev 620) +++ mplayerxp/Makefile 2012-12-28 14:18:34 UTC (rev 621) @@ -11,7 +11,7 @@ TARGET_EXE = $(PROGNAME) # these subdirectories required installation due binaries within them -SUBDIRS = libmpdemux libmpstream2 libmpsub libplaytree libmpcodecs libmpconf libao3 osdep postproc input2 nls libvo2 xmpcore +SUBDIRS = libmpdemux libmpstream2 libmpsub libplaytree2 libmpcodecs libmpconf libao3 osdep postproc input2 nls libvo2 xmpcore ifeq ($(ENABLE_WIN32LOADER),yes) SUBDIRS+=win32loader endif @@ -36,7 +36,7 @@ libmpdemux/libmpdemux.a \ libmpcodecs/libmpcodecs.a \ libmpsub/libmpsub.a \ - libplaytree/libplaytree.a \ + libplaytree2/libplaytree2.a \ libao3/libao3.a \ postproc/libpostproc.a \ input2/libinput2.a \ Modified: mplayerxp/libmpconf/cfgparser.cpp =================================================================== --- mplayerxp/libmpconf/cfgparser.cpp 2012-12-28 14:12:56 UTC (rev 620) +++ mplayerxp/libmpconf/cfgparser.cpp 2012-12-28 14:18:34 UTC (rev 621) @@ -24,7 +24,7 @@ #include "mplayerxp.h" #include "mpxp_help.h" #include "cfgparser.h" -#include "libplaytree/playtree.h" +#include "libplaytree2/playtree.h" #include "parser_msg.h" namespace mpxp { Modified: mplayerxp/libplaytree2/Makefile =================================================================== --- mplayerxp/libplaytree2/Makefile 2012-12-28 14:12:56 UTC (rev 620) +++ mplayerxp/libplaytree2/Makefile 2012-12-28 14:18:34 UTC (rev 621) @@ -1,5 +1,5 @@ -LIBNAME = libplaytree.a +LIBNAME = libplaytree2.a include ../mpxp_config.mak Modified: mplayerxp/mplayerxp.cpp =================================================================== --- mplayerxp/mplayerxp.cpp 2012-12-28 14:12:56 UTC (rev 620) +++ mplayerxp/mplayerxp.cpp 2012-12-28 14:18:34 UTC (rev 621) @@ -41,7 +41,7 @@ #include "libmpdemux/demuxer.h" #include "libmpconf/codec-cfg.h" -#include "libplaytree/playtree.h" +#include "libplaytree2/playtree.h" #include "libmpcodecs/dec_video.h" #include "libmpcodecs/dec_audio.h" Modified: mplayerxp/postproc/libmenu/menu.cpp =================================================================== --- mplayerxp/postproc/libmenu/menu.cpp 2012-12-28 14:12:56 UTC (rev 620) +++ mplayerxp/postproc/libmenu/menu.cpp 2012-12-28 14:18:34 UTC (rev 621) @@ -15,7 +15,7 @@ #include "libvo2/font_load.h" #include "libvo2/sub.h" #include "osdep/keycodes.h" -#include "libplaytree/asxparser.h" +#include "libplaytree2/asxparser.h" #include "nls/nls.h" #include "libvo2/img_format.h" Modified: mplayerxp/postproc/libmenu/menu_cmdlist.cpp =================================================================== --- mplayerxp/postproc/libmenu/menu_cmdlist.cpp 2012-12-28 14:12:56 UTC (rev 620) +++ mplayerxp/postproc/libmenu/menu_cmdlist.cpp 2012-12-28 14:18:34 UTC (rev 621) @@ -14,7 +14,7 @@ #include "libmpconf/m_option.h" #include "libmpconf/m_struct.h" -#include "libplaytree/asxparser.h" +#include "libplaytree2/asxparser.h" #include "menu.h" #include "menu_list.h" Modified: mplayerxp/postproc/libmenu/menu_param.cpp =================================================================== --- mplayerxp/postproc/libmenu/menu_param.cpp 2012-12-28 14:12:56 UTC (rev 620) +++ mplayerxp/postproc/libmenu/menu_param.cpp 2012-12-28 14:18:34 UTC (rev 621) @@ -17,7 +17,7 @@ #include "libmpconf/m_struct.h" #include "libmpconf/m_option.h" #include "libmpconf/m_property.h" -#include "libplaytree/asxparser.h" +#include "libplaytree2/asxparser.h" #include "libvo2/img_format.h" #include "xmpcore/xmp_image.h" Modified: mplayerxp/postproc/libmenu/menu_pt.cpp =================================================================== --- mplayerxp/postproc/libmenu/menu_pt.cpp 2012-12-28 14:12:56 UTC (rev 620) +++ mplayerxp/postproc/libmenu/menu_pt.cpp 2012-12-28 14:18:34 UTC (rev 621) @@ -15,7 +15,7 @@ #include "menu.h" #include "menu_list.h" -#include "libplaytree/playtree.h" +#include "libplaytree2/playtree.h" #include "input2/input.h" #include "pp_msg.h" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2012-12-28 14:13:03
|
Revision: 620 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=620&view=rev Author: nickols_k Date: 2012-12-28 14:12:56 +0000 (Fri, 28 Dec 2012) Log Message: ----------- rename libplaytree -> libplaytree2 (TRANSACTION BEGIN) Added Paths: ----------- mplayerxp/libplaytree2/ Removed Paths: ------------- mplayerxp/libplaytree/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2012-12-28 13:50:04
|
Revision: 619 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=619&view=rev Author: nickols_k Date: 2012-12-28 13:49:55 +0000 (Fri, 28 Dec 2012) Log Message: ----------- convert struct playtree_parser_t into class PlayTree_Parser Modified Paths: -------------- mplayerxp/libplaytree/asxparser.cpp mplayerxp/libplaytree/playtree.cpp mplayerxp/libplaytree/playtree.h mplayerxp/libplaytree/playtreeparser.cpp mplayerxp/libplaytree/playtreeparser.h Modified: mplayerxp/libplaytree/asxparser.cpp =================================================================== --- mplayerxp/libplaytree/asxparser.cpp 2012-12-28 12:53:00 UTC (rev 618) +++ mplayerxp/libplaytree/asxparser.cpp 2012-12-28 13:49:55 UTC (rev 619) @@ -333,7 +333,7 @@ PlayTree* pt; std::string href; Stream* stream; - play_tree_parser_t* ptp; + PlayTree_Parser* ptp; int f; UNUSED(buffer); @@ -356,9 +356,9 @@ return NULL; } mpxp_v<<"Adding playlist "<<href<<" to element entryref"<<std::endl; - ptp = play_tree_parser_new(stream,deep+1); - pt = play_tree_parser_get_play_tree(libinput,ptp); - play_tree_parser_free(ptp); + ptp = new(zeromem) PlayTree_Parser(stream,deep+1); + pt = ptp->get_play_tree(libinput); + delete ptp; delete stream; return pt; } @@ -386,7 +386,6 @@ } else mpxp_dbg2<<"Ignoring element "<<element.name()<<std::endl; } if(nref <= 0) { - pt_ref->free(1); delete pt_ref; return NULL; } @@ -446,7 +445,6 @@ } if(!list) { - pt_repeat->free(1); delete pt_repeat; return NULL; } @@ -526,7 +524,6 @@ delete &parser; if(!list) { - asx->free(1); delete asx; return NULL; } Modified: mplayerxp/libplaytree/playtree.cpp =================================================================== --- mplayerxp/libplaytree/playtree.cpp 2012-12-28 12:53:00 UTC (rev 618) +++ mplayerxp/libplaytree/playtree.cpp 2012-12-28 13:49:55 UTC (rev 619) @@ -12,13 +12,42 @@ #include "libmpstream2/stream.h" #include "libmpconf/cfgparser.h" #include "playtree.h" +#include "playtreeparser.h" #include "playtree_msg.h" namespace mpxp { +PlayTree* PlayTree::parse_playtree(libinput_t&libinput,Stream* stream) { + PlayTree_Parser* p; + PlayTree* ret; + p = new(zeromem) PlayTree_Parser(stream,0); + if(!p) return NULL; + + ret = p->get_play_tree(libinput); + delete p; + + return ret; +} + +PlayTree* PlayTree::parse_playlist_file(libinput_t&libinput,const std::string& file) { + Stream *stream; + PlayTree* ret; + int ff; + + mpxp_v<<"Parsing playlist file "<<file<<"..."<<std::endl; + ff=0; + stream = new(zeromem) Stream; + stream->open(libinput,file,&ff); + stream->type(Stream::Type_Text); + ret = PlayTree::parse_playtree(libinput,stream); + delete stream; + + return ret; +} + PlayTree::PlayTree() :entry_type(PLAY_TREE_ENTRY_NODE) {} -PlayTree::~PlayTree() {} +PlayTree::~PlayTree() { free_list(1); } void PlayTree::free(int childs) { PlayTree* iter; Modified: mplayerxp/libplaytree/playtree.h =================================================================== --- mplayerxp/libplaytree/playtree.h 2012-12-28 12:53:00 UTC (rev 618) +++ mplayerxp/libplaytree/playtree.h 2012-12-28 13:49:55 UTC (rev 619) @@ -60,7 +60,6 @@ virtual MPXP_Rc cleanup(); // If childs is true mp_free also the childs virtual void free(int childs); - virtual void free_list(int childs); virtual void set_child(PlayTree* child); virtual void set_parent(PlayTree* parent); @@ -98,6 +97,8 @@ int get_flags() const { return flags; } void set_flags(int f) { flags=f; } private: + void free_list(int childs); + PlayTree* parent; PlayTree* child; PlayTree* next; Modified: mplayerxp/libplaytree/playtreeparser.cpp =================================================================== --- mplayerxp/libplaytree/playtreeparser.cpp 2012-12-28 12:53:00 UTC (rev 618) +++ mplayerxp/libplaytree/playtreeparser.cpp 2012-12-28 13:49:55 UTC (rev 619) @@ -16,8 +16,9 @@ #include "playtreeparser.h" #include "playtree_msg.h" -static const int BUF_STEP=1024; +namespace mpxp { +static const int BUF_STEP=1024; static const char* WHITES=" \n\r\t"; static void __FASTCALL__ strstrip(char* str) { @@ -34,154 +35,133 @@ str[0] = '\0'; } -static char* __FASTCALL__ play_tree_parser_get_line(play_tree_parser_t* p) { - char *end,*line_end; - int r,resize = 0; +char* PlayTree_Parser::get_line() { + char *end,*line_end; + int r,resize = 0; - if(p->buffer == NULL) { - p->buffer = (char*)mp_malloc(BUF_STEP); - p->buffer_size = BUF_STEP; - p->iter = p->buffer; - } + if(buffer == NULL) { + buffer = new char [BUF_STEP]; + buffer_size = BUF_STEP; + iter = buffer; + } - if(p->stream->eof() && (p->buffer_end == 0 || p->iter[0] == '\0')) - return NULL; + if(stream->eof() && (buffer_end == 0 || iter[0] == '\0')) return NULL; - while(1) { + while(1) { + if(resize) { + r = iter - buffer; + buffer = (char*)mp_realloc(buffer,buffer_size+BUF_STEP); + iter = buffer + r; + buffer_size += BUF_STEP; + resize = 0; + } - if(resize) { - r = p->iter - p->buffer; - p->buffer = (char*)mp_realloc(p->buffer,p->buffer_size+BUF_STEP); - p->iter = p->buffer + r; - p->buffer_size += BUF_STEP; - resize = 0; - } + if(buffer_size - buffer_end > 1 && !stream->eof()) { + r = stream->read(buffer + buffer_end,buffer_size - buffer_end - 1); + if(r > 0) { + buffer_end += r; + buffer[buffer_end] = '\0'; + } + } - if(p->buffer_size - p->buffer_end > 1 && !p->stream->eof()) { - r = p->stream->read(p->buffer + p->buffer_end,p->buffer_size - p->buffer_end - 1); - if(r > 0) { - p->buffer_end += r; - p->buffer[p->buffer_end] = '\0'; - } - } - - end = strchr(p->iter,'\n'); - if(!end) { - if(p->stream->eof()) { - end = p->buffer + p->buffer_end; + end = strchr(iter,'\n'); + if(!end) { + if(stream->eof()) { + end = buffer + buffer_end; + break; + } + resize = 1; + continue; + } break; - } - resize = 1; - continue; } - break; - } - - line_end = (end > p->iter && *(end-1) == '\r') ? end-1 : end; - if(line_end - p->iter >= 0) - p->line = (char*)mp_realloc(p->line,line_end - p->iter+1); - else - return NULL; - if(line_end - p->iter > 0) - strncpy(p->line,p->iter,line_end - p->iter); - p->line[line_end - p->iter] = '\0'; - if(end[0] != '\0') - end++; - - if(!p->keep) { - if(end[0] != '\0') { - p->buffer_end -= end-p->iter; - memmove(p->buffer,end,p->buffer_end); - } else - p->buffer_end = 0; - p->iter = p->buffer; - } else - p->iter = end; - - return p->line; + line_end = (end > iter && *(end-1) == '\r') ? end-1 : end; + if(line_end - iter >= 0) + line = (char*)mp_realloc(line,line_end - iter+1); + else + return NULL; + if(line_end - iter > 0) + strncpy(line,iter,line_end - iter); + line[line_end - iter] = '\0'; + if(end[0] != '\0') end++; + if(!keep) { + if(end[0] != '\0') { + buffer_end -= end-iter; + memmove(buffer,end,buffer_end); + } else + buffer_end = 0; + iter = buffer; + } else iter = end; + return line; } -static void __FASTCALL__ play_tree_parser_reset(play_tree_parser_t* p) { - p->iter = p->buffer; -} +void PlayTree_Parser::reset() { iter = buffer; } -static void __FASTCALL__ play_tree_parser_stop_keeping(play_tree_parser_t* p) { - p->keep = 0; - if(p->iter && p->iter != p->buffer) { - p->buffer_end -= p->iter -p->buffer; - if(p->buffer_end) - memmove(p->buffer,p->iter,p->buffer_end); - p->iter = p->buffer; - } +void PlayTree_Parser::stop_keeping() { + keep = 0; + if(iter && iter != buffer) { + buffer_end -= iter - buffer; + if(buffer_end) memmove(buffer,iter,buffer_end); + iter = buffer; + } } +PlayTree* PlayTree_Parser::parse_asx(libinput_t& libinput) { + int comments = 0,_get_line = 1; + char* _line = NULL; -static PlayTree* parse_asx(libinput_t& libinput,play_tree_parser_t* p) { - int comments = 0,get_line = 1; - char* line = NULL; + mpxp_v<<"Trying asx..."<<std::endl; - mpxp_v<<"Trying asx..."<<std::endl; - - while(1) { - if(get_line) { - line = play_tree_parser_get_line(p); - if(!line) - return NULL; - strstrip(line); - if(line[0] == '\0') - continue; - } - if(!comments) { - if(line[0] != '<') { - mpxp_dbg2<<"First char isn't '<' but '"<<line[0]<<"'"<<std::endl; - mpxp_dbg3<<"Buffer = ["<<p->buffer<<"]"<<std::endl; - return NULL; - } else if(strncmp(line,"<!--",4) == 0) { // Comments - comments = 1; - line += 4; - if(line[0] != '\0' && strlen(line) > 0) - get_line = 0; - } else if(strncasecmp(line,"<ASX",4) == 0) // We got an asx element - break; - else // We don't get an asx - return NULL; - } else { // Comments - char* c; - c = strchr(line,'-'); - if(c) { - if (strncmp(c,"--!>",4) == 0) { // End of comments - comments = 0; - line = c+4; - if(line[0] != '\0') // There is some more data on this line : keep it - get_line = 0; - - } else { - line = c+1; // Jump the - - if(line[0] != '\0') // Some more data - get_line = 0; - else // End of line - get_line = 1; + while(1) { + if(_get_line) { + _line = get_line(); + if(!_line) return NULL; + strstrip(_line); + if(_line[0] == '\0') continue; } - } else // No - on this line (or rest of line) : get next one - get_line = 1; + if(!comments) { + if(_line[0] != '<') { + mpxp_dbg2<<"First char isn't '<' but '"<<_line[0]<<"'"<<std::endl; + mpxp_dbg3<<"Buffer = ["<<buffer<<"]"<<std::endl; + return NULL; + } else if(strncmp(_line,"<!--",4) == 0) { // Comments + comments = 1; + _line += 4; + if(_line[0] != '\0' && strlen(_line) > 0) _get_line = 0; + } else if(strncasecmp(_line,"<ASX",4) == 0) // We got an asx element + break; + else // We don't get an asx + return NULL; + } else { // Comments + char* c; + c = strchr(_line,'-'); + if(c) { + if(strncmp(c,"--!>",4) == 0) { // End of comments + comments = 0; + _line = c+4; + if(_line[0] != '\0') _get_line = 0; // There is some more data on this line : keep it + } else { + _line = c+1; // Jump the - + if(_line[0] != '\0') // Some more data + _get_line = 0; + else // End of line + _get_line = 1; + } + } else // No - on this line (or rest of line) : get next one + _get_line = 1; + } } - } - - mpxp_v<<"Detected asx format"<<std::endl; - - // We have an asx : load it in memory and parse - - while((line = play_tree_parser_get_line(p)) != NULL) - /* NOTHING */; - - mpxp_dbg3<<"Parsing asx file : ["<<p->buffer<<"]"<<std::endl; - return ASX_Parser::build_tree(libinput,p->buffer,p->deep); + mpxp_v<<"Detected asx format"<<std::endl; + // We have an asx : load it in memory and parse + while((_line = get_line()) != NULL)/* NOTHING */; + mpxp_dbg3<<"Parsing asx file : ["<<buffer<<"]"<<std::endl; + return ASX_Parser::build_tree(libinput,buffer,deep); } -static char* __FASTCALL__ pls_entry_get_value(char* line) { +static char* __FASTCALL__ pls_entry_get_value(const char* line) { char* i; - i = strchr(line,'='); + i = strchr(const_cast<char*>(line),'='); if(!i || i[1] == '\0') return NULL; else @@ -194,7 +174,7 @@ char* length; }; -static int __FASTCALL__ pls_read_entry(char* line,pls_entry_t** _e,int* _max_entry,char** val) { +static int __FASTCALL__ pls_read_entry(const char* line,pls_entry_t** _e,int* _max_entry,char** val) { int num,max_entry = (*_max_entry); pls_entry_t* e = (*_e); char* v; @@ -224,199 +204,134 @@ } -PlayTree* -parse_pls(play_tree_parser_t* p) { - char *line,*v; - pls_entry_t* entries = NULL; - int n_entries = 0,max_entry=0,num; - PlayTree *list = NULL, *entry = NULL; +PlayTree* PlayTree_Parser::parse_pls() { + char *_line,*v; + pls_entry_t* entries = NULL; + int n_entries = 0,max_entry=0,num; + PlayTree *list = NULL, *entry = NULL; - mpxp_v<<"Trying winamp playlist..."<<std::endl; - line = play_tree_parser_get_line(p); - strstrip(line); - if(strcasecmp(line,"[playlist]")) - return NULL; - mpxp_v<<"Detected winamp playlist format"<<std::endl; - play_tree_parser_stop_keeping(p); - line = play_tree_parser_get_line(p); - if(!line) - return NULL; - strstrip(line); - if(strncasecmp(line,"NumberOfEntries",15) == 0) { - v = pls_entry_get_value(line); - n_entries = atoi(v); - if(n_entries < 0) - mpxp_dbg2<<"Invalid number of entries : very funny !!!"<<std::endl; - else - mpxp_dbg2<<"Playlist claim to have "<<n_entries<<" entries. Let's see"<<std::endl; - line = play_tree_parser_get_line(p); - } + mpxp_v<<"Trying winamp playlist..."<<std::endl; + _line = get_line(); + strstrip(_line); + if(strcasecmp(_line,"[playlist]")) return NULL; + mpxp_v<<"Detected winamp playlist format"<<std::endl; + stop_keeping(); + _line = get_line(); + if(!_line) return NULL; + strstrip(_line); + if(strncasecmp(_line,"NumberOfEntries",15) == 0) { + v = pls_entry_get_value(_line); + n_entries = atoi(v); + if(n_entries < 0) mpxp_dbg2<<"Invalid number of entries : very funny !!!"<<std::endl; + else mpxp_dbg2<<"Playlist claim to have "<<n_entries<<" entries. Let's see"<<std::endl; + _line = get_line(); + } - while(line) { - strstrip(line); - if(line[0] == '\0') { - line = play_tree_parser_get_line(p); - continue; + while(_line) { + strstrip(_line); + if(_line[0] == '\0') { + _line = get_line(); + continue; + } + if(strncasecmp(_line,"File",4) == 0) { + num = pls_read_entry(_line+4,&entries,&max_entry,&v); + if(num < 0) mpxp_err<<"No value in entry "<<_line<<std::endl; + else entries[num-1].file = mp_strdup(v); + } else if(strncasecmp(_line,"Title",5) == 0) { + num = pls_read_entry(_line+5,&entries,&max_entry,&v); + if(num < 0) mpxp_err<<"No value in entry "<<_line<<std::endl; + else entries[num-1].title = mp_strdup(v); + } else if(strncasecmp(_line,"Length",6) == 0) { + num = pls_read_entry(_line+6,&entries,&max_entry,&v); + if(num < 0) mpxp_err<<"No value in entry "<<_line<<std::endl; + else entries[num-1].length = mp_strdup(v); + } else mpxp_warn<<"Unknow entry type "<<_line<<std::endl; + _line = get_line(); } - if(strncasecmp(line,"File",4) == 0) { - num = pls_read_entry(line+4,&entries,&max_entry,&v); - if(num < 0) - mpxp_err<<"No value in entry "<<line<<std::endl; - else - entries[num-1].file = mp_strdup(v); - } else if(strncasecmp(line,"Title",5) == 0) { - num = pls_read_entry(line+5,&entries,&max_entry,&v); - if(num < 0) - mpxp_err<<"No value in entry "<<line<<std::endl; - else - entries[num-1].title = mp_strdup(v); - } else if(strncasecmp(line,"Length",6) == 0) { - num = pls_read_entry(line+6,&entries,&max_entry,&v); - if(num < 0) - mpxp_err<<"No value in entry "<<line<<std::endl; - else - entries[num-1].length = mp_strdup(v); - } else - mpxp_warn<<"Unknow entry type "<<line<<std::endl; - line = play_tree_parser_get_line(p); - } - for(num = 0; num < max_entry ; num++) { - if(entries[num].file == NULL) - mpxp_err<<"Entry "<<(num+1)<<" don't have a file !!!!"<<std::endl; - else { - mpxp_dbg2<<"Adding entry "<<entries[num].file<<std::endl; - entry = new(zeromem) PlayTree; - entry->add_file(entries[num].file); - delete entries[num].file; - if(list) - list->append_entry(entry); - else - list = entry; + for(num = 0; num < max_entry ; num++) { + if(entries[num].file == NULL) + mpxp_err<<"Entry "<<(num+1)<<" don't have a file !!!!"<<std::endl; + else { + mpxp_dbg2<<"Adding entry "<<entries[num].file<<std::endl; + entry = new(zeromem) PlayTree; + entry->add_file(entries[num].file); + delete entries[num].file; + if(list) list->append_entry(entry); + else list = entry; + } + if(entries[num].title) { + // When we have info in playtree we add this info + delete entries[num].title; + } + if(entries[num].length) { + // When we have info in playtree we add this info + delete entries[num].length; + } } - if(entries[num].title) { - // When we have info in playtree we add this info - delete entries[num].title; - } - if(entries[num].length) { - // When we have info in playtree we add this info - delete entries[num].length; - } - } + delete entries; - delete entries; - - entry = new(zeromem) PlayTree; - entry->set_child(list); - return entry; + entry = new(zeromem) PlayTree; + entry->set_child(list); + return entry; } -PlayTree* -parse_textplain(play_tree_parser_t* p) { - char* line; - PlayTree *list = NULL, *entry = NULL; +PlayTree* PlayTree_Parser::parse_textplain() { + char* _line; + PlayTree *list = NULL, *entry = NULL; - mpxp_v<<"Trying plaintext..."<<std::endl; - play_tree_parser_stop_keeping(p); + mpxp_v<<"Trying plaintext..."<<std::endl; + stop_keeping(); - while((line = play_tree_parser_get_line(p)) != NULL) { - strstrip(line); - if(line[0] == '\0') - continue; + while((_line = get_line()) != NULL) { + strstrip(_line); + if(_line[0] == '\0') continue; + entry = new(zeromem) PlayTree; + entry->add_file(_line); + if(!list) list = entry; + else list->append_entry(entry); + } + if(!list) return NULL; entry = new(zeromem) PlayTree; - entry->add_file(line); - if(!list) - list = entry; - else - list->append_entry(entry); - } - - if(!list) return NULL; - entry = new(zeromem) PlayTree; - entry->set_child(list); - return entry; + entry->set_child(list); + return entry; } -namespace mpxp { -PlayTree* PlayTree::parse_playtree(libinput_t&libinput,Stream* stream) { - play_tree_parser_t* p; - PlayTree* ret; - - p = play_tree_parser_new(stream,0); - if(!p) - return NULL; - - ret = play_tree_parser_get_play_tree(libinput,p); - play_tree_parser_free(p); - - return ret; +PlayTree_Parser::PlayTree_Parser(Stream* _stream,int _deep) + :stream(_stream), + deep(_deep) +{ + keep = 1; } -PlayTree* PlayTree::parse_playlist_file(libinput_t&libinput,const std::string& file) { - Stream *stream; - PlayTree* ret; - int ff; - - mpxp_v<<"Parsing playlist file "<<file<<"..."<<std::endl; - ff=0; - stream = new(zeromem) Stream; - stream->open(libinput,file,&ff); - stream->type(Stream::Type_Text); - ret = PlayTree::parse_playtree(libinput,stream); - delete stream; - - return ret; +PlayTree_Parser::~PlayTree_Parser() { + if(buffer) delete buffer; + if(line) delete line; } -} // namespace mpxp -play_tree_parser_t* play_tree_parser_new(Stream* stream,int deep) { - play_tree_parser_t* p; +PlayTree* PlayTree_Parser::get_play_tree(libinput_t& libinput) { + PlayTree* tree = NULL; - p = (play_tree_parser_t*)mp_calloc(1,sizeof(play_tree_parser_t)); - if(!p) - return NULL; - p->stream = stream; - p->deep = deep; - p->keep = 1; + while(get_line() != NULL) { + reset(); - return p; + tree = parse_asx(libinput); + if(tree) break; + reset(); -} + tree = parse_pls(); + if(tree) break; + reset(); -void -play_tree_parser_free(play_tree_parser_t* p) { + // Here come the others formats ( textplain must stay the last one ) + tree = parse_textplain(); + if(tree) break; + break; + } - if(p->buffer) delete p->buffer; - if(p->line) delete p->line; - delete p; + if(tree) mpxp_v<<"Playlist succefully parsed"<<std::endl; + else mpxp_err<<"Error while parsing playlist"<<std::endl; + if(tree->cleanup()!=MPXP_Ok) mpxp_warn<<"Warning empty playlist"<<std::endl; + return tree; } - -PlayTree* -play_tree_parser_get_play_tree(libinput_t& libinput,play_tree_parser_t* p) { - PlayTree* tree = NULL; - - while(play_tree_parser_get_line(p) != NULL) { - play_tree_parser_reset(p); - - tree = parse_asx(libinput,p); - if(tree) break; - play_tree_parser_reset(p); - - tree = parse_pls(p); - if(tree) break; - play_tree_parser_reset(p); - - // Here come the others formats ( textplain must stay the last one ) - tree = parse_textplain(p); - if(tree) break; - break; - } - - if(tree) - mpxp_v<<"Playlist succefully parsed"<<std::endl; - else mpxp_err<<"Error while parsing playlist"<<std::endl; - - if(tree->cleanup()!=MPXP_Ok) mpxp_warn<<"Warning empty playlist"<<std::endl; - - return tree; -} +} // namespace mpxp Modified: mplayerxp/libplaytree/playtreeparser.h =================================================================== --- mplayerxp/libplaytree/playtreeparser.h 2012-12-28 12:53:00 UTC (rev 618) +++ mplayerxp/libplaytree/playtreeparser.h 2012-12-28 13:49:55 UTC (rev 619) @@ -1,19 +1,32 @@ #ifndef __PLAYTREEPARSER_H #define __PLAYTREEPARSER_H +#include "osdep/mplib.h" #include "playtree.h" -struct play_tree_parser_t { - Stream* stream; - char *buffer,*iter,*line; - int buffer_size , buffer_end; - int deep,keep; -}; +namespace mpxp { + class PlayTree_Parser : public Opaque { + public: + PlayTree_Parser(Stream* _stream,int _deep); + virtual ~PlayTree_Parser(); -play_tree_parser_t* play_tree_parser_new(Stream * stream,int deep); + virtual PlayTree* get_play_tree(libinput_t&libinput); + private: + void reset(); + char* get_line(); + void stop_keeping(); + PlayTree* parse_asx(libinput_t& libinput); + PlayTree* parse_pls(); + PlayTree* parse_textplain(); -void play_tree_parser_free(play_tree_parser_t* p); - -PlayTree* play_tree_parser_get_play_tree(libinput_t&libinput,play_tree_parser_t* p); - + Stream* stream; + char* buffer; + char* iter; + char* line; + int buffer_size; + int buffer_end; + int deep; + int keep; + }; +}// namespace mpxp #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2012-12-28 12:53:09
|
Revision: 618 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=618&view=rev Author: nickols_k Date: 2012-12-28 12:53:00 +0000 (Fri, 28 Dec 2012) Log Message: ----------- cleanups Modified Paths: -------------- mplayerxp/libmpconf/cfgparser.cpp mplayerxp/libmpconf/cfgparser.h mplayerxp/libplaytree/playtree.cpp mplayerxp/libplaytree/playtree.h mplayerxp/mplayerxp.cpp mplayerxp/mplayerxp.h mplayerxp/postproc/libmenu/menu_pt.cpp Modified: mplayerxp/libmpconf/cfgparser.cpp =================================================================== --- mplayerxp/libmpconf/cfgparser.cpp 2012-12-28 12:22:38 UTC (rev 617) +++ mplayerxp/libmpconf/cfgparser.cpp 2012-12-28 12:53:00 UTC (rev 618) @@ -271,14 +271,9 @@ out: if(ret >= 0 && ! is_running() && !is_global() && ! (conf[i].flags & CONF_GLOBAL) && conf[i].type != CONF_TYPE_SUBCONFIG ) { PlayTree* dest = last_entry ? last_entry : last_parent; - std::string o; - if(sub_conf) o=std::string(sub_conf)+":"+opt; - else o=opt; - if(ret == 0) - dest->set_param(o,""); - else if(ret > 0) - dest->set_param(o,param); + if(ret == 0) dest->set_param(opt,""); + else if(ret > 0) dest->set_param(opt,param); } return ret; err_missing_param: @@ -395,13 +390,13 @@ line_pos = 0; /* skip whitespaces */ - while (isspace(line[line_pos])) ++line_pos; + while (::isspace(line[line_pos])) ++line_pos; /* EOL / comment */ if (line[line_pos] == '\0' || line[line_pos] == '#') continue; /* read option. */ - for (opt_pos = 0; isprint(line[line_pos]) && + for (opt_pos = 0; ::isprint(line[line_pos]) && line[line_pos] != ' ' && line[line_pos] != '#' && line[line_pos] != '='; /* NOTHING */) { @@ -424,7 +419,7 @@ opt[opt_pos] = '\0'; /* skip whitespaces */ - while (isspace(line[line_pos])) ++line_pos; + while (::isspace(line[line_pos])) ++line_pos; /* check '=' */ if (line[line_pos++] != '=') { @@ -436,7 +431,7 @@ } /* whitespaces... */ - while (isspace(line[line_pos])) ++line_pos; + while (::isspace(line[line_pos])) ++line_pos; /* read the parameter */ if (line[line_pos] == '"' || line[line_pos] == '\'') { @@ -454,7 +449,7 @@ } line_pos++; /* skip the closing " or ' */ } else { - for (param_pos = 0; isprint(line[line_pos]) && !isspace(line[line_pos]) + for (param_pos = 0; ::isprint(line[line_pos]) && !::isspace(line[line_pos]) && line[line_pos] != '#'; /* NOTHING */) { param[param_pos++] = line[line_pos++]; if (param_pos >= MAX_PARAM_LEN) { @@ -479,7 +474,7 @@ /* now, check if we have some more chars on the line */ /* whitespace... */ - while (isspace(line[line_pos])) ++line_pos; + while (::isspace(line[line_pos])) ++line_pos; /* EOL / comment */ if (line[line_pos] != '\0' && line[line_pos] != '#') { @@ -897,7 +892,7 @@ ::write(conffile_fd, default_config, strlen(default_config)); ::close(conffile_fd); } - if (parse_config_file(conffile) != MPXP_Ok) exit(1); + if (parse_config_file(conffile) != MPXP_Ok) ::exit(1); } } Modified: mplayerxp/libmpconf/cfgparser.h =================================================================== --- mplayerxp/libmpconf/cfgparser.h 2012-12-28 12:22:38 UTC (rev 617) +++ mplayerxp/libmpconf/cfgparser.h 2012-12-28 12:53:00 UTC (rev 618) @@ -132,7 +132,6 @@ std::vector<const mpxp_option_t*> opt_list; mode_e parser_mode; flags_e flags; - const char* sub_conf; // When we save a subconfig PlayTree* pt; // play tree we use for playlist option, etc PlayTree* last_entry; // last added entry PlayTree* last_parent; // if last_entry is NULL we must create child of this Modified: mplayerxp/libplaytree/playtree.cpp =================================================================== --- mplayerxp/libplaytree/playtree.cpp 2012-12-28 12:22:38 UTC (rev 617) +++ mplayerxp/libplaytree/playtree.cpp 2012-12-28 12:53:00 UTC (rev 618) @@ -319,14 +319,14 @@ return NULL; } -_PlayTree_Iter::_PlayTree_Iter(PlayTree* pt,M_Config& _config) +PlayTree_Iter::PlayTree_Iter(PlayTree* pt,M_Config& _config) :root(pt), tree(NULL), config(_config) { if(pt->get_parent()) loop = pt->get_parent()->get_loop(); } -_PlayTree_Iter::_PlayTree_Iter(const _PlayTree_Iter& old) +PlayTree_Iter::PlayTree_Iter(const PlayTree_Iter& old) :root(old.root), tree(old.tree), config(old.config), @@ -335,9 +335,9 @@ num_files(old.num_files), mode(old.mode) {} -_PlayTree_Iter::~_PlayTree_Iter() {} +PlayTree_Iter::~PlayTree_Iter() {} -void _PlayTree_Iter::push_params() { +void PlayTree_Iter::push_params() { PlayTree* pt; pt = tree; @@ -354,7 +354,7 @@ return; } -int _PlayTree_Iter::step(int d,int with_nodes) { +int PlayTree_Iter::step(int d,int with_nodes) { PlayTree* pt; int rnd; @@ -430,7 +430,7 @@ return PLAY_TREE_ITER_ENTRY; } -int _PlayTree_Iter::up_step(int d,int with_nodes) { +int PlayTree_Iter::up_step(int d,int with_nodes) { file = -1; if(tree->get_parent() == root->get_parent()) return PLAY_TREE_ITER_END; @@ -441,7 +441,7 @@ return step(d,with_nodes); } -int _PlayTree_Iter::down_step(int d,int with_nodes) { +int PlayTree_Iter::down_step(int d,int with_nodes) { file = -1; // Push subtree params @@ -459,7 +459,7 @@ return step(0,with_nodes); } -std::string _PlayTree_Iter::get_file(int d) { +std::string PlayTree_Iter::get_file(int d) { std::string entry; if(tree->get_files().empty()) return ""; @@ -506,79 +506,3 @@ } } // namespace mpxp - -void pt_iter_destroy(_PlayTree_Iter** iter) -{ - if (iter && *iter) - { - delete *iter; - iter=NULL; - } -} - -std::string pt_iter_get_file(_PlayTree_Iter* iter, int d) -{ - int i=0; - std::string r; - - if (iter==NULL) - return NULL; - - r = iter->get_file(d); - - while (r.empty() && d!=0) - { - if (iter->step(d,0) != PLAY_TREE_ITER_ENTRY) break; - r=iter->get_file(d); - i++; - } - - return r; -} - -void pt_iter_insert_entry(_PlayTree_Iter* iter, PlayTree* entry) -{ - PlayTree *pt = iter->get_tree(); - - pt->insert_entry(entry); - entry->set_params_from(*pt); -} - -void pt_iter_replace_entry(_PlayTree_Iter* iter, PlayTree* entry) -{ - PlayTree *pt = iter->get_tree(); - - pt_iter_insert_entry(iter, entry); - pt->remove(1, 1); - iter->set_tree(entry); -} - -//Add a new file as a new entry -void pt_add_file(PlayTree** ppt,const std::string& filename) -{ - PlayTree *pt = *ppt, *entry = new(zeromem) PlayTree; - - entry->add_file(filename); - if (pt) - pt->append_entry(entry); - else - { - pt=entry; - *ppt=pt; - } - entry->set_params_from(*pt); -} - -void pt_add_gui_file(PlayTree** ppt,const std::string& path,const std::string& file) -{ - std::string wholename; - - wholename=path+"/"+file; - pt_add_file(ppt, wholename); -} - -void pt_iter_goto_head(_PlayTree_Iter* iter) -{ - iter->reset_tree(); - iter->step(0, 0); -} Modified: mplayerxp/libplaytree/playtree.h =================================================================== --- mplayerxp/libplaytree/playtree.h 2012-12-28 12:22:38 UTC (rev 617) +++ mplayerxp/libplaytree/playtree.h 2012-12-28 12:53:00 UTC (rev 618) @@ -110,11 +110,11 @@ int flags; }; - struct _PlayTree_Iter : public Opaque { + struct PlayTree_Iter : public Opaque { public: - _PlayTree_Iter(PlayTree* parent,M_Config& config); - _PlayTree_Iter(const _PlayTree_Iter& old); - virtual ~_PlayTree_Iter(); + PlayTree_Iter(PlayTree* parent,M_Config& config); + PlayTree_Iter(const PlayTree_Iter& old); + virtual ~PlayTree_Iter(); // d is the direction : d > 0 == next , d < 0 == prev // with_node : TRUE == stop on nodes with childs, FALSE == go directly to the next child @@ -141,46 +141,7 @@ int num_files; int mode; - std::stack<int> status_stack; + std::stack<int> status_stack; }; } // namespace mpxp - -/// \defgroup PtAPI Playtree highlevel API -/// \ingroup Playtree -/// Highlevel API with pt-suffix to different from low-level API -/// by Fabian Franz (mp...@fa...). -///@{ - -/// Frees the iter. -void pt_iter_destroy(_PlayTree_Iter** iter); - -/// Gets the next available file in the direction (d=-1 || d=+1). -std::string pt_iter_get_file(_PlayTree_Iter* iter, int d); - -// Two Macros that implement forward and backward direction. -static inline std::string pt_iter_get_next_file(_PlayTree_Iter* iter) { return pt_iter_get_file(iter, 1); } -static inline std::string pt_iter_get_prev_file(_PlayTree_Iter* iter) { return pt_iter_get_file(iter, -1); } - -/// Inserts entry into the playtree. -void pt_iter_insert_entry(_PlayTree_Iter* iter, PlayTree* entry); - -/// Replaces current entry in playtree with entry by doing insert and remove. -void pt_iter_replace_entry(_PlayTree_Iter* iter, PlayTree* entry); - -/// Adds a new file to the playtree, if it is not valid it is created. -void pt_add_file(PlayTree** ppt,const std::string& filename); - -/// \brief Performs a convert to playtree-syntax, by concat path/file -/// and performs pt_add_file -void pt_add_gui_file(PlayTree** ppt,const std::string& path,const std::string& file); - -// Two macros to use only the iter and not the other things. -static inline void pt_iter_add_file(_PlayTree_Iter* iter, const std::string& filename) { PlayTree* tree=iter->get_tree(); pt_add_file(&tree, filename); } -static inline void pt_iter_add_gui_file(_PlayTree_Iter* iter,const std::string& path,const std::string& name) { PlayTree* tree=iter->get_tree(); pt_add_gui_file(&tree, path, name); } - -/// Resets the iter and goes back to head. -void pt_iter_goto_head(_PlayTree_Iter* iter); - -///@} - #endif Modified: mplayerxp/mplayerxp.cpp =================================================================== --- mplayerxp/mplayerxp.cpp 2012-12-28 12:22:38 UTC (rev 617) +++ mplayerxp/mplayerxp.cpp 2012-12-28 12:53:00 UTC (rev 618) @@ -156,7 +156,7 @@ int osd_function; PlayTree* playtree; // for multifile support: - _PlayTree_Iter* playtree_iter; + PlayTree_Iter* playtree_iter; private: Opaque unusable; Demuxer* _demuxer; @@ -1395,7 +1395,7 @@ exit_player(MSGTR_Exit_quit); case MP_CMD_PLAY_TREE_STEP : { int n = cmd->args[0].v.i > 0 ? 1 : -1; - _PlayTree_Iter* it = new _PlayTree_Iter(*playtree_iter); + PlayTree_Iter* it = new PlayTree_Iter(*playtree_iter); if(it->step(n,0) == PLAY_TREE_ITER_ENTRY) eof = (n > 0) ? PT_NEXT_ENTRY : PT_PREV_ENTRY; @@ -1403,7 +1403,7 @@ } break; case MP_CMD_PLAY_TREE_UP_STEP : { int n = cmd->args[0].v.i > 0 ? 1 : -1; - _PlayTree_Iter* it = new _PlayTree_Iter(*playtree_iter); + PlayTree_Iter* it = new PlayTree_Iter(*playtree_iter); if(it->up_step(n,0) == PLAY_TREE_ITER_ENTRY) eof = (n > 0) ? PT_UP_NEXT : PT_UP_PREV; delete it; @@ -1564,7 +1564,7 @@ return eof; } -_PlayTree_Iter* mpxp_get_playtree_iter() { return mpxp_context().engine().MPXPSys->playtree_iter; } +PlayTree_Iter& mpxp_get_playtree_iter() { return *(mpxp_context().engine().MPXPSys->playtree_iter); } /******************************************\ * MAIN MPLAYERXP FUNCTION !!! * \******************************************/ @@ -1633,7 +1633,7 @@ // MPXPSys.playtree = play_tree_cleanup(MPXPSys.playtree); if(MPXPSys.playtree) { - MPXPSys.playtree_iter = new _PlayTree_Iter(MPXPSys.playtree,m_config); + MPXPSys.playtree_iter = new PlayTree_Iter(MPXPSys.playtree,m_config); if(MPXPSys.playtree_iter) { if(MPXPSys.playtree_iter->step(0,0) != PLAY_TREE_ITER_ENTRY) { delete MPXPSys.playtree_iter; Modified: mplayerxp/mplayerxp.h =================================================================== --- mplayerxp/mplayerxp.h 2012-12-28 12:22:38 UTC (rev 617) +++ mplayerxp/mplayerxp.h 2012-12-28 12:53:00 UTC (rev 618) @@ -19,7 +19,7 @@ struct video_decoder_t; namespace mpxp { class M_Config; - struct _PlayTree_Iter; + struct PlayTree_Iter; /* List of all modules which require protection by pin-code */ enum { Module_Stream=0, @@ -194,7 +194,7 @@ MPXPContext& mpxp_context(); - _PlayTree_Iter* mpxp_get_playtree_iter(); + PlayTree_Iter& mpxp_get_playtree_iter(); unsigned get_number_cpu(void); void show_help(void); Modified: mplayerxp/postproc/libmenu/menu_pt.cpp =================================================================== --- mplayerxp/postproc/libmenu/menu_pt.cpp 2012-12-28 12:22:38 UTC (rev 617) +++ mplayerxp/postproc/libmenu/menu_pt.cpp 2012-12-28 12:53:00 UTC (rev 618) @@ -59,22 +59,22 @@ char str[15]; PlayTree* i; mp_cmd_t* c; - _PlayTree_Iter* _playtree_iter =mpxp_get_playtree_iter(); + PlayTree_Iter& pt_iter =mpxp_get_playtree_iter(); - if(_playtree_iter->get_tree() == mpriv->p.current->pt) + if(pt_iter.get_tree() == mpriv->p.current->pt) break; - if(_playtree_iter->get_tree()->get_parent() && mpriv->p.current->pt == _playtree_iter->get_tree()->get_parent()) + if(pt_iter.get_tree()->get_parent() && mpriv->p.current->pt == pt_iter.get_tree()->get_parent()) snprintf(str,15,"pt_up_step 1"); else { - for(i = _playtree_iter->get_tree()->get_next(); i != NULL ; i = i->get_next()) { + for(i = pt_iter.get_tree()->get_next(); i != NULL ; i = i->get_next()) { if(i == mpriv->p.current->pt) break; d++; } if(i == NULL) { d = -1; - for(i = _playtree_iter->get_tree()->get_prev(); i != NULL ; i = i->get_prev()) { + for(i = pt_iter.get_tree()->get_prev(); i != NULL ; i = i->get_prev()) { if(i == mpriv->p.current->pt) break; d--; @@ -108,7 +108,7 @@ static int op(menu_t* menu,const char* args) { PlayTree* i; list_entry_t* e; - _PlayTree_Iter* _playtree_iter = mpxp_get_playtree_iter(); + PlayTree_Iter& pt_iter = mpxp_get_playtree_iter(); args = NULL; // Warning kill @@ -121,14 +121,14 @@ mpriv->p.title = mpriv->title; - if(_playtree_iter->get_tree()->get_parent() != _playtree_iter->get_root()) { + if(pt_iter.get_tree()->get_parent() != pt_iter.get_root()) { e = new(zeromem) list_entry_t; e->p.txt = ".."; - e->pt = _playtree_iter->get_tree()->get_parent(); + e->pt = pt_iter.get_tree()->get_parent(); menu_list_add_entry(menu,e); } - for(i = _playtree_iter->get_tree() ; i->get_prev() != NULL ; i = i->get_prev()) + for(i = pt_iter.get_tree() ; i->get_prev() != NULL ; i = i->get_prev()) /* NOP */; for( ; i != NULL ; i = i->get_next() ) { e = new(zeromem) list_entry_t; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2012-12-28 12:22:49
|
Revision: 617 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=617&view=rev Author: nickols_k Date: 2012-12-28 12:22:38 +0000 (Fri, 28 Dec 2012) Log Message: ----------- convert struct m_config_t into class M_Config + simplifications (remove meaningless config_save_t - that fix multiple problems Modified Paths: -------------- mplayerxp/input2/input.cpp mplayerxp/libmpcodecs/ad.cpp mplayerxp/libmpcodecs/vd.cpp mplayerxp/libmpconf/cfgparser.cpp mplayerxp/libmpconf/cfgparser.h mplayerxp/libmpdemux/demuxer.cpp mplayerxp/libmpstream2/cdd.h mplayerxp/libmpstream2/cdda.cpp mplayerxp/libplaytree/asxparser.cpp mplayerxp/libplaytree/playtree.cpp mplayerxp/libplaytree/playtree.h mplayerxp/mplayerxp.cpp mplayerxp/mplayerxp.h mplayerxp/xmpcore/xmp_context.cpp Modified: mplayerxp/input2/input.cpp =================================================================== --- mplayerxp/input2/input.cpp 2012-12-28 08:16:10 UTC (rev 616) +++ mplayerxp/input2/input.cpp 2012-12-28 12:22:38 UTC (rev 617) @@ -1349,8 +1349,8 @@ delete &handle; } -void mp_input_register_options(m_config_t& cfg) { - m_config_register_options(cfg,mp_input_opts); +void mp_input_register_options(M_Config& cfg) { + cfg.register_options(mp_input_opts); } void mp_input_print_keys(libinput_t& handle) { Modified: mplayerxp/libmpcodecs/ad.cpp =================================================================== --- mplayerxp/libmpcodecs/ad.cpp 2012-12-28 08:16:10 UTC (rev 616) +++ mplayerxp/libmpcodecs/ad.cpp 2012-12-28 12:22:38 UTC (rev 617) @@ -66,13 +66,13 @@ static unsigned int nddrivers=sizeof(mpcodecs_ad_drivers)/sizeof(ad_functions_t*); -void libmpcodecs_ad_register_options(m_config_t& cfg) +void libmpcodecs_ad_register_options(M_Config& cfg) { unsigned i; for(i=0;i<nddrivers;i++) { if(mpcodecs_ad_drivers[i]) if(mpcodecs_ad_drivers[i]->options) - m_config_register_options(cfg,mpcodecs_ad_drivers[i]->options); + cfg.register_options(mpcodecs_ad_drivers[i]->options); if(mpcodecs_ad_drivers[i]==&mpcodecs_ad_null) break; } } Modified: mplayerxp/libmpcodecs/vd.cpp =================================================================== --- mplayerxp/libmpcodecs/vd.cpp 2012-12-28 08:16:10 UTC (rev 616) +++ mplayerxp/libmpcodecs/vd.cpp 2012-12-28 12:22:38 UTC (rev 617) @@ -73,13 +73,13 @@ }; static unsigned int nddrivers=sizeof(mpcodecs_vd_drivers)/sizeof(vd_functions_t*); -void libmpcodecs_vd_register_options(m_config_t& cfg) +void libmpcodecs_vd_register_options(M_Config& cfg) { unsigned i; for(i=0;i<nddrivers;i++) { if(mpcodecs_vd_drivers[i]) if(mpcodecs_vd_drivers[i]->options) - m_config_register_options(cfg,mpcodecs_vd_drivers[i]->options); + cfg.register_options(mpcodecs_vd_drivers[i]->options); if(mpcodecs_vd_drivers[i]==&mpcodecs_vd_null) break; } } Modified: mplayerxp/libmpconf/cfgparser.cpp =================================================================== --- mplayerxp/libmpconf/cfgparser.cpp 2012-12-28 08:16:10 UTC (rev 616) +++ mplayerxp/libmpconf/cfgparser.cpp 2012-12-28 12:22:38 UTC (rev 617) @@ -9,6 +9,7 @@ * subconfig support by alex */ #include <algorithm> +#include <limits> #include <stdlib.h> #include <stdio.h> @@ -17,211 +18,51 @@ #include <fcntl.h> #include <string.h> #include <errno.h> +#include <sys/stat.h> +#include <sys/types.h> #include "mplayerxp.h" +#include "mpxp_help.h" #include "cfgparser.h" #include "libplaytree/playtree.h" #include "parser_msg.h" namespace mpxp { -enum { - COMMAND_LINE=0, - CONFIG_FILE=1, +static const int MAX_RECURSION_DEPTH=8; - CONFIG_GLOBAL=(1<<0), - CONFIG_RUNNING=(1<<1), - - MAX_RECURSION_DEPTH=8 -}; - -inline void SET_GLOBAL(m_config_t& c) { c.flags |= CONFIG_GLOBAL; } -inline void UNSET_GLOBAL(m_config_t& c) { c.flags &= (!CONFIG_GLOBAL); } -inline int IS_GLOBAL(const m_config_t& c) { return c.flags & CONFIG_GLOBAL; } -inline void SET_RUNNING(m_config_t& c) { c.flags |= CONFIG_RUNNING; } -inline int IS_RUNNING(const m_config_t& c) { return c.flags & CONFIG_RUNNING; } - typedef int (*cfg_func_arg_param_t)(const mpxp_option_t *,const std::string& ,const std::string& ); typedef int (*cfg_func_param_t)(const mpxp_option_t *,const std::string& ); typedef int (*cfg_func_t)(const mpxp_option_t *); -static void -m_config_save_option(m_config_t& config,const mpxp_option_t* conf,const std::string& opt,const std::string& param) { - config_save_t* save; - int sl=0; - switch(conf->type) { - case CONF_TYPE_PRINT : - case CONF_TYPE_SUBCONFIG : - return; - default : - ; - } - - mpxp_dbg2<<"Saving option "<<opt<<std::endl; - - save = config.config_stack[config.cs_level]; - - if(save) { - std::string lopt=opt; - std::transform(lopt.begin(),lopt.end(),lopt.begin(), ::tolower); - for(sl = 0; save[sl].opt != NULL; sl++){ - // Check to not save the same arg two times - if(save[sl].opt == conf && (save[sl].opt_name == NULL || lopt==save[sl].opt_name)) - break; - } - if(save[sl].opt) - return; - } - - save = (config_save_t*)mp_realloc(save,(sl+2)*sizeof(config_save_t)); - if(save == NULL) { - mpxp_err<<"Can't allocate "<<((sl+2)*sizeof(config_save_t))<<" bytes of memory : "<<strerror(errno)<<std::endl; - return; - } - memset(&save[sl],0,2*sizeof(config_save_t)); - save[sl].opt = conf; - - switch(conf->type) { - case CONF_TYPE_FLAG : - case CONF_TYPE_INC : - case CONF_TYPE_INT : - save[sl].param.as_int = *((int*)conf->p); - break; - case CONF_TYPE_FLOAT : - save[sl].param.as_float = *((float*)conf->p); - break; - case CONF_TYPE_STRING : - save[sl].param.as_pointer = *((char**)conf->p); - break; - case CONF_TYPE_INCLUDE : - if(!param.empty()) - save->param.as_pointer = mp_strdup(param.c_str()); - default : - mpxp_err<<"Should never append in m_config_save_option : conf->type="<<conf->type<<std::endl; - } - - config.config_stack[config.cs_level] = save; +M_Config::M_Config(PlayTree* _pt,libinput_t& _libinput) + :pt(_pt),libinput(_libinput) +{ + set_global(); // We always start with global options } +M_Config::~M_Config() {} -static int m_config_revert_option(m_config_t& config, config_save_t* save) { - const char* arg = NULL; - config_save_t* iter=NULL; - int i=-1; +void M_Config::set_global() { flags |= M_Config::Global; } +void M_Config::unset_global() { flags &= ~M_Config::Global; } +int M_Config::is_global() const { return flags & M_Config::Global; } +void M_Config::set_running() { flags |= M_Config::Running; } +void M_Config::unset_running() { flags &= ~M_Config::Running; } +int M_Config::is_running() const { return flags & M_Config::Running; } - arg = save->opt_name ? save->opt_name : save->opt->name; - mpxp_dbg2<<"Reverting option: "<<arg<<std::endl; - - switch(save->opt->type) { - case CONF_TYPE_FLAG: - case CONF_TYPE_INC : - case CONF_TYPE_INT : - *((int*)save->opt->p) = save->param.as_int; - break; - case CONF_TYPE_FLOAT : - *((float*)save->opt->p) = save->param.as_float; - break; - case CONF_TYPE_STRING : - *((char**)save->opt->p) = reinterpret_cast<char*>(save->param.as_pointer); - break; - case CONF_TYPE_INCLUDE : - if(config.cs_level > 0) { - for(i = config.cs_level - 1 ; i >= 0 ; i--){ - if(config.config_stack[i] == NULL) continue; - for(iter = config.config_stack[i]; iter != NULL && iter->opt != NULL ; iter++) { - if(iter->opt == save->opt && - ((save->param.as_pointer == NULL || iter->param.as_pointer == NULL) || strcasecmp((const char *)save->param.as_pointer,(const char *)iter->param.as_pointer) == 0) && - (save->opt_name == NULL || - (iter->opt_name && strcasecmp(save->opt_name,iter->opt_name)))) break; - } - } - } - delete save->param.as_pointer; - if(save->opt_name) delete save->opt_name; - save->param.as_pointer = NULL; - save->opt_name = reinterpret_cast<char*>(save->param.as_pointer); - if(i < 0) break; - arg = iter->opt_name ? iter->opt_name : iter->opt->name; - switch(iter->opt->type) { - case CONF_TYPE_INCLUDE : - if (iter->param.as_pointer == NULL) { - mpxp_err<<"We lost param for option "<<iter->opt->name<<"?"<<std::endl; - return -1; - } - if ((((cfg_func_param_t) iter->opt->p)(iter->opt, (char*)iter->param.as_pointer)) < 0) - return -1; - break; - } - break; - default : - mpxp_err<<"Why do we reverse this : name="<<save->opt->name<<" type="<<save->opt->type<<" ?"<<std::endl; - } - - return 1; -} - -void m_config_push(m_config_t& config) { - - config.cs_level++; - config.config_stack = (config_save_t**)mp_realloc(config.config_stack ,sizeof(config_save_t*)*(config.cs_level+1)); - if(config.config_stack == NULL) { - mpxp_err<<"Can't allocate "<<(sizeof(config_save_t*)*(config.cs_level+1))<<" bytes of memory : "<<strerror(errno)<<std::endl; - config.cs_level = -1; - return; - } - config.config_stack[config.cs_level] = NULL; - mpxp_dbg2<<"Config pushed level="<<config.cs_level<<std::endl; -} - -int m_config_pop(m_config_t& config) { - int i,ret= 1; - config_save_t* cs; - - if(config.config_stack[config.cs_level] != NULL) { - cs = config.config_stack[config.cs_level]; - for(i=0; cs[i].opt != NULL ; i++ ) { - if (m_config_revert_option(config,&cs[i]) < 0) - ret = -1; - } - delete config.config_stack[config.cs_level]; - } - config.config_stack = (config_save_t**)mp_realloc(config.config_stack ,sizeof(config_save_t*)*config.cs_level); - config.cs_level--; - if(config.cs_level > 0 && config.config_stack == NULL) { - mpxp_err<<"Can't allocate memory"<<std::endl; - config.cs_level = -1; - return -1; - } - mpxp_dbg2<<"Config poped level="<<config.cs_level<<std::endl; - return ret; -} - -m_config_t& m_config_new(PlayTree* pt,libinput_t&libinput) { - m_config_t& config = *new(zeromem) m_config_t(libinput); - config.config_stack = (config_save_t**)mp_calloc(1,sizeof(config_save_t*)); - SET_GLOBAL(config); // We always start with global options - config.pt = pt; - return config; -} - -void m_config_free(m_config_t* config) { - delete config->config_stack; - delete config; -} - -static int init_conf(m_config_t& config, int mode) +MPXP_Rc M_Config::init_conf(mode_e mode) { - config.parser_mode = mode; - return 1; + parser_mode = mode; + return MPXP_Ok; } -static int config_is_entry_option(m_config_t& config,const std::string& opt,const std::string& param) { +int M_Config::is_entry_option(const std::string& opt,const std::string& param) { PlayTree* entry = NULL; std::string lopt=opt; std::transform(lopt.begin(),lopt.end(),lopt.begin(), ::tolower); if(lopt=="playlist") { // We handle playlist here if(param.empty()) return ERR_MISSING_PARAM; - entry = PlayTree::parse_playlist_file(config.libinput,param); + entry = PlayTree::parse_playlist_file(libinput,param); if(!entry) { mpxp_err<<"Playlist parsing failed: "<<param<<std::endl; return 1; @@ -229,23 +70,22 @@ } if(entry) { - if(config.last_entry) config.last_entry->append_entry(entry); - else config.pt->set_child(entry); - config.last_entry = entry; - if(config.parser_mode == COMMAND_LINE) UNSET_GLOBAL(config); + if(last_entry) last_entry->append_entry(entry); + else pt->set_child(entry); + last_entry = entry; + if(parser_mode == M_Config::CmdLine) unset_global(); return 1; } return 0; } -static MPXP_Rc cfg_include(m_config_t& conf,const std::string& filename){ - return m_config_parse_config_file(conf, filename); +MPXP_Rc M_Config::cfg_include(const std::string& filename){ + return parse_config_file(filename); } -static int cfg_inc_int(int value){ return ++value; } +int M_Config::cfg_inc_int(int value){ return ++value; } -static int config_read_option(m_config_t& config,const std::vector<const mpxp_option_t*>& conf_list,const std::string& opt,const std::string& param) -{ +int M_Config::read_option(const std::vector<const mpxp_option_t*>& conf_list,const std::string& opt,const std::string& param) { int i=0,nconf = 0; long tmp_int; double tmp_float; @@ -276,30 +116,25 @@ option_found : mpxp_dbg3<<"read_option: name='"<<conf[i].name<<"' type="<<conf[i].type<<std::endl; - if (conf[i].flags & CONF_NOCFG && config.parser_mode == CONFIG_FILE) { + if (conf[i].flags & CONF_NOCFG && parser_mode == M_Config::File) { mpxp_err<<"this option can only be used on command line:"<<opt<<std::endl; ret = ERR_NOT_AN_OPTION; goto out; } - if (conf[i].flags & CONF_NOCMD && config.parser_mode == COMMAND_LINE) { + if (conf[i].flags & CONF_NOCMD && parser_mode == M_Config::CmdLine) { mpxp_err<<"this option can only be used in config file:"<<opt<<std::endl; ret = ERR_NOT_AN_OPTION; goto out; } - ret = config_is_entry_option(config,opt,param); + ret = is_entry_option(opt,param); if(ret != 0) return ret; else ret = -1; - if(! IS_RUNNING(config) && ! IS_GLOBAL(config) && - ! (conf[i].flags & CONF_GLOBAL) && conf[i].type != CONF_TYPE_SUBCONFIG ) - m_config_push(config); - if( !(conf[i].flags & CONF_NOSAVE) && ! (conf[i].flags & CONF_GLOBAL) ) - m_config_save_option(config,&conf[i],opt,param); switch (conf[i].type) { case CONF_TYPE_FLAG: /* flags need a parameter in config file */ - if (config.parser_mode == CONFIG_FILE) { + if (parser_mode == M_Config::File) { std::string lparm=param; std::transform(lparm.begin(),lparm.end(),lparm.begin(), ::tolower); if (lparm=="yes" || /* any other language? */ @@ -420,7 +255,7 @@ case CONF_TYPE_INCLUDE: if (param.empty()) goto err_missing_param; - if (cfg_include(config, param) < 0) { + if (cfg_include(param) < 0) { ret = ERR_FUNC_ERR; goto out; } @@ -434,17 +269,16 @@ break; } out: - if(ret >= 0 && ! IS_RUNNING(config) && ! IS_GLOBAL(config) && ! (conf[i].flags & CONF_GLOBAL) && conf[i].type != CONF_TYPE_SUBCONFIG ) { - PlayTree* dest = config.last_entry ? config.last_entry : config.last_parent; + if(ret >= 0 && ! is_running() && !is_global() && ! (conf[i].flags & CONF_GLOBAL) && conf[i].type != CONF_TYPE_SUBCONFIG ) { + PlayTree* dest = last_entry ? last_entry : last_parent; std::string o; - if(config.sub_conf) o=std::string(config.sub_conf)+":"+opt; - else o=opt; + if(sub_conf) o=std::string(sub_conf)+":"+opt; + else o=opt; if(ret == 0) dest->set_param(o,""); else if(ret > 0) dest->set_param(o,param); - m_config_pop(config); } return ret; err_missing_param: @@ -453,26 +287,25 @@ goto out; } -static const mpxp_option_t* m_config_find_option(const std::vector<const mpxp_option_t*>& list,const std::string& name); - -int m_config_set_option(m_config_t& config,const std::string& _opt,const std::string& param) { +int M_Config::set_option(const std::string& _opt,const std::string& param) { size_t e; - std::vector<const mpxp_option_t*> clist=config.opt_list; + std::vector<const mpxp_option_t*> clist=opt_list; std::string opt=_opt; std::string s; mpxp_dbg2<<"Setting option "<<opt<<"="<<param<<std::endl; - clist = config.opt_list; + clist = opt_list; e=opt.find('.'); if(e!=std::string::npos) { - int flg,ret; + int ret; + flags_e flg; const mpxp_option_t *subconf=NULL; mpxp_dbg2<<"Parsing "<<opt<<" as subconfig"<<std::endl; do { if((e = opt.find('.'))==std::string::npos) break; s=opt.substr(0,e); mpxp_dbg2<<"Treat "<<s<<" as subconfig name"<<std::endl; - subconf = m_config_find_option(clist,s); + subconf = find_option(clist,s); clist.clear(); if(!subconf) return ERR_NO_SUBCONF; if(subconf->type!=CONF_TYPE_SUBCONFIG) return ERR_NO_SUBCONF; @@ -480,10 +313,10 @@ opt = opt.substr(e+1); mpxp_dbg2<<"switching next subconf="<<subconf->name<<std::endl; }while(1); - flg=config.flags; - config.flags|=CONFIG_GLOBAL; - ret=config_read_option(config,clist,opt,param); - config.flags=flg; + flg=flags; + set_global(); + ret=read_option(clist,opt,param); + flags=flg; return ret; } @@ -491,26 +324,26 @@ if(e!=std::string::npos && e<(opt.length()-1)) { int ret; const mpxp_option_t* m_opt; - std::vector<const mpxp_option_t*> opt_list; + std::vector<const mpxp_option_t*> _opt_list; s=opt.substr(0,e); - m_opt=(const mpxp_option_t*)m_config_get_option_ptr(config,s); + m_opt=(const mpxp_option_t*)get_option_ptr(s); if(!m_opt) { mpxp_err<<"m_config_set_option "<<opt<<"="<<param<<" : no "<<s<<" subconfig"<<std::endl; return ERR_NOT_AN_OPTION; } - opt_list.push_back(m_opt); + _opt_list.push_back(m_opt); s=opt.substr(e+1); - ret = config_read_option(config,opt_list,s,param); + ret = read_option(_opt_list,s,param); return ret; } - return config_read_option(config,config.opt_list,opt,param); + return read_option(opt_list,opt,param); } static void PRINT_LINENUM(const std::string& conffile,int line_num) { mpxp_err<<conffile<<"("<<line_num<<")"<<std::endl; } static const int MAX_LINE_LEN=1000; static const int MAX_OPT_LEN=100; static const int MAX_PARAM_LEN=100; -MPXP_Rc m_config_parse_config_file(m_config_t& config,const std::string& conffile) +MPXP_Rc M_Config::parse_config_file(const std::string& conffile) { FILE *fp; char *line; @@ -525,15 +358,15 @@ MPXP_Rc ret = MPXP_Ok; int errors = 0; - if (++config.recursion_depth > 1) mpxp_info<<"Reading config file: "<<conffile<<std::endl; + if (++recursion_depth > 1) mpxp_info<<"Reading config file: "<<conffile<<std::endl; - if (config.recursion_depth > MAX_RECURSION_DEPTH) { + if (recursion_depth > MAX_RECURSION_DEPTH) { mpxp_fatal<<": too deep 'include'. check your configfiles"<<std::endl; ret = MPXP_False; goto out; } - if (init_conf(config, CONFIG_FILE) == -1) { + if (init_conf(M_Config::File) == -1) { ret = MPXP_False; goto out; } @@ -545,12 +378,12 @@ } if ((fp = ::fopen(conffile.c_str(), "r")) == NULL) { - if (config.recursion_depth > 1) mpxp_err<<": "<<strerror(errno)<<std::endl; + if (recursion_depth > 1) mpxp_err<<": "<<::strerror(errno)<<std::endl; delete line; ret = MPXP_Ok; goto out; } - if (config.recursion_depth > 1) mpxp_fatal<<std::endl; + if (recursion_depth > 1) mpxp_fatal<<std::endl; while (fgets(line, MAX_LINE_LEN, fp)) { if (errors >= 16) { @@ -655,7 +488,7 @@ ret = MPXP_False; } - tmp = m_config_set_option(config, opt, param); + tmp = set_option(opt, param); switch (tmp) { case ERR_NOT_AN_OPTION: case ERR_MISSING_PARAM: @@ -676,21 +509,20 @@ delete line; fclose(fp); out: - --config.recursion_depth; + --recursion_depth; return ret; } -MPXP_Rc mpxp_parse_command_line(m_config_t& config, const std::vector<std::string>& argv,const std::map<std::string,std::string>& envm) -{ +MPXP_Rc M_Config::parse_command_line(const std::vector<std::string>& argv,const std::map<std::string,std::string>& envm) { size_t i,siz=argv.size(); int tmp; std::string opt; int no_more_opts = 0; - if (init_conf(config, COMMAND_LINE) == -1) return MPXP_False; - if(config.last_parent == NULL) config.last_parent = config.pt; + if (init_conf(M_Config::CmdLine) == -1) return MPXP_False; + if(last_parent == NULL) last_parent = pt; /* in order to work recursion detection properly in parse_config_file */ - ++config.recursion_depth; + ++recursion_depth; for (i = 1; i < siz; i++) { //next: @@ -700,7 +532,7 @@ exit(0); } if(opt=="--long-help") { - show_long_help(config,envm); + show_long_help(*this,envm); exit(0); } /* check for -- (no more options id.) except --help! */ @@ -714,24 +546,24 @@ } if(opt[0] == '{' && opt[1] == '\0') { PlayTree* entry = new(zeromem) PlayTree; - UNSET_GLOBAL(config); - if(config.last_entry == NULL) { - config.last_parent->set_child(entry); + unset_global(); + if(last_entry == NULL) { + last_parent->set_child(entry); } else { - config.last_entry->append_entry(entry); - config.last_entry = NULL; + last_entry->append_entry(entry); + last_entry = NULL; } - config.last_parent = entry; + last_parent = entry; continue; } if(opt[0] == '}' && opt[1] == '\0') { - if( ! config.last_parent || ! config.last_parent->get_parent()) { + if( ! last_parent || ! last_parent->get_parent()) { mpxp_err<<"too much }-"<<std::endl; goto err_out; } - config.last_entry = config.last_parent; - config.last_parent = config.last_entry->get_parent(); + last_entry = last_parent; + last_parent = last_entry->get_parent(); continue; } @@ -749,7 +581,7 @@ parm=item.substr(pos+1); item=item.substr(0,pos); } - tmp = m_config_set_option(config, item, parm); + tmp = set_option(item, parm); if(!tmp && pos!=std::string::npos) { mpxp_err<<"Option '"<<item<<"' doesn't require arguments"<<std::endl; goto err_out; @@ -776,32 +608,32 @@ PlayTree* entry = new(zeromem) PlayTree; mpxp_dbg2<<"Adding file "<<argv[i]<<std::endl; entry->add_file(argv[i]); - if(argv[i]=="-") m_config_set_option(config,"use-stdin",NULL); + if(argv[i]=="-") set_option("use-stdin",""); /* opt is not an option -> treat it as a filename */ - UNSET_GLOBAL(config); // We start entry specific options - if(config.last_entry == NULL) config.last_parent->set_child(entry); - else config.last_entry->append_entry(entry); - config.last_entry = entry; + unset_global(); // We start entry specific options + if(last_entry == NULL) last_parent->set_child(entry); + else last_entry->append_entry(entry); + last_entry = entry; } } - --config.recursion_depth; - if(config.last_parent != config.pt) mpxp_err<<"Missing }- ?"<<std::endl; - UNSET_GLOBAL(config); - SET_RUNNING(config); + --recursion_depth; + if(last_parent != pt) mpxp_err<<"Missing }- ?"<<std::endl; + unset_global(); + set_running(); return MPXP_Ok; err_out: - --config.recursion_depth; + --recursion_depth; mpxp_err<<"command line: "<<argv[i]<<std::endl; return MPXP_False; } -MPXP_Rc m_config_register_options(m_config_t& config,const mpxp_option_t *args) { - config.opt_list.push_back(args); - return MPXP_Ok; +MPXP_Rc M_Config::register_options(const mpxp_option_t *args) { + opt_list.push_back(args); + return MPXP_Ok; } -static const mpxp_option_t* m_config_find_option(const std::vector<const mpxp_option_t*>& list,const std::string& name) { +const mpxp_option_t* M_Config::find_option(const std::vector<const mpxp_option_t*>& list,const std::string& name) const { unsigned i,j; const mpxp_option_t *conf; if(!list.empty()) { @@ -819,7 +651,7 @@ return NULL; } -const mpxp_option_t* m_config_get_option(const m_config_t& config,const std::string& arg) { +const mpxp_option_t* M_Config::get_option(const std::string& arg) const { size_t e; e = arg.find(':'); @@ -828,25 +660,25 @@ const mpxp_option_t* opt; std::string s; s=arg.substr(0,e); - opt = m_config_get_option(config,s); + opt = get_option(s); cl.push_back(opt); - return m_config_find_option(cl,arg); + return find_option(cl,arg); } - return m_config_find_option(config.opt_list,arg); + return find_option(opt_list,arg); } -any_t* m_config_get_option_ptr(const m_config_t& config,const std::string& arg) { - const mpxp_option_t* conf; +any_t* M_Config::get_option_ptr(const std::string& arg) const { + const mpxp_option_t* conf; - conf = m_config_get_option(config,arg); - if(!conf) return NULL; - return conf->p; + conf = get_option(arg); + if(!conf) return NULL; + return conf->p; } -int m_config_get_int (const m_config_t& config,const std::string& arg,int& err_ret) { +int M_Config::get_int (const std::string& arg,int& err_ret) const { int *ret; - ret = (int*)m_config_get_option_ptr(config,arg); + ret = (int*)get_option_ptr(arg); err_ret = 0; if(!ret) { err_ret = 1; @@ -855,10 +687,10 @@ return *ret; } -float m_config_get_float (const m_config_t& config,const std::string& arg,int& err_ret) { +float M_Config::get_float (const std::string& arg,int& err_ret) const { float *ret; - ret = (float*)m_config_get_option_ptr(config,arg); + ret = (float*)get_option_ptr(arg); err_ret = 0; if(!ret) { err_ret = 1; @@ -870,100 +702,66 @@ inline int AS_INT(const mpxp_option_t* c) { return *((int*)c->p); } inline void AS_INT(const mpxp_option_t* c,int val) { *((int*)c->p)=val; } -int m_config_set_int(m_config_t& config,const std::string& arg,int val) { - const mpxp_option_t* opt; +int M_Config::set_int(const std::string& arg,int val) { + const mpxp_option_t* opt; - opt = m_config_get_option(config,arg); + opt = get_option(arg); - if(!opt || opt->type != CONF_TYPE_INT) - return ERR_NOT_AN_OPTION; + if(!opt || opt->type != CONF_TYPE_INT) return ERR_NOT_AN_OPTION; + if(opt->flags & CONF_MIN && val < opt->min) return ERR_OUT_OF_RANGE; + if(opt->flags & CONF_MAX && val > opt->max) return ERR_OUT_OF_RANGE; - if(opt->flags & CONF_MIN && val < opt->min) - return ERR_OUT_OF_RANGE; - if(opt->flags & CONF_MAX && val > opt->max) - return ERR_OUT_OF_RANGE; + AS_INT(opt,val); - m_config_save_option(config,opt,arg,NULL); - AS_INT(opt,val); - - return 1; + return 1; } -int m_config_set_float(m_config_t& config,const std::string& arg,float val) { - const mpxp_option_t* opt; +int M_Config::set_float(const std::string& arg,float val) { + const mpxp_option_t* opt; - opt = m_config_get_option(config,arg); + opt = get_option(arg); - if(!opt || opt->type != CONF_TYPE_FLOAT) - return ERR_NOT_AN_OPTION; + if(!opt || opt->type != CONF_TYPE_FLOAT) return ERR_NOT_AN_OPTION; + if(opt->flags & CONF_MIN && val < opt->min) return ERR_OUT_OF_RANGE; + if(opt->flags & CONF_MAX && val > opt->max) return ERR_OUT_OF_RANGE; - if(opt->flags & CONF_MIN && val < opt->min) - return ERR_OUT_OF_RANGE; - if(opt->flags & CONF_MAX && val > opt->max) - return ERR_OUT_OF_RANGE; - - m_config_save_option(config,opt,arg,NULL); - *((float*)opt->p) = val; - - return 1; + *((float*)opt->p) = val; + return 1; } -int m_config_switch_flag(m_config_t& config,const std::string& opt) { - const mpxp_option_t *conf; +int M_Config::switch_flag(const std::string& opt) { + const mpxp_option_t *conf; - conf = m_config_get_option(config,opt); - if(!conf || conf->type != CONF_TYPE_FLAG) return 0; - if( AS_INT(conf) == conf->min) AS_INT(conf,conf->max); - else if(AS_INT(conf) == conf->max) AS_INT(conf,conf->min); - else return 0; + conf = get_option(opt); + if(!conf || conf->type != CONF_TYPE_FLAG) return 0; + if( AS_INT(conf) == conf->min) AS_INT(conf,conf->max); + else if(AS_INT(conf) == conf->max) AS_INT(conf,conf->min); + else return 0; - return 1; + return 1; } -int m_config_set_flag(m_config_t& config,const std::string& opt, int state) { - const mpxp_option_t *conf; +int M_Config::set_flag(const std::string& opt, int state) { + const mpxp_option_t *conf; - conf = m_config_get_option(config,opt); - if(!conf || conf->type != CONF_TYPE_FLAG) return 0; - if(state) AS_INT(conf,conf->max); - else AS_INT(conf,conf->min); - return 1; + conf = get_option(opt); + if(!conf || conf->type != CONF_TYPE_FLAG) return 0; + if(state) AS_INT(conf,conf->max); + else AS_INT(conf,conf->min); + return 1; } -int m_config_get_flag(const m_config_t& config,const std::string& opt) { +int M_Config::get_flag(const std::string& opt) const { + const mpxp_option_t* conf = get_option(opt); - const mpxp_option_t* conf = m_config_get_option(config,opt); - if(!conf || conf->type != CONF_TYPE_FLAG) return -1; - if(AS_INT(conf) == conf->max) return 1; - else if(AS_INT(conf) == conf->min) return 0; - return -1; -} - -int m_config_is_option_set(const m_config_t& config,const std::string& arg) { - const mpxp_option_t* opt; - config_save_t* save; - int l,i; - - opt = m_config_get_option(config,arg); - - if(!opt) + if(!conf || conf->type != CONF_TYPE_FLAG) return -1; + if(AS_INT(conf) == conf->max) return 1; + else if(AS_INT(conf) == conf->min) return 0; return -1; - - for(l = config.cs_level ; l >= 0 ; l--) { - save = config.config_stack[l]; - if(!save) - continue; - for(i = 0 ; save[i].opt != NULL ; i++) { - if(save[i].opt == opt) - return 1; - } - } - - return 0; } -static void __m_config_show_options(unsigned ntabs,const std::string& pfx,const mpxp_option_t* opts) { +void M_Config::__show_options(unsigned ntabs,const std::string& pfx,const mpxp_option_t* opts) const { unsigned i,n; i=0; while(opts[i].name) { @@ -978,7 +776,7 @@ else newpfx=""; newpfx+=opts[i].name; newpfx+="."; - __m_config_show_options(ntabs+2,newpfx,(const mpxp_option_t *)opts[i].p); + __show_options(ntabs+2,newpfx,(const mpxp_option_t *)opts[i].p); } else if(opts[i].type<=CONF_TYPE_PRINT) { @@ -1050,14 +848,57 @@ }; } -void m_config_show_options(const m_config_t& args) { - size_t j,sz=args.opt_list.size(); +void M_Config::show_options() const { + size_t j,sz=opt_list.size(); const mpxp_option_t *opts; j=0; mpxp_info<<"List of available command-line options:"<<std::endl; for(j=0;j<sz;j++) { - opts=args.opt_list[j]; - __m_config_show_options(2,"",opts); + opts=opt_list[j]; + __show_options(2,"",opts); }; } + +static const char* default_config= +"# Write your default config options here!\n" +"\n" +//"nosound=nein" +"\n"; + +__always_inline std::string get_path(const std::map<std::string,std::string>& envm,const std::string& filename="") { + std::map<std::string,std::string>::const_iterator it; + it = envm.find("HOME"); + const std::string homedir = (*it).second; + std::string rs; + std::string config_dir = std::string("/.")+PROGNAME; + + if (homedir.empty()) throw "No 'HOME' environment found"; + rs=homedir+config_dir; + if (!filename.empty()) rs+="/"+filename; + mpxp_v<<"get_path('"<<homedir<<":"<<filename<<"') -> "<<rs<<std::endl; + return rs; +} + +void M_Config::parse_cfgfiles(const std::map<std::string,std::string>& envm) +{ + std::string conffile; + int conffile_fd; + conffile = get_path(envm); + if (conffile.empty()) mpxp_warn<<MSGTR_NoHomeDir<<std::endl; + else { + ::mkdir(conffile.c_str(), 0777); + conffile = get_path(envm,"config"); + if (conffile.empty()) { + mpxp_err<<MSGTR_GetpathProblem<<std::endl; + conffile="config"; + } + if ((conffile_fd = ::open(conffile.c_str(), O_CREAT | O_EXCL | O_WRONLY, 0666)) != -1) { + mpxp_info<<MSGTR_CreatingCfgFile<<": "<<conffile<<std::endl; + ::write(conffile_fd, default_config, strlen(default_config)); + ::close(conffile_fd); + } + if (parse_config_file(conffile) != MPXP_Ok) exit(1); + } +} + } // namespace mpxp Modified: mplayerxp/libmpconf/cfgparser.h =================================================================== --- mplayerxp/libmpconf/cfgparser.h 2012-12-28 08:16:10 UTC (rev 616) +++ mplayerxp/libmpconf/cfgparser.h 2012-12-28 12:22:38 UTC (rev 617) @@ -43,133 +43,109 @@ CONF_NOSAVE =(1<<5) }; + // Plain C-structure for static declarations struct mpxp_option_t { - const char *name; - any_t* const p; - unsigned int type; - unsigned int flags; - float min,max; - const char *help; + const char* name; + any_t* const p; + unsigned int type; + unsigned int flags; + float min,max; + const char* help; }; typedef void (*cfg_default_func_t)(mpxp_option_t*,const std::string&); - struct config_save_t; - struct m_config_t : public Opaque { - m_config_t(libinput_t& _libinput):libinput(_libinput) {} - virtual ~m_config_t() {} + class M_Config : public Opaque { + public: + enum mode_e { + CmdLine=0, + File=1, + }; + enum flags_e { + Global=0x01, + Running=0x02 + }; - std::vector<const mpxp_option_t*> opt_list; - config_save_t** config_stack; - int cs_level; - int parser_mode; /* COMMAND_LINE or CONFIG_FILE */ - int flags; - const char* sub_conf; // When we save a subconfig - PlayTree* pt; // play tree we use for playlist option, etc - PlayTree* last_entry; // last added entry - PlayTree* last_parent; // if last_entry is NULL we must create child of this - int recursion_depth; - libinput_t& libinput; - }; + M_Config(PlayTree* pt,libinput_t& _libinput); + virtual ~M_Config(); - struct config_save_t { - const mpxp_option_t* opt; - union { - int as_int; - float as_float; - any_t* as_pointer; - } param; - const char* opt_name; - }; + virtual MPXP_Rc parse_command_line(const std::vector<std::string>& argv,const std::map<std::string,std::string>& envm); + virtual MPXP_Rc register_options(const mpxp_option_t *args); + virtual MPXP_Rc parse_config_file(const std::string& conffile); + /** Return 1 on sucess 0 on failure + **/ + virtual int set_option(const std::string& opt,const std::string& param); + /** Get the config struct defining an option + * @return NULL on error + **/ + virtual const mpxp_option_t* get_option(const std::string& arg) const; + /** Get the p field of the struct defining an option + * @return NULL on error + **/ + virtual any_t* get_option_ptr(const std::string& arg) const; + /** Return 0 on error 1 on success + **/ + virtual int switch_flag(const std::string& opt); + /** Return 0 on error 1 on success + **/ + virtual int set_flag(const std::string& opt, int max); + /** Return the value of a flag (O or 1) and -1 on error + **/ + virtual int get_flag(const std::string& opt) const; + /** Set the value of an int option + * @return 0 on error 1 on success + **/ + virtual int set_int(const std::string& arg,int val); + /** Get the value of an int option + * @param err_ret If it is not NULL it's set to 1 on error + * @return the option value or -1 on error + **/ + virtual int get_int (const std::string& arg,int& err_ret) const; + /** Set the value of a float option + * @return 0 on error 1 on success + **/ + virtual int set_float(const std::string& arg,float val); + /** Get the value of a float option + * @param err_ret If it is not NULL it's set to 1 on error + * @return the option value or -1 on error + **/ + virtual float get_float (const std::string& arg,int& err_ret) const; - /* parse_command_line returns: - * -1 on error (invalid option...) - * 1 otherwise - */ - MPXP_Rc mpxp_parse_command_line(m_config_t& config, const std::vector<std::string>& argv,const std::map<std::string,std::string>& envm); - /* - * Return 0 on error 1 on success - */ - MPXP_Rc m_config_register_options(m_config_t& config,const mpxp_option_t *args); + virtual void parse_cfgfiles(const std::map<std::string,std::string>& envm); + virtual void show_options() const; + private: + void set_global(); + void unset_global(); + int is_global() const; + void set_running(); + void unset_running(); + int is_running() const; - /* parse_config_file returns: - * -1 on error (can't mp_malloc, invalid option...) - * 0 if can't open configfile - * 1 on success - */ - MPXP_Rc m_config_parse_config_file(m_config_t& config,const std::string& conffile); + void __show_options(unsigned ntabs,const std::string& pfx,const mpxp_option_t* opts) const; + const mpxp_option_t* find_option(const std::vector<const mpxp_option_t*>& list,const std::string& name) const; + MPXP_Rc init_conf(mode_e mode); + int read_option(const std::vector<const mpxp_option_t*>& conf_list,const std::string& opt,const std::string& param); + MPXP_Rc cfg_include(const std::string& filename); + int cfg_inc_int(int value); + int is_entry_option(const std::string& opt,const std::string& param); - m_config_t& m_config_new(PlayTree* pt,libinput_t&libinput); - - void m_config_free(m_config_t* config); - - void m_config_push(m_config_t& config); - - /* - * Return 0 on error 1 on success - */ - int m_config_pop(m_config_t& config); - - void m_config_show_options(const m_config_t& args); - - /* - * For all the following function when it's a subconfig option - * you must give an option name like 'tv:channel' and not just - * 'channel' - */ - - /** Return 1 on sucess 0 on failure - **/ - int m_config_set_option(m_config_t& config,const std::string& opt,const std::string& param); - - /** Get the config struct defining an option - * @return NULL on error - **/ - const mpxp_option_t* m_config_get_option(const m_config_t& config,const std::string& arg); - - /** Get the p field of the struct defining an option - * @return NULL on error - **/ - any_t* m_config_get_option_ptr(const m_config_t& config,const std::string& arg); - - /** Tell is an option is alredy set or not - * @return -1 one error (requested option arg exist) otherwise 0 or 1 - **/ - int m_config_is_option_set(const m_config_t& config,const std::string& arg); - - /** Return 0 on error 1 on success - **/ - int m_config_switch_flag(m_config_t& config,const std::string& opt); - - /** Return 0 on error 1 on success - **/ - int m_config_set_flag(m_config_t& config,const std::string& opt, int max); - - /** Return the value of a flag (O or 1) and -1 on error - **/ - int m_config_get_flag(const m_config_t& config,const std::string& opt); - - /** Set the value of an int option - * @return 0 on error 1 on success - **/ - int m_config_set_int(m_config_t& config,const std::string& arg,int val); - - /** Get the value of an int option - * @param err_ret If it is not NULL it's set to 1 on error - * @return the option value or -1 on error - **/ - int m_config_get_int (const m_config_t&,const std::string& arg,int& err_ret); - - /** Set the value of a float option - * @return 0 on error 1 on success - **/ - int m_config_set_float(m_config_t& config,const std::string& arg,float val); - - /** Get the value of a float option - * @param err_ret If it is not NULL it's set to 1 on error - * @return the option value or -1 on error - **/ - float m_config_get_float (const m_config_t&,const std::string& arg,int& err_ret); + std::vector<const mpxp_option_t*> opt_list; + mode_e parser_mode; + flags_e flags; + const char* sub_conf; // When we save a subconfig + PlayTree* pt; // play tree we use for playlist option, etc + PlayTree* last_entry; // last added entry + PlayTree* last_parent; // if last_entry is NULL we must create child of this + int recursion_depth; + libinput_t& libinput; + }; + inline M_Config::flags_e operator~(M_Config::flags_e a) { return static_cast<M_Config::flags_e>(~static_cast<unsigned>(a)); } + inline M_Config::flags_e operator|(M_Config::flags_e a, M_Config::flags_e b) { return static_cast<M_Config::flags_e>(static_cast<unsigned>(a)|static_cast<unsigned>(b)); } + inline M_Config::flags_e operator&(M_Config::flags_e a, M_Config::flags_e b) { return static_cast<M_Config::flags_e>(static_cast<unsigned>(a)&static_cast<unsigned>(b)); } + inline M_Config::flags_e operator^(M_Config::flags_e a, M_Config::flags_e b) { return static_cast<M_Config::flags_e>(static_cast<unsigned>(a)^static_cast<unsigned>(b)); } + inline M_Config::flags_e operator|=(M_Config::flags_e a, M_Config::flags_e b) { return (a=static_cast<M_Config::flags_e>(static_cast<unsigned>(a)|static_cast<unsigned>(b))); } + inline M_Config::flags_e operator&=(M_Config::flags_e a, M_Config::flags_e b) { return (a=static_cast<M_Config::flags_e>(static_cast<unsigned>(a)&static_cast<unsigned>(b))); } + inline M_Config::flags_e operator^=(M_Config::flags_e a, M_Config::flags_e b) { return (a=static_cast<M_Config::flags_e>(static_cast<unsigned>(a)^static_cast<unsigned>(b))); } } // namespace mpxp #endif /* __CONFIG_H */ Modified: mplayerxp/libmpdemux/demuxer.cpp =================================================================== --- mplayerxp/libmpdemux/demuxer.cpp 2012-12-28 08:16:10 UTC (rev 616) +++ mplayerxp/libmpdemux/demuxer.cpp 2012-12-28 12:22:38 UTC (rev 617) @@ -121,12 +121,12 @@ const demuxer_driver_t* driver; /**< driver associated with this demuxer */ }; -void libmpdemux_register_options(m_config_t& cfg) +void libmpdemux_register_options(M_Config& cfg) { unsigned i; for(i=0;ddrivers[i];i++) { if(ddrivers[i]->options) - m_config_register_options(cfg,ddrivers[i]->options); + cfg.register_options(ddrivers[i]->options); if(ddrivers[i]==&demux_null) break; } } @@ -463,7 +463,7 @@ delete ad; ad = NULL; } else if(ad->audio->sh && ((sh_audio_t*)ad->audio->sh)->wtag == 0x55) // MP3 - m_config_set_flag(*mpxp_context().mconfig,"mp3.hr-seek",1); // Enable high res seeking + mpxp_context().mconfig->set_flag("mp3.hr-seek",1); // Enable high res seeking } if(ss) { sd = new(zeromem) Demuxer(ss,-2,-2,dvdsub_id); @@ -528,8 +528,8 @@ { NULL, NULL, 0, 0, 0, 0, NULL} }; -void demuxer_register_options(m_config_t& cfg) { - m_config_register_options(cfg,demuxer_opts); +void demuxer_register_options(M_Config& cfg) { + cfg.register_options(demuxer_opts); } int Demuxer::demux(Demuxer_Stream* ds) { Modified: mplayerxp/libmpstream2/cdd.h =================================================================== --- mplayerxp/libmpstream2/cdd.h 2012-12-28 08:16:10 UTC (rev 616) +++ mplayerxp/libmpstream2/cdd.h 2012-12-28 12:22:38 UTC (rev 617) @@ -100,6 +100,6 @@ lsn_t end_sector; }; - void cdda_register_options(m_config_t& cfg); + void cdda_register_options(M_Config& cfg); } // namespace mpxp #endif // __CDD_H__ Modified: mplayerxp/libmpstream2/cdda.cpp =================================================================== --- mplayerxp/libmpstream2/cdda.cpp 2012-12-28 08:16:10 UTC (rev 616) +++ mplayerxp/libmpstream2/cdda.cpp 2012-12-28 12:22:38 UTC (rev 617) @@ -33,8 +33,8 @@ { NULL,NULL, 0, 0, 0, 0, NULL} }; -void cdda_register_options(m_config_t& cfg) { - m_config_register_options(cfg,cdda_conf); +void cdda_register_options(M_Config& cfg) { + cfg.register_options(cdda_conf); } static unsigned cdda_parse_tracks(unsigned char *arr,unsigned nelem,const std::string& arg) Modified: mplayerxp/libplaytree/asxparser.cpp =================================================================== --- mplayerxp/libplaytree/asxparser.cpp 2012-12-28 08:16:10 UTC (rev 616) +++ mplayerxp/libplaytree/asxparser.cpp 2012-12-28 12:22:38 UTC (rev 617) @@ -304,7 +304,7 @@ return; } val = cattribs.get("VALUE"); - if(m_config_get_option(*mpxp_context().mconfig,name) == NULL) { + if(mpxp_context().mconfig->get_option(name) == NULL) { mpxp_warn<<"Found unknow param in asx: "<<name<<std::endl; if(!val.empty())mpxp_warn<<"="<<val<<std::endl; else mpxp_warn<<std::endl; Modified: mplayerxp/libplaytree/playtree.cpp =================================================================== --- mplayerxp/libplaytree/playtree.cpp 2012-12-28 08:16:10 UTC (rev 616) +++ mplayerxp/libplaytree/playtree.cpp 2012-12-28 12:22:38 UTC (rev 617) @@ -319,7 +319,7 @@ return NULL; } -_PlayTree_Iter::_PlayTree_Iter(PlayTree* pt,m_config_t& _config) +_PlayTree_Iter::_PlayTree_Iter(PlayTree* pt,M_Config& _config) :root(pt), tree(NULL), config(_config) { @@ -342,20 +342,15 @@ pt = tree; - // We always push a config because we can set some option - // while playing - m_config_push(config); - if(pt->get_params().empty()) return; size_t n,sz=pt->get_params().size(); for(n=0; n<sz; n++) { int e; - if((e = m_config_set_option(config,pt->get_param(n).name,pt->get_param(n).value)) < 0) + if((e = config.set_option(pt->get_param(n).name,pt->get_param(n).value)) < 0) mpxp_err<<"Error "<<e<<" while setting option '"<<pt->get_param(n).name<<"' with value '"<<pt->get_param(n).value<<"'"<<std::endl; } - if(!pt->get_child()) entry_pushed = 1; return; } @@ -368,11 +363,6 @@ return step(0,with_nodes); } - if(entry_pushed > 0) { - entry_pushed = 0; - m_config_pop(config); - } - if(tree->get_parent() && (tree->get_parent()->get_flags() & PLAY_TREE_RND)) rnd=mode = PLAY_TREE_ITER_RND; else @@ -435,8 +425,6 @@ num_files = tree->get_files().size(); - push_params(); - entry_pushed = 1; if(mode == PLAY_TREE_ITER_RND) pt->set_flags(pt->get_flags()|PLAY_TREE_RND_PLAYED); return PLAY_TREE_ITER_ENTRY; @@ -449,8 +437,6 @@ loop = status_stack.top(); status_stack.pop(); tree = tree->get_parent(); - // Pop subtree params - m_config_pop(config); if(mode == PLAY_TREE_ITER_RND) tree->set_flags(tree->get_flags()|PLAY_TREE_RND_PLAYED); return step(d,with_nodes); } @@ -490,11 +476,11 @@ switch(tree->get_entry_type()) { case PLAY_TREE_ENTRY_DVD : if(entry.length() == 0) entry = "1"; - m_config_set_option(config,"dvd",entry); + config.set_option("dvd",entry); return std::string("DVD title ")+entry; case PLAY_TREE_ENTRY_VCD : if(entry.length() == 0) entry = "1"; - m_config_set_option(config,"vcd",entry); + config.set_option("vcd",entry); return std::string("vcd://")+entry; case PLAY_TREE_ENTRY_TV: { if(entry.length() != 0) { @@ -502,7 +488,7 @@ size_t e; std::string rs; val="on:channel="+entry; - m_config_set_option(config,"tv",val); + config.set_option("tv",val); rs="TV channel "; e = entry.find(':'); if(e==std::string::npos) rs+=entry.substr(0,255-11); @@ -511,7 +497,7 @@ rs+=entry.substr(0,e); } return rs; - } else m_config_set_option(config,"tv","on"); + } else config.set_option("tv","on"); return "TV"; } default: break; Modified: mplayerxp/libplaytree/playtree.h =================================================================== --- mplayerxp/libplaytree/playtree.h 2012-12-28 08:16:10 UTC (rev 616) +++ mplayerxp/libplaytree/playtree.h 2012-12-28 12:22:38 UTC (rev 617) @@ -6,7 +6,7 @@ #include <vector> #include <stack> -struct m_config_t; +struct M_Config; namespace mpxp { struct Stream; struct libinput_t; @@ -112,7 +112,7 @@ struct _PlayTree_Iter : public Opaque { public: - _PlayTree_Iter(PlayTree* parent,m_config_t& config); + _PlayTree_Iter(PlayTree* parent,M_Config& config); _PlayTree_Iter(const _PlayTree_Iter& old); virtual ~_PlayTree_Iter(); @@ -135,11 +135,10 @@ void push_params(); PlayTree* root; // Iter root tree PlayTree* tree; // Current tree - m_config_t& config; + M_Config& config; int loop; // Looping status int file; int num_files; - int entry_pushed; int mode; std::stack<int> status_stack; Modified: mplayerxp/mplayerxp.cpp =================================================================== --- mplayerxp/mplayerxp.cpp 2012-12-28 08:16:10 UTC (rev 616) +++ mplayerxp/mplayerxp.cpp 2012-12-28 12:22:38 UTC (rev 617) @@ -386,7 +386,7 @@ MP_UNIT("exit_player"); if(!why.empty()) mpxp_hint<<std::endl<<MSGTR_Exiting<<"...("<<why<<")"<<std::endl; - if(mpxp_context().mconfig) m_config_free(mpxp_context().mconfig); + if(mpxp_context().mconfig) delete mpxp_context().mconfig; mpxp_print_uninit(); mpxp_uninit_structs(); if(!why.empty()) ::exit(0); @@ -414,34 +414,6 @@ __exit_sighandler(); } -static const char* default_config= -"# Write your default config options here!\n" -"\n" -//"nosound=nein" -"\n"; - -void parse_cfgfiles(const std::map<std::string,std::string>& envm, m_config_t& conf ) -{ - std::string conffile; - int conffile_fd; - conffile = get_path(envm); - if (conffile.empty()) mpxp_warn<<MSGTR_NoHomeDir<<std::endl; - else { - ::mkdir(conffile.c_str(), 0777); - conffile = get_path(envm,"config"); - if (conffile.empty()) { - mpxp_err<<MSGTR_GetpathProblem<<std::endl; - conffile="config"; - } - if ((conffile_fd = ::open(conffile.c_str(), O_CREAT | O_EXCL | O_WRONLY, 0666)) != -1) { - mpxp_info<<MSGTR_CreatingCfgFile<<": "<<conffile<<std::endl; - ::write(conffile_fd, default_config, strlen(default_config)); - ::close(conffile_fd); - } - if (m_config_parse_config_file(conf, conffile.c_str()) != MPXP_Ok) exit(1); - } -} - // When libmpdemux perform a blocking operation (network connection or cache filling) // if the operation fail we use this function to check if it was interrupted by the user. // The function return a new value for eof. @@ -594,9 +566,9 @@ mpxp_info<<"Use --long-help option for full help"<<std::endl; } -void show_long_help(const m_config_t& cfg,const std::map<std::string,std::string>& envm) { +void show_long_help(const M_Config& cfg,const std::map<std::string,std::string>& envm) { MPXPSystem& MPXPSys=*mpxp_context().engine().MPXPSys; - m_config_show_options(cfg); + cfg.show_options(); mp_input_print_binds(MPXPSys.libinput()); Stream::print_drivers(); Video_Output::print_help(); @@ -1631,14 +1603,14 @@ MPXPSys.playtree = new(zeromem) PlayTree; - m_config_t& m_config=m_config_new(MPXPSys.playtree,MPXPSys.libinput()); + M_Config& m_config=*new(zeromem) M_Config(MPXPSys.playtree,MPXPSys.libinput()); mpxp_context().mconfig = &m_config; - m_config_register_options(m_config,mplayerxp_opts); + m_config.register_options(mplayerxp_opts); // TODO : add something to let modules register their options mp_register_options(m_config); - parse_cfgfiles(envm,m_config); + m_config.parse_cfgfiles(envm); - if(mpxp_parse_command_line(m_config, argv,envm)!=MPXP_Ok) + if(m_config.parse_command_line(argv,envm)!=MPXP_Ok) exit_player("Error parse command line"); // error parsing cmdline if(!mp_conf.xp) { Modified: mplayerxp/mplayerxp.h =================================================================== --- mplayerxp/mplayerxp.h 2012-12-28 08:16:10 UTC (rev 616) +++ mplayerxp/mplayerxp.h 2012-12-28 12:22:38 UTC (rev 617) @@ -18,7 +18,7 @@ struct audio_decoder_t; struct video_decoder_t; namespace mpxp { - struct m_config_t; + class M_Config; struct _PlayTree_Iter; /* List of all modules which require protection by pin-code */ enum { @@ -183,7 +183,7 @@ int use_pts_fix2; unsigned mplayer_accel; subtitle* subtitles; - m_config_t* mconfig; + M_Config* mconfig; time_usage_t* bench; any_t* msg_priv; private: @@ -198,7 +198,7 @@ unsigned get_number_cpu(void); void show_help(void); - void show_long_help(const m_config_t& cfg,const std::map<std::string,std::string>& envm); + void show_long_help(const M_Config& cfg,const std::map<std::string,std::string>& envm); void update_osd( float v_pts ); @@ -228,6 +228,6 @@ void mplayer_put_key(int code); - void mp_register_options(m_config_t& cfg); + void mp_register_options(M_Config& cfg); } #endif Modified: mplayerxp/xmpcore/xmp_context.cpp =================================================================== --- mplayerxp/xmpcore/xmp_context.cpp 2012-12-28 08:16:10 UTC (rev 616) +++ mplayerxp/xmpcore/xmp_context.cpp 2012-12-28 12:22:38 UTC (rev 617) @@ -272,17 +272,17 @@ const mpxp_option_t* mplayerxp_opts=mplayerxp_options; } // namespace mpxp -extern void libmpcodecs_ad_register_options(m_config_t& cfg); -extern void libmpcodecs_vd_register_options(m_config_t& cfg); +extern void libmpcodecs_ad_register_options(M_Config& cfg); +extern void libmpcodecs_vd_register_options(M_Config& cfg); namespace mpxp { #ifdef HAVE_LIBCDIO -extern void cdda_register_options(m_config_t& cfg); +extern void cdda_register_options(M_Config& cfg); #endif -extern void mp_input_register_options(m_config_t& cfg); -extern void libmpdemux_register_options(m_config_t& cfg); -extern void demuxer_register_options(m_config_t& cfg); -void mp_register_options(m_config_t& cfg) +extern void mp_input_register_options(M_Config& cfg); +extern void libmpdemux_register_options(M_Config& cfg); +extern void demuxer_register_options(M_Config& cfg); +void mp_register_options(M_Config& cfg) { mp_input_register_options(cfg); libmpdemux_register_options(cfg); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2012-12-28 08:16:23
|
Revision: 616 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=616&view=rev Author: nickols_k Date: 2012-12-28 08:16:10 +0000 (Fri, 28 Dec 2012) Log Message: ----------- cleanups and fixes Modified Paths: -------------- mplayerxp/libmpcodecs/dec_audio.cpp mplayerxp/libmpcodecs/dec_audio.h mplayerxp/libmpcodecs/dec_video.cpp mplayerxp/libmpcodecs/dec_video.h mplayerxp/mplayerxp.cpp Modified: mplayerxp/libmpcodecs/dec_audio.cpp =================================================================== --- mplayerxp/libmpcodecs/dec_audio.cpp 2012-12-28 07:33:30 UTC (rev 615) +++ mplayerxp/libmpcodecs/dec_audio.cpp 2012-12-28 08:16:10 UTC (rev 616) @@ -196,7 +196,7 @@ /* Init audio filters */ MPXP_Rc mpca_preinit_filters(audio_decoder_t& opaque, unsigned in_samplerate, unsigned in_channels, unsigned in_format, - unsigned* out_samplerate, unsigned* out_channels, unsigned* out_format){ + unsigned& out_samplerate, unsigned& out_channels, unsigned& out_format){ decaudio_priv_t* priv = reinterpret_cast<decaudio_priv_t*>(opaque.ad_private); sh_audio_t* sh_audio = priv->parent; char strbuf[200]; @@ -208,9 +208,9 @@ afs->input.format = afmt2mpaf(in_format); // output format: same as ao driver's input format (if missing, fallback to input) - afs->output.rate = *out_samplerate ? *out_samplerate : afs->input.rate; - afs->output.nch = *out_channels ? *out_channels : afs->input.nch; - if(*out_format) afs->output.format = afmt2mpaf(*out_format); + afs->output.rate = out_samplerate ? out_samplerate : afs->input.rate; + afs->output.nch = out_channels ? out_channels : afs->input.nch; + if(out_format) afs->output.format = afmt2mpaf(out_format); else afs->output.format = afs->input.format; // filter config: @@ -225,9 +225,9 @@ return MPXP_False; // failed :( } - *out_samplerate=afs->output.rate; - *out_channels=afs->output.nch; - *out_format=mpaf2afmt(afs->output.format); + out_samplerate=afs->output.rate; + out_channels=afs->output.nch; + out_format=mpaf2afmt(afs->output.format); sh_audio->af_bps = afs->output.rate*afs->output.nch*(afs->output.format&MPAF_BPS_MASK); Modified: mplayerxp/libmpcodecs/dec_audio.h =================================================================== --- mplayerxp/libmpcodecs/dec_audio.h 2012-12-28 07:33:30 UTC (rev 615) +++ mplayerxp/libmpcodecs/dec_audio.h 2012-12-28 08:16:10 UTC (rev 616) @@ -24,7 +24,7 @@ unsigned out_minsize, unsigned out_maxsize); extern MPXP_Rc mpca_preinit_filters(audio_decoder_t& sh_audio, unsigned in_samplerate, unsigned in_channels, unsigned in_format, - unsigned* out_samplerate, unsigned* out_channels, unsigned* out_format); + unsigned& out_samplerate, unsigned& out_channels, unsigned& out_format); extern MPXP_Rc mpca_reinit_filters(audio_decoder_t& sh_audio, unsigned in_samplerate, unsigned in_channels, mpaf_format_e in_format, unsigned out_samplerate, unsigned out_channels, mpaf_format_e out_format, Modified: mplayerxp/libmpcodecs/dec_video.cpp =================================================================== --- mplayerxp/libmpcodecs/dec_video.cpp 2012-12-28 07:33:30 UTC (rev 615) +++ mplayerxp/libmpcodecs/dec_video.cpp 2012-12-28 08:16:10 UTC (rev 616) @@ -83,15 +83,15 @@ return MPXP_False; } -MPXP_Rc mpcv_set_colors(video_decoder_t& opaque,const char *item,int value) +MPXP_Rc mpcv_set_colors(video_decoder_t& opaque,const std::string& item,int value) { decvideo_priv_t* priv=reinterpret_cast<decvideo_priv_t*>(opaque.vd_private); vf_stream_t* vs=priv->vfilter; vf_equalizer_t eq; - eq.item=item; + eq.item=item.c_str(); eq.value=value*10; if(vf_control(vs,VFCTRL_SET_EQUALIZER,&eq)!=MPXP_True) { - if(priv->mpvdec) return priv->mpvdec->control_vd(*priv->ctx,VDCTRL_SET_EQUALIZER,(any_t*)item,(int)value); + if(priv->mpvdec) return priv->mpvdec->control_vd(*priv->ctx,VDCTRL_SET_EQUALIZER,(any_t*)item.c_str(),(int)value); } return MPXP_False; } @@ -169,7 +169,7 @@ return handle; } -video_decoder_t* mpcv_init(sh_video_t *sh_video,const char* codecname,const char * vfm,int status,libinput_t&libinput){ +video_decoder_t* mpcv_init(sh_video_t *sh_video,const std::string& codecname,const std::string& family,int status,libinput_t&libinput){ UNUSED(codecname); UNUSED(status); int done=0; @@ -179,6 +179,7 @@ decvideo_priv_t* priv = new(zeromem) decvideo_priv_t(libinput); priv->parent=sh_video; handle->vd_private=priv; + std::string vfm=family; MP_UNIT("init_video_filters"); if(priv->vfilter_inited<=0) { @@ -190,7 +191,7 @@ priv->vfilter_inited=1; } - if(vfm) { + if(!vfm.empty()) { priv->mpvdec=vfm_find_driver(vfm); if(priv->mpvdec) vprobe=priv->mpvdec->probe(sh_video->fourcc); } Modified: mplayerxp/libmpcodecs/dec_video.h =================================================================== --- mplayerxp/libmpcodecs/dec_video.h 2012-12-28 07:33:30 UTC (rev 615) +++ mplayerxp/libmpcodecs/dec_video.h 2012-12-28 08:16:10 UTC (rev 616) @@ -12,14 +12,14 @@ }; // dec_video.c: -extern video_decoder_t* __FASTCALL__ mpcv_init(sh_video_t *sh_video, const char *codec_name,const char *family,int status,libinput_t&libinput); +extern video_decoder_t* __FASTCALL__ mpcv_init(sh_video_t *sh_video, const std::string& codec_name,const std::string& family,int status,libinput_t&libinput); extern void __FASTCALL__ mpcv_uninit(video_decoder_t& handle); extern video_decoder_t* __FASTCALL__ mpcv_lavc_init(sh_video_t*,libinput_t& libinput); extern int __FASTCALL__ mpcv_decode(video_decoder_t& handle,const enc_frame_t& frame); extern MPXP_Rc __FASTCALL__ mpcv_get_quality_max(video_decoder_t& handle,unsigned& quality); extern MPXP_Rc __FASTCALL__ mpcv_set_quality(video_decoder_t& handle,int quality); -extern MPXP_Rc __FASTCALL__ mpcv_set_colors(video_decoder_t& handle,const char *item,int value); +extern MPXP_Rc __FASTCALL__ mpcv_set_colors(video_decoder_t& handle,const std::string& item,int value); extern void __FASTCALL__ mpcv_resync_stream(video_decoder_t& handle); extern void vfm_help(void); Modified: mplayerxp/mplayerxp.cpp =================================================================== --- mplayerxp/mplayerxp.cpp 2012-12-28 07:33:30 UTC (rev 615) +++ mplayerxp/mplayerxp.cpp 2012-12-28 08:16:10 UTC (rev 616) @@ -243,22 +243,6 @@ /**************************************************************************/ MPXPContext& mpxp_context() { return *MPXPCtx; } -static int mpxp_init_antiviral_protection(int verbose) -{ - int rc; - rc=mp_mprotect((any_t*)antiviral_hole1,sizeof(antiviral_hole1),MP_DENY_ALL); - rc|=mp_mprotect((any_t*)antiviral_hole2,sizeof(antiviral_hole2),MP_DENY_ALL); - rc|=mp_mprotect((any_t*)antiviral_hole3,sizeof(antiviral_hole3),MP_DENY_ALL); - rc|=mp_mprotect((any_t*)antiviral_hole4,sizeof(antiviral_hole4),MP_DENY_ALL); - if(verbose) { - if(rc) - mpxp_err<<"*** Error! Cannot initialize antiviral protection: '"<<strerror(errno)<<"' ***!"<<std::endl; - else - mpxp_ok<<"*** Antiviral protection was inited ***!!!"<<std::endl; - } - return rc; -} - static MPXP_Rc mpxp_test_antiviral_protection(int* verbose) { if(*verbose) mpxp_info<<"Your've specified test-av option!\nRight now MPlayerXP should make coredump!"<<std::endl; @@ -282,12 +266,6 @@ #endif } -static void mpxp_init_structs(void) { -#if defined( ARCH_X86 ) || defined(ARCH_X86_64) - memset(&mp_conf.x86,-1,sizeof(x86_features_t)); -#endif -} - static void mpxp_uninit_structs(void) { #ifdef ENABLE_WIN32LOADER free_codec_cfg(); @@ -1159,7 +1137,7 @@ if(vo_conf.softzoom) mpxp_context().video().output->ZOOM_SET(); if(vo_conf.flip>0) mpxp_context().video().output->FLIP_SET(); if(vo_conf.vidmode) mpxp_context().video().output->VM_SET(); - if((mpxp_context().video().decoder=mpcv_init(sh_video,mp_conf.video_codec,mp_conf.video_family,-1,_libinput))) sh_video->inited=1; + if((mpxp_context().video().decoder=mpcv_init(sh_video,mp_conf.video_codec?mp_conf.video_codec:"",mp_conf.video_family?mp_conf.video_family:"",-1,_libinput))) sh_video->inited=1; #ifdef ENABLE_WIN32LOADER if(!sh_video->inited) { /* Go through the codec.conf and find the best codec...*/ @@ -1167,15 +1145,15 @@ if(mp_conf.video_codec) { /* forced codec by name: */ mpxp_info<<"Forced video codec: "<<mp_conf.video_codec<<std::endl; - mpxp_context().video().decoder=mpcv_init(sh_video,mp_conf.video_codec,NULL,-1,_libinput); + mpxp_context().video().decoder=mpcv_init(sh_video,video_codec?mp_conf.video_codec:"","",-1,_libinput); } else { int status; /* try in stability order: UNTESTED, WORKING, BUGGY, BROKEN */ if(mp_conf.video_family) mpxp_info<<MSGTR_TryForceVideoFmt<<": "<<mp_conf.video_family<<std::endl; for(status=CODECS_STATUS__MAX;status>=CODECS_STATUS__MIN;--status){ if(mp_conf.video_family) /* try first the preferred codec family:*/ - if((mpxp_context().video().decoder=mpcv_init(sh_video,NULL,mp_conf.video_family,status,_libinput))) break; - if((mpxp_context().video().decoder=mpcv_init(sh_video,NULL,NULL,status,_libinput))) break; + if((mpxp_context().video().decoder=mpcv_init(sh_video,"",mp_conf.video_family?mp_conf.video_family:"",status,_libinput))) break; + if((mpxp_context().video().decoder=mpcv_init(sh_video,"","",status,_libinput))) break; } } } @@ -1232,7 +1210,7 @@ (int)(sh_audio->rate), sh_audio->nch, sh_audio->afmt, // output: - &samplerate, &channels, &format)!=MPXP_Ok){ + samplerate, channels, format)!=MPXP_Ok){ mpxp_err<<"Audio filter chain preinit failed"<<std::endl; } else { mpxp_v<<"AF_pre: "<<samplerate<<"Hz "<<channels<<"ch (" @@ -1614,37 +1592,11 @@ return eof; } -static void mpxp_config_malloc(const std::vector<std::string>& argv) -{ - size_t i,sz=argv.size(); - mp_conf.malloc_debug=0; - mp_malloc_e flg=MPA_FLG_RANDOMIZER; - for(i=0;i<sz;i++) { - std::string s=argv[i]; - if(s.substr(0,18)=="-core.malloc-debug") { - size_t pos; - if((pos=s.find('='))!=std::string::npos) { - mp_conf.malloc_debug=::atoi(s.substr(pos+1).c_str()); - } - switch(mp_conf.malloc_debug) { - default: - case 0: flg=MPA_FLG_RANDOMIZER; break; - case 1: flg=MPA_FLG_BOUNDS_CHECK; break; - case 2: flg=MPA_FLG_BEFORE_CHECK; break; - case 3: flg=MPA_FLG_BACKTRACE; break; - } - break; - } - } - mp_init_malloc(argv[0],1000,10,flg); -} - _PlayTree_Iter* mpxp_get_playtree_iter() { return mpxp_context().engine().MPXPSys->playtree_iter; } /******************************************\ * MAIN MPLAYERXP FUNCTION !!! * \******************************************/ int MPlayerXP(const std::vector<std::string>& argv, const std::map<std::string,std::string>& envm){ - mpxp_init_antiviral_protection(1); // mpxp_test_backtrace(); Stream* stream=NULL; int stream_dump_type=0; @@ -1659,14 +1611,10 @@ int forced_subs_only=0; seek_args_t seek_args = { 0, DEMUX_SEEK_CUR|DEMUX_SEEK_SECONDS }; - mpxp_config_malloc(argv); - // Yes, it really must be placed in stack or in very secret place PointerProtector<MPXPSecureKeys> ptr_protector; secure_keys=ptr_protector.protect(new(zeromem) MPXPSecureKeys(10)); - mpxp_init_structs(); - mpxp_context().video().output=new(zeromem) Video_Output; init_signal_handling(); @@ -2012,7 +1960,6 @@ while(!eof){ int in_pause=0; - eof |= mpxp_context().engine().xp_core->audio->eof; /*========================== UPDATE TIMERS ============================*/ MP_UNIT("Update timers"); if(sh_audio) eof = mpxp_context().engine().xp_core->audio->eof; @@ -2030,7 +1977,7 @@ //================= Keyboard events, SEEKing ==================== memset(&input_state,0,sizeof(input_state_t)); - eof=MPXPSys.handle_input(&seek_args,&osd,&input_state); + eof|=MPXPSys.handle_input(&seek_args,&osd,&input_state); if(input_state.next_file) goto goto_next_file; if (mp_conf.seek_to_sec) { @@ -2169,11 +2116,46 @@ str=str.substr(0,pos); envm[str]=stmp; } + /* init antiviral protection */ + int rc; + rc=mp_mprotect((any_t*)antiviral_hole1,sizeof(antiviral_hole1),MP_DENY_ALL); + rc|=mp_mprotect((any_t*)antiviral_hole2,sizeof(antiviral_hole2),MP_DENY_ALL); + rc|=mp_mprotect((any_t*)antiviral_hole3,sizeof(antiviral_hole3),MP_DENY_ALL); + rc|=mp_mprotect((any_t*)antiviral_hole4,sizeof(antiviral_hole4),MP_DENY_ALL); + if(rc) { + mpxp_err<<"*** Error! Cannot initialize antiviral protection: '"<<strerror(errno)<<"' ***!"<<std::endl; + return EXIT_FAILURE; + } + mpxp_ok<<"*** Antiviral protection was inited ***!!!"<<std::endl; + /* init malloc */ + size_t i,sz=argv.size(); + mp_conf.malloc_debug=0; + mp_malloc_e flg=MPA_FLG_RANDOMIZER; + for(i=0;i<sz;i++) { + std::string s=argv[i]; + if(s.substr(0,18)=="-core.malloc-debug") { + if((pos=s.find('='))!=std::string::npos) { + mp_conf.malloc_debug=::atoi(s.substr(pos+1).c_str()); + } + switch(mp_conf.malloc_debug) { + default: + case 0: flg=MPA_FLG_RANDOMIZER; break; + case 1: flg=MPA_FLG_BOUNDS_CHECK; break; + case 2: flg=MPA_FLG_BEFORE_CHECK; break; + case 3: flg=MPA_FLG_BACKTRACE; break; + } + break; + } + } + mp_init_malloc(argv[0],1000,10,flg); + /* init structs */ +#if defined( ARCH_X86 ) || defined(ARCH_X86_64) + memset(&mp_conf.x86,-1,sizeof(x86_features_t)); +#endif + /* call player */ return MPlayerXP(argv,envm); } catch(const std::string& what) { std::cout<<"[main_module] Exception '"<<what<<"'caught in module: MPlayerXP"<<std::endl; -// } catch(...) { -// std::cout<<"[main_module] Exception caught in module: MPlayerXP"<<std::endl; } return EXIT_FAILURE; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2012-12-28 07:33:37
|
Revision: 615 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=615&view=rev Author: nickols_k Date: 2012-12-28 07:33:30 +0000 (Fri, 28 Dec 2012) Log Message: ----------- remove unused stuff Modified Paths: -------------- mplayerxp/libmpconf/Makefile mplayerxp/libvo2/vo_opengl.cpp Removed Paths: ------------- mplayerxp/libmpconf/subopt-helper.cpp mplayerxp/libmpconf/subopt-helper.h Modified: mplayerxp/libmpconf/Makefile =================================================================== --- mplayerxp/libmpconf/Makefile 2012-12-28 07:23:44 UTC (rev 614) +++ mplayerxp/libmpconf/Makefile 2012-12-28 07:33:30 UTC (rev 615) @@ -6,7 +6,7 @@ DO_MAKE = @ for i in $(SUBDIRS); do $(MAKE) -C $$i $@ || exit; done DO_ALL = @ for i in $(SUBDIRS); do $(MAKE) -C $$i all || exit; done -CXXSRCS=cfgparser.cpp m_option.cpp m_property.cpp m_struct.cpp subopt-helper.cpp +CXXSRCS=cfgparser.cpp m_option.cpp m_property.cpp m_struct.cpp SRCS = ifeq ($(ENABLE_WIN32LOADER),yes) CXXSRCS += codec-cfg.cpp Deleted: mplayerxp/libmpconf/subopt-helper.cpp =================================================================== --- mplayerxp/libmpconf/subopt-helper.cpp 2012-12-28 07:23:44 UTC (rev 614) +++ mplayerxp/libmpconf/subopt-helper.cpp 2012-12-28 07:33:30 UTC (rev 615) @@ -1,325 +0,0 @@ -#include "mpxp_config.h" -#include "osdep/mplib.h" -using namespace mpxp; -/** - * \file subopt-helper.c - * - * \brief Compensates the suboption parsing code duplication a bit. - * - * The routines defined below are there to help you with the - * suboption parsing. Meaning extracting the options and their - * values for you and also outputting generic help message if - * a parse error is encountered. - * - * Most stuff happens in the subopt_parse function: if you call it - * it parses for the passed opts in the passed string. It calls some - * extra functions for explicit argument parsing ( where the option - * itself isn't the argument but a value given after the argument - * delimiter ('='). It also calls your test function if you supplied - * one. - * - */ -#include <stdlib.h> -#include <string.h> -#include <limits.h> - -#include "subopt-helper.h" -#include "global_msg.h" - -/* prototypes for argument parsing */ -static char const * parse_int( char const * const str, int * const valp ); -static char const * parse_str( char const * const str, strarg_t * const valp ); -static char const * parse_float( char const * const str, float * const valp ); - -/** - * \brief Try to parse all options in str and fail if it was not possible. - * - * \param str Pointer to the zero terminated string to be parsed. - * \param opts Pointer to a options array. The array must be terminated - * with an element having set name to NULL in its opt_t structure. - * - * \return The return value is zero if the string could be parsed - * else a non-zero value is returned. - * - */ -int subopt_parse( char const * const str, const opt_t * opts ) -{ - int parse_err = 0, idx; - unsigned int parse_pos = 0; - - if ( str ) - { - while ( str[parse_pos] && !parse_err ) - { - int next = 0; - - idx = 0; // reset index for the below loop - while ( opts[idx].name ) - { - int opt_len; - int substr_len; - - // get length of the option we test against */ - opt_len = strlen( opts[idx].name ); - - // get length of the current substring of str */ - { - const char* arg_delim; - const char* delim; - - /* search nearest delimiter ( option or argument delimiter ) */ - delim = strchr( &str[parse_pos], ':' ); - arg_delim = strchr( &str[parse_pos], '=' ); - - if ( ( delim && arg_delim && delim > arg_delim ) || - delim == NULL ) - { - delim = strchr( &str[parse_pos], '=' ); - } - - substr_len = delim ? // is a delim present - delim - &str[parse_pos] : // yes - strlen( &str[parse_pos] ); // no, end of string - } - - //printf( "substr_len=%d, opt_len=%d\n", substr_len, opt_len ); - - /* Check if the length of the current option matches the * - * length of the option we want to test again. */ - if ( substr_len == opt_len ) -{ - /* check if option was activated/deactivated */ - if( strncmp( &str[parse_pos], opts[idx].name, opt_len ) == 0 ) - { - /* option was found */ - next = 1; - - /* type specific code */ - if ( opts[idx].type == OPT_ARG_BOOL ) - { - /* Handle OPT_ARG_BOOL separately so * - * the others can share code. */ - - /* set option to true */ - *((int *)(opts[idx].valp)) = 1; - - /* increment position */ - parse_pos += opt_len; - } - else - { - /* Type is not OPT_ARG_BOOL, means we have to parse * - * for the arg delimiter character and eventually * - * call a test function. */ - char const * last; - - /* increment position to check for arg */ - parse_pos += opt_len; - - if ( str[parse_pos] != '=' ) - { - parse_err = 1; break; - } - - /* '=' char was there, so let's move after it */ - ++parse_pos; - - switch ( opts[idx].type ) - { - case OPT_ARG_INT: - last = parse_int( &str[parse_pos], - (int *)opts[idx].valp ); - - break; - case OPT_ARG_STR: - last = parse_str( &str[parse_pos], - (strarg_t *)opts[idx].valp ); - break; - case OPT_ARG_MSTRZ: - { - char **valp = reinterpret_cast<char**>(opts[idx].valp); - strarg_t tmp; - tmp.str = NULL; - tmp.len = 0; - last = parse_str( &str[parse_pos], &tmp ); - if (*valp) - delete *valp; - *valp = NULL; - if (tmp.str && tmp.len > 0) { - *valp = new char [tmp.len + 1]; - memcpy(*valp, tmp.str, tmp.len); - (*valp)[tmp.len] = 0; - } - break; - } - case OPT_ARG_FLOAT: - last = parse_float( &str[parse_pos], - (float *)opts[idx].valp ); - break; - default: - last = NULL; // break parsing! - } - - /* was the conversion succesful? */ - if ( !last ) - { - parse_err = 1; break; - } - - /* make test if supplied */ - if ( opts[idx].test && !opts[idx].test( opts[idx].valp ) ) - { - parse_err = 1; break; - } - - /* we succeded, set position */ - parse_pos = last - str; - } - } -} -else if ( substr_len == opt_len+2 ) -{ - if ( opts[idx].type == OPT_ARG_BOOL && // check for no<opt> - strncmp( &str[parse_pos], "no", 2 ) == 0 && - strncmp( &str[parse_pos+2], opts[idx].name, opt_len ) == 0 ) - { - /* option was found but negated */ - next = 1; - - /* set arg to false */ - *((int *)(opts[idx].valp)) = 0; - - /* increment position */ - parse_pos += opt_len+2; - } -} - - ++idx; // test against next option - - /* break out of the loop, if this subopt is processed */ - if ( next ) { break; } - } - - /* if we had a valid suboption the current pos should * - * equal the delimiter char, which should be ':' for * - * suboptions. */ - if ( !parse_err && str[parse_pos] == ':' ) { ++parse_pos; } - else if ( str[parse_pos] ) { parse_err = 1; } - } - } - - /* if an error was encountered */ - if (parse_err) - { - unsigned int i; - MSG_FATAL("Could not parse arguments at the position indicated below:\n%s\n", str ); - for ( i = 0; i < parse_pos; ++i ) - { - MSG_FATAL(" "); - } - MSG_FATAL("^\n"); - - return -1; - } - - /* we could parse everything */ - return 0; -} - -static char const * parse_int( char const * const str, int * const valp ) -{ - char * endp; - - *valp = (int)strtol( str, &endp, 0 ); - - /* nothing was converted */ - if ( str == endp ) { return NULL; } - - return endp; -} - -static char const * parse_float( char const * const str, float * const valp ) -{ - char * endp; - - *valp = strtod( str, &endp ); - - /* nothing was converted */ - if ( str == endp ) { return NULL; } - - return endp; -} - -static const char QUOTE_CHAR='%'; -static char const * parse_str( char const * str, strarg_t * const valp ) -{ - char const * match = strchr( str, ':' ); - - if (str[0] == QUOTE_CHAR) { - int len = 0; - str = &str[1]; - len = (int)strtol(str, (char **)&str, 0); - if (!str || str[0] != QUOTE_CHAR || (len > strlen(str) - 1)) - return NULL; - str = &str[1]; - match = &str[len]; - } - else - if (str[0] == '"') { - str = &str[1]; - match = strchr(str, '"'); - if (!match) - return NULL; - valp->len = match - str; - valp->str = str; - return &match[1]; - } - if ( !match ) - match = &str[strlen(str)]; - - // empty string or too long - if ((match == str) || (match - str > INT_MAX)) - return NULL; - - valp->len = match - str; - valp->str = str; - - return match; -} - - -/*** common test functions ***/ - -/** \brief Test if i is not negative */ -int int_non_neg( int * i ) -{ - if ( *i < 0 ) { return 0; } - - return 1; -} -/** \brief Test if i is positive. */ -int int_pos( int * i ) -{ - if ( *i > 0 ) { return 1; } - - return 0; -} - -/*** little helpers */ - -/** \brief compare the stings just as strcmp does */ -int strargcmp(strarg_t *arg, const char *str) { - int res = strncmp(arg->str, str, arg->len); - if (!res && arg->len != strlen(str)) - res = arg->len - strlen(str); - return res; -} - -/** \brief compare the stings just as strcasecmp does */ -int strargcasecmp(strarg_t *arg, char *str) { - int res = strncasecmp(arg->str, str, arg->len); - if (!res && arg->len != strlen(str)) - res = arg->len - strlen(str); - return res; -} - Deleted: mplayerxp/libmpconf/subopt-helper.h =================================================================== --- mplayerxp/libmpconf/subopt-helper.h 2012-12-28 07:23:44 UTC (rev 614) +++ mplayerxp/libmpconf/subopt-helper.h 2012-12-28 07:33:30 UTC (rev 615) @@ -1,44 +0,0 @@ -#ifndef MPLAYER_SUBOPT_HELPER_H -#define MPLAYER_SUBOPT_HELPER_H - -#include "mpxp_config.h" -/** - * \file subopt-helper.h - * - * \brief Datatype and functions declarations for usage - * of the suboption parser. - * - */ -enum { - OPT_ARG_BOOL =0, - OPT_ARG_INT =1, - OPT_ARG_STR =2, - OPT_ARG_MSTRZ =3, ///< A malloced, zero terminated string, use mp_free()! - OPT_ARG_FLOAT =4 -}; -typedef int (*opt_test_f)(any_t*); - -/** simple structure for defining the option name, type and storage location */ -struct opt_t { - const char * name; ///< string that identifies the option - int type; ///< option type as defined in subopt-helper.h - any_t* valp; ///< pointer to the mem where the value should be stored - opt_test_f test; ///< argument test func ( optional ) -}; - -/** parses the string for the options specified in opt */ -int subopt_parse( char const * const str, const opt_t * opts ); - - -/*------------------ arg specific types and declaration -------------------*/ -typedef struct strarg_t { - int len; ///< length of the string determined by the parser - char const * str; ///< pointer to position inside the parse string -}; - -int int_non_neg( int * i ); -int int_pos( int * i ); - -int strargcmp(strarg_t *arg, const char *str); -int strargcasecmp(strarg_t *arg, char *str); -#endif /* MPLAYER_SUBOPT_HELPER_H */ Modified: mplayerxp/libvo2/vo_opengl.cpp =================================================================== --- mplayerxp/libvo2/vo_opengl.cpp 2012-12-28 07:23:44 UTC (rev 614) +++ mplayerxp/libvo2/vo_opengl.cpp 2012-12-28 07:33:30 UTC (rev 615) @@ -33,7 +33,6 @@ #include "video_out_internal.h" #include "font_load.h" #include "sub.h" -#include "libmpconf/subopt-helper.h" #include "postproc/swscale.h" /* for MODE_RGB(BGR) definitions */ #ifdef GL_WIN32 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2012-12-28 07:23:56
|
Revision: 614 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=614&view=rev Author: nickols_k Date: 2012-12-28 07:23:44 +0000 (Fri, 28 Dec 2012) Log Message: ----------- improve readability of sources: rename config_t -> mpxp_option_t Modified Paths: -------------- mplayerxp/input2/input.cpp mplayerxp/libmpcodecs/ad.h mplayerxp/libmpcodecs/ad_a52.cpp mplayerxp/libmpcodecs/ad_acm.cpp mplayerxp/libmpcodecs/ad_dca.cpp mplayerxp/libmpcodecs/ad_dmo.cpp mplayerxp/libmpcodecs/ad_dshow.cpp mplayerxp/libmpcodecs/ad_dvdpcm.cpp mplayerxp/libmpcodecs/ad_faad.cpp mplayerxp/libmpcodecs/ad_hwac3.cpp mplayerxp/libmpcodecs/ad_lavc.cpp mplayerxp/libmpcodecs/ad_libdv.cpp mplayerxp/libmpcodecs/ad_mp3.cpp mplayerxp/libmpcodecs/ad_null.cpp mplayerxp/libmpcodecs/ad_pcm.cpp mplayerxp/libmpcodecs/ad_qtaudio.cpp mplayerxp/libmpcodecs/ad_real.cpp mplayerxp/libmpcodecs/ad_twin.cpp mplayerxp/libmpcodecs/ad_vorbis.cpp mplayerxp/libmpcodecs/vd.h mplayerxp/libmpcodecs/vd_divx4.cpp mplayerxp/libmpcodecs/vd_dmo.cpp mplayerxp/libmpcodecs/vd_dshow.cpp mplayerxp/libmpcodecs/vd_huffyuv.cpp mplayerxp/libmpcodecs/vd_internal.h mplayerxp/libmpcodecs/vd_lavc.cpp mplayerxp/libmpcodecs/vd_libdv.cpp mplayerxp/libmpcodecs/vd_libmpeg2.cpp mplayerxp/libmpcodecs/vd_mpegpes.cpp mplayerxp/libmpcodecs/vd_null.cpp mplayerxp/libmpcodecs/vd_nuv.cpp mplayerxp/libmpcodecs/vd_qtvideo.cpp mplayerxp/libmpcodecs/vd_raw.cpp mplayerxp/libmpcodecs/vd_real.cpp mplayerxp/libmpcodecs/vd_theora.cpp mplayerxp/libmpcodecs/vd_vfw.cpp mplayerxp/libmpcodecs/vd_xanim.cpp mplayerxp/libmpcodecs/vd_xvid.cpp mplayerxp/libmpconf/cfgparser.cpp mplayerxp/libmpconf/cfgparser.h mplayerxp/libmpdemux/demux_ac3.cpp mplayerxp/libmpdemux/demux_avi.cpp mplayerxp/libmpdemux/demux_dca.cpp mplayerxp/libmpdemux/demux_flac.cpp mplayerxp/libmpdemux/demux_lavf.cpp mplayerxp/libmpdemux/demux_mp3.cpp mplayerxp/libmpdemux/demux_musepack.cpp mplayerxp/libmpdemux/demux_null.cpp mplayerxp/libmpdemux/demux_rawaudio.cpp mplayerxp/libmpdemux/demux_rawvideo.cpp mplayerxp/libmpdemux/demux_snd_au.cpp mplayerxp/libmpdemux/demux_viv.cpp mplayerxp/libmpdemux/demux_voc.cpp mplayerxp/libmpdemux/demux_wav.cpp mplayerxp/libmpdemux/demuxer.cpp mplayerxp/libmpdemux/demuxer_internal.h mplayerxp/libmpstream2/cdda.cpp mplayerxp/mplayerxp.cpp mplayerxp/mplayerxp.h mplayerxp/xmpcore/xmp_context.cpp mplayerxp/xmpcore/xmp_context.h Modified: mplayerxp/input2/input.cpp =================================================================== --- mplayerxp/input2/input.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/input2/input.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -430,7 +430,7 @@ static int mp_input_print_key_list(libinput_t&); static int mp_input_print_cmd_list(libinput_t&); -static const config_t joystick_conf[] = { +static const mpxp_option_t joystick_conf[] = { { "on", &libinput_conf.use_joystick, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, "enables using of joystick" }, { "off", &libinput_conf.use_joystick, CONF_TYPE_FLAG, CONF_GLOBAL, 1, 0, "disables using of joystick" }, { "dev", &libinput_conf.js_dev, CONF_TYPE_STRING, CONF_GLOBAL, 0, 0, "specifies the joystick device" }, @@ -439,7 +439,7 @@ extern char *lirc_configfile; // Our command line options -static const config_t input_conf[] = { +static const mpxp_option_t input_conf[] = { { "conf", (any_t*)&config_file, CONF_TYPE_STRING, CONF_GLOBAL, 0, 0, "specifies alternative input.conf" }, { "ar-delay", (any_t*)&libinput_conf.ar_delay, CONF_TYPE_INT, CONF_GLOBAL, 0, 0, "autorepeate a key delay in milliseconds (0 to disable)" }, { "ar-rate", (any_t*)&libinput_conf.ar_rate, CONF_TYPE_INT, CONF_GLOBAL, 0, 0, "number of key-presses per second generating on autorepeat" }, @@ -457,7 +457,7 @@ { NULL, NULL, 0, 0, 0, 0, NULL} }; -static const config_t mp_input_opts[] = { +static const mpxp_option_t mp_input_opts[] = { { "input", (any_t*)&input_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, "Input specific options"}, { NULL, NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpcodecs/ad.h =================================================================== --- mplayerxp/libmpcodecs/ad.h 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpcodecs/ad.h 2012-12-28 07:23:44 UTC (rev 614) @@ -48,7 +48,7 @@ struct ad_functions_t { const ad_info_t* info; - const config_t* options;/**< Optional: MPlayerXP's option related */ + const mpxp_option_t* options;/**< Optional: MPlayerXP's option related */ const audio_probe_t*(* __FASTCALL__ probe)(uint32_t wtag); Opaque* (* __FASTCALL__ preinit)(const audio_probe_t&,sh_audio_t*,audio_filter_info_t&); MPXP_Rc (* __FASTCALL__ init)(Opaque& ctx); Modified: mplayerxp/libmpcodecs/ad_a52.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_a52.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpcodecs/ad_a52.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -46,7 +46,7 @@ "build-in" }; -static const config_t options[] = { +static const mpxp_option_t options[] = { { NULL, NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpcodecs/ad_acm.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_acm.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpcodecs/ad_acm.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -20,7 +20,7 @@ "build-in" }; -static const config_t options[] = { +static const mpxp_option_t options[] = { { NULL, NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpcodecs/ad_dca.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_dca.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpcodecs/ad_dca.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -45,7 +45,7 @@ "build-in" }; -static const config_t options[] = { +static const mpxp_option_t options[] = { { NULL, NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpcodecs/ad_dmo.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_dmo.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpcodecs/ad_dmo.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -20,7 +20,7 @@ "build-in" }; -static const config_t options[] = { +static const mpxp_option_t options[] = { { NULL, NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpcodecs/ad_dshow.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_dshow.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpcodecs/ad_dshow.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -17,7 +17,7 @@ "build-in" }; -static const config_t options[] = { +static const mpxp_option_t options[] = { { NULL, NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpcodecs/ad_dvdpcm.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_dvdpcm.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpcodecs/ad_dvdpcm.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -24,7 +24,7 @@ "build-in" }; -static const config_t options[] = { +static const mpxp_option_t options[] = { { NULL, NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpcodecs/ad_faad.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_faad.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpcodecs/ad_faad.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -29,7 +29,7 @@ "http://www.audiocoding.com/faad2.html" }; -static const config_t options[] = { +static const mpxp_option_t options[] = { { NULL, NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpcodecs/ad_hwac3.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_hwac3.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpcodecs/ad_hwac3.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -155,7 +155,7 @@ "build-in" }; -static const config_t options[] = { +static const mpxp_option_t options[] = { { NULL, NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpcodecs/ad_lavc.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_lavc.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpcodecs/ad_lavc.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -88,7 +88,7 @@ "build-in" }; -static const config_t options[] = { +static const mpxp_option_t options[] = { { NULL, NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpcodecs/ad_libdv.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_libdv.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpcodecs/ad_libdv.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -41,7 +41,7 @@ "http://libdv.sourceforge.net" }; -static const config_t options[] = { +static const mpxp_option_t options[] = { { NULL, NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpcodecs/ad_mp3.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_mp3.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpcodecs/ad_mp3.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -23,7 +23,7 @@ "http://www.mpg123.de" }; -static const config_t options[] = { +static const mpxp_option_t options[] = { { NULL, NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpcodecs/ad_null.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_null.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpcodecs/ad_null.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -22,7 +22,7 @@ "build-in" }; -static const config_t options[] = { +static const mpxp_option_t options[] = { { NULL, NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpcodecs/ad_pcm.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_pcm.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpcodecs/ad_pcm.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -25,7 +25,7 @@ "build-in" }; -static const config_t options[] = { +static const mpxp_option_t options[] = { { NULL, NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpcodecs/ad_qtaudio.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_qtaudio.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpcodecs/ad_qtaudio.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -27,7 +27,7 @@ "build-in" }; -static const config_t options[] = { +static const mpxp_option_t options[] = { { NULL, NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpcodecs/ad_real.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_real.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpcodecs/ad_real.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -22,7 +22,7 @@ "build-in" }; -static const config_t options[] = { +static const mpxp_option_t options[] = { { NULL, NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpcodecs/ad_twin.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_twin.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpcodecs/ad_twin.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -20,7 +20,7 @@ "build-in" }; -static const config_t options[] = { +static const mpxp_option_t options[] = { { NULL, NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpcodecs/ad_vorbis.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_vorbis.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpcodecs/ad_vorbis.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -23,7 +23,7 @@ "build-in" }; -static const config_t options[] = { +static const mpxp_option_t options[] = { { NULL, NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpcodecs/vd.h =================================================================== --- mplayerxp/libmpcodecs/vd.h 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpcodecs/vd.h 2012-12-28 07:23:44 UTC (rev 614) @@ -53,7 +53,7 @@ /* interface of video decoder drivers */ struct vd_functions_t { const vd_info_t* info; - const config_t* options;/**< Optional: MPlayerXP's option related */ + const mpxp_option_t* options;/**< Optional: MPlayerXP's option related */ const video_probe_t*(*__FASTCALL__ probe)(uint32_t fourcc); Opaque* (*__FASTCALL__ preinit)(const video_probe_t& probe,sh_video_t *sh,put_slice_info_t& psi); MPXP_Rc (*__FASTCALL__ init)(Opaque& ctx,video_decoder_t& opaque); Modified: mplayerxp/libmpcodecs/vd_divx4.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_divx4.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpcodecs/vd_divx4.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -32,7 +32,7 @@ "http://labs.divx.com/DivXLinuxCodec" }; -static const config_t options[] = { +static const mpxp_option_t options[] = { { NULL, NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpcodecs/vd_dmo.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_dmo.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpcodecs/vd_dmo.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -21,7 +21,7 @@ "build-in" }; -static const config_t options[] = { +static const mpxp_option_t options[] = { { NULL, NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpcodecs/vd_dshow.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_dshow.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpcodecs/vd_dshow.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -23,7 +23,7 @@ "build-in" }; -static const config_t options[] = { +static const mpxp_option_t options[] = { { NULL, NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpcodecs/vd_huffyuv.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_huffyuv.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpcodecs/vd_huffyuv.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -34,7 +34,7 @@ "build-in" }; -static const config_t options[] = { +static const mpxp_option_t options[] = { { NULL, NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpcodecs/vd_internal.h =================================================================== --- mplayerxp/libmpcodecs/vd_internal.h 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpcodecs/vd_internal.h 2012-12-28 07:23:44 UTC (rev 614) @@ -6,7 +6,7 @@ #include "vd_msg.h" // prototypes: //static vd_info_t info; -//static const config_t options[]; +//static const mpxp_option_t options[]; static const video_probe_t* __FASTCALL__ probe(uint32_t fourcc); static MPXP_Rc control_vd(Opaque& ctx,int cmd,any_t* arg,...); @@ -17,7 +17,7 @@ #define LIBVD_EXTERN(x) extern const vd_functions_t mpcodecs_vd_##x = {\ &info,\ - (const config_t*)options,\ + (const mpxp_option_t*)options,\ probe, \ preinit, \ init,\ Modified: mplayerxp/libmpcodecs/vd_lavc.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_lavc.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpcodecs/vd_lavc.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -50,7 +50,7 @@ static char *lavc_avopt = NULL; static int enable_ffslices=1; -static const config_t ff_options[] = { +static const mpxp_option_t ff_options[] = { {"slices", &enable_ffslices, CONF_TYPE_FLAG, 0, 0, 1, "enables slice-based method of frame rendering in lavc decoder"}, {"noslices", &enable_ffslices, CONF_TYPE_FLAG, 0, 1, 0, "disables slice-based method of frame rendering in lavc decoder"}, {"er", &lavc_param_error_resilience, CONF_TYPE_INT, CONF_RANGE, 0, 99, "specifies error resilience for lavc decoders"}, @@ -70,7 +70,7 @@ { NULL, NULL, 0, 0, 0, 0, NULL} }; -static const config_t options[] = { +static const mpxp_option_t options[] = { {"lavc", (any_t*)&ff_options, CONF_TYPE_SUBCONFIG, 0, 0, 0, "lavc specific options"}, { NULL, NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpcodecs/vd_libdv.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_libdv.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpcodecs/vd_libdv.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -38,7 +38,7 @@ "http://libdv.sourceforge.net" }; -static const config_t options[] = { +static const mpxp_option_t options[] = { { NULL, NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpcodecs/vd_libmpeg2.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_libmpeg2.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpcodecs/vd_libmpeg2.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -28,7 +28,7 @@ "http://libmpeg2.sourceforge.net" }; -static const config_t options[] = { +static const mpxp_option_t options[] = { { NULL, NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpcodecs/vd_mpegpes.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_mpegpes.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpcodecs/vd_mpegpes.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -14,7 +14,7 @@ "build-in" }; -static const config_t options[] = { +static const mpxp_option_t options[] = { { NULL, NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpcodecs/vd_null.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_null.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpcodecs/vd_null.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -22,7 +22,7 @@ "build-in" }; -static const config_t options[] = { +static const mpxp_option_t options[] = { { NULL, NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpcodecs/vd_nuv.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_nuv.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpcodecs/vd_nuv.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -25,7 +25,7 @@ "build-in" }; -static const config_t options[] = { +static const mpxp_option_t options[] = { { NULL, NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpcodecs/vd_qtvideo.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_qtvideo.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpcodecs/vd_qtvideo.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -25,7 +25,7 @@ "build-in" }; -static const config_t options[] = { +static const mpxp_option_t options[] = { { NULL, NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpcodecs/vd_raw.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_raw.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpcodecs/vd_raw.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -24,7 +24,7 @@ "build-in" }; -static const config_t options[] = { +static const mpxp_option_t options[] = { { NULL, NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpcodecs/vd_real.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_real.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpcodecs/vd_real.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -20,7 +20,7 @@ "build-in" }; -static const config_t options[] = { +static const mpxp_option_t options[] = { { NULL, NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpcodecs/vd_theora.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_theora.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpcodecs/vd_theora.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -23,7 +23,7 @@ "build-in" }; -static const config_t options[] = { +static const mpxp_option_t options[] = { { NULL, NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpcodecs/vd_vfw.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_vfw.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpcodecs/vd_vfw.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -29,7 +29,7 @@ "build-in" }; -static const config_t options[] = { +static const mpxp_option_t options[] = { { NULL, NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpcodecs/vd_xanim.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_xanim.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpcodecs/vd_xanim.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -34,7 +34,7 @@ "build-in" }; -static const config_t options[] = { +static const mpxp_option_t options[] = { { NULL, NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpcodecs/vd_xvid.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_xvid.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpcodecs/vd_xvid.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -27,7 +27,7 @@ }; -static const config_t options[] = { +static const mpxp_option_t options[] = { { NULL, NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpconf/cfgparser.cpp =================================================================== --- mplayerxp/libmpconf/cfgparser.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpconf/cfgparser.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -18,6 +18,12 @@ #include <string.h> #include <errno.h> +#include "mplayerxp.h" +#include "cfgparser.h" +#include "libplaytree/playtree.h" +#include "parser_msg.h" + +namespace mpxp { enum { COMMAND_LINE=0, CONFIG_FILE=1, @@ -27,10 +33,6 @@ MAX_RECURSION_DEPTH=8 }; -#include "mplayerxp.h" -#include "cfgparser.h" -#include "libplaytree/playtree.h" -#include "parser_msg.h" inline void SET_GLOBAL(m_config_t& c) { c.flags |= CONFIG_GLOBAL; } inline void UNSET_GLOBAL(m_config_t& c) { c.flags &= (!CONFIG_GLOBAL); } @@ -38,12 +40,12 @@ inline void SET_RUNNING(m_config_t& c) { c.flags |= CONFIG_RUNNING; } inline int IS_RUNNING(const m_config_t& c) { return c.flags & CONFIG_RUNNING; } -typedef int (*cfg_func_arg_param_t)(const config_t *,const std::string& ,const std::string& ); -typedef int (*cfg_func_param_t)(const config_t *,const std::string& ); -typedef int (*cfg_func_t)(const config_t *); +typedef int (*cfg_func_arg_param_t)(const mpxp_option_t *,const std::string& ,const std::string& ); +typedef int (*cfg_func_param_t)(const mpxp_option_t *,const std::string& ); +typedef int (*cfg_func_t)(const mpxp_option_t *); static void -m_config_save_option(m_config_t& config,const config_t* conf,const std::string& opt,const std::string& param) { +m_config_save_option(m_config_t& config,const mpxp_option_t* conf,const std::string& opt,const std::string& param) { config_save_t* save; int sl=0; @@ -242,14 +244,14 @@ static int cfg_inc_int(int value){ return ++value; } -static int config_read_option(m_config_t& config,const std::vector<const config_t*>& conf_list,const std::string& opt,const std::string& param) +static int config_read_option(m_config_t& config,const std::vector<const mpxp_option_t*>& conf_list,const std::string& opt,const std::string& param) { int i=0,nconf = 0; long tmp_int; double tmp_float; int ret = -1; char *endptr; - const config_t* conf=NULL; + const mpxp_option_t* conf=NULL; mpxp_dbg3<<"read_option: opt='"<<opt<<"' param='"<<param<<"'"<<std::endl; std::string lopt=opt; @@ -451,11 +453,11 @@ goto out; } -static const config_t* m_config_find_option(const std::vector<const config_t*>& list,const std::string& name); +static const mpxp_option_t* m_config_find_option(const std::vector<const mpxp_option_t*>& list,const std::string& name); int m_config_set_option(m_config_t& config,const std::string& _opt,const std::string& param) { size_t e; - std::vector<const config_t*> clist=config.opt_list; + std::vector<const mpxp_option_t*> clist=config.opt_list; std::string opt=_opt; std::string s; mpxp_dbg2<<"Setting option "<<opt<<"="<<param<<std::endl; @@ -464,7 +466,7 @@ e=opt.find('.'); if(e!=std::string::npos) { int flg,ret; - const config_t *subconf=NULL; + const mpxp_option_t *subconf=NULL; mpxp_dbg2<<"Parsing "<<opt<<" as subconfig"<<std::endl; do { if((e = opt.find('.'))==std::string::npos) break; @@ -474,7 +476,7 @@ clist.clear(); if(!subconf) return ERR_NO_SUBCONF; if(subconf->type!=CONF_TYPE_SUBCONFIG) return ERR_NO_SUBCONF; - clist.push_back(reinterpret_cast<const config_t*>(subconf->p)); + clist.push_back(reinterpret_cast<const mpxp_option_t*>(subconf->p)); opt = opt.substr(e+1); mpxp_dbg2<<"switching next subconf="<<subconf->name<<std::endl; }while(1); @@ -488,10 +490,10 @@ e = opt.find(':'); if(e!=std::string::npos && e<(opt.length()-1)) { int ret; - const config_t* m_opt; - std::vector<const config_t*> opt_list; + const mpxp_option_t* m_opt; + std::vector<const mpxp_option_t*> opt_list; s=opt.substr(0,e); - m_opt=(const config_t*)m_config_get_option_ptr(config,s); + m_opt=(const mpxp_option_t*)m_config_get_option_ptr(config,s); if(!m_opt) { mpxp_err<<"m_config_set_option "<<opt<<"="<<param<<" : no "<<s<<" subconfig"<<std::endl; return ERR_NOT_AN_OPTION; @@ -678,7 +680,6 @@ return ret; } -namespace mpxp { MPXP_Rc mpxp_parse_command_line(m_config_t& config, const std::vector<std::string>& argv,const std::map<std::string,std::string>& envm) { size_t i,siz=argv.size(); @@ -699,7 +700,7 @@ exit(0); } if(opt=="--long-help") { - show_long_help(envm); + show_long_help(config,envm); exit(0); } /* check for -- (no more options id.) except --help! */ @@ -794,18 +795,15 @@ mpxp_err<<"command line: "<<argv[i]<<std::endl; return MPXP_False; } -} // namespace mpxp -int m_config_register_options(m_config_t& config,const config_t *args) { - std::vector<const config_t*>& conf_list = config.opt_list; - conf_list.push_back(args); - - return 1; +MPXP_Rc m_config_register_options(m_config_t& config,const mpxp_option_t *args) { + config.opt_list.push_back(args); + return MPXP_Ok; } -static const config_t* m_config_find_option(const std::vector<const config_t*>& list,const std::string& name) { +static const mpxp_option_t* m_config_find_option(const std::vector<const mpxp_option_t*>& list,const std::string& name) { unsigned i,j; - const config_t *conf; + const mpxp_option_t *conf; if(!list.empty()) { std::string ln=name; std::transform(ln.begin(),ln.end(),ln.begin(), ::tolower); @@ -821,13 +819,13 @@ return NULL; } -const config_t* m_config_get_option(const m_config_t& config,const std::string& arg) { +const mpxp_option_t* m_config_get_option(const m_config_t& config,const std::string& arg) { size_t e; e = arg.find(':'); if(e!=std::string::npos) { - std::vector<const config_t*> cl; - const config_t* opt; + std::vector<const mpxp_option_t*> cl; + const mpxp_option_t* opt; std::string s; s=arg.substr(0,e); opt = m_config_get_option(config,s); @@ -838,7 +836,7 @@ } any_t* m_config_get_option_ptr(const m_config_t& config,const std::string& arg) { - const config_t* conf; + const mpxp_option_t* conf; conf = m_config_get_option(config,arg); if(!conf) return NULL; @@ -869,11 +867,11 @@ return *ret; } -inline int AS_INT(const config_t* c) { return *((int*)c->p); } -inline void AS_INT(const config_t* c,int val) { *((int*)c->p)=val; } +inline int AS_INT(const mpxp_option_t* c) { return *((int*)c->p); } +inline void AS_INT(const mpxp_option_t* c,int val) { *((int*)c->p)=val; } int m_config_set_int(m_config_t& config,const std::string& arg,int val) { - const config_t* opt; + const mpxp_option_t* opt; opt = m_config_get_option(config,arg); @@ -892,7 +890,7 @@ } int m_config_set_float(m_config_t& config,const std::string& arg,float val) { - const config_t* opt; + const mpxp_option_t* opt; opt = m_config_get_option(config,arg); @@ -912,7 +910,7 @@ int m_config_switch_flag(m_config_t& config,const std::string& opt) { - const config_t *conf; + const mpxp_option_t *conf; conf = m_config_get_option(config,opt); if(!conf || conf->type != CONF_TYPE_FLAG) return 0; @@ -924,7 +922,7 @@ } int m_config_set_flag(m_config_t& config,const std::string& opt, int state) { - const config_t *conf; + const mpxp_option_t *conf; conf = m_config_get_option(config,opt); if(!conf || conf->type != CONF_TYPE_FLAG) return 0; @@ -935,7 +933,7 @@ int m_config_get_flag(const m_config_t& config,const std::string& opt) { - const config_t* conf = m_config_get_option(config,opt); + const mpxp_option_t* conf = m_config_get_option(config,opt); if(!conf || conf->type != CONF_TYPE_FLAG) return -1; if(AS_INT(conf) == conf->max) return 1; else if(AS_INT(conf) == conf->min) return 0; @@ -943,7 +941,7 @@ } int m_config_is_option_set(const m_config_t& config,const std::string& arg) { - const config_t* opt; + const mpxp_option_t* opt; config_save_t* save; int l,i; @@ -965,7 +963,7 @@ return 0; } -static void __m_config_show_options(unsigned ntabs,const std::string& pfx,const config_t* opts) { +static void __m_config_show_options(unsigned ntabs,const std::string& pfx,const mpxp_option_t* opts) { unsigned i,n; i=0; while(opts[i].name) { @@ -980,7 +978,7 @@ else newpfx=""; newpfx+=opts[i].name; newpfx+="."; - __m_config_show_options(ntabs+2,newpfx,(const config_t *)opts[i].p); + __m_config_show_options(ntabs+2,newpfx,(const mpxp_option_t *)opts[i].p); } else if(opts[i].type<=CONF_TYPE_PRINT) { @@ -1053,12 +1051,13 @@ } void m_config_show_options(const m_config_t& args) { - unsigned j; - const config_t *opts; + size_t j,sz=args.opt_list.size(); + const mpxp_option_t *opts; j=0; mpxp_info<<"List of available command-line options:"<<std::endl; - while((opts=args.opt_list[j])!=NULL) { - __m_config_show_options(2,NULL,opts); - j++; + for(j=0;j<sz;j++) { + opts=args.opt_list[j]; + __m_config_show_options(2,"",opts); }; } +} // namespace mpxp Modified: mplayerxp/libmpconf/cfgparser.h =================================================================== --- mplayerxp/libmpconf/cfgparser.h 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpconf/cfgparser.h 2012-12-28 07:23:44 UTC (rev 614) @@ -11,164 +11,165 @@ namespace mpxp { struct libinput_t; struct PlayTree; -} -/* config types */ -enum { - CONF_TYPE_FLAG =0, - CONF_TYPE_INT =1, - CONF_TYPE_FLOAT =2, - CONF_TYPE_STRING =3, - CONF_TYPE_PRINT =4, - CONF_TYPE_INC =5, - CONF_TYPE_INCLUDE =6, - CONF_TYPE_SUBCONFIG =7 -}; -enum { - ERR_NOT_AN_OPTION =-1, - ERR_MISSING_PARAM =-2, - ERR_OUT_OF_RANGE =-3, - ERR_FUNC_ERR =-4, - ERR_NO_SUBCONF =-5 -}; -/* config flags */ -enum { - CONF_MIN =(1<<0), - CONF_MAX =(1<<1), - CONF_RANGE =(CONF_MIN|CONF_MAX), - CONF_NOCFG =(1<<2), - CONF_NOCMD =(1<<3), - CONF_GLOBAL =(1<<4), - CONF_NOSAVE =(1<<5) -}; -struct config_t { - const char *name; - any_t* const p; - unsigned int type; - unsigned int flags; - float min,max; - const char *help; -}; -typedef void (*cfg_default_func_t)(config_t*,const std::string&); + /* config types */ + enum { + CONF_TYPE_FLAG =0, + CONF_TYPE_INT =1, + CONF_TYPE_FLOAT =2, + CONF_TYPE_STRING=3, + CONF_TYPE_PRINT =4, + CONF_TYPE_INC =5, + CONF_TYPE_INCLUDE=6, + CONF_TYPE_SUBCONFIG=7 + }; -struct config_save_t; -struct m_config_t : public Opaque { - m_config_t(libinput_t& _libinput):libinput(_libinput) {} - ~m_config_t() {} + enum { + ERR_NOT_AN_OPTION =-1, + ERR_MISSING_PARAM =-2, + ERR_OUT_OF_RANGE =-3, + ERR_FUNC_ERR =-4, + ERR_NO_SUBCONF =-5 + }; - std::vector<const config_t*> opt_list; - config_save_t** config_stack; - int cs_level; - int parser_mode; /* COMMAND_LINE or CONFIG_FILE */ - int flags; - const char* sub_conf; // When we save a subconfig - PlayTree* pt; // play tree we use for playlist option, etc - PlayTree* last_entry; // last added entry - PlayTree* last_parent; // if last_entry is NULL we must create child of this - int recursion_depth; - libinput_t& libinput; -}; + /* config flags */ + enum { + CONF_MIN =(1<<0), + CONF_MAX =(1<<1), + CONF_RANGE =(CONF_MIN|CONF_MAX), + CONF_NOCFG =(1<<2), + CONF_NOCMD =(1<<3), + CONF_GLOBAL =(1<<4), + CONF_NOSAVE =(1<<5) + }; -struct config_save_t { - const config_t* opt; - union { - int as_int; - float as_float; - any_t* as_pointer; - } param; - char* opt_name; -}; + struct mpxp_option_t { + const char *name; + any_t* const p; + unsigned int type; + unsigned int flags; + float min,max; + const char *help; + }; -/* parse_config_file returns: - * -1 on error (can't mp_malloc, invalid option...) - * 0 if can't open configfile - * 1 on success - */ -MPXP_Rc m_config_parse_config_file(m_config_t& config,const std::string& conffile); + typedef void (*cfg_default_func_t)(mpxp_option_t*,const std::string&); -/* parse_command_line returns: - * -1 on error (invalid option...) - * 1 otherwise - */ -namespace mpxp { + struct config_save_t; + struct m_config_t : public Opaque { + m_config_t(libinput_t& _libinput):libinput(_libinput) {} + virtual ~m_config_t() {} + + std::vector<const mpxp_option_t*> opt_list; + config_save_t** config_stack; + int cs_level; + int parser_mode; /* COMMAND_LINE or CONFIG_FILE */ + int flags; + const char* sub_conf; // When we save a subconfig + PlayTree* pt; // play tree we use for playlist option, etc + PlayTree* last_entry; // last added entry + PlayTree* last_parent; // if last_entry is NULL we must create child of this + int recursion_depth; + libinput_t& libinput; + }; + + struct config_save_t { + const mpxp_option_t* opt; + union { + int as_int; + float as_float; + any_t* as_pointer; + } param; + const char* opt_name; + }; + + /* parse_command_line returns: + * -1 on error (invalid option...) + * 1 otherwise + */ MPXP_Rc mpxp_parse_command_line(m_config_t& config, const std::vector<std::string>& argv,const std::map<std::string,std::string>& envm); -} + /* + * Return 0 on error 1 on success + */ + MPXP_Rc m_config_register_options(m_config_t& config,const mpxp_option_t *args); -m_config_t& m_config_new(PlayTree* pt,libinput_t&libinput); + /* parse_config_file returns: + * -1 on error (can't mp_malloc, invalid option...) + * 0 if can't open configfile + * 1 on success + */ + MPXP_Rc m_config_parse_config_file(m_config_t& config,const std::string& conffile); -void m_config_free(m_config_t* config); + m_config_t& m_config_new(PlayTree* pt,libinput_t&libinput); -void m_config_push(m_config_t& config); + void m_config_free(m_config_t* config); -/* - * Return 0 on error 1 on success - */ -int m_config_pop(m_config_t& config); + void m_config_push(m_config_t& config); -/* - * Return 0 on error 1 on success - */ -int m_config_register_options(m_config_t& config,const config_t *args); + /* + * Return 0 on error 1 on success + */ + int m_config_pop(m_config_t& config); -void m_config_show_options(const m_config_t& args); + void m_config_show_options(const m_config_t& args); -/* - * For all the following function when it's a subconfig option - * you must give an option name like 'tv:channel' and not just - * 'channel' - */ + /* + * For all the following function when it's a subconfig option + * you must give an option name like 'tv:channel' and not just + * 'channel' + */ -/** Return 1 on sucess 0 on failure -**/ -int m_config_set_option(m_config_t& config,const std::string& opt,const std::string& param); + /** Return 1 on sucess 0 on failure + **/ + int m_config_set_option(m_config_t& config,const std::string& opt,const std::string& param); -/** Get the config struct defining an option - * @return NULL on error -**/ -const config_t* m_config_get_option(const m_config_t& config,const std::string& arg); + /** Get the config struct defining an option + * @return NULL on error + **/ + const mpxp_option_t* m_config_get_option(const m_config_t& config,const std::string& arg); -/** Get the p field of the struct defining an option - * @return NULL on error -**/ -any_t* m_config_get_option_ptr(const m_config_t& config,const std::string& arg); + /** Get the p field of the struct defining an option + * @return NULL on error + **/ + any_t* m_config_get_option_ptr(const m_config_t& config,const std::string& arg); -/** Tell is an option is alredy set or not - * @return -1 one error (requested option arg exist) otherwise 0 or 1 -**/ -int m_config_is_option_set(const m_config_t& config,const std::string& arg); + /** Tell is an option is alredy set or not + * @return -1 one error (requested option arg exist) otherwise 0 or 1 + **/ + int m_config_is_option_set(const m_config_t& config,const std::string& arg); -/** Return 0 on error 1 on success -**/ -int m_config_switch_flag(m_config_t& config,const std::string& opt); + /** Return 0 on error 1 on success + **/ + int m_config_switch_flag(m_config_t& config,const std::string& opt); -/** Return 0 on error 1 on success -**/ -int m_config_set_flag(m_config_t& config,const std::string& opt, int max); + /** Return 0 on error 1 on success + **/ + int m_config_set_flag(m_config_t& config,const std::string& opt, int max); -/** Return the value of a flag (O or 1) and -1 on error -**/ -int m_config_get_flag(const m_config_t& config,const std::string& opt); + /** Return the value of a flag (O or 1) and -1 on error + **/ + int m_config_get_flag(const m_config_t& config,const std::string& opt); -/** Set the value of an int option - * @return 0 on error 1 on success -**/ -int m_config_set_int(m_config_t& config,const std::string& arg,int val); + /** Set the value of an int option + * @return 0 on error 1 on success + **/ + int m_config_set_int(m_config_t& config,const std::string& arg,int val); -/** Get the value of an int option - * @param err_ret If it is not NULL it's set to 1 on error - * @return the option value or -1 on error -**/ -int m_config_get_int (const m_config_t&,const std::string& arg,int& err_ret); + /** Get the value of an int option + * @param err_ret If it is not NULL it's set to 1 on error + * @return the option value or -1 on error + **/ + int m_config_get_int (const m_config_t&,const std::string& arg,int& err_ret); -/** Set the value of a float option - * @return 0 on error 1 on success -**/ -int m_config_set_float(m_config_t& config,const std::string& arg,float val); + /** Set the value of a float option + * @return 0 on error 1 on success + **/ + int m_config_set_float(m_config_t& config,const std::string& arg,float val); -/** Get the value of a float option - * @param err_ret If it is not NULL it's set to 1 on error - * @return the option value or -1 on error -**/ -float m_config_get_float (const m_config_t&,const std::string& arg,int& err_ret); + /** Get the value of a float option + * @param err_ret If it is not NULL it's set to 1 on error + * @return the option value or -1 on error + **/ + float m_config_get_float (const m_config_t&,const std::string& arg,int& err_ret); +} // namespace mpxp #endif /* __CONFIG_H */ Modified: mplayerxp/libmpdemux/demux_ac3.cpp =================================================================== --- mplayerxp/libmpdemux/demux_ac3.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpdemux/demux_ac3.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -398,7 +398,7 @@ #include "libmpconf/cfgparser.h" -static const config_t ac3_opts[] = { +static const mpxp_option_t ac3_opts[] = { {NULL, NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpdemux/demux_avi.cpp =================================================================== --- mplayerxp/libmpdemux/demux_avi.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpdemux/demux_avi.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -1370,14 +1370,14 @@ return MPXP_Unknown; } -static const config_t avi_options[] = { +static const mpxp_option_t avi_options[] = { {"noidx", &index_mode, CONF_TYPE_FLAG, 0, -1, 0, "disables INDEXES for AVI's demuxing"}, {"idx", &index_mode, CONF_TYPE_FLAG, 0, -1, 1, "builds internal INDEXES of incomplete AVIs"}, {"forceidx", &index_mode, CONF_TYPE_FLAG, 0, -1, 2, "forces rebuilding of INDEXES for broken AVIs"}, { NULL, NULL, 0, 0, 0, 0, NULL} }; -static const config_t avi_opts[] = { +static const mpxp_option_t avi_opts[] = { { "avi", (any_t*)&avi_options, CONF_TYPE_SUBCONFIG, 0, 0, 0, "AVI related options" }, { NULL, NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpdemux/demux_dca.cpp =================================================================== --- mplayerxp/libmpdemux/demux_dca.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpdemux/demux_dca.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -575,7 +575,7 @@ #include "libmpconf/cfgparser.h" -static const config_t dca_opts[] = { +static const mpxp_option_t dca_opts[] = { {NULL, NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpdemux/demux_flac.cpp =================================================================== --- mplayerxp/libmpdemux/demux_flac.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpdemux/demux_flac.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -286,7 +286,7 @@ #include "libmpconf/cfgparser.h" -static const config_t flac_opts[] = { +static const mpxp_option_t flac_opts[] = { {NULL, NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpdemux/demux_lavf.cpp =================================================================== --- mplayerxp/libmpdemux/demux_lavf.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpdemux/demux_lavf.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -65,13 +65,13 @@ static char *opt_cryptokey; extern int ts_prog; -static const config_t lavf_opts[] = { +static const mpxp_option_t lavf_opts[] = { {"format", &(opt_format), CONF_TYPE_STRING, 0, 0, 0, "forces format of lavf demuxer"}, {"cryptokey", &(opt_cryptokey), CONF_TYPE_STRING, 0, 0, 0, "specifies cryptokey for lavf demuxer"}, {NULL, NULL, 0, 0, 0, 0, NULL} }; -static const config_t lavfdopts_conf[] = { +static const mpxp_option_t lavfdopts_conf[] = { {"lavf", (any_t*)&lavf_opts, CONF_TYPE_SUBCONFIG, 0, 0, 0, "LAVF-demuxer related options"}, {NULL, NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpdemux/demux_mp3.cpp =================================================================== --- mplayerxp/libmpdemux/demux_mp3.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpdemux/demux_mp3.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -709,13 +709,13 @@ #include "libmpconf/cfgparser.h" -static const config_t mp3_opts[] = { +static const mpxp_option_t mp3_opts[] = { { "hr-seek", &hr_mp3_seek, CONF_TYPE_FLAG, 0, 0, 1, "enables hight-resolution mp3 seeking" }, { "nohr-seek", &hr_mp3_seek, CONF_TYPE_FLAG, 0, 1, 0, "disables hight-resolution mp3 seeking"}, {NULL, NULL, 0, 0, 0, 0, NULL} }; -static const config_t mp3_options[] = { +static const mpxp_option_t mp3_options[] = { { "mp3", (any_t*)&mp3_opts, CONF_TYPE_SUBCONFIG, 0, 0, 0, "MP3 related options" }, {NULL, NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpdemux/demux_musepack.cpp =================================================================== --- mplayerxp/libmpdemux/demux_musepack.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpdemux/demux_musepack.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -297,7 +297,7 @@ #include "libmpconf/cfgparser.h" -static const config_t musepack_opts[] = { +static const mpxp_option_t musepack_opts[] = { {NULL, NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpdemux/demux_null.cpp =================================================================== --- mplayerxp/libmpdemux/demux_null.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpdemux/demux_null.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -10,11 +10,11 @@ #include "stheader.h" #include "libmpconf/cfgparser.h" -static const config_t demux_null_opts[] = { +static const mpxp_option_t demux_null_opts[] = { {NULL, NULL, 0, 0, 0, 0, NULL} }; -static const config_t null_conf[] = { +static const mpxp_option_t null_conf[] = { { "null", (any_t*)&demux_null_opts, CONF_TYPE_SUBCONFIG, 0, 0, 0, "Null specific commands"}, { NULL,NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpdemux/demux_rawaudio.cpp =================================================================== --- mplayerxp/libmpdemux/demux_rawaudio.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpdemux/demux_rawaudio.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -20,7 +20,7 @@ static int afmt = AFMT_S16_LE; static int wtag = 0x1; // Raw PCM -static const config_t demux_rawaudio_opts[] = { +static const mpxp_option_t demux_rawaudio_opts[] = { { "on", &use_rawaudio, CONF_TYPE_FLAG, 0,0, 1, "forces treating stream as raw-audio" }, { "channels", &channels, CONF_TYPE_INT,CONF_RANGE,1,8, "specifies number of channels in raw-audio steram" }, { "rate", &samplerate, CONF_TYPE_INT,CONF_RANGE,1000,8*48000, "specifies sample-rate of raw-audio steram" }, @@ -29,7 +29,7 @@ {NULL, NULL, 0, 0, 0, 0, NULL} }; -static const config_t rawaudio_conf[] = { +static const mpxp_option_t rawaudio_conf[] = { { "rawaudio", (any_t*)&demux_rawaudio_opts, CONF_TYPE_SUBCONFIG, 0, 0, 0, "Raw-audio specific commands"}, { NULL,NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpdemux/demux_rawvideo.cpp =================================================================== --- mplayerxp/libmpdemux/demux_rawvideo.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpdemux/demux_rawvideo.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -27,7 +27,7 @@ }; static rawvideo_conf_t priv; -static const config_t demux_rawvideo_opts[] = { +static const mpxp_option_t demux_rawvideo_opts[] = { { "on", &priv.use_rawvideo, CONF_TYPE_FLAG, 0,0, 1, "forces treating stream as raw-vidio" }, // size: { "w", &priv.width, CONF_TYPE_INT,CONF_RANGE,1,8192, "specifies image width of raw-video stream" }, @@ -53,7 +53,7 @@ {NULL, NULL, 0, 0, 0, 0, NULL} }; -static const config_t rawvideo_conf[] = { +static const mpxp_option_t rawvideo_conf[] = { { "rawvideo", (any_t*)&demux_rawvideo_opts, CONF_TYPE_SUBCONFIG, 0, 0, 0, "Raw-video specific options"}, { NULL,NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpdemux/demux_snd_au.cpp =================================================================== --- mplayerxp/libmpdemux/demux_snd_au.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpdemux/demux_snd_au.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -249,7 +249,7 @@ #include "libmpconf/cfgparser.h" -static const config_t snd_au_opts[] = { +static const mpxp_option_t snd_au_opts[] = { {NULL, NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpdemux/demux_viv.cpp =================================================================== --- mplayerxp/libmpdemux/demux_viv.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpdemux/demux_viv.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -105,7 +105,7 @@ if (producer) delete producer; } -static const config_t vivoopts_conf[]={ +static const mpxp_option_t vivoopts_conf[]={ {"version", &vivo_param.version, CONF_TYPE_INT, 0, 0, 0, "forces version of VIVO stream"}, /* audio options */ {"acodec", &vivo_param.acodec, CONF_TYPE_STRING, 0, 0, 0, "specifies audio-codec of VIVO stream"}, @@ -119,7 +119,7 @@ {NULL, NULL, 0, 0, 0, 0, NULL} }; -static const config_t vivo_conf[] = { +static const mpxp_option_t vivo_conf[] = { { "vivo", (any_t*)&vivoopts_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, "Vivo specific options"}, { NULL,NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpdemux/demux_voc.cpp =================================================================== --- mplayerxp/libmpdemux/demux_voc.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpdemux/demux_voc.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -262,7 +262,7 @@ #include "libmpconf/cfgparser.h" -static const config_t voc_opts[] = { +static const mpxp_option_t voc_opts[] = { {NULL, NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpdemux/demux_wav.cpp =================================================================== --- mplayerxp/libmpdemux/demux_wav.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpdemux/demux_wav.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -358,7 +358,7 @@ #include "libmpconf/cfgparser.h" -static const config_t audio_opts[] = { +static const mpxp_option_t audio_opts[] = { {NULL, NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpdemux/demuxer.cpp =================================================================== --- mplayerxp/libmpdemux/demuxer.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpdemux/demuxer.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -516,14 +516,14 @@ /******************* Options stuff **********************/ -static const config_t demux_opts[] = { +static const mpxp_option_t demux_opts[] = { { "audiofile", &demux_conf.audio_stream, CONF_TYPE_STRING, 0, 0, 0, "forces reading of audio-stream from other file" }, { "subfile", &demux_conf.sub_stream, CONF_TYPE_STRING, 0, 0, 0, "forces reading of subtitles from other file" }, { "type", &demux_conf.type, CONF_TYPE_STRING, 0, 0, 0, "forces demuxer by given name" }, { NULL, NULL, 0, 0, 0, 0, NULL} }; -static const config_t demuxer_opts[] = { +static const mpxp_option_t demuxer_opts[] = { { "demuxer", (any_t*)&demux_opts, CONF_TYPE_SUBCONFIG, 0, 0, 0, "Demuxer related options" }, { NULL, NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/libmpdemux/demuxer_internal.h =================================================================== --- mplayerxp/libmpdemux/demuxer_internal.h 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpdemux/demuxer_internal.h 2012-12-28 07:23:44 UTC (rev 614) @@ -7,7 +7,7 @@ const char* short_name; /**< for forcing through comand line */ const char* name; /**< Name of driver ("Matroska MKV parser") */ const char* defext; /**< Default file extension for this movie type */ - const config_t* options;/**< Optional: MPlayerXP's option related */ + const mpxp_option_t* options;/**< Optional: MPlayerXP's option related */ /** Probing stream. * @param d _this demuxer **/ Modified: mplayerxp/libmpstream2/cdda.cpp =================================================================== --- mplayerxp/libmpstream2/cdda.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/libmpstream2/cdda.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -20,7 +20,7 @@ static int search_overlap = -1; static int no_skip = 0; -static const config_t cdda_opts[] = { +static const mpxp_option_t cdda_opts[] = { { "speed", &speed, CONF_TYPE_INT, CONF_RANGE,1,100, "sets driver speed" }, { "overlap", &search_overlap, CONF_TYPE_INT, CONF_RANGE,0,75, "reserved" }, { "noskip", &no_skip, CONF_TYPE_FLAG, 0 , 0, 1, "reserved" }, @@ -28,7 +28,7 @@ {NULL, NULL, 0, 0, 0, 0, NULL} }; -static const config_t cdda_conf[] = { +static const mpxp_option_t cdda_conf[] = { { "cdda", (any_t*)&cdda_opts, CONF_TYPE_SUBCONFIG, 0, 0, 0, "CD-DA related options"}, { NULL,NULL, 0, 0, 0, 0, NULL} }; Modified: mplayerxp/mplayerxp.cpp =================================================================== --- mplayerxp/mplayerxp.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/mplayerxp.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -616,9 +616,9 @@ mpxp_info<<"Use --long-help option for full help"<<std::endl; } -void show_long_help(const std::map<std::string,std::string>& envm) { +void show_long_help(const m_config_t& cfg,const std::map<std::string,std::string>& envm) { MPXPSystem& MPXPSys=*mpxp_context().engine().MPXPSys; - m_config_show_options(*mpxp_context().mconfig); + m_config_show_options(cfg); mp_input_print_binds(MPXPSys.libinput()); Stream::print_drivers(); Video_Output::print_help(); @@ -2171,9 +2171,9 @@ } return MPlayerXP(argv,envm); } catch(const std::string& what) { - std::cout<<"Exception '"<<what<<"'caught in module: MPlayerXP"<<std::endl; - } catch(...) { - std::cout<<"Exception caught in module: MPlayerXP"<<std::endl; + std::cout<<"[main_module] Exception '"<<what<<"'caught in module: MPlayerXP"<<std::endl; +// } catch(...) { +// std::cout<<"[main_module] Exception caught in module: MPlayerXP"<<std::endl; } return EXIT_FAILURE; } Modified: mplayerxp/mplayerxp.h =================================================================== --- mplayerxp/mplayerxp.h 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/mplayerxp.h 2012-12-28 07:23:44 UTC (rev 614) @@ -17,8 +17,8 @@ struct audio_decoder_t; struct video_decoder_t; -struct m_config_t; namespace mpxp { + struct m_config_t; struct _PlayTree_Iter; /* List of all modules which require protection by pin-code */ enum { @@ -198,9 +198,8 @@ unsigned get_number_cpu(void); void show_help(void); - void show_long_help(const std::map<std::string,std::string>& envm); + void show_long_help(const m_config_t& cfg,const std::map<std::string,std::string>& envm); - void update_osd( float v_pts ); extern pthread_mutex_t audio_timer_mutex; Modified: mplayerxp/xmpcore/xmp_context.cpp =================================================================== --- mplayerxp/xmpcore/xmp_context.cpp 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/xmpcore/xmp_context.cpp 2012-12-28 07:23:44 UTC (rev 614) @@ -20,7 +20,7 @@ #endif extern const char *oss_mixer_device; -static const config_t xpcore_config[]={ +static const mpxp_option_t xpcore_config[]={ {"xp", &mp_conf.xp, CONF_TYPE_INT, CONF_RANGE, 0, UINT_MAX, "specifies number cpus to use for playback"}, {"dump", &mp_conf.stream_dump, CONF_TYPE_STRING, 0, 0, 0, "specifies dump type and name for the dump of stream"}, {"gomp", &mp_conf.gomp, CONF_TYPE_FLAG, 0, 0, 1, "enables usage of OpenMP extensions"}, @@ -38,7 +38,7 @@ }; #ifdef HAVE_STREAMING -static const config_t net_config[]={ +static const mpxp_option_t net_config[]={ {"ipv4", &net_conf.prefer_ipv4, CONF_TYPE_FLAG, 0, 0, 1, "forces mplayerxp to use IPv4 protocol over network"}, #ifdef HAVE_AF_INET6 {"ipv6", &net_conf.prefer_ipv4, CONF_TYPE_FLAG, 0, 1, 0, "forces mplayerxp to use IPv6 protocol over network"}, @@ -57,7 +57,7 @@ #endif #if defined( ARCH_X86 ) || defined(ARCH_X86_64) -static const config_t cpu_config[]={ +static const mpxp_option_t cpu_config[]={ {"simd", &mp_conf.x86.simd, CONF_TYPE_FLAG, 0, 0, 1, "enables using of SIMD extensions of CPU"}, {"nosimd", &mp_conf.x86.simd, CONF_TYPE_FLAG, 0, 1, 0, "disables using of SIMD extensions of CPU"}, {"mmx", &mp_conf.x86.mmx, CONF_TYPE_FLAG, 0, 0, 1, "enables using of MMX extensions of CPU"}, @@ -90,7 +90,7 @@ }; #endif -static const config_t osd_config[]={ +static const mpxp_option_t osd_config[]={ {"level", &mp_conf.osd_level, CONF_TYPE_INT, CONF_RANGE, 0, 2 , "specifies initial mode of the OSD"}, #ifdef USE_OSD {"font", &mp_conf.font_name, CONF_TYPE_STRING, 0, 0, 0, "specifies an alternative directory of font.desc location"}, @@ -102,7 +102,7 @@ {NULL, NULL, 0, 0, 0, 0, NULL}, }; -static const config_t veq_config[]={ +static const mpxp_option_t veq_config[]={ {"brightness",&vo_conf.gamma.brightness, CONF_TYPE_INT, CONF_RANGE, -1000, 1000, "specifies brightness-level for output image"}, {"saturation",&vo_conf.gamma.saturation, CONF_TYPE_INT, CONF_RANGE, -1000, 1000, "specifies saturation-level for output image"}, {"contrast",&vo_conf.gamma.contrast, CONF_TYPE_INT, CONF_RANGE, -1000, 1000, "specifies contrast-level for output image"}, @@ -114,7 +114,7 @@ }; -static const config_t avsync_config[]={ +static const mpxp_option_t avsync_config[]={ {"framedrop", &mp_conf.frame_dropping, CONF_TYPE_FLAG, 0, 0, 1, "enables frame-dropping on slow systems: decodes all video frames, but skips displaying some ones"}, /*UD*/ {"hardframedrop", &mp_conf.frame_dropping, CONF_TYPE_FLAG, 0, 0, 2, "enables hard frame-dropping on slow systems: skips displaying and decoding of some frames"}, {"noframedrop", &mp_conf.frame_dropping, CONF_TYPE_FLAG, 0, 1, 0, "disables frame dropping"}, @@ -137,7 +137,7 @@ {NULL, NULL, 0, 0, 0, 0, NULL}, }; -static const config_t subtitle_config[]={ +static const mpxp_option_t subtitle_config[]={ {"on", &mp_conf.has_dvdsub, CONF_TYPE_FLAG, 0, 0, 1, "enables subtitle-steam playback"}, {"off", &mp_conf.has_dvdsub, CONF_TYPE_FLAG, 0, 1, 0, "disables subtitle-stream playback"}, {"vob", &mp_conf.vobsub_name, CONF_TYPE_STRING, 0, 0, 0, "specifies the VobSub files that are to be used for subtitle"}, @@ -164,7 +164,7 @@ }; #ifdef HAVE_X11 -static const config_t x11_config[]={ +static const mpxp_option_t x11_config[]={ {"display", &vo_conf.mDisplayName, CONF_TYPE_STRING, 0, 0, 0, "specifies the hostname and display number of the X server"}, #ifdef HAVE_XINERAMA {"xinerama", &vo_conf.xinerama_screen, CONF_TYPE_INT, CONF_RANGE, 0, 32, "tells MPlayerXP the display for movie playback"}, @@ -173,7 +173,7 @@ }; #endif -static const config_t audio_config[]={ +static const mpxp_option_t audio_config[]={ {"on", &mp_conf.has_audio, CONF_TYPE_FLAG, 0, 0, 1, "enables audio-steam playback"}, {"off", &mp_conf.has_audio, CONF_TYPE_FLAG, 0, 1, 0, "disables audio-stream playback"}, {"mixer", &oss_mixer_device, CONF_TYPE_STRING, 0, 0, 0, "select audio-mixer device"}, @@ -184,7 +184,7 @@ {NULL, NULL, 0, 0, 0, 0, NULL}, }; -static const config_t video_config[]={ +static const mpxp_option_t video_config[]={ {"on", &mp_conf.has_video, CONF_TYPE_FLAG, 0, 0, 1, "enables video-steam playback"}, {"off", &mp_conf.has_video, CONF_TYPE_FLAG, 0, 1, 0, "disables video-stream playback"}, {"width", &vo_conf.image_width, CONF_TYPE_INT, CONF_RANGE, 0, 4096, "scale output image to width (if driver supports)"}, @@ -220,7 +220,7 @@ {NULL, NULL, 0, 0, 0, 0, NULL}, }; -static const config_t playback_config[]={ +static const mpxp_option_t playback_config[]={ {"sb", &mp_conf.seek_to_byte, CONF_TYPE_INT, CONF_MIN, 0, 0, "seek to given byte position before playback"}, {"ss", &mp_conf.seek_to_sec, CONF_TYPE_STRING, CONF_MIN, 0, 0, "seek to given time position before playback"}, {"loop", &mp_conf.loop_times, CONF_TYPE_INT, CONF_RANGE, -1, 10000, "loops movie playback given number of times. 0 means forever"}, @@ -232,7 +232,7 @@ {NULL, NULL, 0, 0, 0, 0, NULL}, }; -static const config_t mplayerxp_options[]={ +static const mpxp_option_t mplayerxp_options[]={ /* name, pointer, type, flags, min, max, help */ {"include", NULL, CONF_TYPE_INCLUDE, CONF_NOSAVE, 0, 0, ""}, /* this don't need anymore to be the first!!! */ @@ -269,7 +269,7 @@ // ------------------------- codec/pp options -------------------- {NULL, NULL, 0, 0, 0, 0, NULL} }; -const config_t* mplayerxp_opts=mplayerxp_options; +const mpxp_option_t* mplayerxp_opts=mplayerxp_options; } // namespace mpxp extern void libmpcodecs_ad_register_options(m_config_t& cfg); Modified: mplayerxp/xmpcore/xmp_context.h =================================================================== --- mplayerxp/xmpcore/xmp_context.h 2012-12-28 06:34:01 UTC (rev 613) +++ mplayerxp/xmpcore/xmp_context.h 2012-12-28 07:23:44 UTC (rev 614) @@ -1,9 +1,9 @@ #ifndef _XMP_CONTEXT_H_INCLUDED #define _XMP_CONTEXT_H_INCLUDED 1 -struct config_t; namespace mpxp { - extern const config_t* mplayerxp_opts; + struct mpxp_option_t; + extern const mpxp_option_t* mplayerxp_opts; } #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2012-12-28 06:34:09
|
Revision: 613 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=613&view=rev Author: nickols_k Date: 2012-12-28 06:34:01 +0000 (Fri, 28 Dec 2012) Log Message: ----------- rename loader -> win32loader (TRANSACTION END) Modified Paths: -------------- mplayerxp/Makefile mplayerxp/libmpcodecs/ad_acm.cpp mplayerxp/libmpcodecs/ad_dmo.cpp mplayerxp/libmpcodecs/ad_dshow.cpp mplayerxp/libmpcodecs/ad_internal.h mplayerxp/libmpcodecs/ad_qtaudio.cpp mplayerxp/libmpcodecs/ad_twin.cpp mplayerxp/libmpcodecs/vd_dmo.cpp mplayerxp/libmpcodecs/vd_dshow.cpp mplayerxp/libmpcodecs/vd_qtvideo.cpp mplayerxp/libmpcodecs/vd_vfw.cpp mplayerxp/libmpconf/codec-cfg.cpp mplayerxp/libmpdemux/asf.h mplayerxp/libmpdemux/aviprint.h mplayerxp/libmpdemux/demux_mkv.cpp mplayerxp/libmpdemux/demux_mov.cpp mplayerxp/libmpdemux/demux_mpxp64.cpp mplayerxp/libmpdemux/mux_mpxp64.cpp mplayerxp/libmpdemux/mux_raw.cpp mplayerxp/libmpdemux/muxer.cpp mplayerxp/libmpdemux/stheader.h mplayerxp/libmpstream2/s_oss.cpp mplayerxp/postproc/af_format.cpp mplayerxp/win32loader/Makefile mplayerxp/win32loader/wine/avifmt.h mplayerxp/xmpcore/xmp_aframe.cpp Modified: mplayerxp/Makefile =================================================================== --- mplayerxp/Makefile 2012-12-28 06:24:26 UTC (rev 612) +++ mplayerxp/Makefile 2012-12-28 06:34:01 UTC (rev 613) @@ -13,7 +13,7 @@ # these subdirectories required installation due binaries within them SUBDIRS = libmpdemux libmpstream2 libmpsub libplaytree libmpcodecs libmpconf libao3 osdep postproc input2 nls libvo2 xmpcore ifeq ($(ENABLE_WIN32LOADER),yes) -SUBDIRS+=loader +SUBDIRS+=win32loader endif DO_MAKE = @ for i in $(SUBDIRS); do $(MAKE) -C $$i $@ || exit; done DO_MAKE_ALL = @ for i in $(SUBDIRS); do $(MAKE) -C $$i all || exit; done @@ -46,7 +46,7 @@ libmpconf/libmpconf.a \ xmpcore/libxmpcore.a ifeq ($(ENABLE_WIN32LOADER),yes) - MP_LIBS += loader/libloader.a + MP_LIBS += win32loader/libwin32loader.a endif LIBS+= $(MP_LIBS) $(LAVC_LIBS) $(EXTRALIBS) -lm Modified: mplayerxp/libmpcodecs/ad_acm.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_acm.cpp 2012-12-28 06:24:26 UTC (rev 612) +++ mplayerxp/libmpcodecs/ad_acm.cpp 2012-12-28 06:34:01 UTC (rev 613) @@ -8,7 +8,7 @@ #define __AD_ACM #include "ad_internal.h" #include "codecs_ld.h" -#include "loader/wineacm.h" +#include "win32loader/wineacm.h" #include "libmpdemux/aviprint.h" #include "libao3/afmt.h" #include "mpxp_help.h" Modified: mplayerxp/libmpcodecs/ad_dmo.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_dmo.cpp 2012-12-28 06:24:26 UTC (rev 612) +++ mplayerxp/libmpcodecs/ad_dmo.cpp 2012-12-28 06:34:01 UTC (rev 613) @@ -26,7 +26,7 @@ LIBAD_EXTERN(dmo) -#include "loader/dmo/DMO_AudioDecoder.h" +#include "win32loader/dmo/DMO_AudioDecoder.h" struct admo_private_t : public Opaque { admo_private_t(); Modified: mplayerxp/libmpcodecs/ad_dshow.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_dshow.cpp 2012-12-28 06:24:26 UTC (rev 612) +++ mplayerxp/libmpcodecs/ad_dshow.cpp 2012-12-28 06:34:01 UTC (rev 613) @@ -7,7 +7,7 @@ #include <dlfcn.h> /* GLIBC specific. Exists under cygwin too! */ #include "ad_internal.h" #include "mpxp_help.h" -#include "loader/dshow/DS_AudioDecoder.h" +#include "win32loader/dshow/DS_AudioDecoder.h" #include "codecs_ld.h" static const ad_info_t info = { Modified: mplayerxp/libmpcodecs/ad_internal.h =================================================================== --- mplayerxp/libmpcodecs/ad_internal.h 2012-12-28 06:24:26 UTC (rev 612) +++ mplayerxp/libmpcodecs/ad_internal.h 2012-12-28 06:34:01 UTC (rev 613) @@ -1,5 +1,5 @@ #ifdef __AD_ACM /* simply ugly hack */ -#include "loader/wine/msacm.h" +#include "win32loader/wine/msacm.h" #endif #include "libmpconf/codec-cfg.h" #include "libmpdemux/demuxer_r.h" Modified: mplayerxp/libmpcodecs/ad_qtaudio.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_qtaudio.cpp 2012-12-28 06:24:26 UTC (rev 612) +++ mplayerxp/libmpcodecs/ad_qtaudio.cpp 2012-12-28 06:34:01 UTC (rev 613) @@ -13,7 +13,7 @@ #include "mplayerxp.h" #include "libao3/afmt.h" #ifdef WIN32_LOADER -#include "loader/ldt_keeper.h" +#include "win32loader/ldt_keeper.h" #endif #ifdef MACOSX Modified: mplayerxp/libmpcodecs/ad_twin.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_twin.cpp 2012-12-28 06:24:26 UTC (rev 612) +++ mplayerxp/libmpcodecs/ad_twin.cpp 2012-12-28 06:34:01 UTC (rev 613) @@ -7,8 +7,8 @@ #include <dlfcn.h> /* GLIBC specific. Exists under cygwin too! */ #include "ad_internal.h" #include "codecs_ld.h" -#include "loader/ldt_keeper.h" -#include "loader/wine/windef.h" +#include "win32loader/ldt_keeper.h" +#include "win32loader/wine/windef.h" #include "libao3/afmt.h" #include "libmpdemux/aviprint.h" #include "mpxp_help.h" Modified: mplayerxp/libmpcodecs/vd_dmo.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_dmo.cpp 2012-12-28 06:24:26 UTC (rev 612) +++ mplayerxp/libmpcodecs/vd_dmo.cpp 2012-12-28 06:34:01 UTC (rev 613) @@ -11,7 +11,7 @@ #include "vd_internal.h" #include "codecs_ld.h" -#include "loader/dmo/DMO_VideoDecoder.h" +#include "win32loader/dmo/DMO_VideoDecoder.h" #include "vd_msg.h" static const vd_info_t info = { Modified: mplayerxp/libmpcodecs/vd_dshow.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_dshow.cpp 2012-12-28 06:24:26 UTC (rev 612) +++ mplayerxp/libmpcodecs/vd_dshow.cpp 2012-12-28 06:34:01 UTC (rev 613) @@ -12,7 +12,7 @@ #include "vd_internal.h" -#include "loader/dshow/DS_VideoDecoder.h" +#include "win32loader/dshow/DS_VideoDecoder.h" #include "codecs_ld.h" #include "osdep/bswap.h" Modified: mplayerxp/libmpcodecs/vd_qtvideo.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_qtvideo.cpp 2012-12-28 06:24:26 UTC (rev 612) +++ mplayerxp/libmpcodecs/vd_qtvideo.cpp 2012-12-28 06:34:01 UTC (rev 613) @@ -13,7 +13,7 @@ #include "codecs_ld.h" #ifdef WIN32_LOADER -#include "loader/ldt_keeper.h" +#include "win32loader/ldt_keeper.h" #endif #include "codecs_ld.h" #include "vd_msg.h" @@ -38,7 +38,7 @@ #include <QuickTime/ImageCodec.h> #define dump_ImageDescription(x) #else -#include "loader/qtx/qtxsdk/components.h" +#include "win32loader/qtx/qtxsdk/components.h" #endif //#include "wine/windef.h" Modified: mplayerxp/libmpcodecs/vd_vfw.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_vfw.cpp 2012-12-28 06:24:26 UTC (rev 612) +++ mplayerxp/libmpcodecs/vd_vfw.cpp 2012-12-28 06:34:01 UTC (rev 613) @@ -11,8 +11,8 @@ #include "vd_internal.h" #include "codecs_ld.h" -#include "loader/wine/vfw.h" -#include "loader/wine/driver.h" +#include "win32loader/wine/vfw.h" +#include "win32loader/wine/driver.h" #include "libmpdemux/aviprint.h" static const vd_info_t info_vfw = { Modified: mplayerxp/libmpconf/codec-cfg.cpp =================================================================== --- mplayerxp/libmpconf/codec-cfg.cpp 2012-12-28 06:24:26 UTC (rev 612) +++ mplayerxp/libmpconf/codec-cfg.cpp 2012-12-28 06:34:01 UTC (rev 613) @@ -21,7 +21,7 @@ #include <string.h> // for mmioFOURCC: -#include "loader/wine/avifmt.h" +#include "win32loader/wine/avifmt.h" #include "libvo2/img_format.h" #include "codec-cfg.h" #include "parser_msg.h" Modified: mplayerxp/libmpdemux/asf.h =================================================================== --- mplayerxp/libmpdemux/asf.h 2012-12-28 06:24:26 UTC (rev 612) +++ mplayerxp/libmpdemux/asf.h 2012-12-28 06:34:01 UTC (rev 613) @@ -3,9 +3,9 @@ //#include "cp_config.h" /* for WORDS_BIGENDIAN */ #include <inttypes.h> -#include "loader/wine/mmreg.h" -#include "loader/wine/avifmt.h" -#include "loader/wine/vfw.h" +#include "win32loader/wine/mmreg.h" +#include "win32loader/wine/avifmt.h" +#include "win32loader/wine/vfw.h" #include "osdep/bswap.h" #ifndef MIN Modified: mplayerxp/libmpdemux/aviprint.h =================================================================== --- mplayerxp/libmpdemux/aviprint.h 2012-12-28 06:24:26 UTC (rev 612) +++ mplayerxp/libmpdemux/aviprint.h 2012-12-28 06:34:01 UTC (rev 613) @@ -1,9 +1,9 @@ #ifndef MPXP_AVIPRINT_H #define MPXP_AVIPRINT_H 1 -#include "loader/wine/mmreg.h" -#include "loader/wine/avifmt.h" -#include "loader/wine/vfw.h" +#include "win32loader/wine/mmreg.h" +#include "win32loader/wine/avifmt.h" +#include "win32loader/wine/vfw.h" extern void print_avih_flags(MainAVIHeader *h); extern void print_avih(MainAVIHeader *h); Modified: mplayerxp/libmpdemux/demux_mkv.cpp =================================================================== --- mplayerxp/libmpdemux/demux_mkv.cpp 2012-12-28 06:24:26 UTC (rev 612) +++ mplayerxp/libmpdemux/demux_mkv.cpp 2012-12-28 06:34:01 UTC (rev 613) @@ -41,7 +41,7 @@ #include "libao3/afmt.h" #include "demux_msg.h" -#include "loader/qtx/qtxsdk/components.h" +#include "win32loader/qtx/qtxsdk/components.h" #include "demux_msg.h" enum { Modified: mplayerxp/libmpdemux/demux_mov.cpp =================================================================== --- mplayerxp/libmpdemux/demux_mov.cpp 2012-12-28 06:24:26 UTC (rev 612) +++ mplayerxp/libmpdemux/demux_mov.cpp 2012-12-28 06:34:01 UTC (rev 613) @@ -39,7 +39,7 @@ #include "qtpalette.h" #include "parse_mp4.h" // .MP4 specific stuff -#include "loader/qtx/qtxsdk/components.h" +#include "win32loader/qtx/qtxsdk/components.h" #include "demux_msg.h" #include "libao3/afmt.h" Modified: mplayerxp/libmpdemux/demux_mpxp64.cpp =================================================================== --- mplayerxp/libmpdemux/demux_mpxp64.cpp 2012-12-28 06:24:26 UTC (rev 612) +++ mplayerxp/libmpdemux/demux_mpxp64.cpp 2012-12-28 06:34:01 UTC (rev 613) @@ -17,7 +17,7 @@ #include "demuxer.h" #include "demuxer_internal.h" #include "stheader.h" -#include "loader/qtx/qtxsdk/components.h" +#include "win32loader/qtx/qtxsdk/components.h" #include "nls/nls.h" #include "libmpsub/subreader.h" Modified: mplayerxp/libmpdemux/mux_mpxp64.cpp =================================================================== --- mplayerxp/libmpdemux/mux_mpxp64.cpp 2012-12-28 06:24:26 UTC (rev 612) +++ mplayerxp/libmpdemux/mux_mpxp64.cpp 2012-12-28 06:34:01 UTC (rev 613) @@ -18,10 +18,10 @@ #include "nls/nls.h" -#include "loader/wine/mmreg.h" -#include "loader/wine/avifmt.h" -#include "loader/wine/vfw.h" -#include "loader/qtx/qtxsdk/components.h" +#include "win32loader/wine/mmreg.h" +#include "win32loader/wine/avifmt.h" +#include "win32loader/wine/vfw.h" +#include "win32loader/qtx/qtxsdk/components.h" #include "osdep/bswap.h" #include "libmpstream2/stream.h" Modified: mplayerxp/libmpdemux/mux_raw.cpp =================================================================== --- mplayerxp/libmpdemux/mux_raw.cpp 2012-12-28 06:24:26 UTC (rev 612) +++ mplayerxp/libmpdemux/mux_raw.cpp 2012-12-28 06:34:01 UTC (rev 613) @@ -10,9 +10,9 @@ #include "version.h" -#include "loader/wine/mmreg.h" -#include "loader/wine/avifmt.h" -#include "loader/wine/vfw.h" +#include "win32loader/wine/mmreg.h" +#include "win32loader/wine/avifmt.h" +#include "win32loader/wine/vfw.h" #include "osdep/bswap.h" #include "muxer.h" #include "aviheader.h" Modified: mplayerxp/libmpdemux/muxer.cpp =================================================================== --- mplayerxp/libmpdemux/muxer.cpp 2012-12-28 06:24:26 UTC (rev 612) +++ mplayerxp/libmpdemux/muxer.cpp 2012-12-28 06:34:01 UTC (rev 613) @@ -10,9 +10,9 @@ #include "version.h" -#include "loader/wine/mmreg.h" -#include "loader/wine/avifmt.h" -#include "loader/wine/vfw.h" +#include "win32loader/wine/mmreg.h" +#include "win32loader/wine/avifmt.h" +#include "win32loader/wine/vfw.h" #include "muxer.h" muxer_packet_t* new_muxer_packet(float pts,any_t*data,unsigned length,unsigned flags) Modified: mplayerxp/libmpdemux/stheader.h =================================================================== --- mplayerxp/libmpdemux/stheader.h 2012-12-28 06:24:26 UTC (rev 612) +++ mplayerxp/libmpdemux/stheader.h 2012-12-28 06:34:01 UTC (rev 613) @@ -5,9 +5,9 @@ #ifdef __cplusplus extern "C" { #endif -#include "loader/wine/mmreg.h" -#include "loader/wine/avifmt.h" -#include "loader/wine/vfw.h" +#include "win32loader/wine/mmreg.h" +#include "win32loader/wine/avifmt.h" +#include "win32loader/wine/vfw.h" #ifdef __cplusplus } #endif Modified: mplayerxp/libmpstream2/s_oss.cpp =================================================================== --- mplayerxp/libmpstream2/s_oss.cpp 2012-12-28 06:24:26 UTC (rev 612) +++ mplayerxp/libmpstream2/s_oss.cpp 2012-12-28 06:34:01 UTC (rev 613) @@ -21,7 +21,7 @@ #include "postproc/af.h" #include "libao3/afmt.h" #include "libao3/audio_out.h" -#include "loader/wine/mmreg.h" +#include "win32loader/wine/mmreg.h" #include "stream.h" #include "stream_internal.h" #include "mrl.h" Modified: mplayerxp/postproc/af_format.cpp =================================================================== --- mplayerxp/postproc/af_format.cpp 2012-12-28 06:24:26 UTC (rev 612) +++ mplayerxp/postproc/af_format.cpp 2012-12-28 06:34:01 UTC (rev 613) @@ -18,7 +18,7 @@ #include "af_internal.h" #include "osdep/bswap.h" #include "aflib.h" -#include "loader/wine/mmreg.h" +#include "win32loader/wine/mmreg.h" #include "pp_msg.h" // Integer to float conversion through lrintf() Modified: mplayerxp/win32loader/Makefile =================================================================== --- mplayerxp/win32loader/Makefile 2012-12-28 06:24:26 UTC (rev 612) +++ mplayerxp/win32loader/Makefile 2012-12-28 06:34:01 UTC (rev 613) @@ -1,7 +1,7 @@ include ../mpxp_config.mak ifeq ($(ENABLE_WIN32LOADER),yes) -LIBNAME=libloader.a +LIBNAME=libwin32loader.a SUBDIRS=dshow dmo else LIBNAME= Modified: mplayerxp/win32loader/wine/avifmt.h =================================================================== --- mplayerxp/win32loader/wine/avifmt.h 2012-12-28 06:24:26 UTC (rev 612) +++ mplayerxp/win32loader/wine/avifmt.h 2012-12-28 06:34:01 UTC (rev 613) @@ -9,7 +9,7 @@ #ifndef NOAVIFMT #ifndef __WINE_WINDEF_H -#include "loader/wine/windef.h" +#include "win32loader/wine/windef.h" #endif #ifndef __WINE_MMSYSTEM_H Modified: mplayerxp/xmpcore/xmp_aframe.cpp =================================================================== --- mplayerxp/xmpcore/xmp_aframe.cpp 2012-12-28 06:24:26 UTC (rev 612) +++ mplayerxp/xmpcore/xmp_aframe.cpp 2012-12-28 06:34:01 UTC (rev 613) @@ -6,7 +6,7 @@ #include "xmp_aframe.h" #include "libao3/afmt.h" -#include "loader/wine/mmreg.h" +#include "win32loader/wine/mmreg.h" #include "player_msg.h" namespace mpxp { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2012-12-28 06:24:34
|
Revision: 612 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=612&view=rev Author: nickols_k Date: 2012-12-28 06:24:26 +0000 (Fri, 28 Dec 2012) Log Message: ----------- rename loader -> win32loader (TRANSACTION BEGIN) Added Paths: ----------- mplayerxp/win32loader/ Removed Paths: ------------- mplayerxp/loader/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2012-12-27 18:06:06
|
Revision: 611 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=611&view=rev Author: nickols_k Date: 2012-12-27 18:05:58 +0000 (Thu, 27 Dec 2012) Log Message: ----------- It seems that my development system was damaged! At end of log -- patch which i can't apply due such behaviour of g++/gdb pair $ gdb --args ./ffmpeg -ao alsa:hw:1 -vo x11 M/l.avi -vf menu=main GNU gdb (GDB) 7.5 Copyright (C) 2012 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-unknown-linux-gnu". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>... Reading symbols from /Data/-SF.NET-/MPXP/mplayerxp/mplayerxp/ffmpeg...done. (gdb) break cfgparser.cpp:60 Breakpoint 1 at 0x5d518a: file cfgparser.cpp, line 60. (gdb) run Starting program: /Data/-SF.NET-/MPXP/mplayerxp/mplayerxp/ffmpeg -ao alsa:hw:1 -vo x11 M/l.avi -vf menu=main warning: Could not load shared library symbols for linux-vdso.so.1. Do you need "set solib-search-path" or "set sysroot"? [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". *** Antiviral protection was inited ***!!! MPlayerXP svn.598 2002 Nickols_K 2000-2002 Arpad Gereoffy (?\209?\129?\208?\188. DOCS!) Can't open input config file /root/.ffmpeg/input.conf : No such file or directory Can't open input config file /usr/local/share/mplayerxp/input.conf : No such file or directory Falling back on default (hardcoded) input config Opening joystick device:/dev/input/js0 Can't open joystick device: /dev/input/js0 : No such file or directory Can't init input joystick with using: /dev/input/js0 ?\208?\163?\209?\129?\209?\130?\208?\176?\208?\189?\208?\190?\208?\178?\208?\186?\208?\176 ?\208?\191?\208?\190?\208?\180?\208?\180?\208?\181?\209?\128?\208?\182?\208?\186?\208?\184 lirc... mplayer: could not connect to socket mplayer: No such file or directory ?\208?\157?\208?\181?\209?\131?\208?\180?\208?\176?\209?\135?\208?\189?\208?\190?\208?\181 ?\208?\190?\209?\130?\208?\186?\209?\128?\209?\139?\209?\130?\208?\184?\208?\181 ?\208?\191?\208?\190?\208?\180?\208?\180?\208?\181?\209?\128?\208?\182?\208?\186?\208?\184 lirc! ?\208?\146?\209?\139 ?\208?\189?\208?\181 ?\209?\129?\208?\188?\208?\190?\208?\182?\208?\181?\209?\130?\208?\181 ?\208?\184?\209?\129?\208?\191?\208?\190?\208?\187?\209?\140?\208?\183?\208?\190?\208?\178?\208?\176?\209?\130?\209?\140 ?\208?\146?\208?\176?\209?\136?\208?\181 ?\209?\131?\208?\180?\208?\176?\208?\187?\209?\145?\208?\189?\208?\189?\208?\190?\208?\181 ?\209?\131?\208?\191?\209?\128?\208?\176?\208?\178?\208?\187?\208?\181?\208?\189?\208?\184?\208?\181 Breakpoint 1, m_config_save_option (conf= 0xcafa30 <mpxp::mplayerxp_options+80>, opt=..., param=..., config=...) at cfgparser.cpp:60 60 save = config.config_stack[config.cs_level]; (gdb) print config $1 = <optimized out> (gdb) print *config value has been optimized out (gdb) s operator[] (__n=<optimized out>, this=<optimized out>) at /usr/lib/gcc/x86_64-unknown-linux-gnu/4.5.4/../../../../include/c++/4.5.4/bits/stl_vector.h:619 619 { return *(this->_M_impl._M_start + __n); } (gdb) n m_config_save_option (conf=0xcafa30 <mpxp::mplayerxp_options+80>, opt=..., param=..., config=...) at cfgparser.cpp:60 60 save = config.config_stack[config.cs_level]; (gdb) n Program received signal SIGSEGV, Segmentation fault. std::vector<config_save_t, std::allocator<config_save_t> >::operator= (this= 0x7fffffffd2c0, __x=...) at cfgparser.cpp:160 160 mpxp_dbg2<<"Config pushed level="<<config.cs_level<<std::endl; (gdb) run The program being debugged has been started already. Start it from the beginning? (y or n) y Starting program: /Data/-SF.NET-/MPXP/mplayerxp/mplayerxp/ffmpeg -ao alsa:hw:1 -vo x11 M/l.avi -vf menu=main warning: Could not load shared library symbols for linux-vdso.so.1. Do you need "set solib-search-path" or "set sysroot"? [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". *** Antiviral protection was inited ***!!! MPlayerXP svn.598 2002 Nickols_K 2000-2002 Arpad Gereoffy (?\209?\129?\208?\188. DOCS!) Can't open input config file /root/.ffmpeg/input.conf : No such file or directory Can't open input config file /usr/local/share/mplayerxp/input.conf : No such file or directory Falling back on default (hardcoded) input config Opening joystick device:/dev/input/js0 Can't open joystick device: /dev/input/js0 : No such file or directory Can't init input joystick with using: /dev/input/js0 ?\208?\163?\209?\129?\209?\130?\208?\176?\208?\189?\208?\190?\208?\178?\208?\186?\208?\176 ?\208?\191?\208?\190?\208?\180?\208?\180?\208?\181?\209?\128?\208?\182?\208?\186?\208?\184 lirc... mplayer: could not connect to socket mplayer: No such file or directory ?\208?\157?\208?\181?\209?\131?\208?\180?\208?\176?\209?\135?\208?\189?\208?\190?\208?\181 ?\208?\190?\209?\130?\208?\186?\209?\128?\209?\139?\209?\130?\208?\184?\208?\181 ?\208?\191?\208?\190?\208?\180?\208?\180?\208?\181?\209?\128?\208?\182?\208?\186?\208?\184 lirc! ?\208?\146?\209?\139 ?\208?\189?\208?\181 ?\209?\129?\208?\188?\208?\190?\208?\182?\208?\181?\209?\130?\208?\181 ?\208?\184?\209?\129?\208?\191?\208?\190?\208?\187?\209?\140?\208?\183?\208?\190?\208?\178?\208?\176?\209?\130?\209?\140 ?\208?\146?\208?\176?\209?\136?\208?\181 ?\209?\131?\208?\180?\208?\176?\208?\187?\209?\145?\208?\189?\208?\189?\208?\190?\208?\181 ?\209?\131?\208?\191?\209?\128?\208?\176?\208?\178?\208?\187?\208?\181?\208?\189?\208?\184?\208?\181 Breakpoint 1, m_config_save_option (conf= 0xcafa30 <mpxp::mplayerxp_options+80>, opt=..., param=..., config=...) at cfgparser.cpp:60 60 save = config.config_stack[config.cs_level]; (gdb) s operator[] (__n=<optimized out>, this=<optimized out>) at /usr/lib/gcc/x86_64-unknown-linux-gnu/4.5.4/../../../../include/c++/4.5.4/bits/stl_vector.h:619 619 { return *(this->_M_impl._M_start + __n); } (gdb) s m_config_save_option (conf=0xcafa30 <mpxp::mplayerxp_options+80>, opt=..., param=..., config=...) at cfgparser.cpp:60 60 save = config.config_stack[config.cs_level]; (gdb) s operator[] (__n=<optimized out>, this=<optimized out>) at /usr/lib/gcc/x86_64-unknown-linux-gnu/4.5.4/../../../../include/c++/4.5.4/bits/stl_vector.h:619 619 { return *(this->_M_impl._M_start + __n); } (gdb) s m_config_save_option (conf=0xcafa30 <mpxp::mplayerxp_options+80>, opt=..., param=..., config=...) at cfgparser.cpp:60 60 save = config.config_stack[config.cs_level]; (gdb) s std::vector<config_save_t, std::allocator<config_save_t> >::operator= (this= 0x7fffffffd2c0, __x=...) at /usr/lib/gcc/x86_64-unknown-linux-gnu/4.5.4/../../../../include/c++/4.5.4/bits/vector.tcc:156 156 vector<_Tp, _Alloc>:: (gdb) s 159 if (&__x != this) (gdb) s 156 vector<_Tp, _Alloc>:: (gdb) n 159 if (&__x != this) (gdb) n 160 mpxp_dbg2<<"Config pushed level="<<config.cs_level<<std::endl; ----- Patch: ------ Index: libmpconf/cfgparser.h =================================================================== --- libmpconf/cfgparser.h (revision 609) +++ libmpconf/cfgparser.h (working copy) @@ -57,7 +57,7 @@ ~m_config_t() {} std::vector<const config_t*> opt_list; - config_save_t** config_stack; + std::vector<std::vector<config_save_t> > config_stack; int cs_level; int parser_mode; /* COMMAND_LINE or CONFIG_FILE */ int flags; @@ -76,7 +76,7 @@ float as_float; any_t* as_pointer; } param; - char* opt_name; + std::string opt_name; }; /* parse_config_file returns: Index: libmpconf/cfgparser.cpp =================================================================== --- libmpconf/cfgparser.cpp (revision 609) +++ libmpconf/cfgparser.cpp (working copy) @@ -44,8 +44,8 @@ static void m_config_save_option(m_config_t& config,const config_t* conf,const std::string& opt,const std::string& param) { - config_save_t* save; - int sl=0; + std::vector<config_save_t> save; + size_t sl=0; switch(conf->type) { case CONF_TYPE_PRINT : @@ -59,26 +59,23 @@ save = config.config_stack[config.cs_level]; - if(save) { + if(!save.empty()) { std::string lopt=opt; std::transform(lopt.begin(),lopt.end(),lopt.begin(), ::tolower); - for(sl = 0; save[sl].opt != NULL; sl++){ + size_t sz = save.size(); + for(sl = 0; sl<sz; sl++){ // Check to not save the same arg two times - if(save[sl].opt == conf && (save[sl].opt_name == NULL || lopt==save[sl].opt_name)) + if(save[sl].opt == conf && (save[sl].opt_name.empty() || lopt==save[sl].opt_name)) break; } if(save[sl].opt) return; } + config_save_t cs; + cs.opt=conf; + cs.opt_name=opt; + save.push_back(cs); - save = (config_save_t*)mp_realloc(save,(sl+2)*sizeof(config_save_t)); - if(save == NULL) { - mpxp_err<<"Can't allocate "<<((sl+2)*sizeof(config_save_t))<<" bytes of memory : "<<strerror(errno)<<std::endl; - return; - } - memset(&save[sl],0,2*sizeof(config_save_t)); - save[sl].opt = conf; - switch(conf->type) { case CONF_TYPE_FLAG : case CONF_TYPE_INC : @@ -93,7 +90,7 @@ break; case CONF_TYPE_INCLUDE : if(!param.empty()) - save->param.as_pointer = mp_strdup(param.c_str()); + save[sl].param.as_pointer = mp_strdup(param.c_str()); default : mpxp_err<<"Should never append in m_config_save_option : conf->type="<<conf->type<<std::endl; } @@ -102,11 +99,11 @@ } static int m_config_revert_option(m_config_t& config, config_save_t* save) { - const char* arg = NULL; + std::string arg; config_save_t* iter=NULL; int i=-1; - arg = save->opt_name ? save->opt_name : save->opt->name; + arg = !save->opt_name.empty() ? save->opt_name : save->opt->name; mpxp_dbg2<<"Reverting option: "<<arg<<std::endl; switch(save->opt->type) { @@ -124,21 +121,22 @@ case CONF_TYPE_INCLUDE : if(config.cs_level > 0) { for(i = config.cs_level - 1 ; i >= 0 ; i--){ - if(config.config_stack[i] == NULL) continue; - for(iter = config.config_stack[i]; iter != NULL && iter->opt != NULL ; iter++) { + if(config.config_stack[i].empty()) continue; + size_t si,sz=config.config_stack[i].size(); + for(si = 0; si<sz ; si++) { + iter = &config.config_stack[i].at(si); if(iter->opt == save->opt && ((save->param.as_pointer == NULL || iter->param.as_pointer == NULL) || strcasecmp((const char *)save->param.as_pointer,(const char *)iter->param.as_pointer) == 0) && - (save->opt_name == NULL || - (iter->opt_name && strcasecmp(save->opt_name,iter->opt_name)))) break; + (save->opt_name.empty() || + (!iter->opt_name.empty() && strcasecmp(save->opt_name.c_str(),iter->opt_name.c_str())))) break; } } } delete save->param.as_pointer; - if(save->opt_name) delete save->opt_name; save->param.as_pointer = NULL; save->opt_name = reinterpret_cast<char*>(save->param.as_pointer); if(i < 0) break; - arg = iter->opt_name ? iter->opt_name : iter->opt->name; + arg = !iter->opt_name.empty() ? iter->opt_name : iter->opt->name; switch(iter->opt->type) { case CONF_TYPE_INCLUDE : if (iter->param.as_pointer == NULL) { @@ -158,51 +156,36 @@ } void m_config_push(m_config_t& config) { - - config.cs_level++; - config.config_stack = (config_save_t**)mp_realloc(config.config_stack ,sizeof(config_save_t*)*(config.cs_level+1)); - if(config.config_stack == NULL) { - mpxp_err<<"Can't allocate "<<(sizeof(config_save_t*)*(config.cs_level+1))<<" bytes of memory : "<<strerror(errno)<<std::endl; - config.cs_level = -1; - return; - } - config.config_stack[config.cs_level] = NULL; - mpxp_dbg2<<"Config pushed level="<<config.cs_level<<std::endl; + config.cs_level++; + mpxp_dbg2<<"Config pushed level="<<config.cs_level<<std::endl; } int m_config_pop(m_config_t& config) { - int i,ret= 1; - config_save_t* cs; + int ret= 1; + std::vector<config_save_t> cs; - if(config.config_stack[config.cs_level] != NULL) { + if(!config.config_stack[config.cs_level].empty()) { cs = config.config_stack[config.cs_level]; - for(i=0; cs[i].opt != NULL ; i++ ) { + size_t i,sz=cs.size(); + for(i=0; i<sz; i++ ) { if (m_config_revert_option(config,&cs[i]) < 0) ret = -1; } - delete config.config_stack[config.cs_level]; + config.config_stack.erase(config.config_stack.begin()+config.cs_level); } - config.config_stack = (config_save_t**)mp_realloc(config.config_stack ,sizeof(config_save_t*)*config.cs_level); config.cs_level--; - if(config.cs_level > 0 && config.config_stack == NULL) { - mpxp_err<<"Can't allocate memory"<<std::endl; - config.cs_level = -1; - return -1; - } mpxp_dbg2<<"Config poped level="<<config.cs_level<<std::endl; return ret; } m_config_t& m_config_new(PlayTree* pt,libinput_t&libinput) { m_config_t& config = *new(zeromem) m_config_t(libinput); - config.config_stack = (config_save_t**)mp_calloc(1,sizeof(config_save_t*)); SET_GLOBAL(config); // We always start with global options config.pt = pt; return config; } void m_config_free(m_config_t* config) { - delete config->config_stack; delete config; } @@ -944,8 +927,8 @@ int m_config_is_option_set(const m_config_t& config,const std::string& arg) { const config_t* opt; - config_save_t* save; - int l,i; + std::vector<config_save_t> save; + int l; opt = m_config_get_option(config,arg); @@ -954,12 +937,9 @@ for(l = config.cs_level ; l >= 0 ; l--) { save = config.config_stack[l]; - if(!save) - continue; - for(i = 0 ; save[i].opt != NULL ; i++) { - if(save[i].opt == opt) - return 1; - } + if(save.empty()) continue; + size_t i,sz=save.size(); + for(i = 0 ; i<sz ; i++) if(save[i].opt == opt) return 1; } return 0; Revision Links: -------------- http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=609&view=rev http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=609&view=rev Modified Paths: -------------- mplayerxp/global_msg.h Modified: mplayerxp/global_msg.h =================================================================== --- mplayerxp/global_msg.h 2012-12-27 17:51:43 UTC (rev 610) +++ mplayerxp/global_msg.h 2012-12-27 18:05:58 UTC (rev 611) @@ -16,5 +16,6 @@ static mpxp_ostream_dbg2 mpxp_dbg2(MSGT_GLOBAL); static mpxp_ostream_dbg3 mpxp_dbg3(MSGT_GLOBAL); static mpxp_ostream_dbg4 mpxp_dbg4(MSGT_GLOBAL); + } // namespace mpxp #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2012-12-27 17:51:51
|
Revision: 610 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=610&view=rev Author: nickols_k Date: 2012-12-27 17:51:43 +0000 (Thu, 27 Dec 2012) Log Message: ----------- use forward declaration instead of #include Modified Paths: -------------- mplayerxp/libplaytree/playtree.cpp mplayerxp/mplayerxp.h Modified: mplayerxp/libplaytree/playtree.cpp =================================================================== --- mplayerxp/libplaytree/playtree.cpp 2012-12-27 17:43:45 UTC (rev 609) +++ mplayerxp/libplaytree/playtree.cpp 2012-12-27 17:51:43 UTC (rev 610) @@ -10,6 +10,7 @@ #include <errno.h> #include <time.h> #include "libmpstream2/stream.h" +#include "libmpconf/cfgparser.h" #include "playtree.h" #include "playtree_msg.h" Modified: mplayerxp/mplayerxp.h =================================================================== --- mplayerxp/mplayerxp.h 2012-12-27 17:43:45 UTC (rev 609) +++ mplayerxp/mplayerxp.h 2012-12-27 17:51:43 UTC (rev 610) @@ -2,6 +2,7 @@ #define __MPLAYERXP_MAIN 1 #include <string> +#include <map> #include <pthread.h> #include <stdint.h> @@ -10,13 +11,13 @@ #include "mpxp_config.h" #include "osdep/mplib.h" #include "xmpcore/xmp_enums.h" -#include "libmpconf/cfgparser.h" #include "libmpsub/subreader.h" #include "libao3/audio_out.h" #include "libvo2/video_out.h" struct audio_decoder_t; struct video_decoder_t; +struct m_config_t; namespace mpxp { struct _PlayTree_Iter; /* List of all modules which require protection by pin-code */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2012-12-27 17:43:51
|
Revision: 609 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=609&view=rev Author: nickols_k Date: 2012-12-27 17:43:45 +0000 (Thu, 27 Dec 2012) Log Message: ----------- remove unused fields Modified Paths: -------------- mplayerxp/libmpconf/cfgparser.cpp mplayerxp/libmpconf/cfgparser.h Modified: mplayerxp/libmpconf/cfgparser.cpp =================================================================== --- mplayerxp/libmpconf/cfgparser.cpp 2012-12-27 16:37:25 UTC (rev 608) +++ mplayerxp/libmpconf/cfgparser.cpp 2012-12-27 17:43:45 UTC (rev 609) @@ -201,30 +201,15 @@ return config; } -static void m_config_add_dynamic(m_config_t& conf,any_t*ptr) { - if(!conf.dynasize) conf.dynamics = (any_t**)mp_malloc(sizeof(any_t*)); - else conf.dynamics = (any_t**)mp_realloc(conf.dynamics,(conf.dynasize+1)*sizeof(any_t*)); - conf.dynamics[conf.dynasize] = ptr; - conf.dynasize++; -} - void m_config_free(m_config_t* config) { - unsigned i; - for(i=0;i<config->dynasize;i++) delete config->dynamics[i]; - delete config->dynamics; - config->dynasize=0; delete config->config_stack; delete config; } - static int init_conf(m_config_t& config, int mode) { - config.parser_mode = mode; - config.dynamics=NULL; - config.dynasize=0; - - return 1; + config.parser_mode = mode; + return 1; } static int config_is_entry_option(m_config_t& config,const std::string& opt,const std::string& param) { @@ -423,7 +408,6 @@ goto out; } *((char **) conf[i].p) = mp_strdup(param.c_str()); - m_config_add_dynamic(config,*((char **) conf[i].p)); mpxp_dbg3<<"assigning "<<conf[i].name<<"="<<param<<" as string value"<<std::endl; ret = 1; break; Modified: mplayerxp/libmpconf/cfgparser.h =================================================================== --- mplayerxp/libmpconf/cfgparser.h 2012-12-27 16:37:25 UTC (rev 608) +++ mplayerxp/libmpconf/cfgparser.h 2012-12-27 17:43:45 UTC (rev 609) @@ -58,8 +58,6 @@ std::vector<const config_t*> opt_list; config_save_t** config_stack; - any_t**dynamics; - unsigned dynasize; int cs_level; int parser_mode; /* COMMAND_LINE or CONFIG_FILE */ int flags; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |