[Mplayerxp-cvslog] SF.net SVN: mplayerxp:[647] mplayerxp
Brought to you by:
olov
From: <nic...@us...> - 2013-05-26 12:23:00
|
Revision: 647 http://sourceforge.net/p/mplayerxp/code/647 Author: nickols_k Date: 2013-05-26 12:22:56 +0000 (Sun, 26 May 2013) Log Message: ----------- use throw technique Modified Paths: -------------- mplayerxp/dump.cpp mplayerxp/libmpcodecs/ad_twin.cpp mplayerxp/libmpcodecs/libnuppelvideo/RTjpegN.cpp mplayerxp/libmpcodecs/vd_real.cpp mplayerxp/libmpconf/cfgparser.cpp mplayerxp/libmpstream2/librtsp/rtsp.cpp mplayerxp/libmpstream2/realrtsp/sdpplin.cpp mplayerxp/libvo2/vidix_system.cpp mplayerxp/libvo2/vo_fbdev.cpp mplayerxp/libvo2/vo_sdl.cpp mplayerxp/libvo2/vo_vesa.cpp mplayerxp/libvo2/vo_x11.cpp mplayerxp/libvo2/vo_xv.cpp mplayerxp/libvo2/x11_system.cpp mplayerxp/main.cpp mplayerxp/mplayerxp.h mplayerxp/osdep/cpudetect.cpp mplayerxp/osdep/cpudetect.h mplayerxp/osdep/mp_malloc.cpp mplayerxp/postproc/libmenu/menu_console.cpp mplayerxp/postproc/postprocess.cpp mplayerxp/postproc/vf.cpp mplayerxp/xmpcore/xmp_vdecoder.cpp Modified: mplayerxp/dump.cpp =================================================================== --- mplayerxp/dump.cpp 2013-05-26 08:28:07 UTC (rev 646) +++ mplayerxp/dump.cpp 2013-05-26 12:22:56 UTC (rev 647) @@ -6,6 +6,7 @@ */ #include <iostream> #include <fstream> +#include <stdexcept> #include <stdio.h> #include <stdlib.h> @@ -60,7 +61,7 @@ f.open(name,std::ios_base::out|std::ios_base::binary); if(!f.is_open()){ MSG_FATAL(MSGTR_CantOpenDumpfile); - exit_player(MSGTR_Fatal_error); + throw std::runtime_error(MSGTR_Fatal_error); } MSG_INFO("Dumping stream to %s\n",name); while(!stream->eof()){ @@ -69,7 +70,7 @@ } f.close(); mpxp_info<<MSGTR_StreamDumped<<std::endl; - exit_player(MSGTR_Exit_eof); + throw std::runtime_error(MSGTR_Exit_eof); } enum { @@ -140,17 +141,17 @@ else if(strcmp(media,"raw") == 0) strcat(stream_dump_name,"dump.raw"); else { MSG_FATAL("Unsupported muxer format %s found\n",media); - exit_player(MSGTR_Fatal_error); + throw std::runtime_error(MSGTR_Fatal_error); } priv->mux_file.open(stream_dump_name,std::ios_base::out|std::ios_base::binary); MSG_DBG2("Preparing stream dumping: %s\n",stream_dump_name); if(!priv->mux_file.is_open()){ MSG_FATAL(MSGTR_CantOpenDumpfile); - exit_player(MSGTR_Fatal_error); + throw std::runtime_error(MSGTR_Fatal_error); } if(!(priv->muxer=muxer_new_muxer(media,port,priv->mux_file))) { MSG_FATAL("Can't initialize muxer\n"); - exit_player(MSGTR_Fatal_error); + throw std::runtime_error(MSGTR_Fatal_error); } if(sha && (priv->mux_type&MUX_HAVE_AUDIO)) { priv->m_audio=muxer_new_stream(priv->muxer,MUXER_TYPE_AUDIO); Modified: mplayerxp/libmpcodecs/ad_twin.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_twin.cpp 2013-05-26 08:28:07 UTC (rev 646) +++ mplayerxp/libmpcodecs/ad_twin.cpp 2013-05-26 12:22:56 UTC (rev 647) @@ -1,6 +1,8 @@ #include "mpxp_config.h" #include "osdep/mplib.h" using namespace usr; +#include <stdexcept> + #include <stdio.h> #include <stdlib.h> #include <unistd.h> @@ -426,11 +428,8 @@ char tmpbit[BITS_INT]; int retval; - if ( nbits > BITS_INT ){ - MSG_ERR( "get_bstm(): %d: %d Error.\n", - nbits, BITS_INT); - exit(1); - } + if ( nbits > BITS_INT ) throw std::runtime_error("get_bstm(): falied"); + retval = bread(tmpbit, sizeof(*tmpbit), nbits, priv, pts ); for (ibit=retval; ibit<nbits; ibit++){ tmpbit[ibit] = 0; Modified: mplayerxp/libmpcodecs/libnuppelvideo/RTjpegN.cpp =================================================================== --- mplayerxp/libmpcodecs/libnuppelvideo/RTjpegN.cpp 2013-05-26 08:28:07 UTC (rev 646) +++ mplayerxp/libmpcodecs/libnuppelvideo/RTjpegN.cpp 2013-05-26 12:22:56 UTC (rev 647) @@ -3120,22 +3120,16 @@ void RTjpeg_init_mcompress(void) { - unsigned long tmp; + unsigned long tmp; - if(!RTjpeg_old) - { - RTjpeg_old=(__s16*)mp_malloc((4*RTjpeg_width*RTjpeg_height)+32); - tmp=(unsigned long)RTjpeg_old; - tmp+=32; - tmp=tmp>>5; - RTjpeg_old=(__s16 *)(tmp<<5); - } - if (!RTjpeg_old) - { - fprintf(stderr, "RTjpeg: Could not allocate memory\n"); - exit(-1); - } - bzero(RTjpeg_old, ((4*RTjpeg_width*RTjpeg_height))); + if(!RTjpeg_old) { + RTjpeg_old=new __s16[(4*RTjpeg_width*RTjpeg_height)+32]; + tmp=(unsigned long)RTjpeg_old; + tmp+=32; + tmp=tmp>>5; + RTjpeg_old=(__s16 *)(tmp<<5); + } + bzero(RTjpeg_old, ((4*RTjpeg_width*RTjpeg_height))); } #ifdef MMX Modified: mplayerxp/libmpcodecs/vd_real.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_real.cpp 2013-05-26 08:28:07 UTC (rev 646) +++ mplayerxp/libmpcodecs/vd_real.cpp 2013-05-26 12:22:56 UTC (rev 647) @@ -1,6 +1,8 @@ #include "mpxp_config.h" #include "osdep/mplib.h" using namespace usr; +#include <stdexcept> + #include <stdio.h> #include <stdlib.h> #include <inttypes.h> @@ -83,8 +85,7 @@ void __pure_virtual(void) { - MSG_ERR( "I'm outa here!\n"); - exit(1); + throw std::runtime_error( "I'm outa here!\n"); } #endif struct vreal_private_t : public Opaque { Modified: mplayerxp/libmpconf/cfgparser.cpp =================================================================== --- mplayerxp/libmpconf/cfgparser.cpp 2013-05-26 08:28:07 UTC (rev 646) +++ mplayerxp/libmpconf/cfgparser.cpp 2013-05-26 12:22:56 UTC (rev 647) @@ -12,6 +12,7 @@ #include <limits> #include <iostream> #include <fstream> +#include <stdexcept> #include <stdlib.h> #include <stdio.h> @@ -883,7 +884,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) throw std::runtime_error("Error in config file"); } } Modified: mplayerxp/libmpstream2/librtsp/rtsp.cpp =================================================================== --- mplayerxp/libmpstream2/librtsp/rtsp.cpp 2013-05-26 08:28:07 UTC (rev 646) +++ mplayerxp/libmpstream2/librtsp/rtsp.cpp 2013-05-26 12:22:56 UTC (rev 647) @@ -31,6 +31,7 @@ * 2006, Benjamin Zores and Vincent Mussard * fixed a lot of RFC compliance issues. */ +#include <stdexcept> #include <unistd.h> #include <stdio.h> @@ -178,10 +179,8 @@ n++; } - if (n>=BUF_SIZE) { - mpxp_fatal<<"librtsp: buffer overflow in rtsp_get"<<std::endl; - exit(1); - } + if (n>=BUF_SIZE) throw std::runtime_error("librtsp: buffer overflow in rtsp_get"); + string=new char [n]; memcpy(string,buffer,n-1); string[n-1]=0; Modified: mplayerxp/libmpstream2/realrtsp/sdpplin.cpp =================================================================== --- mplayerxp/libmpstream2/realrtsp/sdpplin.cpp 2013-05-26 08:28:07 UTC (rev 646) +++ mplayerxp/libmpstream2/realrtsp/sdpplin.cpp 2013-05-26 12:22:56 UTC (rev 647) @@ -76,7 +76,6 @@ if (dtable[c] & 0x80) { mpxp_info<<"Illegal character '"<<c<<"' in input"<<std::endl; -// exit(1); return NULL; } a[i] = (char) c; Modified: mplayerxp/libvo2/vidix_system.cpp =================================================================== --- mplayerxp/libvo2/vidix_system.cpp 2013-05-26 08:28:07 UTC (rev 646) +++ mplayerxp/libvo2/vidix_system.cpp 2013-05-26 12:22:56 UTC (rev 647) @@ -13,6 +13,7 @@ * (Partly based on vesa_lvo.c from mplayer's package) */ #include <iomanip> +#include <stdexcept> #include <errno.h> #include <inttypes.h> @@ -51,15 +52,15 @@ mpxp_dbg2<<"vidix_preinit("<<drvname<<") was called"<<std::endl; if(vidix->version() != VIDIX_VERSION) { mpxp_fatal<<"You have wrong version of VIDIX library"<<std::endl; - exit_player("Vidix"); + throw std::runtime_error("Vidix"); } if(vidix->is_error()) { mpxp_fatal<<"Couldn't find working VIDIX driver"<<std::endl; - exit_player("Vidix"); + throw std::runtime_error("Vidix"); } if((err=vidix->get_capabilities()) != 0) { mpxp_fatal<<"Couldn't get capability: "<<strerror(err)<<std::endl; - exit_player("Vidix"); + throw std::runtime_error("Vidix"); } else mpxp_v<<"Driver capability: "<<std::hex<<vidix->cap.flags<<std::endl; mpxp_v<<"Using: "<<vidix->cap.name<<" by "<<vidix->cap.author<<std::endl; @@ -152,9 +153,8 @@ err=vidix->dma_copy_frame(); if(err) { /* We can switch back to DR here but for now exit */ - mpxp_fatal<<"error '"<<strerror(err)<<"' occured during DMA transfer"<<std::endl; mpxp_fatal<<"Please send BUGREPORT to developers!!!"<<std::endl; - exit(EXIT_FAILURE); /* it's OK vidix_term will be called */ + throw std::runtime_error(std::string("error '")+strerror(err)+"' occured during DMA transfer"); } #if 0 mpxp_info<<"frame is DMA copied"<<std::endl; Modified: mplayerxp/libvo2/vo_fbdev.cpp =================================================================== --- mplayerxp/libvo2/vo_fbdev.cpp 2013-05-26 08:28:07 UTC (rev 646) +++ mplayerxp/libvo2/vo_fbdev.cpp 2013-05-26 12:22:56 UTC (rev 647) @@ -10,6 +10,7 @@ */ #include <iostream> #include <fstream> +#include <stdexcept> static const char* FBDEV= "fbdev: "; @@ -306,11 +307,11 @@ if(!vidix_name.empty()) { if(!(vidix=new(zeromem) Vidix_System(vidix_name))) { mpxp_err<<"Cannot initialze vidix with '"<<vidix_name<<"' argument"<<std::endl; - exit_player("Vidix error"); + throw std::runtime_error("Vidix error"); } } #endif - if(fb_preinit()!=MPXP_Ok) exit_player("FBDev preinit"); + if(fb_preinit()!=MPXP_Ok) throw std::runtime_error("FBDev preinit"); } int FBDev_VO_Interface::get_token(std::ifstream& fp,int num) Modified: mplayerxp/libvo2/vo_sdl.cpp =================================================================== --- mplayerxp/libvo2/vo_sdl.cpp 2013-05-26 08:28:07 UTC (rev 646) +++ mplayerxp/libvo2/vo_sdl.cpp 2013-05-26 12:22:56 UTC (rev 647) @@ -93,6 +93,7 @@ * */ #include <algorithm> +#include <stdexcept> /* define to force software-surface (video surface stored in system memory)*/ #undef SDL_NOHWSURFACE @@ -278,7 +279,7 @@ if(!vidix_name.empty()) { if(!(vidix=new(zeromem) Vidix_System(vidix_name))) { mpxp_err<<"Cannot initialze vidix with '"<<vidix_name<<"' argument"<<std::endl; - exit_player("Vidix error"); + throw std::runtime_error("Vidix error"); } } #endif @@ -343,7 +344,7 @@ if (!SDL_WasInit(SDL_INIT_VIDEO)) { if (SDL_Init (SDL_INIT_VIDEO|SDL_INIT_NOPARACHUTE)) { mpxp_err<<"SDL: Initializing of SDL failed: "<<SDL_GetError()<<std::endl; - exit_player("SDL error"); + throw std::runtime_error("SDL error"); } } @@ -389,7 +390,7 @@ sdlflags &= ~SDL_HWSURFACE; if ((!SDL_ListModes (vidInfo->vfmt, sdlflags)) && (!fullmodes)) { mpxp_err<<"SDL: Couldn't get any acceptable SDL Mode for output."<<std::endl; - exit_player("SDL error"); + throw std::runtime_error("SDL error"); } } /* YUV overlays need at least 16-bit color depth, but the @@ -835,7 +836,7 @@ (*vrest->adjust_size)(vrest->vo,windowsize.w,windowsize.h,reinterpret_cast<unsigned*>(&event.resize.w), reinterpret_cast<unsigned*>(&event.resize.h)); if(set_video_mode(event.resize.w, event.resize.h, bpp, sdlflags)!=0) - exit_player("SDL set video mode"); + throw std::runtime_error("SDL set video mode"); /* save video extents, to restore them after going fullscreen */ windowsize.w = surface->w; @@ -884,7 +885,7 @@ /* select next fullscreen mode */ fullmode++; if (fullmode > (findArrayEnd(fullmodes) - 1)) fullmode = 0; - if(set_fullmode(fullmode)!=0) exit_player("SDL set full mode"); + if(set_fullmode(fullmode)!=0) throw std::runtime_error("SDL set full mode"); mpxp_v<<"SDL: Set next available fullscreen mode."<<std::endl; retval = VO_EVENT_RESIZE; } else if ( keypressed == SDLK_n ) { @@ -892,13 +893,13 @@ aspect->calc(dstwidth, dstheight,flags&VOFLAG_FULLSCREEN?Aspect::ZOOM:Aspect::NOZOOM); #endif if (unsigned(surface->w) != dstwidth || unsigned(surface->h) != dstheight) { - if(set_video_mode(dstwidth, dstheight, bpp, sdlflags)!=0) exit_player("SDL set video mode"); + if(set_video_mode(dstwidth, dstheight, bpp, sdlflags)!=0) throw std::runtime_error("SDL set video mode"); windowsize.w = surface->w; windowsize.h = surface->h; mpxp_v<<"SDL: Normal size"<<std::endl; retval |= VO_EVENT_RESIZE; } else if (unsigned(surface->w) != dstwidth * 2 || unsigned(surface->h) != dstheight * 2) { - if(set_video_mode(dstwidth * 2, dstheight * 2, bpp, sdlflags)!=0) exit_player("SDL set video mode"); + if(set_video_mode(dstwidth * 2, dstheight * 2, bpp, sdlflags)!=0) throw std::runtime_error("SDL set video mode"); windowsize.w = surface->w; windowsize.h = surface->h; mpxp_v<<"SDL: Double size"<<std::endl; @@ -1217,11 +1218,11 @@ MPXP_Rc SDL_VO_Interface::toggle_fullscreen() { if (surface->flags & SDL_FULLSCREEN) { - if(set_video_mode(windowsize.w, windowsize.h, bpp, sdlflags)!=0) exit_player("SDL set fullscreen"); + if(set_video_mode(windowsize.w, windowsize.h, bpp, sdlflags)!=0) throw std::runtime_error("SDL set fullscreen"); SDL_ShowCursor(1); mpxp_v<<"SDL: Windowed mode"<<std::endl; } else if (fullmodes) { - if(set_fullmode(fullmode)!=0) exit_player("SDL set fullmode"); + if(set_fullmode(fullmode)!=0) throw std::runtime_error("SDL set fullmode"); mpxp_v<<"SDL: Set fullscreen mode"<<std::endl; } return MPXP_True; Modified: mplayerxp/libvo2/vo_vesa.cpp =================================================================== --- mplayerxp/libvo2/vo_vesa.cpp 2013-05-26 08:28:07 UTC (rev 646) +++ mplayerxp/libvo2/vo_vesa.cpp 2013-05-26 12:22:56 UTC (rev 647) @@ -20,6 +20,7 @@ */ #include <algorithm> #include <iomanip> +#include <stdexcept> #include <stdio.h> #include <stdlib.h> @@ -175,7 +176,7 @@ if(!vidix_name.empty()) { if(!(vidix=new(zeromem) Vidix_System(vidix_name))) { mpxp_err<<"Cannot initialze vidix with '"<<vidix_name<<"' argument"<<std::endl; - exit_player("Vidix error"); + throw std::runtime_error("Vidix error"); } } #endif @@ -184,7 +185,7 @@ if(vbeInit()!=VBE_OK) { pre_init_err=MPXP_False; PRINT_VBE_ERR("vbeInit",pre_init_err); - exit_player("VESA preinit"); + throw std::runtime_error("VESA preinit"); } } @@ -214,7 +215,7 @@ vesa_term(); PRINT_VBE_ERR("vbeSetWindow",err); mpxp_fatal<<"vo_vesa: Fatal error occured! Can't continue"<<std::endl; - exit_player("VESA error"); + throw std::runtime_error("VESA error"); } win.low = new_offset * gran; win.high = win.low + vmode_info.WinSize*1024; @@ -301,7 +302,7 @@ vesa_term(); PRINT_VBE_ERR("vbeSetDisplayStart",err); mpxp_fatal<<"vo_vesa: Fatal error occured! Can't continue"<<std::endl; - exit_player("VESA error"); + throw std::runtime_error("VESA error"); } win.ptr = dga_buffer = video_base + multi_buff[(idx+1)%multi_size]; } Modified: mplayerxp/libvo2/vo_x11.cpp =================================================================== --- mplayerxp/libvo2/vo_x11.cpp 2013-05-26 08:28:07 UTC (rev 646) +++ mplayerxp/libvo2/vo_x11.cpp 2013-05-26 12:22:56 UTC (rev 647) @@ -17,6 +17,7 @@ * runtime fullscreen switching by alex * */ +#include <stdexcept> #include <limits.h> #include <stdio.h> @@ -144,7 +145,7 @@ mpxp_info<<"args="<<arg<<" vidix_name="<<vidix_name<<std::endl; if(!(vidix=new(zeromem) Vidix_System(vidix_name))) { mpxp_err<<"Cannot initialze vidix with '"<<vidix_name<<"' argument"<<std::endl; - exit_player("Vidix error"); + throw std::runtime_error("Vidix error"); } } #endif @@ -176,9 +177,9 @@ { mpxp_fatal<<"Can't initialize VIDIX: "<<strerror(errno)<<std::endl; delete vidix; - exit_player("Vidix init"); /* !!! */ + throw std::runtime_error("Vidix init"); /* !!! */ } - if(vidix->start()!=0) { delete vidix; exit_player("Vidix start"); } + if(vidix->start()!=0) { delete vidix; throw std::runtime_error("Vidix start"); } } #endif Modified: mplayerxp/libvo2/vo_xv.cpp =================================================================== --- mplayerxp/libvo2/vo_xv.cpp 2013-05-26 08:28:07 UTC (rev 646) +++ mplayerxp/libvo2/vo_xv.cpp 2013-05-26 12:22:56 UTC (rev 647) @@ -15,6 +15,7 @@ * double buffering support by A'rpi */ #include <algorithm> +#imclude <stdexcept> #include <stdio.h> #include <stdlib.h> @@ -91,7 +92,7 @@ num_buffers=1; if(!arg.empty()) { mpxp_err<<"vo_xv: Unknown subdevice: "<<arg<<std::endl; - exit_player("Xv error"); + throw std::runtime_error("Xv error"); } } Modified: mplayerxp/libvo2/x11_system.cpp =================================================================== --- mplayerxp/libvo2/x11_system.cpp 2013-05-26 08:28:07 UTC (rev 646) +++ mplayerxp/libvo2/x11_system.cpp 2013-05-26 12:22:56 UTC (rev 647) @@ -2,6 +2,7 @@ #include "osdep/mplib.h" using namespace usr; #include <iomanip> +#include <stdexcept> #include <errno.h> #include <stdio.h> @@ -76,7 +77,7 @@ if(!(mDisplay=::XOpenDisplay(dispName.c_str()))) { mpxp_err<<"X11_System: couldn't open the X11 display: "<<dispName<<std::endl; - exit_player("X11_System error"); + throw std::runtime_error("X11_System error"); } mScreen=DefaultScreen( mDisplay ); mRootWin=RootWindow( mDisplay,mScreen );// Root window ID. @@ -1211,7 +1212,7 @@ ctx=::glXCreateContext(get_display(), vi, NULL, GL_TRUE); if (ctx == NULL) { mpxp_err<<"[GLX_System]: Can't create GLX context"<<std::endl; - exit_player("vo error"); + throw std::runtime_error("vo error"); } theCmap =::XCreateColormap( get_display(),RootWindow( get_display(),vi->screen), Modified: mplayerxp/main.cpp =================================================================== --- mplayerxp/main.cpp 2013-05-26 08:28:07 UTC (rev 646) +++ mplayerxp/main.cpp 2013-05-26 12:22:56 UTC (rev 647) @@ -483,37 +483,37 @@ #endif -static void init_player(const std::map<std::string,std::string>& envm) +static MPXP_Rc 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); + return MPXP_False; } if(mp_conf.audio_driver && strcmp(mp_conf.audio_driver,"help")==0) { mpxp_context().audio().output->print_help(); mpxp_uninit_structs(); - exit(0); + return MPXP_False; } if(mp_conf.video_family && strcmp(mp_conf.video_family,"help")==0) { vfm_help(); mpxp_uninit_structs(); - exit(0); + return MPXP_False; } if(mp_conf.audio_family && strcmp(mp_conf.audio_family,"help")==0) { afm_help(); mpxp_uninit_structs(); - exit(0); + return MPXP_False; } if(vf_cfg.list && strcmp(vf_cfg.list,"help")==0) { vf_help(); mpxp_uninit_structs(); - exit(0); + return MPXP_False; } if(af_cfg.list && strcmp(af_cfg.list,"help")==0) { af_help(); mpxp_uninit_structs(); - exit(0); + return MPXP_False; } #ifdef ENABLE_WIN32LOADER @@ -522,7 +522,7 @@ if(!parse_codec_cfg(CONFDIR"/win32codecs.conf")) { mpxp_hint<<MSGTR_CopyCodecsConf<<std::endl; mpxp_uninit_structs(); - exit(0); + return MPXP_False; } } #endif @@ -531,15 +531,16 @@ list_codecs(1); #endif mpxp_uninit_structs(); - exit(0); + return MPXP_False; } if(mp_conf.video_codec && strcmp(mp_conf.video_codec,"help")==0) { #ifdef ENABLE_WIN32LOADER list_codecs(0); #endif mpxp_uninit_structs(); - exit(0); + return MPXP_False; } + return MPXP_Ok; } void show_help(void) { @@ -824,7 +825,7 @@ if(vo_inited==MPXP_False){ mpxp_fatal<<MSGTR_InvalidVOdriver<<": "<<(mp_conf.video_driver?mp_conf.video_driver:"?")<<std::endl; - exit_player(MSGTR_Fatal_error); + throw std::runtime_error(MSGTR_Fatal_error); } // check audio_out driver name: @@ -1079,7 +1080,7 @@ 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); + throw std::runtime_error(MSGTR_Fatal_error); } } } @@ -1211,12 +1212,12 @@ 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"); + throw std::runtime_error("Try other '-vo' driver."); } if(xmp_init_engine(sh_video,sh_audio)!=0) - exit_player("Can't initialize decoding ahead!\n"); + throw std::runtime_error("Can't initialize decoding ahead!"); if(xmp_run_decoders()!=0) - exit_player("Can't run decoding ahead!\n"); + throw std::runtime_error("Can't run decoding ahead!"); 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 @@ -1598,17 +1599,16 @@ m_config.parse_cfgfiles(envm); if(m_config.parse_command_line(argv,envm)!=MPXP_Ok) - exit_player("Error parse command line"); // error parsing cmdline + throw std::runtime_error("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); + throw std::runtime_error("Error: detected option: -core.xp=0"); } if(mp_conf.test_av) { int verb=1; if(mpxp_test_antiviral_protection(&verb)==MPXP_Virus) - exit_player("Bad test of antiviral protection"); + throw std::runtime_error("Bad test of antiviral protection"); } MPXPSys.xp_num_cpu=get_number_cpu(); @@ -1632,7 +1632,7 @@ mpxp_context().engine().xp_core->num_a_buffs = vo_conf.xp_buffs; - init_player(envm); + if(init_player(envm)!=MPXP_Ok) return EXIT_SUCCESS; if(filename.empty()){ show_help(); @@ -1686,7 +1686,7 @@ 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); + throw std::runtime_error(MSGTR_Fatal_error); } if(stream_dump_type) mp_conf.s_cache_size=0; @@ -1866,7 +1866,7 @@ if(MPXPSys.vo_inited) MPXPSys.uninit_player(INITED_VO); } - if(!sh_audio && !sh_video) exit_player("Nothing to do"); + if(!sh_audio && !sh_video) throw std::runtime_error("Nothing to do"); if(mp_conf.force_fps && sh_video) { sh_video->fps=mp_conf.force_fps; @@ -1903,7 +1903,7 @@ // TODO: rewrite test backtrace in .asm // mpxp_test_backtrace(); - if(xmp_run_players()!=0) exit_player("Can't run xp players!\n"); + if(xmp_run_players()!=0) throw std::runtime_error("Can't run xp players!"); mpxp_ok<<"Using the next "<<mpxp_context().engine().xp_core->num_threads<<" threads:"<<std::endl; unsigned idx; for(idx=0;idx<mpxp_context().engine().xp_core->num_threads;idx++) Modified: mplayerxp/mplayerxp.h =================================================================== --- mplayerxp/mplayerxp.h 2013-05-26 08:28:07 UTC (rev 646) +++ mplayerxp/mplayerxp.h 2013-05-26 12:22:56 UTC (rev 647) @@ -1,6 +1,6 @@ #ifndef __MPLAYERXP_MAIN #define __MPLAYERXP_MAIN 1 - +#include <stdexcept> #include <string> #include <map> @@ -212,7 +212,7 @@ inline void escape_player(const std::string& why,unsigned num_calls) { show_backtrace(why,num_calls); - exit_player(why); + throw std::runtime_error(why); } inline MPXP_Rc check_pin(const std::string& module,unsigned pin1,unsigned pin2) { Modified: mplayerxp/osdep/cpudetect.cpp =================================================================== --- mplayerxp/osdep/cpudetect.cpp 2013-05-26 08:28:07 UTC (rev 646) +++ mplayerxp/osdep/cpudetect.cpp 2013-05-26 12:22:56 UTC (rev 647) @@ -92,14 +92,13 @@ } do_cpuid(0x00000000, regs); // get _max_ cpuid level and vendor name if (regs[0]>=0x00000001) { - char *tmpstr; + std::string tmpstr; unsigned cl_size; do_cpuid(0x00000001, regs2); tmpstr=GetCpuFriendlyName(regs, regs2); mpxp_v<<"CPU: "<<tmpstr<<std::endl; - delete tmpstr; caps->cpuType=(regs2[0] >> 8)&0xf; if(caps->cpuType==0xf){ @@ -163,16 +162,14 @@ #define CPUID_MODEL ((regs2[0] >> 4)&0x0F) /* 07..04 */ #define CPUID_STEPPING ((regs2[0] >> 0)&0x0F) /* 03..00 */ -char *GetCpuFriendlyName(unsigned int regs[], unsigned int regs2[]){ +std::string GetCpuFriendlyName(unsigned int regs[], unsigned int regs2[]){ #include "cputable.h" /* get cpuname and cpuvendors */ char vendor[17]; char *retname; int i; + std::string rc; - if (NULL==(retname=(char*)mp_malloc(256))) { - mpxp_err<<MSGTR_OutOfMemory<<std::endl; - ::exit(1); - } + retname=new char[256]; sprintf(vendor,"%.4s%.4s%.4s",(char*)(regs+1),(char*)(regs+3),(char*)(regs+2)); @@ -194,8 +191,9 @@ } } - //printf("Detected CPU: %s\n", retname); - return retname; + rc=retname; + delete retname; + return rc; } #undef CPUID_EXTFAMILY Modified: mplayerxp/osdep/cpudetect.h =================================================================== --- mplayerxp/osdep/cpudetect.h 2013-05-26 08:28:07 UTC (rev 646) +++ mplayerxp/osdep/cpudetect.h 2013-05-26 12:22:56 UTC (rev 647) @@ -62,7 +62,7 @@ void GetCpuCaps(CpuCaps *caps); /* returned value is mp_malloc()'ed so mp_free() it after use */ - char *GetCpuFriendlyName(unsigned int regs[], unsigned int regs2[]); + std::string GetCpuFriendlyName(unsigned int regs[], unsigned int regs2[]); } // namespace usr #endif /* !CPUDETECT_H */ Modified: mplayerxp/osdep/mp_malloc.cpp =================================================================== --- mplayerxp/osdep/mp_malloc.cpp 2013-05-26 08:28:07 UTC (rev 646) +++ mplayerxp/osdep/mp_malloc.cpp 2013-05-26 12:22:56 UTC (rev 647) @@ -570,13 +570,45 @@ mp_free(ptr); } -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) throw(std::bad_alloc) { + any_t* rc; + rc=SECURE_NAME0(_mp_malloc)(size); + if(!rc) throw std::runtime_error("Memory allocation failed"); + return rc; +} +any_t* operator new(size_t size,const zeromemory_t&) { + any_t* rc; + rc=SECURE_NAME1(_mp_mallocz)(size); + if(!rc) throw std::runtime_error("Memory allocation failed"); + return rc; +} +any_t* operator new(size_t size,const alignedmemory_t&,size_t boundary) { + any_t* rc; + rc=SECURE_NAME2(_mp_memalign)(boundary,size); + if(!rc) throw std::runtime_error("Memory allocation failed"); + return rc; +} 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) throw(std::bad_alloc) { + any_t* rc; + rc=SECURE_NAME0(_mp_malloc)(size); + if(!rc) throw std::runtime_error("Memory allocation failed"); + return rc; +} +any_t* operator new[](size_t size,const zeromemory_t&) { + any_t* rc; + rc=SECURE_NAME1(_mp_mallocz)(size); + if(!rc) throw std::runtime_error("Memory allocation failed"); + return rc; +} +any_t* operator new[](size_t size,const alignedmemory_t&,size_t boundary) { + any_t* rc; + rc=SECURE_NAME2(_mp_memalign)(boundary,size); + if(!rc) throw std::runtime_error("Memory allocation failed"); + return rc; +} 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/postproc/libmenu/menu_console.cpp =================================================================== --- mplayerxp/postproc/libmenu/menu_console.cpp 2013-05-26 08:28:07 UTC (rev 646) +++ mplayerxp/postproc/libmenu/menu_console.cpp 2013-05-26 12:22:56 UTC (rev 647) @@ -1,6 +1,7 @@ #include "mpxp_config.h" #include "osdep/mplib.h" using namespace usr; +#include <stdexcept> #include "mpxp_help.h" @@ -294,6 +295,7 @@ #define close_pipe(pipe) close(pipe[0]); close(pipe[1]) +#if 0 static int run_shell_cmd(menu_t* menu, char* cmd) { #ifndef __MINGW32__ int in[2],out[2],err[2]; @@ -317,15 +319,12 @@ return 0; } if(!mpriv->child) { // Chlid process - int err_fd = dup(2); - FILE* errf = fdopen(err_fd,"w"); // Bind the std fd to our pipes dup2(in[0],0); dup2(out[1],1); dup2(err[1],2); execl("/bin/sh","sh","-c",cmd,(any_t*)NULL); - fprintf(errf,"exec failed : %s\n",strerror(errno)); - exit(1); + throw std::runtime_error(std::string("exec failed : ")+strerror(errno)); } // MPlayer mpriv->child_fd[0] = in[1]; @@ -336,6 +335,7 @@ #endif return 1; } +#endif static void enter_cmd(menu_t* menu) { history_t* h; Modified: mplayerxp/postproc/postprocess.cpp =================================================================== --- mplayerxp/postproc/postprocess.cpp 2013-05-26 08:28:07 UTC (rev 646) +++ mplayerxp/postproc/postprocess.cpp 2013-05-26 12:22:56 UTC (rev 647) @@ -12,6 +12,7 @@ #include "postprocess.h" #include "libmpcodecs/codecs_ld.h" #include "osdep/cpudetect.h" +#include "mpxp_help.h" #include "pp_msg.h" pp_context *pp2_get_context(int width, int height, int flags) @@ -29,7 +30,7 @@ { if(strcmp(mp_conf.npp_options,"help")==0) { MSG_INFO(pp_help); - exit_player(""); + exit_player(MSGTR_Exit_quit); } return 1; } Modified: mplayerxp/postproc/vf.cpp =================================================================== --- mplayerxp/postproc/vf.cpp 2013-05-26 08:28:07 UTC (rev 646) +++ mplayerxp/postproc/vf.cpp 2013-05-26 12:22:56 UTC (rev 647) @@ -1,6 +1,8 @@ #include "mpxp_config.h" #include "osdep/mplib.h" using namespace usr; +#include <stdexcept> + #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -678,7 +680,7 @@ vf_stream_t* vf_init(libinput_t& libinput,const vf_conf_t* conf) { if(!sws_init()) { MSG_ERR("MPlayerXP requires working copy of libswscaler\n"); - exit_player(MSGTR_Exit_quit); + throw std::runtime_error("libswscaler"); } vf_stream_t* s = new(zeromem) vf_stream_t(libinput); vf_instance_t* first; Modified: mplayerxp/xmpcore/xmp_vdecoder.cpp =================================================================== --- mplayerxp/xmpcore/xmp_vdecoder.cpp 2013-05-26 08:28:07 UTC (rev 646) +++ mplayerxp/xmpcore/xmp_vdecoder.cpp 2013-05-26 12:22:56 UTC (rev 647) @@ -1,6 +1,8 @@ #include "mpxp_config.h" #include "osdep/mplib.h" using namespace usr; +#include <stdexcept> + #include <stdio.h> #include <math.h> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |