[Mplayerxp-cvslog] SF.net SVN: mplayerxp:[655] mplayerxp
Brought to you by:
olov
From: <nic...@us...> - 2013-06-14 21:51:07
|
Revision: 655 http://sourceforge.net/p/mplayerxp/code/655 Author: nickols_k Date: 2013-06-14 21:51:03 +0000 (Fri, 14 Jun 2013) Log Message: ----------- remove exit_player() + escape_player() and fix segfault in cfgparser.cpp Modified Paths: -------------- mplayerxp/input2/input.cpp mplayerxp/libmpconf/cfgparser.cpp mplayerxp/libvo2/x11_system.cpp mplayerxp/main.cpp mplayerxp/mplayerxp.h mplayerxp/osdep/mplib.cpp mplayerxp/osdep/mplib.h mplayerxp/postproc/postprocess.cpp mplayerxp/xmpcore/xmp_vdecoder.cpp Modified: mplayerxp/input2/input.cpp =================================================================== --- mplayerxp/input2/input.cpp 2013-06-14 16:28:01 UTC (rev 654) +++ mplayerxp/input2/input.cpp 2013-06-14 21:51:03 UTC (rev 655) @@ -1361,7 +1361,7 @@ static int mp_input_print_key_list(libinput_t& handle) { mp_input_print_keys(handle); - exit_player(MSGTR_Exit_quit); + throw soft_exit_exception(MSGTR_Exit_quit); } void mp_input_print_binds(libinput_t& handle) { @@ -1407,7 +1407,7 @@ static int mp_input_print_cmd_list(libinput_t& handle) { mp_input_print_cmds(handle); - exit_player(MSGTR_Exit_quit); + throw soft_exit_exception(MSGTR_Exit_quit); } MPXP_Rc mp_input_check_interrupt(libinput_t& handle,int tim) { Modified: mplayerxp/libmpconf/cfgparser.cpp =================================================================== --- mplayerxp/libmpconf/cfgparser.cpp 2013-06-14 16:28:01 UTC (rev 654) +++ mplayerxp/libmpconf/cfgparser.cpp 2013-06-14 21:51:03 UTC (rev 655) @@ -12,6 +12,7 @@ #include <limits> #include <iostream> #include <fstream> +#include <sstream> #include <stdexcept> #include <stdlib.h> @@ -268,7 +269,7 @@ break; case CONF_TYPE_PRINT: mpxp_info<<(char *)conf[i].p; - exit_player(MSGTR_Exit_quit); + throw soft_exit_exception(MSGTR_Exit_quit); default: mpxp_err<<"read_option: Unknown config type specified in conf-mplayerxp.h!"<<std::endl; break; @@ -531,11 +532,11 @@ opt = argv[i]; if(opt=="--help") { show_help(); - exit_player(MSGTR_Exit_quit); + throw soft_exit_exception(MSGTR_Exit_quit); } if(opt=="--long-help") { show_long_help(*this,envm); - exit_player(MSGTR_Exit_quit); + throw soft_exit_exception(MSGTR_Exit_quit); } /* check for -- (no more options id.) except --help! */ if (opt[0] == '-' && opt[1] == '-') { @@ -774,19 +775,18 @@ for(n=0;n<ntabs;n++) mpxp_info<<" "; mpxp_info<<opts[i].help<<":"<<std::endl; pfxlen=strlen(opts[i].name)+1; - if(!pfx.empty()) pfxlen+=pfx.length(); - if(!pfx.empty()) newpfx=pfx; + if(!pfx.empty()) { pfxlen+=pfx.length(); newpfx=pfx; } else newpfx=""; newpfx+=opts[i].name; newpfx+="."; __show_options(ntabs+2,newpfx,(const mpxp_option_t *)opts[i].p); - } - else - if(opts[i].type<=CONF_TYPE_PRINT) { + } else if(opts[i].type<=CONF_TYPE_PRINT) { + std::ostringstream os; for(n=0;n<ntabs;n++) mpxp_info<<" "; - if(!pfx.empty()) mpxp_info<<std::left<<pfx<<std::endl; - else mpxp_info<<" "<<std::endl; - mpxp_info<<std::left<<opts[i].name<<" "<<opts[i].help<<std::endl; + if(!pfx.empty()) os<<std::left<<pfx; + else os<<" "; + os<<opts[i].name; + mpxp_info<<std::left<<std::setw(25)<<os.str()<<" "<<opts[i].help; if((opts[i].flags&CONF_NOCFG)==0) { mpxp_info<<" {"<< (opts[i].type==CONF_TYPE_FLAG?"flg": @@ -803,7 +803,7 @@ break; case CONF_TYPE_STRING: { const char **defv = (const char**)(opts[i].p); - if(defv) mpxp_info<<"\""<<*defv<<"\""; + if(defv && *defv) mpxp_info<<"\""<<*defv<<"\""; } break; case CONF_TYPE_INT: { Modified: mplayerxp/libvo2/x11_system.cpp =================================================================== --- mplayerxp/libvo2/x11_system.cpp 2013-06-14 16:28:01 UTC (rev 654) +++ mplayerxp/libvo2/x11_system.cpp 2013-06-14 21:51:03 UTC (rev 655) @@ -41,7 +41,8 @@ mpxp_err<<"X11_System: "<<msg<<std::endl; mpxp_v<<"Type: "<<std::hex<<event->type<<", display: "<<std::hex<<event->display<<", resourceid: "<<std::hex<<event->resourceid<<", serial: "<<event->serial<<std::endl; mpxp_v<<"Error code: "<<std::hex<<event->error_code<<", request code: "<<std::hex<<event->request_code<<", minor code: "<<event->minor_code<<std::endl; - escape_player("X11_System error",mp_conf.max_trace); + show_backtrace("X11_System error",mp_conf.max_trace); + throw std::runtime_error("X11_System error"); return 0; } Modified: mplayerxp/main.cpp =================================================================== --- mplayerxp/main.cpp 2013-06-14 16:28:01 UTC (rev 654) +++ mplayerxp/main.cpp 2013-06-14 21:51:03 UTC (rev 655) @@ -362,26 +362,6 @@ MP_UNIT(NULL); } -class soft_exit_exception : public std::exception { - public: - soft_exit_exception(const std::string& why) throw(); - virtual ~soft_exit_exception() throw(); - - virtual const char* what() const throw(); - private: - std::string why; -}; - -soft_exit_exception::soft_exit_exception(const std::string& _why) throw() { why=_why; } -soft_exit_exception::~soft_exit_exception() throw() {} -const char* soft_exit_exception::what() const throw() { return why.c_str(); } - -void exit_player(const std::string& why) -{ - if(!why.empty()) throw soft_exit_exception(why); - throw std::exception(); -} - void __exit_sighandler() { static int sig_count=0; @@ -393,14 +373,14 @@ kill(getpid(),SIGKILL); return; } - exit_player(""); + throw std::exception(); } void exit_sighandler(void) { - xmp_killall_threads(pthread_self()); - __exit_sighandler(); + xmp_killall_threads(pthread_self()); + __exit_sighandler(); } // When libmpdemux perform a blocking operation (network connection or cache filling) @@ -413,7 +393,7 @@ switch(cmd->id) { case MP_CMD_QUIT: case MP_CMD_SOFT_QUIT: // should never happen - exit_player(MSGTR_Exit_quit); + throw soft_exit_exception(MSGTR_Exit_quit); case MP_CMD_PLAY_TREE_STEP: { eof = (cmd->args[0].v.i > 0) ? PT_NEXT_ENTRY : PT_PREV_ENTRY; } break; @@ -1310,9 +1290,9 @@ osd_function=OSD_PAUSE; break; case MP_CMD_SOFT_QUIT : - exit_player(MSGTR_Exit_quit); + throw soft_exit_exception(MSGTR_Exit_quit); case MP_CMD_QUIT : - exit_player(MSGTR_Exit_quit); + throw soft_exit_exception(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); @@ -1568,7 +1548,7 @@ if(filename.empty()){ show_help(); - exit_player(MSGTR_Exit_quit); + throw soft_exit_exception(MSGTR_Exit_quit); } // Many users forget to include command line in bugreports... Modified: mplayerxp/mplayerxp.h =================================================================== --- mplayerxp/mplayerxp.h 2013-06-14 16:28:01 UTC (rev 654) +++ mplayerxp/mplayerxp.h 2013-06-14 21:51:03 UTC (rev 655) @@ -205,21 +205,15 @@ extern pthread_mutex_t audio_timer_mutex; - void exit_player(const std::string& why); - /* 10 ms or 10'000 microsecs is optimal time for thread sleeping */ inline int yield_timeslice() { return ::usleep(10000); } - inline void escape_player(const std::string& why,unsigned num_calls) { - show_backtrace(why,num_calls); - throw std::runtime_error(why); - } - inline MPXP_Rc check_pin(const std::string& module,unsigned pin1,unsigned pin2) { if(pin1!=pin2) { std::string msg; msg=std::string("Found incorrect PIN in module: ")+module; - escape_player(msg,mp_conf.max_trace); + show_backtrace(msg,mp_conf.max_trace); + throw std::runtime_error(msg); } return MPXP_Ok; } Modified: mplayerxp/osdep/mplib.cpp =================================================================== --- mplayerxp/osdep/mplib.cpp 2013-06-14 16:28:01 UTC (rev 654) +++ mplayerxp/osdep/mplib.cpp 2013-06-14 21:51:03 UTC (rev 655) @@ -74,4 +74,8 @@ missing_driver_exception::missing_driver_exception() throw() {} missing_driver_exception::~missing_driver_exception() throw() {} const char* missing_driver_exception::what() const throw() { return "missing driver"; } + +soft_exit_exception::soft_exit_exception(const std::string& _why) throw() { why=_why; } +soft_exit_exception::~soft_exit_exception() throw() {} +const char* soft_exit_exception::what() const throw() { return why.c_str(); } } // namespace usr Modified: mplayerxp/osdep/mplib.h =================================================================== --- mplayerxp/osdep/mplib.h 2013-06-14 16:28:01 UTC (rev 654) +++ mplayerxp/osdep/mplib.h 2013-06-14 21:51:03 UTC (rev 655) @@ -65,5 +65,15 @@ virtual const char* what() const throw(); }; + + class soft_exit_exception : public std::exception { + public: + soft_exit_exception(const std::string& why) throw(); + virtual ~soft_exit_exception() throw(); + + virtual const char* what() const throw(); + private: + std::string why; + }; } // namespace usr #endif Modified: mplayerxp/postproc/postprocess.cpp =================================================================== --- mplayerxp/postproc/postprocess.cpp 2013-06-14 16:28:01 UTC (rev 654) +++ mplayerxp/postproc/postprocess.cpp 2013-06-14 21:51:03 UTC (rev 655) @@ -30,7 +30,7 @@ { if(strcmp(mp_conf.npp_options,"help")==0) { mpxp_info<<pp_help<<std::endl; - exit_player(MSGTR_Exit_quit); + throw soft_exit_exception(MSGTR_Exit_quit); } return 1; } Modified: mplayerxp/xmpcore/xmp_vdecoder.cpp =================================================================== --- mplayerxp/xmpcore/xmp_vdecoder.cpp 2013-06-14 16:28:01 UTC (rev 654) +++ mplayerxp/xmpcore/xmp_vdecoder.cpp 2013-06-14 21:51:03 UTC (rev 655) @@ -192,7 +192,10 @@ if(cur_time - mpxp_context().seek_time > (mpxp_context().engine().xp_core->num_v_buffs/sh_video->fps)*100) xp_n_frame_to_drop=compute_frame_dropping(sh_video,frame->pts,drop_barrier); } /* if( mp_conf.frame_dropping ) */ if(!finite(frame->pts)) mpxp_warn<<"Bug of demuxer! Value of video pts="<<frame->pts<<std::endl; - if(frame->type!=VideoFrame) escape_player("VideoDecoder doesn't parse non video frames",mp_conf.max_trace); + if(frame->type!=VideoFrame) { + show_backtrace("VideoDecoder doesn't parse non video frames",mp_conf.max_trace); + throw std::runtime_error("VideoDecoder doesn't parse non video frames"); + } #if 0 /* We can't seriously examine question of too slow machines This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |