Thread: [Mplayerxp-cvslog] SF.net SVN: mplayerxp:[521] mplayerxp (Page 15)
Brought to you by:
olov
From: <nic...@us...> - 2012-12-08 08:35:45
|
Revision: 521 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=521&view=rev Author: nickols_k Date: 2012-12-08 08:35:38 +0000 (Sat, 08 Dec 2012) Log Message: ----------- combine various configurable network_* variables into structure Modified Paths: -------------- mplayerxp/cfg-mplayerxp.h mplayerxp/libmpstream/cookies.cpp mplayerxp/libmpstream/network.cpp mplayerxp/libmpstream/network.h mplayerxp/libmpstream/s_rtsp.cpp mplayerxp/libmpstream/s_udp.cpp mplayerxp/libmpstream/stream.h Modified: mplayerxp/cfg-mplayerxp.h =================================================================== --- mplayerxp/cfg-mplayerxp.h 2012-12-08 08:15:09 UTC (rev 520) +++ mplayerxp/cfg-mplayerxp.h 2012-12-08 08:35:38 UTC (rev 521) @@ -11,15 +11,6 @@ //extern char *sdl_adriver; #endif -extern int network_prefer_ipv4; -extern char *network_username; -extern char *network_password; -extern int network_bandwidth; -extern char *network_useragent; -extern int network_ipv4_only_proxy; -extern int network_cookies_enabled; -extern char *cookies_file; - extern af_cfg_t af_cfg; // Configuration for audio filters extern vf_cfg_t vf_cfg; // Configuration for audio filters @@ -42,19 +33,19 @@ #ifdef HAVE_STREAMING static const config_t net_config[]={ - {"ipv4", &network_prefer_ipv4, CONF_TYPE_FLAG, 0, 0, 1, "forces mplayerxp to use IPv4 protocol over network"}, + {"ipv4", &net_conf.prefer_ipv4, CONF_TYPE_FLAG, 0, 0, 1, "forces mplayerxp to use IPv4 protocol over network"}, #ifdef HAVE_AF_INET6 - {"ipv6", &network_prefer_ipv4, CONF_TYPE_FLAG, 0, 1, 0, "forces mplayerxp to use IPv6 protocol over network"}, + {"ipv6", &net_conf.prefer_ipv4, CONF_TYPE_FLAG, 0, 1, 0, "forces mplayerxp to use IPv6 protocol over network"}, #else {"ipv6", "MPlayerXP was compiled without IPv6 support.\n", CONF_TYPE_PRINT, 0, 0, 0, NULL}, #endif /* HAVE_AF_INET6 */ - {"ipv4-only-proxy", &network_ipv4_only_proxy, CONF_TYPE_FLAG, 0, 0, 1, "skip the proxy for IPv6 addresses"}, - {"user", &network_username, CONF_TYPE_STRING, 0, 0, 0, "specifies username for HTTP authentication"}, - {"passwd", &network_password, CONF_TYPE_STRING, 0, 0, 0, "specifies password for HTTP authentication"}, - {"bandwidth", &network_bandwidth, CONF_TYPE_INT, CONF_MIN, 0, 0, "specifies the maximum bandwidth for network streaming"}, - {"user-agent", &network_useragent, CONF_TYPE_STRING, 0, 0, 0, "specifies string as user agent for HTTP streaming"}, - {"cookies", &network_cookies_enabled, CONF_TYPE_FLAG, 0, 0, 1, "send cookies when making HTTP requests"}, - {"cookies-file", &cookies_file, CONF_TYPE_STRING, 0, 0, 0, "Read HTTP cookies from file"}, + {"ipv4-only-proxy", &net_conf.ipv4_only_proxy, CONF_TYPE_FLAG, 0, 0, 1, "skip the proxy for IPv6 addresses"}, + {"user", &net_conf.username, CONF_TYPE_STRING, 0, 0, 0, "specifies username for HTTP authentication"}, + {"passwd", &net_conf.password, CONF_TYPE_STRING, 0, 0, 0, "specifies password for HTTP authentication"}, + {"bandwidth", &net_conf.bandwidth, CONF_TYPE_INT, CONF_MIN, 0, 0, "specifies the maximum bandwidth for network streaming"}, + {"user-agent", &net_conf.useragent, CONF_TYPE_STRING, 0, 0, 0, "specifies string as user agent for HTTP streaming"}, + {"cookies", &net_conf.cookies_enabled, CONF_TYPE_FLAG, 0, 0, 1, "send cookies when making HTTP requests"}, + {"cookies-file", &net_conf.cookies_file, CONF_TYPE_STRING, 0, 0, 0, "Read HTTP cookies from file"}, {NULL, NULL, 0, 0, 0, 0, NULL}, }; #endif Modified: mplayerxp/libmpstream/cookies.cpp =================================================================== --- mplayerxp/libmpstream/cookies.cpp 2012-12-08 08:15:09 UTC (rev 520) +++ mplayerxp/libmpstream/cookies.cpp 2012-12-08 08:35:38 UTC (rev 521) @@ -21,12 +21,11 @@ #include "cookies.h" #include "http.h" +#include "network.h" #include "stream_msg.h" #define MAX_COOKIES 20 -char *cookies_file = NULL; - typedef struct cookie_list_type { char *name; char *value; @@ -184,8 +183,8 @@ char *homedir; - if (cookies_file) - return load_cookies_from(cookies_file, list); + if (net_conf.cookies_file) + return load_cookies_from(net_conf.cookies_file, list); homedir = getenv("HOME"); if (!homedir) Modified: mplayerxp/libmpstream/network.cpp =================================================================== --- mplayerxp/libmpstream/network.cpp 2012-12-08 08:15:09 UTC (rev 520) +++ mplayerxp/libmpstream/network.cpp 2012-12-08 08:35:38 UTC (rev 521) @@ -49,16 +49,20 @@ #include "stream_msg.h" /* Variables for the command line option -user, -passwd & -bandwidth */ -char* network_username=NULL; -char* network_password=NULL; -int network_bandwidth=0; -int network_cookies_enabled = 0; -char* network_useragent=NULL; +net_config_t::net_config_t() + :username(NULL), + password(NULL), + bandwidth(0), + cookies_enabled(0), + cookies_file(NULL), + useragent(NULL), + prefer_ipv4(1), + ipv4_only_proxy(0) +{ +} +net_config_t::~net_config_t() {} +net_config_t net_conf; -/* IPv6 options */ -int network_prefer_ipv4 = 1; -int network_ipv4_only_proxy = 0; - static const struct { const char *mime_type; int demuxer_type; @@ -138,7 +142,7 @@ } #ifdef HAVE_AF_INET6 - if (network_ipv4_only_proxy && (gethostbyname(url->hostname)==NULL)) { + if (net_conf.ipv4_only_proxy && (gethostbyname(url->hostname)==NULL)) { MSG_WARN( "Could not find resolve remote hostname for AF_INET. Trying without proxy.\n"); return url_out; @@ -188,9 +192,9 @@ else snprintf(str, 256, "Host: %s", server_url->hostname ); http_set_field( http_hdr, str); - if (network_useragent) + if (net_conf.useragent) { - snprintf(str, 256, "User-Agent: %s", network_useragent); + snprintf(str, 256, "User-Agent: %s", net_conf.useragent); http_set_field(http_hdr, str); } else @@ -204,7 +208,7 @@ http_set_field(http_hdr, str); } - if (network_cookies_enabled) cookies_set( http_hdr, server_url->hostname, server_url->url ); + if (net_conf.cookies_enabled) cookies_set( http_hdr, server_url->hostname, server_url->url ); http_set_field( http_hdr, "Connection: closed"); http_add_basic_authentication( http_hdr, url->username, url->password ); @@ -298,8 +302,8 @@ } else { MSG_INFO("Authentication required\n"); } - if( network_username ) { - url->username = mp_strdup(network_username); + if( net_conf.username ) { + url->username = mp_strdup(net_conf.username); if( url->username==NULL ) { MSG_FATAL(MSGTR_OutOfMemory); return -1; @@ -308,8 +312,8 @@ MSG_ERR(MSGTR_ConnAuthFailed); return -1; } - if( network_password ) { - url->password = mp_strdup(network_password); + if( net_conf.password ) { + url->password = mp_strdup(net_conf.password); if( url->password==NULL ) { MSG_FATAL(MSGTR_OutOfMemory); return -1; @@ -696,7 +700,7 @@ sprintf(mrl,"rtsp://%s:%i/%s",networking->url->hostname,port,file); rtsp = rtsp_session_start(tcp,&mrl, file, networking->url->hostname, port, &redirected, - network_bandwidth,networking->url->username, + net_conf.bandwidth,networking->url->username, networking->url->password); if ( redirected == 1 ) { @@ -761,7 +765,7 @@ rc = MPXP_False; // Get the bandwidth available - networking->bandwidth = network_bandwidth; + networking->bandwidth = net_conf.bandwidth; // For RTP streams, we usually don't know the stream type until we open it. if( !strcasecmp( networking->url->protocol, "rtp")) { Modified: mplayerxp/libmpstream/network.h =================================================================== --- mplayerxp/libmpstream/network.h 2012-12-08 08:15:09 UTC (rev 520) +++ mplayerxp/libmpstream/network.h 2012-12-08 08:35:38 UTC (rev 521) @@ -30,6 +30,24 @@ struct libinput_t; class Tcp; } + +struct net_config_t { + public: + net_config_t(); + virtual ~net_config_t(); + + char* username; + char* password; + int bandwidth; + int cookies_enabled; + char* cookies_file; + char* useragent; +/* IPv6 options */ + int prefer_ipv4; + int ipv4_only_proxy; +}; +extern net_config_t net_conf; + enum networking_status { networking_stopped_e, networking_playing_e Modified: mplayerxp/libmpstream/s_rtsp.cpp =================================================================== --- mplayerxp/libmpstream/s_rtsp.cpp 2012-12-08 08:15:09 UTC (rev 520) +++ mplayerxp/libmpstream/s_rtsp.cpp 2012-12-08 08:35:38 UTC (rev 521) @@ -137,7 +137,6 @@ return MPXP_Ok; } -extern int network_bandwidth; extern int index_mode; MPXP_Rc Rtsp_Stream_Interface::open(const char *filename,unsigned flags) { @@ -149,7 +148,7 @@ networking = new_networking(); if (!networking) return MPXP_False; - networking->bandwidth = network_bandwidth; + networking->bandwidth = net_conf.bandwidth; url = url_new (filename); networking->url = check4proxies (url); Modified: mplayerxp/libmpstream/s_udp.cpp =================================================================== --- mplayerxp/libmpstream/s_udp.cpp 2012-12-08 08:15:09 UTC (rev 520) +++ mplayerxp/libmpstream/s_udp.cpp 2012-12-08 08:35:38 UTC (rev 521) @@ -91,7 +91,6 @@ return MPXP_Ok; } -extern int network_bandwidth; MPXP_Rc Udp_Stream_Interface::open(const char *filename,unsigned flags) { URL_t *url; @@ -100,7 +99,7 @@ networking = new_networking(); if (!networking) return MPXP_False; - networking->bandwidth = network_bandwidth; + networking->bandwidth = net_conf.bandwidth; url = url_new (filename); networking->url = check4proxies (url); if (url->port == 0) { Modified: mplayerxp/libmpstream/stream.h =================================================================== --- mplayerxp/libmpstream/stream.h 2012-12-08 08:15:09 UTC (rev 520) +++ mplayerxp/libmpstream/stream.h 2012-12-08 08:35:38 UTC (rev 521) @@ -13,6 +13,7 @@ #include "network.h" #endif +struct networking_t; namespace mpxp { struct libinput_t; enum { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2012-12-08 13:41:05
|
Revision: 525 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=525&view=rev Author: nickols_k Date: 2012-12-08 13:40:58 +0000 (Sat, 08 Dec 2012) Log Message: ----------- fixes Modified Paths: -------------- mplayerxp/libmpdemux/demux_bmp.cpp mplayerxp/libmpstream/stream.cpp mplayerxp/libmpstream/stream.h mplayerxp/mplayerxp.cpp Modified: mplayerxp/libmpdemux/demux_bmp.cpp =================================================================== --- mplayerxp/libmpdemux/demux_bmp.cpp 2012-12-08 13:27:53 UTC (rev 524) +++ mplayerxp/libmpdemux/demux_bmp.cpp 2012-12-08 13:40:58 UTC (rev 525) @@ -212,7 +212,7 @@ // Check if a file is a BMP file depending on whether starts with 'BM' static MPXP_Rc bmp_probe(Demuxer *demuxer) { - if (stream_read_word(demuxer->stream) == (('B' << 8) | 'M')) + if (demuxer->stream->read_word() == (('B' << 8) | 'M')) return MPXP_Ok; else return MPXP_False; @@ -225,8 +225,8 @@ { bmp_image_t *bmp_image = static_cast<bmp_image_t*>(demuxer->priv); - stream_reset(demuxer->stream); - stream_seek(demuxer->stream, bmp_image->image_offset); + demuxer->stream->reset(); + demuxer->stream->seek( bmp_image->image_offset); demuxer->video->read_packet(demuxer->stream, bmp_image->image_size, 0, bmp_image->image_offset, DP_KEYFRAME); return 1; @@ -240,12 +240,12 @@ bmp_image_t *bmp_image; // go back to the beginning - stream_reset(demuxer->stream); - stream_seek(demuxer->stream, demuxer->stream->start_pos+2); - filesize = stream_read_dword_le(demuxer->stream); - stream_skip(demuxer->stream, 4); - data_offset = stream_read_word_le(demuxer->stream); - stream_skip(demuxer->stream, 2); + demuxer->stream->reset(); + demuxer->stream->seek( demuxer->stream->start_pos()+2); + filesize = demuxer->stream->read_dword_le(); + demuxer->stream->skip( 4); + data_offset = demuxer->stream->read_word_le(); + demuxer->stream->skip( 2); // create a new video stream header sh_video = demuxer->new_sh_video(); @@ -260,19 +260,19 @@ // load the BITMAPINFOHEADER // allocate size and take the palette table into account sh_video->bih = (BITMAPINFOHEADER *)mp_malloc(data_offset - 12); - sh_video->bih->biSize = stream_read_dword_le(demuxer->stream); - sh_video->bih->biWidth = stream_read_dword_le(demuxer->stream); - sh_video->bih->biHeight = stream_read_dword_le(demuxer->stream); - sh_video->bih->biPlanes = stream_read_word_le(demuxer->stream); - sh_video->bih->biBitCount = stream_read_word_le(demuxer->stream); - sh_video->bih->biCompression = stream_read_dword_le(demuxer->stream); - sh_video->bih->biSizeImage = stream_read_dword_le(demuxer->stream); - sh_video->bih->biXPelsPerMeter = stream_read_dword_le(demuxer->stream); - sh_video->bih->biYPelsPerMeter = stream_read_dword_le(demuxer->stream); - sh_video->bih->biClrUsed = stream_read_dword_le(demuxer->stream); - sh_video->bih->biClrImportant = stream_read_dword_le(demuxer->stream); + sh_video->bih->biSize = demuxer->stream->read_dword_le(); + sh_video->bih->biWidth = demuxer->stream->read_dword_le(); + sh_video->bih->biHeight = demuxer->stream->read_dword_le(); + sh_video->bih->biPlanes = demuxer->stream->read_word_le(); + sh_video->bih->biBitCount = demuxer->stream->read_word_le(); + sh_video->bih->biCompression = demuxer->stream->read_dword_le(); + sh_video->bih->biSizeImage = demuxer->stream->read_dword_le(); + sh_video->bih->biXPelsPerMeter = demuxer->stream->read_dword_le(); + sh_video->bih->biYPelsPerMeter = demuxer->stream->read_dword_le(); + sh_video->bih->biClrUsed = demuxer->stream->read_dword_le(); + sh_video->bih->biClrImportant = demuxer->stream->read_dword_le(); // fetch the palette - stream_read(demuxer->stream, (unsigned char *)(sh_video->bih) + 40, + demuxer->stream->read( (unsigned char *)(sh_video->bih) + 40, sh_video->bih->biClrUsed * 4); // load the data Modified: mplayerxp/libmpstream/stream.cpp =================================================================== --- mplayerxp/libmpstream/stream.cpp 2012-12-08 13:27:53 UTC (rev 524) +++ mplayerxp/libmpstream/stream.cpp 2012-12-08 13:40:58 UTC (rev 525) @@ -225,7 +225,7 @@ return y; } -void print_stream_drivers( void ) +void Stream::print_drivers() { unsigned i; MSG_INFO("Available stream drivers:\n"); Modified: mplayerxp/libmpstream/stream.h =================================================================== --- mplayerxp/libmpstream/stream.h 2012-12-08 13:27:53 UTC (rev 524) +++ mplayerxp/libmpstream/stream.h 2012-12-08 13:40:58 UTC (rev 525) @@ -55,6 +55,8 @@ Stream(type_e type=Stream::Type_Unknown); virtual ~Stream(); + static void print_drivers(); + virtual MPXP_Rc open(libinput_t*libinput,const char* filename,int* file_format); virtual int read(any_t* mem,int total); virtual int read(stream_packet_t * sp); @@ -238,7 +240,5 @@ SCTRL_EOF=10000 }; - - void print_stream_drivers(void); } // namespace mpxp #endif // __STREAM_H Modified: mplayerxp/mplayerxp.cpp =================================================================== --- mplayerxp/mplayerxp.cpp 2012-12-08 13:27:53 UTC (rev 524) +++ mplayerxp/mplayerxp.cpp 2012-12-08 13:40:58 UTC (rev 525) @@ -634,7 +634,7 @@ void show_help(void) { // no file/vcd/dvd -> show HELP: MSG_INFO("%s",help_text); - print_stream_drivers(); + Stream::print_drivers(); MSG_INFO("\nExample: mplayerxp -ao alsa:hw:0 -vo x11 your.avi\n" "Use --long-help option for full help\n"); } @@ -643,7 +643,7 @@ MPXPSystem& MPXPSys=*mpxp_context().engine().MPXPSys; m_config_show_options(mpxp_context().mconfig); mp_input_print_binds(MPXPSys.libinput()); - print_stream_drivers(); + Stream::print_drivers(); mpxp_context().video().output->print_help(); ao_print_help(); vf_help(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2012-12-09 13:46:33
|
Revision: 527 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=527&view=rev Author: nickols_k Date: 2012-12-09 13:46:25 +0000 (Sun, 09 Dec 2012) Log Message: ----------- remove class Buffered_Stream + cleanups + fixes Modified Paths: -------------- mplayerxp/libmpdemux/demux_avi.cpp mplayerxp/libmpstream/cache2.cpp mplayerxp/libmpstream/cookies.cpp mplayerxp/libmpstream/pnm.cpp mplayerxp/libmpstream/s_dvdnav.cpp mplayerxp/libmpstream/s_file.cpp mplayerxp/libmpstream/stream.cpp mplayerxp/libmpstream/stream.h mplayerxp/libmpstream/url.cpp mplayerxp/libmpsub/vobsub.cpp mplayerxp/mp_msg.cpp mplayerxp/mp_msg.h mplayerxp/mplayerxp.cpp mplayerxp/xmpcore/sig_hand.cpp Modified: mplayerxp/libmpdemux/demux_avi.cpp =================================================================== --- mplayerxp/libmpdemux/demux_avi.cpp 2012-12-08 14:01:01 UTC (rev 526) +++ mplayerxp/libmpdemux/demux_avi.cpp 2012-12-09 13:46:25 UTC (rev 527) @@ -144,7 +144,7 @@ if(id==mmioFOURCC('L','I','S','T')){ unsigned len=demuxer->stream->read_dword_le(); // list size id=demuxer->stream->read_dword_le(); // list type - MSG_DBG2("LIST %.4s len=%u\n",(char *) &id,len); + MSG_DBG2("LIST '%.4s' len=%u\n",(char *) &id,len); if(len >= 4) { len -= 4; list_end=demuxer->stream->tell()+((len+1)&(~1)); @@ -167,7 +167,7 @@ continue; } size2=demuxer->stream->read_dword_le(); - MSG_V("CHUNK %.4s len=%u\n",(char *) &id,size2); + MSG_V("CHUNK '%.4s' len=%u\n",(char *) &id,size2); chunksize=(size2+1)&(~1); infot=-1; switch(id){ Modified: mplayerxp/libmpstream/cache2.cpp =================================================================== --- mplayerxp/libmpstream/cache2.cpp 2012-12-08 14:01:01 UTC (rev 526) +++ mplayerxp/libmpstream/cache2.cpp 2012-12-09 13:46:25 UTC (rev 527) @@ -146,7 +146,7 @@ CACHE2_PACKET_TLOCK(cidx); c->packets[cidx].sp.len=c->sector_size; c->packets[cidx].filepos = c->stream->tell(); - c->stream->read(&c->packets[cidx].sp); + c->stream->read(c->packets[cidx].sp.buf,c->packets[cidx].sp.len); MSG_DBG2("CACHE2: read_packet at %lli (wanted %u got %u type %i)",c->packets[cidx].filepos,c->sector_size,c->packets[cidx].sp.len,c->packets[cidx].sp.type); if(mp_conf.verbose>1) if(c->packets[cidx].sp.len>8) { @@ -499,32 +499,28 @@ /* main interface here! */ -Cached_Stream::Cached_Stream(Stream::type_e t) - :Buffered_Stream(t) +Cached_Stream::Cached_Stream(libinput_t* libinput,int size,int _min,int prefill,Stream::type_e t) + :Stream(t) { -} -Cached_Stream::~Cached_Stream() {} - -int Cached_Stream::enable_cache(libinput_t* libinput,int size,int _min,int prefill){ int ss=sector_size()>1?sector_size():STREAM_BUFFER_SIZE; cache_vars_t* c; if (!(type()&Stream::Type_Seekable)) { // The stream has no 'fd' behind it, so is non-cacheable MSG_WARN("\rThis stream is non-cacheable\n"); - return 1; + return; } if(size<32*1024) size=32*1024; // 32kb min c=c2_cache_init(size,ss); cache_data=c; - if(!c) return 0; + if(!c) return; c->stream=this; c->prefill=size*prefill; c->read_filepos=start_pos(); unsigned rc; - if((rc=xmp_register_thread(NULL,sig_cache2,cache2_routine,"cache2"))==UINT_MAX) return 0; + if((rc=xmp_register_thread(NULL,sig_cache2,cache2_routine,"cache2"))==UINT_MAX) return; c->pth=mpxp_context().engine().xp_core->mpxp_threads[rc]; // wait until cache is filled at least prefill_init % MSG_V("CACHE_PRE_INIT: %lld [%lld] %lld pre:%d eof:%d SS=%u \n", @@ -541,14 +537,13 @@ END_FILEPOS(c)-c->read_filepos); if(c->eof) break; // file is smaller than prefill size if(mpdemux_check_interrupt(libinput,PREFILL_SLEEP_TIME)) - return 0; + return; } MSG_STATUS("cache info: size=%u min=%u prefill=%u\n",size,_min,prefill); - return 1; // parent exits + return; // parent exits } -void Cached_Stream::disable_cache() -{ +Cached_Stream::~Cached_Stream() { cache_vars_t* c; c=cache_data; if(c) { @@ -562,22 +557,17 @@ } } -int Cached_Stream::read(stream_packet_t* sp) { - if(cache_data) return c2_stream_read(cache_data,sp->buf,sp->len); - else return Buffered_Stream::read(sp); -} - int Cached_Stream::read(any_t* _mem,int total) { char *mem = reinterpret_cast<char*>(_mem); if(cache_data) return c2_stream_read(cache_data,mem,total); - else return Buffered_Stream::read(mem,total); + else return Stream::read(mem,total); } int Cached_Stream::eof() const { if(cache_data) return c2_stream_eof(cache_data); - else return Buffered_Stream::eof(); + else return Stream::eof(); } void Cached_Stream::eof(int _e) @@ -585,85 +575,32 @@ if(!_e) reset(); else { if(cache_data) c2_stream_set_eof(cache_data,_e); - else Buffered_Stream::eof(_e); + else Stream::eof(_e); } } -int Cached_Stream::read_char() -{ - if(cache_data) { - char retval; - c2_stream_read(cache_data,&retval,1); - return eof()?-256:retval; - } - else return Buffered_Stream::read_char(); -} - off_t Cached_Stream::tell() const { if(cache_data) return c2_stream_tell(cache_data); - else return Buffered_Stream::tell(); + else return Stream::tell(); } off_t Cached_Stream::seek(off_t _p) { if(cache_data) return c2_stream_seek(cache_data,_p); - else return Buffered_Stream::seek(_p); + else return Stream::seek(_p); } int Cached_Stream::skip(off_t len) { if(cache_data) return c2_stream_skip(cache_data,len); - else return Buffered_Stream::skip(len); + else return Stream::skip(len); } void Cached_Stream::reset() { if(cache_data) c2_stream_reset(cache_data); - else Buffered_Stream::reset(); + else Stream::reset(); } -unsigned int Cached_Stream::read_word(){ - unsigned short retval; - read((char *)&retval,2); - return me2be_16(retval); -} - -unsigned int Cached_Stream::read_dword(){ - unsigned int retval; - read((char *)&retval,4); - return me2be_32(retval); -} - -uint64_t Cached_Stream::read_qword(){ - uint64_t retval; - read((char *)&retval,8); - return me2be_64(retval); -} - -unsigned int Cached_Stream::read_word_le(){ - unsigned short retval; - read((char *)&retval,2); - return me2le_16(retval); -} - -unsigned int Cached_Stream::read_dword_le(){ - unsigned int retval; - read((char *)&retval,4); - return me2le_32(retval); -} - -uint64_t Cached_Stream::read_qword_le(){ - uint64_t retval; - read((char *)&retval,8); - return me2le_64(retval); -} - -unsigned int Cached_Stream::read_int24(){ - unsigned int y; - y = read_char(); - y=(y<<8)|read_char(); - y=(y<<8)|read_char(); - return y; -} } // namespace mpxp Modified: mplayerxp/libmpstream/cookies.cpp =================================================================== --- mplayerxp/libmpstream/cookies.cpp 2012-12-08 14:01:01 UTC (rev 526) +++ mplayerxp/libmpstream/cookies.cpp 2012-12-09 13:46:25 UTC (rev 527) @@ -160,7 +160,7 @@ char *cols[7]; if (parse_line(&ptr, cols)) { struct cookie_list_type *newc; - newc = new cookie_list_t; + newc = new(zeromem) cookie_list_t; newc->name = col_dup(cols[5]); newc->value = col_dup(cols[6]); newc->path = col_dup(cols[2]); Modified: mplayerxp/libmpstream/pnm.cpp =================================================================== --- mplayerxp/libmpstream/pnm.cpp 2012-12-08 14:01:01 UTC (rev 526) +++ mplayerxp/libmpstream/pnm.cpp 2012-12-09 13:46:25 UTC (rev 527) @@ -755,7 +755,7 @@ // pnm_t *pnm_connect(const char *mrl) { pnm_t *pnm_connect(Tcp& tcp,const char *path) { - pnm_t *p=new pnm_t; + pnm_t *p=new(zeromem) pnm_t; int need_response=0; p->path=mp_strdup(path); Modified: mplayerxp/libmpstream/s_dvdnav.cpp =================================================================== --- mplayerxp/libmpstream/s_dvdnav.cpp 2012-12-08 14:01:01 UTC (rev 526) +++ mplayerxp/libmpstream/s_dvdnav.cpp 2012-12-09 13:46:25 UTC (rev 527) @@ -95,7 +95,7 @@ DvdNav_Stream_Interface::DvdNav_Stream_Interface(libinput_t* libinput) :Stream_Interface(libinput), - hlev(*new dvdnav_highlight_event_t) {} + hlev(*new(zeromem) dvdnav_highlight_event_t) {} DvdNav_Stream_Interface::~DvdNav_Stream_Interface() { dvdnav_close(dvdnav); delete &hlev; Modified: mplayerxp/libmpstream/s_file.cpp =================================================================== --- mplayerxp/libmpstream/s_file.cpp 2012-12-08 14:01:01 UTC (rev 526) +++ mplayerxp/libmpstream/s_file.cpp 2012-12-09 13:46:25 UTC (rev 527) @@ -61,7 +61,6 @@ /* decreasing number of packet from 256 to 10 speedups cache2 from 3.27% to 1.26% with full speed 1.04% for -nocache */ /* Note: Please locate sector_size changinf after all read/write operations of open() function */ - spos = 0; return MPXP_Ok; } @@ -69,31 +68,20 @@ off_t File_Stream_Interface::size() const { return end_pos; } off_t File_Stream_Interface::sector_size() const { return STREAM_BUFFER_SIZE; } -#ifndef TEMP_FAILURE_RETRY -#define TEMP_FAILURE_RETRY(x) (x) -#endif - int File_Stream_Interface::read(stream_packet_t*sp) { /* Should we repeate read() again on these errno: `EAGAIN', `EIO' ??? */ sp->type=0; - sp->len = TEMP_FAILURE_RETRY(::read(fd,sp->buf,sp->len)); + sp->len = ::read(fd,sp->buf,sp->len); if(sp->len>0) spos += sp->len; return sp->len; } -# define TEMP_FAILURE_RETRY64(expression) \ - (__extension__ \ - ({ long long int __result; \ - do __result = (long long int) (expression); \ - while (__result == -1LL && errno == EINTR); \ - __result; })) - off_t File_Stream_Interface::seek(off_t pos) { - spos=TEMP_FAILURE_RETRY64(::lseek(fd,pos,SEEK_SET)); + spos=::lseek(fd,pos,SEEK_SET); return spos; } Modified: mplayerxp/libmpstream/stream.cpp =================================================================== --- mplayerxp/libmpstream/stream.cpp 2012-12-08 14:01:01 UTC (rev 526) +++ mplayerxp/libmpstream/stream.cpp 2012-12-09 13:46:25 UTC (rev 527) @@ -3,6 +3,7 @@ using namespace mpxp; #include <algorithm> +#include <ctype.h> #include <errno.h> #include <stdio.h> #include <stdlib.h> @@ -115,10 +116,8 @@ unsigned Stream::sector_size() const { return driver->sector_size(); } float Stream::stream_pts() const { return driver->stream_pts(); } void Stream::type(Stream::type_e t) { _type=t; } -off_t Stream::pos() const { return _pos; } -void Stream::pos(off_t p) { _pos = p; } int Stream::eof() const { return _eof; } -void Stream::eof(int e) { _eof = e; } +void Stream::eof(int e) { if(!e) reset(); _eof = e; } MPXP_Rc Stream::open(libinput_t*libinput,const char* filename,int* ff) { @@ -155,22 +154,35 @@ return MPXP_False; } MPXP_Rc Stream::ctrl(unsigned cmd,any_t* param) { return driver->ctrl(cmd,param); } -int Stream::read(stream_packet_t * sp) { return driver->read(sp); } +int Stream::read(stream_packet_t* sp) { return driver->read(sp); } int Stream::read(any_t* mem,int total) { + off_t _off; + int rc; stream_packet_t sp; sp.type=0; sp.buf=(char *)mem; sp.len=total; - return read(&sp); + _off=tell(); + rc=read(&sp); + if(rc<=0) eof(1); + /* ------------ print packet ---------- */ + unsigned j,_lim=std::min(sp.len,20); + int printable=1; + MSG_DBG4("%i=[stream.read(%p,%i)] [%016X]",rc,sp.buf,sp.len,_off); + for(j=0;j<_lim;j++) { if(!isprint(sp.buf[j])) { printable=0; break; } } + if(printable) MSG_DBG4("%20s",sp.buf); + else for(j=0;j<_lim;j++) MSG_DBG4("%02X ",(unsigned char)sp.buf[j]); + /* ------------ print packet ---------- */ + return rc; } off_t Stream::seek(off_t off) { return driver->seek(off); } -int Stream::skip(off_t off) { return driver->seek(_pos+off); } +int Stream::skip(off_t off) { return driver->seek(tell()+off)?1:0; } off_t Stream::tell() const { return driver->tell(); } void Stream::close() { driver->close(); } -void Stream::reset(){ +void Stream::reset() { if(_eof){ - _pos=0; + seek(0); _eof=0; } } @@ -234,271 +246,16 @@ } } -Buffered_Stream::Buffered_Stream(Stream::type_e _t) - :Stream(_t), - buf_pos(0),buf_len(0),buffer(NULL) -{ -} +/* ================================================ */ -Buffered_Stream::~Buffered_Stream() { - if(buffer) delete buffer; -} - -//=================== STREAMER ========================= -MPXP_Rc Buffered_Stream::open(libinput_t*libinput,const char* filename,int* ff) -{ - MPXP_Rc rc=Stream::open(libinput,filename,ff); - if(rc==MPXP_Ok) { - delete buffer; - buf_len=sector_size(); - buffer= new unsigned char [buf_len]; - buf_pos=0; - } - return rc; -} - -int Buffered_Stream::read_cbuffer(){ - int len,legacy_eof; - stream_packet_t sp; - if(eof()) { buf_pos=buf_len=0; return 0; } - while(1) { - sp.type=0; - sp.len=sector_size(); - sp.buf=(char *)buffer; - len = Stream::read(&sp); - if(sp.type) { -// if(event_handler) event_handler(this,&sp); - continue; - } - if(ctrl(SCTRL_EOF,NULL)==MPXP_Ok)legacy_eof=1; - else legacy_eof=0; - if(sp.len<=0 || legacy_eof) { - MSG_DBG3("nc_stream_read_cbuffer: Guess EOF\n"); - eof(1); - buf_pos=buf_len=0; - if(errno) { MSG_WARN("nc_stream_read_cbuffer(drv:%s) error: %s\n",driver_info->mrl,strerror(errno)); errno=0; } - return 0; - } - break; - } - buf_pos=0; - buf_len=sp.len; - pos(pos()+sp.len); - MSG_DBG3("nc_stream_read_cbuffer(%s) done[sector_size=%i len=%i]: buf_pos=%u buf_len=%u pos=%llu\n",driver_info->mrl,sector_size(),len,buf_pos,buf_len,pos()); - return buf_len; -} - -off_t Buffered_Stream::seek_long(off_t _p) -{ - off_t newpos=_p; - unsigned _sector_size=sector_size(); - - buf_pos=buf_len=0; -// newpos=pos&(~((long long)sector_size-1)); - newpos=(_p/(long long)_sector_size)*(long long)_sector_size; - - _p-=newpos; - MSG_DBG3("nc_stream_seek_long to %llu\n",newpos); - if(newpos==0 || newpos!=pos()) { - pos(Stream::seek(newpos)); - if(errno) { MSG_WARN("nc_stream_seek(drv:%s) error: %s\n",driver_info->mrl,strerror(errno)); errno=0; } - } - MSG_DBG3("nc_stream_seek_long after: %llu\n",pos()); - - if(pos()<0) eof(1); - else { - eof(0); - read_cbuffer(); - if(_p>=0 && _p<=buf_len){ - buf_pos=_p; - MSG_DBG3("nc_stream_seek_long done: pos=%llu buf_pos=%lu buf_len=%lu\n",pos(),buf_pos,buf_len); - if(buf_pos==buf_len) { - MSG_DBG3("nc_stream_seek_long: Guess EOF\n"); - eof(1); - } - return _p; - } - } - MSG_V("stream_seek: WARNING! Can't seek to 0x%llX !\n",(long long)(_p+newpos)); - return 0; -} - -int Buffered_Stream::read_char() -{ - unsigned char retval; - read(&retval,1); - return eof()?-256:retval; -} - -int Buffered_Stream::read(stream_packet_t* sp) { - return Stream::read(sp); -} - -int Buffered_Stream::read(any_t* _mem,int total){ - int i,x,ilen,_total=total,got_len; - char *mem=reinterpret_cast<char *>(_mem); - MSG_DBG3( "nc_stream_read %u bytes from %llu\n",total,file_pos()+buf_pos); - if(eof()) return 0; - x=buf_len-buf_pos; - if(x>0) { - ilen=std::min(_total,x); - memcpy(mem,&buffer[buf_pos],ilen); - MSG_DBG3("nc_stream_read: copy prefetched %u bytes\n",ilen); - buf_pos+=ilen; - mem+=ilen; _total-=ilen; - } - ilen=_total; - ilen /= sector_size(); - ilen *= sector_size(); - /* - Perform direct reading to avoid an additional memcpy(). - This case happens for un-compressed streams or for movies with large image. - Note: for stream with high compression-ratio stream reading is invisible - from point of CPU usage. - */ - got_len=0; - if(ilen) { - int rlen,stat,tile; - any_t*smem; - smem=buffer; - rlen=ilen; - stat=0; - tile=0; - eof(0); - got_len=0; - while(rlen) { - buffer=(unsigned char *)mem; - buf_len=rlen; - read_cbuffer(); - mem += std::min(rlen,(int)buf_len); - tile=buf_len-rlen; - rlen -= std::min(rlen,(int)buf_len); - got_len += std::min(rlen,(int)buf_len); - if(eof()) break; - stat++; - } - buffer=reinterpret_cast<unsigned char *>(smem); - buf_len=0; - buf_pos=0; - ilen += rlen; - MSG_DBG2("nc_stream_read got %u bytes directly for %u calls\n",got_len,stat); - if(tile && !eof()) { - /* should never happen. Store data back to native cache! */ - MSG_DBG3("nc_stream_read: we have tile %u bytes\n",tile); - buf_pos=0; - memcpy(buffer,&mem[buf_len-tile],std::min(int(STREAM_BUFFER_SIZE),tile)); - buf_len=std::min(int(STREAM_BUFFER_SIZE),tile); - } - } - ilen=_total-ilen; - if(eof()) return got_len; - while(ilen) { - if(buf_pos>=buf_len){ - read_cbuffer(); - if(buf_len<=0) return -1; // EOF - } - x=buf_len-buf_pos; - if(buf_pos>buf_len) MSG_WARN( "stream_read: WARNING! buf_pos(%i)>buf_len(%i)\n",buf_pos,buf_len); - if(x>ilen) x=ilen; - memcpy(mem,&buffer[buf_pos],x); - buf_pos+=x; - mem+=x; ilen-=x; - } - MSG_DBG3( "nc_stream_read got %u bytes ",total); - for(i=0;i<std::min(8,total);i++) MSG_DBG3("%02X ",(int)((unsigned char)mem[i])); - MSG_DBG3("\n"); - return total; -} - -off_t Buffered_Stream::tell() const { - off_t retval; - retval = file_pos()+buf_pos; - return retval; -} - -off_t Buffered_Stream::seek(off_t _p){ - MSG_DBG3( "nc_stream_seek to %llu\n",(long long)_p); - if(type()&Stream::Type_Memory) { - buf_pos=_p; - return _p; - } else if(_p>=file_pos() && _p<file_pos()+buf_len) { - buf_pos=_p-file_pos(); - return _p; - } - return (type()&Stream::Type_Seekable)?seek_long(_p):_p; -} - -int Buffered_Stream::skip(off_t len){ - if(len<0 || (len>2*STREAM_BUFFER_SIZE && type()&Stream::Type_Seekable)) { - /* negative or big skip! */ - return seek(tell()+len); - } - while(len>0){ - int x=buf_len-buf_pos; - if(x==0){ - if(!read_cbuffer()) return 0; // EOF - x=buf_len-buf_pos; - } - if(x>len) x=len; - buf_pos+=x; len-=x; - } - return 1; -} - -unsigned int Buffered_Stream::read_word(){ - unsigned short retval; - read((char *)&retval,2); - return me2be_16(retval); -} - -unsigned int Buffered_Stream::read_dword(){ - unsigned int retval; - read((char *)&retval,4); - return me2be_32(retval); -} - -uint64_t Buffered_Stream::read_qword(){ - uint64_t retval; - read((char *)&retval,8); - return me2be_64(retval); -} - -unsigned int Buffered_Stream::read_word_le(){ - unsigned short retval; - read((char *)&retval,2); - return me2le_16(retval); -} - -unsigned int Buffered_Stream::read_dword_le(){ - unsigned int retval; - read((char *)&retval,4); - return me2le_32(retval); -} - -uint64_t Buffered_Stream::read_qword_le(){ - uint64_t retval; - read((char *)&retval,8); - return me2le_64(retval); -} - -unsigned int Buffered_Stream::read_int24(){ - unsigned int y; - y = read_char(); - y=(y<<8)|read_char(); - y=(y<<8)|read_char(); - return y; -} - Memory_Stream::Memory_Stream(const unsigned char* data,unsigned len) :Stream(Stream::Type_Memory), _len(len) { - pin=STREAM_PIN; -// may be methods of class Memory_Stream : public Stream - buffer=new uint8_t [len]; - reset(); - pos(0); - memcpy(buffer,data,len); + buffer=new uint8_t [len]; + reset(); + _pos=0; + memcpy(buffer,data,len); } Memory_Stream::~Memory_Stream() { delete buffer; } @@ -508,65 +265,15 @@ int Memory_Stream::read(any_t* mem,int total) { memcpy(mem,buffer,total); - pos(pos()+total); + _pos+=total; return total; } -off_t Memory_Stream::tell() const { return pos(); } -off_t Memory_Stream::seek(off_t p) { pos(p); return pos(); } -int Memory_Stream::skip(off_t len) { pos(pos()+len); return 1; } -int Memory_Stream::eof() const { return pos()>=_len; } -void Memory_Stream::eof(int e) { UNUSED(e); } -void Memory_Stream::reset() { pos(0); } +off_t Memory_Stream::tell() const { return _pos; } +off_t Memory_Stream::seek(off_t p) { return _pos=p; } +int Memory_Stream::skip(off_t len) { _pos+=len; return 1; } +int Memory_Stream::eof() const { return _pos>=_len; } +void Memory_Stream::eof(int e) { e?_pos=_len+1:_pos=0; } +void Memory_Stream::reset() { _pos=0; } -int Memory_Stream::read_char(){ - int retval; - read((char *)&retval,1); - return eof()?-256:retval; -} - -unsigned int Memory_Stream::read_word(){ - unsigned short retval; - read((char *)&retval,2); - return me2be_16(retval); -} - -unsigned int Memory_Stream::read_dword(){ - unsigned int retval; - read((char *)&retval,4); - return me2be_32(retval); -} - -uint64_t Memory_Stream::read_qword(){ - uint64_t retval; - read((char *)&retval,8); - return me2be_64(retval); -} - -unsigned int Memory_Stream::read_word_le(){ - unsigned short retval; - read((char *)&retval,2); - return me2le_16(retval); -} - -unsigned int Memory_Stream::read_dword_le(){ - unsigned int retval; - read((char *)&retval,4); - return me2le_32(retval); -} - -uint64_t Memory_Stream::read_qword_le(){ - uint64_t retval; - read((char *)&retval,8); - return me2le_64(retval); -} - -unsigned int Memory_Stream::read_int24(){ - unsigned int y; - y = read_char(); - y=(y<<8)|read_char(); - y=(y<<8)|read_char(); - return y; -} - } //namespace mpxp Modified: mplayerxp/libmpstream/stream.h =================================================================== --- mplayerxp/libmpstream/stream.h 2012-12-08 14:01:01 UTC (rev 526) +++ mplayerxp/libmpstream/stream.h 2012-12-09 13:46:25 UTC (rev 527) @@ -59,7 +59,6 @@ virtual MPXP_Rc open(libinput_t*libinput,const char* filename,int* file_format); virtual int read(any_t* mem,int total); - virtual int read(stream_packet_t * sp); virtual off_t seek(off_t off); virtual int skip(off_t len); virtual off_t tell() const; @@ -69,8 +68,6 @@ virtual void reset(); virtual void type(type_e);/**< assign new propertie for the stream (see STREAMTYPE_ for detail) */ virtual type_e type(); /**< properties of the stream (see STREAMTYPE_ for detail) */ - virtual off_t pos() const; /**< SOF offset from begin of stream */ - virtual void pos(off_t); /**< SOF offset from begin of stream */ virtual int eof() const; /**< indicates EOF */ virtual void eof(int); /**< set EOF */ virtual off_t start_pos() const; /**< real start of stream (without internet's headers) */ @@ -93,10 +90,10 @@ int file_format; /**< detected file format (by http:// protocol for example) */ const stream_interface_info_t* driver_info; private: + int read(stream_packet_t* sp); Stream_Interface* driver; /**< low-level stream driver */ Opaque* priv; /**< private data used by stream driver */ type_e _type; - off_t _pos; /**< SOF offset from begin of stream */ int _eof; /**< indicates EOF */ }; inline Stream::type_e operator~(Stream::type_e a) { return static_cast<Stream::type_e>(~static_cast<unsigned>(a)); } @@ -120,77 +117,27 @@ virtual void eof(int eof); virtual void reset(); - virtual int read_char(); - virtual unsigned read_word(); - virtual unsigned read_dword(); - virtual unsigned read_word_le(); - virtual unsigned read_dword_le(); - virtual uint64_t read_qword(); - virtual uint64_t read_qword_le(); - virtual unsigned read_int24(); - virtual off_t start_pos() const; /**< real start of stream (without internet's headers) */ virtual off_t end_pos() const; /**< real end of stream (media may be not fully filled) */ virtual unsigned sector_size() const; /**< alignment of read operations (1 for file, VCD_SECTOR_SIZE for VCDs) */ private: + off_t _pos; unsigned _len; uint8_t* buffer; }; - struct Buffered_Stream : public Stream { + struct Cached_Stream : public Stream { public: - Buffered_Stream(Stream::type_e type=Stream::Type_Unknown); - virtual ~Buffered_Stream(); - - virtual MPXP_Rc open(libinput_t*libinput,const char* filename,int* file_format); - virtual off_t seek_long(off_t pos); - virtual int read(any_t* mem,int total); - virtual int read(stream_packet_t * sp); - virtual off_t tell() const; - virtual off_t seek(off_t pos); - virtual int skip(off_t len); - - virtual int read_char(); - virtual unsigned read_word(); - virtual unsigned read_dword(); - virtual unsigned read_word_le(); - virtual unsigned read_dword_le(); - virtual uint64_t read_qword(); - virtual uint64_t read_qword_le(); - virtual unsigned read_int24(); - private: - off_t file_pos() const { return pos()-buf_len; } - int read_cbuffer(); - unsigned int buf_pos; /**< position whitin of small cache */ - unsigned int buf_len; /**< length of small cache */ - unsigned char* buffer;/**< buffer of small cache */ - }; - - struct Cached_Stream : public Buffered_Stream { - public: - Cached_Stream(Stream::type_e type=Stream::Type_Unknown); + Cached_Stream(libinput_t* libinput,int size,int _min,int prefill,Stream::type_e type=Stream::Type_Unknown); virtual ~Cached_Stream(); - virtual int enable_cache(libinput_t* libinput,int size,int min,int prefill); - virtual void disable_cache(); - virtual int read(any_t* mem,int total); - virtual int read(stream_packet_t * sp); virtual off_t tell() const; virtual off_t seek(off_t pos); virtual int skip(off_t len); virtual int eof() const; virtual void eof(int eof); virtual void reset(); - - virtual int read_char(); - virtual unsigned read_word(); - virtual unsigned read_dword(); - virtual unsigned read_word_le(); - virtual unsigned read_dword_le(); - virtual uint64_t read_qword(); - virtual uint64_t read_qword_le(); - virtual unsigned read_int24(); private: cache_vars_t* cache_data; /**< large cache */ }; Modified: mplayerxp/libmpstream/url.cpp =================================================================== --- mplayerxp/libmpstream/url.cpp 2012-12-08 14:01:01 UTC (rev 526) +++ mplayerxp/libmpstream/url.cpp 2012-12-09 13:46:25 UTC (rev 527) @@ -66,7 +66,7 @@ } // Create the URL container - Curl = new URL_t; + Curl = new(zeromem) URL_t; if( Curl==NULL ) { MSG_FATAL("MemAllocFailed\n"); goto err_out; Modified: mplayerxp/libmpsub/vobsub.cpp =================================================================== --- mplayerxp/libmpsub/vobsub.cpp 2012-12-08 14:01:01 UTC (rev 526) +++ mplayerxp/libmpsub/vobsub.cpp 2012-12-09 13:46:25 UTC (rev 527) @@ -353,7 +353,7 @@ queue->packets_reserve *= 2; } else { - queue->packets = new packet_t; + queue->packets = new(zeromem) packet_t; if (queue->packets == NULL) { MSG_ERR("mp_malloc failure"); return -1; Modified: mplayerxp/mp_msg.cpp =================================================================== --- mplayerxp/mp_msg.cpp 2012-12-08 14:01:01 UTC (rev 526) +++ mplayerxp/mp_msg.cpp 2012-12-09 13:46:25 UTC (rev 527) @@ -43,7 +43,7 @@ { unsigned i; int _color[8]={0,4,2,6,1,5,3,7}; - priv_t*priv=new priv_t; + priv_t*priv=new(zeromem) priv_t; mpxp_context().msg_priv=priv; memcpy(priv->_color,_color,sizeof(_color)); pthread_mutex_init(&priv->mp_msg_mutex,NULL); Modified: mplayerxp/mp_msg.h =================================================================== --- mplayerxp/mp_msg.h 2012-12-08 14:01:01 UTC (rev 526) +++ mplayerxp/mp_msg.h 2012-12-09 13:46:25 UTC (rev 527) @@ -1,6 +1,5 @@ #ifndef __MP_MSG_H #define __MP_MSG_H 1 - #include "mplayerxp.h" /* TODO: more highlighted levels */ @@ -85,24 +84,26 @@ return mpxp_printf((MSGL_STATUS<<28)|(MSGT_CLASS&0x0FFFFFFF),args,__va_arg_pack ()); } __always_inline int MSG_V(const char* args,...) { - return mpxp_printf((MSGL_V<<28)|(MSGT_CLASS&0x0FFFFFFF),args,__va_arg_pack ()); + return mp_conf.verbose ? + mpxp_printf((MSGL_V<<28)|(MSGT_CLASS&0x0FFFFFFF),args,__va_arg_pack ()): + 0; } -#ifdef MP_DEBUG + __always_inline int MSG_DBG2(const char* args,...) { - return mpxp_printf((MSGL_DBG2<<28)|(MSGT_CLASS&0x0FFFFFFF),args,__va_arg_pack ()); + return mp_conf.verbose>1 ? + mpxp_printf((MSGL_DBG2<<28)|(MSGT_CLASS&0x0FFFFFFF),args,__va_arg_pack ()): + 0; } __always_inline int MSG_DBG3(const char* args,...) { - return mpxp_printf((MSGL_DBG3<<28)|(MSGT_CLASS&0x0FFFFFFF),args,__va_arg_pack ()); + return mp_conf.verbose>2 ? + mpxp_printf((MSGL_DBG3<<28)|(MSGT_CLASS&0x0FFFFFFF),args,__va_arg_pack ()): + 0; } __always_inline int MSG_DBG4(const char* args,...) { - return mpxp_printf((MSGL_DBG4<<28)|(MSGT_CLASS&0x0FFFFFFF),args,__va_arg_pack ()); + return mp_conf.verbose>3 ? + mpxp_printf((MSGL_DBG4<<28)|(MSGT_CLASS&0x0FFFFFFF),args,__va_arg_pack ()): + 0; } - -#else -__always_inline int MSG_DBG2(const char* args,...) { return mpxp_print_dummy(args); } -__always_inline int MSG_DBG3(const char* args,...) { return mpxp_print_dummy(args); } -__always_inline int MSG_DBG4(const char* args,...) { return mpxp_print_dummy(args); } -#endif #else // __va_arg_pack #ifdef __GNUC__ #define mpxp_print(mod,lev, args... ) ((lev<(mp_conf.verbose+MSGL_V))?(mpxp_printf(((lev&0xF)<<28)|(mod&0x0FFFFFFF),## args)):(mpxp_print_dummy(args))) Modified: mplayerxp/mplayerxp.cpp =================================================================== --- mplayerxp/mplayerxp.cpp 2012-12-08 14:01:01 UTC (rev 526) +++ mplayerxp/mplayerxp.cpp 2012-12-09 13:46:25 UTC (rev 527) @@ -336,11 +336,11 @@ } } void MPXPSystem::uninit_player(unsigned int mask){ - Cached_Stream* stream=NULL; + Stream* stream=NULL; sh_audio_t* sh_audio=NULL; sh_video_t* sh_video=NULL; if(_demuxer) { - stream=static_cast<Cached_Stream*>(_demuxer->stream); + 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); } @@ -959,7 +959,7 @@ } int MPXPSystem::handle_playlist(const char *filename) const { - Cached_Stream* stream=static_cast<Cached_Stream*>(_demuxer->stream); + Stream* stream=static_cast<Stream*>(_demuxer->stream); int eof=0; play_tree_t* entry; // Handle playlist @@ -995,7 +995,7 @@ void MPXPSystem::init_dvd_nls() const { /* Add NLS support here */ - Cached_Stream* stream=static_cast<Cached_Stream*>(_demuxer->stream); + Stream* stream=static_cast<Stream*>(_demuxer->stream); char *lang; if(!mp_conf.audio_lang) mp_conf.audio_lang=nls_get_screen_cp(); MP_UNIT("dvd lang->id"); @@ -1022,7 +1022,7 @@ sh_video_t* sh_video=reinterpret_cast<sh_video_t*>(_demuxer->video->sh); int fmt; char *c; - MSG_INFO("[Cached_Stream]:"); + MSG_INFO("[Stream]:"); if(sh_video) { MSG_INFO("Video="); if(sh_video->bih)fmt=sh_video->bih->biCompression; @@ -1073,7 +1073,7 @@ void MPXPSystem::read_subtitles(const char *filename,int forced_subs_only,int stream_dump_type) { sh_video_t* sh_video=reinterpret_cast<sh_video_t*>(_demuxer->video->sh); - Cached_Stream* stream=static_cast<Cached_Stream*>(_demuxer->stream); + Stream* stream=static_cast<Stream*>(_demuxer->stream); if (mp_conf.spudec_ifo) { unsigned int palette[16], width, height; MP_UNIT("spudec_init_vobsub"); @@ -1346,7 +1346,7 @@ #ifdef USE_OSD int MPXPSystem::paint_osd(int* osd_visible,int* in_pause) { - Cached_Stream* stream=static_cast<Cached_Stream*>(_demuxer->stream); + 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; @@ -1416,7 +1416,7 @@ #endif int MPXPSystem::handle_input(seek_args_t* _seek,osd_args_t* osd,input_state_t* state) { - Cached_Stream* stream=static_cast<Cached_Stream*>(_demuxer->stream); + 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; @@ -1603,7 +1603,7 @@ 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(Cached_Stream::Type_Menu); + stream->type(Stream::Type_Menu); state->need_repaint=1; } osd_function=OSD_DVDMENU; @@ -1669,7 +1669,7 @@ mpxp_init_antiviral_protection(1); mpxp_test_backtrace(); int i; - Cached_Stream* stream=NULL; + Stream* stream=NULL; int stream_dump_type=0; input_state_t input_state = { 0, 0, 0 }; char *ao_subdevice; @@ -1686,7 +1686,7 @@ // Yes, it really must be placed in stack or in very secret place PointerProtector<MPXPSecureKeys> ptr_protector; - secure_keys=ptr_protector.protect(new MPXPSecureKeys(10)); + secure_keys=ptr_protector.protect(new(zeromem) MPXPSecureKeys(10)); mpxp_init_structs(); MPXPSystem& MPXPSys=*mpxp_context().engine().MPXPSys; @@ -1802,7 +1802,11 @@ if(stream_dump_type) mp_conf.s_cache_size=0; MP_UNIT("open_stream"); - if(!input_state.after_dvdmenu) stream=new(zeromem) Cached_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... MSG_ERR("Can't open: %s\n",filename); eof = MPXPSys.libmpdemux_was_interrupted(PT_NEXT_ENTRY); @@ -1817,13 +1821,6 @@ MP_UNIT(NULL); - // CACHE2: initial prefill: 20% later: 5% (should be set by -cacheopts) - if(mp_conf.s_cache_size && !stream_dump_type){ - MP_UNIT("enable_cache"); - if(!stream->enable_cache(MPXPSys.libinput(),mp_conf.s_cache_size*1024,mp_conf.s_cache_size*1024/5,mp_conf.s_cache_size*1024/20)) - if((eof = MPXPSys.libmpdemux_was_interrupted(PT_NEXT_ENTRY))) goto goto_next_file; - } - // DUMP STREAMS: if(stream_dump_type==1) dump_stream(stream); Modified: mplayerxp/xmpcore/sig_hand.cpp =================================================================== --- mplayerxp/xmpcore/sig_hand.cpp 2012-12-08 14:01:01 UTC (rev 526) +++ mplayerxp/xmpcore/sig_hand.cpp 2012-12-09 13:46:25 UTC (rev 527) @@ -56,6 +56,7 @@ void init_signal_handling( void ) { +#if 0 /*========= Catch terminate signals: ================*/ /* terminate requests:*/ signal(SIGTERM,my_callback); /* kill*/ @@ -70,6 +71,7 @@ signal(SIGILL,my_callback); /* illegal instruction */ signal(SIGFPE,my_callback); /* floating point exc. */ signal(SIGABRT,my_callback); /* abort() */ +#endif #ifndef NDEBUG /* on many systems default coresize is 0. Enable any coresize here. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2012-12-11 11:31:35
|
Revision: 536 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=536&view=rev Author: nickols_k Date: 2012-12-11 11:31:23 +0000 (Tue, 11 Dec 2012) Log Message: ----------- simplify logic of HTTP_Header: use std::vector<std::string> instead of HTTP_field_t + move variables into private Modified Paths: -------------- mplayerxp/Makefile mplayerxp/libmpstream/asf_streaming.cpp mplayerxp/libmpstream/cddb.cpp mplayerxp/libmpstream/http.cpp mplayerxp/libmpstream/http.h mplayerxp/libmpstream/network.cpp mplayerxp/libmpstream/tcp.cpp Modified: mplayerxp/Makefile =================================================================== --- mplayerxp/Makefile 2012-12-10 17:44:11 UTC (rev 535) +++ mplayerxp/Makefile 2012-12-11 11:31:23 UTC (rev 536) @@ -68,7 +68,7 @@ $(DO_MAKE_ALL) $(CXX) -o $(TARGET_EXE) $(OBJS) $(LDFLAGS) $(LDXXFLAGS) $(LIBS) #-Xlinker --export-dynamic -Xlinker --gc-sections -Xlinker --sort-common -$(SRCS): dep +$(SRCS): .depend install: $(TARGET_EXE) ifeq ($(INSTALL),) @@ -103,7 +103,7 @@ -rm -f mp_config.h mp_config.mak mp_conf_lavc.h version.h -rm -f cpuinfo help_mp.h -dep: version.h +.depend: $(CXX) -MM $(CXXFLAGS) $(SRCS) 1>.depend $(DO_MAKE) Modified: mplayerxp/libmpstream/asf_streaming.cpp =================================================================== --- mplayerxp/libmpstream/asf_streaming.cpp 2012-12-10 17:44:11 UTC (rev 535) +++ mplayerxp/libmpstream/asf_streaming.cpp 2012-12-11 11:31:23 UTC (rev 536) @@ -502,15 +502,15 @@ static int asf_header_check( HTTP_Header& http_hdr ) { ASF_obj_header_t *objh; - if( http_hdr.body==NULL || http_hdr.body_size<sizeof(ASF_obj_header_t) ) return -1; + if( http_hdr.get_body()==NULL || http_hdr.get_body_size()<sizeof(ASF_obj_header_t) ) return -1; - objh = (ASF_obj_header_t*)http_hdr.body; + objh = (ASF_obj_header_t*)http_hdr.get_body(); if( ASF_LOAD_GUID_PREFIX(objh->guid)==0x75B22630 ) return 0; return -1; } static ASF_StreamType_e -asf_http_networking_type(char *content_type, char *features, HTTP_Header& http_hdr ) { +asf_http_networking_type(const char *content_type,const char *features, HTTP_Header& http_hdr ) { if( content_type==NULL ) return ASF_Unknown_e; if( !strcasecmp(content_type, "application/octet-stream") || !strcasecmp(content_type, "application/vnd.ms.wms-hdr.asfv1") || // New in Corona, first request @@ -529,7 +529,7 @@ // so we could used mime type to know the stream type, // but guess what? All of them are not well configured. // So we have to check for an asf header :(, but it works :p - if( http_hdr.body_size>sizeof(ASF_obj_header_t) ) { + if( http_hdr.get_body_size()>sizeof(ASF_obj_header_t) ) { if( asf_header_check( http_hdr )==0 ) { MSG_V("=====> ASF Plain text\n"); return ASF_PlainText_e; @@ -661,20 +661,20 @@ static int asf_http_parse_response(asf_http_networking_t *asf_http_ctrl, HTTP_Header& http_hdr ) { - char *content_type, *pragma; + const char *content_type, *pragma; char features[64] = "\0"; size_t len; if( http_hdr.response_parse()<0 ) { MSG_ERR("Failed to parse HTTP response\n"); return -1; } - switch( http_hdr.status_code ) { + switch( http_hdr.get_status()) { case 200: break; case 401: // Authentication required return ASF_Authenticate_e; default: - MSG_ERR("Server return %d:%s\n", http_hdr.status_code, http_hdr.get_reason_phrase()); + MSG_ERR("Server return %d:%s\n", http_hdr.get_status(), http_hdr.get_reason_phrase()); return -1; } @@ -682,8 +682,8 @@ pragma = http_hdr.get_field("Pragma"); while( pragma!=NULL ) { - char *comma_ptr=NULL; - char *end; + const char *comma_ptr=NULL; + const char *end; // The pragma line can get severals attributes // separeted with a comma ','. do { @@ -750,9 +750,9 @@ if( !tcp.established()) return MPXP_False; http_hdr = asf_http_request( networking ); - MSG_DBG2("Request [%s]\n", http_hdr->buffer ); - for(i=0; i < (int)http_hdr->buffer_size ; ) { - int r = tcp.write((uint8_t*)(http_hdr->buffer+i), http_hdr->buffer_size-i); + MSG_DBG2("Request [%s]\n", http_hdr->get_buffer() ); + for(i=0; i < (int)http_hdr->get_buffer_size() ; ) { + int r = tcp.write((uint8_t*)(http_hdr->get_buffer()+i), http_hdr->get_buffer_size()-i); if(r<0) { MSG_ERR("Socket write error : %s\n",strerror(errno)); return MPXP_False; @@ -771,8 +771,7 @@ http_hdr->response_append(buffer,i); } while( !http_hdr->is_header_entire()); if( mp_conf.verbose>0 ) { - http_hdr->buffer[http_hdr->buffer_size]='\0'; - MSG_DBG2("Response [%s]\n", http_hdr->buffer ); + MSG_DBG2("Response [%s]\n", http_hdr->get_buffer() ); } ret = asf_http_parse_response(asf_http_ctrl, *http_hdr); if( ret<0 ) { @@ -784,8 +783,8 @@ case ASF_Live_e: case ASF_Prerecorded_e: case ASF_PlainText_e: - if( http_hdr->body_size>0 ) { - if( networking_bufferize( networking, http_hdr->body, http_hdr->body_size )<0 ) { + if( http_hdr->get_body_size()>0 ) { + if( networking_bufferize( networking, (unsigned char *)(http_hdr->get_body()), http_hdr->get_body_size())<0 ) { delete http_hdr; return MPXP_False; } @@ -805,8 +804,8 @@ } break; case ASF_Redirector_e: - if( http_hdr->body_size>0 ) { - if( networking_bufferize( networking, http_hdr->body, http_hdr->body_size )<0 ) { + if( http_hdr->get_body_size()>0 ) { + if( networking_bufferize( networking, (unsigned char*)http_hdr->get_body(), http_hdr->get_body_size())<0 ) { delete http_hdr; return MPXP_False; } Modified: mplayerxp/libmpstream/cddb.cpp =================================================================== --- mplayerxp/libmpstream/cddb.cpp 2012-12-10 17:44:11 UTC (rev 535) +++ mplayerxp/libmpstream/cddb.cpp 2012-12-11 11:31:23 UTC (rev 536) @@ -171,7 +171,7 @@ http_hdr->debug_hdr(); - switch(http_hdr->status_code) { + switch(http_hdr->get_status()) { case 200: ret = reply_parser(*http_hdr, cddb_data); break; @@ -271,7 +271,7 @@ if( cddb_data==NULL ) return -1; - ret = sscanf((char*)http_hdr.body, "%d ", &status); + ret = sscanf(http_hdr.get_body(), "%d ", &status); if( ret!=1 ) { MSG_ERR("Parse error\n"); return -1; @@ -279,13 +279,13 @@ switch(status) { case 210: - ret = sscanf((char*)http_hdr.body, "%d %s %08lx", &status, category, &disc_id); + ret = sscanf(http_hdr.get_body(), "%d %s %08lx", &status, category, &disc_id); if( ret!=3 ) { MSG_ERR("Parse error\n"); return -1; } // Check if it's a xmcd database file - ptr = strstr((char*)http_hdr.body, "# xmcd"); + ptr = strstr(const_cast<char*>(http_hdr.get_body()), "# xmcd"); if( ptr==NULL ) { MSG_ERR("Invalid xmcd database file returned\n"); return -1; @@ -302,7 +302,7 @@ } // Ok found the end // do a sanity check - if( http_hdr.body_size<(unsigned long)(ptr2-ptr) ) { + if( http_hdr.get_body_size()<(unsigned long)(ptr2-ptr) ) { MSG_ERR("Unexpected fix me\n"); return -1; } @@ -310,8 +310,7 @@ cddb_data->xmcd_file_size = ptr2-ptr+2; cddb_data->xmcd_file[cddb_data->xmcd_file_size] = '\0'; // Avoid the http_free function to mp_free the xmcd file...save a mempcy... - http_hdr.body = NULL; - http_hdr.body_size = 0; + http_hdr.erase_body(); return cddb_write_cache(cddb_data); default: MSG_ERR("Unhandled code\n"); @@ -330,7 +329,7 @@ char *ptr = NULL; int ret, status; - ret = sscanf((char*)http_hdr.body, "%d ", &status); + ret = sscanf(http_hdr.get_body(), "%d ", &status); if( ret!=1 ) { MSG_ERR("Parse error\n"); return -1; @@ -339,18 +338,18 @@ switch(status) { case 200: // Found exact match - ret = sscanf((char*)http_hdr.body, "%d %s %08lx %s", &status, cddb_data->category.c_str(), &(cddb_data->disc_id), album_title); + ret = sscanf(http_hdr.get_body(), "%d %s %08lx %s", &status, cddb_data->category.c_str(), &(cddb_data->disc_id), album_title); if( ret!=4 ) { MSG_ERR("Parse error\n"); return -1; } - ptr = strstr((char*)http_hdr.body, album_title); + ptr = strstr(const_cast<char*>(http_hdr.get_body()), album_title); if( ptr!=NULL ) { char *ptr2; int len; ptr2 = strstr(ptr, "\n"); if( ptr2==NULL ) { - len = (http_hdr.body_size)-(ptr-(char*)(http_hdr.body)); + len = http_hdr.get_body_size()-(ptr-http_hdr.get_body()); } else { len = ptr2-ptr+1; } @@ -365,7 +364,7 @@ break; case 210: // Found exact matches, list follows - ptr = strstr((char*)http_hdr.body, "\n"); + ptr = strstr(const_cast<char*>(http_hdr.get_body()), "\n"); if( ptr==NULL ) { MSG_ERR("Unable to find end of line\n"); return -1; @@ -378,13 +377,13 @@ MSG_ERR("Parse error\n"); return -1; } - ptr = strstr((char*)http_hdr.body, album_title); + ptr = strstr(const_cast<char*>(http_hdr.get_body()), album_title); if( ptr!=NULL ) { char *ptr2; int len; ptr2 = strstr(ptr, "\n"); if( ptr2==NULL ) { - len = (http_hdr.body_size)-(ptr-(char*)(http_hdr.body)); + len = (http_hdr.get_body_size())-(ptr-http_hdr.get_body()); } else { len = ptr2-ptr+1; } @@ -415,7 +414,7 @@ int ret, status; char *ptr; - ret = sscanf((char*)http_hdr.body, "%d ", &status); + ret = sscanf(http_hdr.get_body(), "%d ", &status); if( ret!=1 ) { MSG_ERR("Parse error\n"); return -1; @@ -423,7 +422,7 @@ switch(status) { case 210: - ptr = strstr((char*)http_hdr.body, "max proto:"); + ptr = strstr(const_cast<char*>(http_hdr.get_body()), "max proto:"); if( ptr==NULL ) { MSG_ERR("Parse error\n"); return -1; @@ -448,7 +447,7 @@ static int cddb_freedb_sites_parse(HTTP_Header& http_hdr, cddb_data_t *cddb_data) { int ret, status; UNUSED(cddb_data); - ret = sscanf((char*)http_hdr.body, "%d ", &status); + ret = sscanf((const char*)http_hdr.get_body(), "%d ", &status); if( ret!=1 ) { MSG_ERR("Parse error\n"); return -1; Modified: mplayerxp/libmpstream/http.cpp =================================================================== --- mplayerxp/libmpstream/http.cpp 2012-12-10 17:44:11 UTC (rev 535) +++ mplayerxp/libmpstream/http.cpp 2012-12-11 11:31:23 UTC (rev 536) @@ -6,6 +6,8 @@ * by Bertrand Baudet <ber...@ya...> * (C) 2001, MPlayer team. */ +#include <algorithm> +#include <ctype.h> #include <limits> #include <stdio.h> @@ -19,20 +21,8 @@ namespace mpxp { HTTP_Header::HTTP_Header() {} HTTP_Header::~HTTP_Header() { - HTTP_field_t *field, *field2free; - if( protocol!=NULL ) delete protocol ; - if( uri!=NULL ) delete uri ; if( reason_phrase!=NULL ) delete reason_phrase ; - if( field_search!=NULL ) delete field_search ; - if( method!=NULL ) delete method ; if( buffer!=NULL ) delete buffer ; - field = first_field; - while( field!=NULL ) { - field2free = field; - if (field->field_name) delete field->field_name; - field = field->next; - delete field2free; - } } int HTTP_Header::response_append(const char *response, int length ) { @@ -75,15 +65,11 @@ return -1; } len = hdr_ptr-buffer; - protocol = new char [len+1]; - if( protocol==NULL ) { - MSG_FATAL("Memory allocation failed\n"); - return -1; - } - strncpy( protocol, buffer, len ); - protocol[len]='\0'; - if( !strncasecmp( protocol, "HTTP", 4) ) { - if( sscanf( protocol+5,"1.%d", &(http_minor_version) )!=1 ) { + protocol.assign(buffer,len); + std::string sstr=protocol.substr(0,4); + std::transform(sstr.begin(), sstr.end(),sstr.begin(), ::toupper); + if(sstr=="HTTP") { + if( sscanf( &protocol.c_str()[5],"1.%d", &(http_minor_version) )!=1 ) { MSG_FATAL("Malformed answer. Unable to get HTTP minor version.\n"); return -1; } @@ -149,7 +135,7 @@ if( pos_hdr_sep+hdr_sep_len<buffer_size ) { // Response has data! - body = (unsigned char*)buffer+pos_hdr_sep+hdr_sep_len; + body = buffer+pos_hdr_sep+hdr_sep_len; body_size = buffer_size-(pos_hdr_sep+hdr_sep_len); } @@ -157,23 +143,19 @@ return 0; } -char* HTTP_Header::build_request() { +const char* HTTP_Header::build_request() { char *ptr; int len; - HTTP_field_t *field; - if( method==NULL ) set_method( "GET"); - if( uri==NULL ) set_uri( "/"); + if( method.empty() ) set_method( "GET"); + if( uri.empty() ) set_uri( "/"); //**** Compute the request length // Add the Method line - len = strlen(method)+strlen(uri)+12; + len = method.length()+uri.length()+12; // Add the fields - field = first_field; - while( field!=NULL ) { - len += strlen(field->field_name)+2; - field = field->next; - } + std::vector<std::string>::size_type sz = fields.size(); + for(unsigned i=0;i<sz;i++) len+= fields[i].length()+2; // Add the CRLF len += 2; // Add the body @@ -195,13 +177,9 @@ //*** Building the request ptr = buffer; // Add the method line - ptr += sprintf( ptr, "%s %s HTTP/1.%d\r\n", method,uri, http_minor_version ); - field = first_field; + ptr += sprintf( ptr, "%s %s HTTP/1.%d\r\n", method.c_str(),uri.c_str(), http_minor_version ); // Add the field - while( field!=NULL ) { - ptr += sprintf( ptr, "%s\r\n", field->field_name ); - field = field->next; - } + for(unsigned i=0;i<sz;i++) ptr += sprintf( ptr, "%s\r\n", fields[i].c_str()); ptr += sprintf( ptr, "\r\n" ); // Add the body if( body!=NULL ) { @@ -211,72 +189,45 @@ return buffer; } -char* HTTP_Header::get_field(const char *field_name ) { - if( field_name==NULL ) return NULL; - field_search_pos = first_field; - field_search = (char*)mp_realloc( field_search, strlen(field_name)+1 ); - if( field_search==NULL ) { - MSG_FATAL("Memory allocation failed\n"); - return NULL; - } - strcpy( field_search, field_name ); +const char* HTTP_Header::get_field(const char *field_name ) { + search_pos=0; + field_search=field_name; return get_next_field(); } -char* HTTP_Header::get_next_field() { - char *ptr; - HTTP_field_t *field; - - field = field_search_pos; - while( field!=NULL ) { - ptr = strstr( field->field_name, ":" ); - if( ptr==NULL ) return NULL; - if( !strncasecmp( field->field_name, field_search, ptr-(field->field_name) ) ) { - ptr++; // Skip the column - while( ptr[0]==' ' ) ptr++; // Skip the spaces if there is some - field_search_pos = field->next; - return ptr; // return the value without the field name +const char* HTTP_Header::get_next_field() { + std::vector<std::string>::size_type sz = fields.size(); + for(unsigned i=search_pos;i<sz;i++) { + size_t pos,epos; + const std::string& str = fields[i]; + pos=0; + epos=str.find(':',pos); + if(epos!=std::string::npos) { + if(str.substr(pos,epos)==field_search) { + epos++; // skip the column + pos=epos; + while(::isspace(str[epos])) epos++; + search_pos=i+1; + return &str[epos]; + } } - field = field->next; } return NULL; } void HTTP_Header::set_field(const char *field_name ) { - HTTP_field_t *new_field; if( field_name==NULL ) return; - - new_field = new(zeromem) HTTP_field_t; - if( new_field==NULL ) { - MSG_FATAL("Memory allocation failed\n"); - return; - } - new_field->next = NULL; - new_field->field_name = new char [strlen(field_name)+1]; - if( new_field->field_name==NULL ) { - MSG_FATAL("Memory allocation failed\n"); - delete new_field; - return; - } - strcpy( new_field->field_name, field_name ); - - if( last_field==NULL ) { - first_field = new_field; - } else { - last_field->next = new_field; - } - last_field = new_field; - field_nb++; + fields.push_back(field_name); } void HTTP_Header::set_method( const char *_method ) { if( _method==NULL ) return; - method=mp_strdup(_method); + method=_method; } void HTTP_Header::set_uri(const char *_uri ) { if(_uri==NULL ) return; - uri=mp_strdup(_uri); + uri=_uri; } int HTTP_Header::add_basic_authentication( const char *username, const char *password ) { @@ -328,9 +279,13 @@ return res; } +void HTTP_Header::erase_body() { + body=NULL; + body_size=0; +} + void HTTP_Header::debug_hdr( ) { - HTTP_field_t *field; - int i = 0; + unsigned i = 0; MSG_V( "--- HTTP DEBUG HEADER --- START ---\n" "protocol: [%s]\n" @@ -340,20 +295,17 @@ "status code: [%d]\n" "reason phrase: [%s]\n" "body size: [%d]\n" - ,protocol + ,protocol.c_str() ,http_minor_version - ,uri - ,method + ,uri.c_str() + ,method.c_str() ,status_code ,reason_phrase ,body_size ); MSG_V("Fields:\n"); - field = first_field; - while( field!=NULL ) { - MSG_V(" %d - %s\n", i++, field->field_name ); - field = field->next; - } + std::vector<std::string>::size_type sz = fields.size(); + for(i=0;i<sz;i++) MSG_V(" %d - %s\n", i, fields[i].c_str()); MSG_V("--- HTTP DEBUG HEADER --- END ---\n"); } Modified: mplayerxp/libmpstream/http.h =================================================================== --- mplayerxp/libmpstream/http.h 2012-12-10 17:44:11 UTC (rev 535) +++ mplayerxp/libmpstream/http.h 2012-12-11 11:31:23 UTC (rev 536) @@ -6,15 +6,12 @@ #ifndef __HTTP_H_INCLUDED #define __HTTP_H_INCLUDED 1 - #include "mp_config.h" +#include <string> +#include <vector> + namespace mpxp { - struct HTTP_field_t { - char *field_name; - HTTP_field_t *next; - }; - class HTTP_Header : public Opaque { public: HTTP_Header(); @@ -23,9 +20,9 @@ virtual int response_append(const char *data, int length ); virtual int response_parse(); virtual int is_header_entire() const; - virtual char* build_request(); - virtual char* get_field(const char *field_name ); - virtual char* get_next_field(); + virtual const char* build_request(); + virtual const char* get_field(const char *field_name ); + virtual const char* get_next_field(); virtual void set_field(const char *field_name ); virtual void set_method(const char *method ); virtual void set_uri(const char *uri ); @@ -34,27 +31,31 @@ virtual void debug_hdr(); virtual void cookies_set(const char *hostname, const char *url); - char* buffer; - size_t buffer_size; - unsigned int status_code; - unsigned char* body; - size_t body_size; const char* get_reason_phrase() const { return reason_phrase; } - const char* get_protocol() const { return protocol; } + const char* get_protocol() const { return protocol.c_str(); } + unsigned get_status() const { return status_code; } + const char* get_body() const { return body; } + size_t get_body_size() const { return body_size; } + virtual void erase_body(); + const char* get_buffer() const { return buffer; } + size_t get_buffer_size() const { return buffer_size; } private: - char* protocol; - char* method; - char* uri; + std::string protocol; + std::string method; + std::string uri; char* reason_phrase; unsigned int http_minor_version; // Field variables - HTTP_field_t* first_field; - HTTP_field_t* last_field; - unsigned int field_nb; - char* field_search; - HTTP_field_t* field_search_pos; + std::vector<std::string> fields; + std::string field_search; + std::vector<std::string>::size_type search_pos; // Body variables + unsigned int status_code; + char* body; + size_t body_size; unsigned int is_parsed; + char* buffer; + size_t buffer_size; }; extern int base64_encode(const any_t*enc, int encLen, char *out, int outMax); Modified: mplayerxp/libmpstream/network.cpp =================================================================== --- mplayerxp/libmpstream/network.cpp 2012-12-10 17:44:11 UTC (rev 535) +++ mplayerxp/libmpstream/network.cpp 2012-12-11 11:31:23 UTC (rev 536) @@ -172,7 +172,7 @@ } MPXP_Rc http_send_request(Tcp& tcp, URL_t *url, off_t pos ) { - HTTP_Header* http_hdr = new(zeromem) HTTP_Header; + HTTP_Header& http_hdr = *new(zeromem) HTTP_Header; URL_t *server_url; char str[256]; int ret; @@ -181,37 +181,37 @@ if( !strcasecmp(url->protocol, "http_proxy") ) { proxy = 1; server_url = url_new( (url->file)+1 ); - http_hdr->set_uri(server_url->url ); + http_hdr.set_uri(server_url->url ); } else { server_url = url; - http_hdr->set_uri( server_url->file ); + http_hdr.set_uri( server_url->file ); } if (server_url->port && server_url->port != 80) snprintf(str, 256, "Host: %s:%d", server_url->hostname, server_url->port ); else snprintf(str, 256, "Host: %s", server_url->hostname ); - http_hdr->set_field(str); + http_hdr.set_field(str); if (net_conf.useragent) { snprintf(str, 256, "User-Agent: %s", net_conf.useragent); - http_hdr->set_field(str); + http_hdr.set_field(str); } else - http_hdr->set_field("User-Agent: MPlayerXP/"VERSION); + http_hdr.set_field("User-Agent: MPlayerXP/"VERSION); - http_hdr->set_field("Icy-MetaData: 1"); + http_hdr.set_field("Icy-MetaData: 1"); if(pos>0) { // Extend http_send_request with possibility to do partial content retrieval snprintf(str, 256, "Range: bytes=%d-", (int)pos); - http_hdr->set_field(str); + http_hdr.set_field(str); } - if (net_conf.cookies_enabled) http_hdr->cookies_set( server_url->hostname, server_url->url ); + if (net_conf.cookies_enabled) http_hdr.cookies_set( server_url->hostname, server_url->url ); - http_hdr->set_field( "Connection: closed"); - http_hdr->add_basic_authentication( url->username, url->password ); - if( http_hdr->build_request( )==NULL ) { + http_hdr.set_field( "Connection: closed"); + http_hdr.add_basic_authentication( url->username, url->password ); + if( http_hdr.build_request( )==NULL ) { goto err_out; } @@ -226,20 +226,20 @@ tcp.close(); tcp.open(server_url->hostname, server_url->port, Tcp::IP4); } - if(!tcp.established()) goto err_out; - MSG_DBG2("Request: [%s]\n", http_hdr->buffer ); + if(!tcp.established()) { MSG_ERR("Cannot establish connection\n"); goto err_out; } + MSG_DBG2("Request: [%s]\n", http_hdr.get_buffer() ); - ret = tcp.write((uint8_t*)(http_hdr->buffer), http_hdr->buffer_size); - if( ret!=(int)http_hdr->buffer_size ) { + ret = tcp.write((uint8_t*)(http_hdr.get_buffer()), http_hdr.get_buffer_size()); + if( ret!=(int)http_hdr.get_buffer_size() ) { MSG_ERR("Error while sending HTTP request: didn't sent all the request\n"); goto err_out; } - delete http_hdr; + delete &http_hdr; return MPXP_Ok; err_out: - delete http_hdr; + delete &http_hdr; if (proxy && server_url) url_free(server_url); return MPXP_False; @@ -272,7 +272,7 @@ int http_authenticate(HTTP_Header& http_hdr, URL_t *url, int *auth_retry) { - char *aut; + const char *aut; if( *auth_retry==1 ) { MSG_ERR(MSGTR_ConnAuthFailed); @@ -291,7 +291,7 @@ aut = http_hdr.get_field("WWW-Authenticate"); if( aut!=NULL ) { - char *aut_space; + const char *aut_space; aut_space = strstr(aut, "realm="); if( aut_space!=NULL ) aut_space += 6; MSG_INFO("Authentication required for %s\n", aut_space); @@ -331,20 +331,20 @@ if( http_hdr==NULL ) return 0; - switch( http_hdr->status_code ) { + switch( http_hdr->get_status() ) { case 200: case 206: // OK MSG_V("Content-Type: [%s]\n", http_hdr->get_field("Content-Type") ); MSG_V("Content-Length: [%s]\n", http_hdr->get_field("Content-Length") ); - if( http_hdr->body_size>0 ) { - if( networking_bufferize( networking, http_hdr->body, http_hdr->body_size )<0 ) { + if( http_hdr->get_body_size()>0 ) { + if( networking_bufferize( networking, (unsigned char *)http_hdr->get_body(), http_hdr->get_body_size() )<0 ) { delete http_hdr; return 0; } } break; default: - MSG_ERR("Server return %d: %s\n", http_hdr->status_code, http_hdr->get_reason_phrase()); + MSG_ERR("Server return %d: %s\n", http_hdr->get_status(), http_hdr->get_reason_phrase()); tcp.close(); } @@ -364,9 +364,9 @@ int redirect; int auth_retry=0; MPXP_Rc seekable=MPXP_False; - char *extension; - char *content_type; - char *next_url; + const char *extension; + const char *content_type; + const char *next_url; URL_t *url = networking->url; @@ -403,16 +403,16 @@ networking->data = (any_t*)http_hdr; // Check if we can make partial content requests and thus seek in http-streams - if( http_hdr->status_code==200 ) { - char *accept_ranges; + if( http_hdr->get_status()==200 ) { + const char *accept_ranges; if( (accept_ranges = http_hdr->get_field("Accept-Ranges")) != NULL ) seekable = strncmp(accept_ranges,"bytes",5)==0?MPXP_Ok:MPXP_False; } - // Check if the response is an ICY status_code reason_phrase + // Check if the response is an ICY get_status() reason_phrase if( !strcasecmp(http_hdr->get_protocol(), "ICY") ) { - switch( http_hdr->status_code ) { + switch( http_hdr->get_status() ) { case 200: { // OK - char *field_data = NULL; + const char *field_data = NULL; // note: I skip icy-notice1 and 2, as they contain html <BR> // and are IMHO useless info ::atmos if( (field_data = http_hdr->get_field("icy-name")) != NULL ) @@ -449,7 +449,7 @@ } // Assume standard http if not ICY - switch( http_hdr->status_code ) { + switch( http_hdr->get_status() ) { case 200: // OK // Look if we can use the Content-Type content_type = http_hdr->get_field("Content-Type" ); @@ -477,7 +477,7 @@ networking->url = url = url_redirect( &url, next_url ); if (!strcasecmp(url->protocol, "mms")) goto err_out; if (strcasecmp(url->protocol, "http")) { - MSG_WARN("Unsupported http %d redirect to %s protocol\n", http_hdr->status_code, url->protocol); + MSG_WARN("Unsupported http %d redirect to %s protocol\n", http_hdr->get_status(), url->protocol); goto err_out; } redirect = 1; @@ -488,7 +488,7 @@ redirect = 1; break; default: - MSG_ERR("Server returned %d: %s\n", http_hdr->status_code, http_hdr->get_reason_phrase()); + MSG_ERR("Server returned %d: %s\n", http_hdr->get_status(), http_hdr->get_reason_phrase()); goto err_out; } } else { @@ -557,7 +557,7 @@ MPXP_Rc nop_networking_start(Tcp& tcp,networking_t* networking ) { HTTP_Header *http_hdr = NULL; - char *next_url=NULL; + const char *next_url=NULL; URL_t *rd_url=NULL; MPXP_Rc ret; @@ -567,12 +567,12 @@ http_hdr = http_read_response(tcp); if( http_hdr==NULL ) return MPXP_False; - switch( http_hdr->status_code ) { + switch( http_hdr->get_status() ) { case 200: // OK MSG_V("Content-Type: [%s]\n", http_hdr->get_field("Content-Type") ); MSG_V("Content-Length: [%s]\n", http_hdr->get_field("Content-Length") ); - if( http_hdr->body_size>0 ) { - if( networking_bufferize( networking, http_hdr->body, http_hdr->body_size )<0 ) { + if( http_hdr->get_body_size()>0 ) { + if( networking_bufferize( networking, (unsigned char *)http_hdr->get_body(), http_hdr->get_body_size() )<0 ) { delete http_hdr; return MPXP_False; } @@ -602,15 +602,15 @@ case 404: //Not found case 500: //Server Error default: - MSG_ERR("Server return %d: %s\n", http_hdr->status_code, http_hdr->get_reason_phrase()); + MSG_ERR("Server return %d: %s\n", http_hdr->get_status(), http_hdr->get_reason_phrase()); tcp.close(); return MPXP_False; break; } } else { http_hdr = (HTTP_Header*)networking->data; - if( http_hdr->body_size>0 ) { - if( networking_bufferize( networking, http_hdr->body, http_hdr->body_size )<0 ) { + if( http_hdr->get_body_size()>0 ) { + if( networking_bufferize( networking, (unsigned char*)http_hdr->get_body(), http_hdr->get_body_size() )<0 ) { delete http_hdr; networking->data = NULL; return MPXP_False; Modified: mplayerxp/libmpstream/tcp.cpp =================================================================== --- mplayerxp/libmpstream/tcp.cpp 2012-12-10 17:44:11 UTC (rev 535) +++ mplayerxp/libmpstream/tcp.cpp 2012-12-11 11:31:23 UTC (rev 536) @@ -72,6 +72,7 @@ struct timeval to; #endif + buf[0]=0; MSG_V("[tcp%s] Trying to resolv host '%s'\n", af2String(af), host.c_str()); _fd = ::socket(af==Tcp::IP4?AF_INET:AF_INET6, SOCK_STREAM, 0); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2012-12-11 13:31:04
|
Revision: 537 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=537&view=rev Author: nickols_k Date: 2012-12-11 13:30:51 +0000 (Tue, 11 Dec 2012) Log Message: ----------- supress warning: deleting any_t* is undefined + declare network support more or less safe Modified Paths: -------------- mplayerxp/configure mplayerxp/libmpdemux/asf.h mplayerxp/libmpstream/asf_mmst_streaming.cpp mplayerxp/libmpstream/asf_streaming.cpp mplayerxp/libmpstream/asf_streaming.h mplayerxp/libmpstream/cddb.cpp mplayerxp/libmpstream/librtsp/rtsp.cpp mplayerxp/libmpstream/librtsp/rtsp.h mplayerxp/libmpstream/librtsp/rtsp_session.cpp mplayerxp/libmpstream/librtsp/rtsp_session.h mplayerxp/libmpstream/network.cpp mplayerxp/libmpstream/network.h mplayerxp/libmpstream/pnm.cpp mplayerxp/libmpstream/pnm.h mplayerxp/libmpstream/s_ftp.cpp mplayerxp/libmpstream/s_network.cpp mplayerxp/libmpstream/s_rtsp.cpp mplayerxp/libmpstream/s_udp.cpp mplayerxp/libmpstream/udp.cpp mplayerxp/libmpstream/udp.h mplayerxp/libmpstream/url.cpp mplayerxp/libmpstream/url.h Modified: mplayerxp/configure =================================================================== --- mplayerxp/configure 2012-12-11 11:31:23 UTC (rev 536) +++ mplayerxp/configure 2012-12-11 13:30:51 UTC (rev 537) @@ -91,7 +91,6 @@ "random_name|generates pseudo random suffix of target", "sdl|build with SDL video and audio output|http://www.libsdl.org", "sdl_image|build with SDL_image for screenshots|http://www.libsdl.org/projects/SDL_image", - "im_sure_that_must_have_streaming| the key to unlock streaming" "libvorbis|build with libvorbis support|http://www.vorbis.com", ) @@ -407,7 +406,6 @@ check_func2 execinfo.h backtrace print_config HAVE_ mp_config.h mp_config.mak backtrace -disabled im_sure_that_must_have_streaming && disable streaming disable inet_pton if enabled streaming ; then disable socklib Modified: mplayerxp/libmpdemux/asf.h =================================================================== --- mplayerxp/libmpdemux/asf.h 2012-12-11 11:31:23 UTC (rev 536) +++ mplayerxp/libmpdemux/asf.h 2012-12-11 13:30:51 UTC (rev 537) @@ -123,25 +123,6 @@ }; #endif -// Definition of the differents type of ASF streaming -typedef enum { - ASF_Unknown_e, - ASF_Live_e, - ASF_Prerecorded_e, - ASF_Redirector_e, - ASF_PlainText_e, - ASF_Authenticate_e -} ASF_StreamType_e; - -typedef struct { - ASF_StreamType_e networking_type; - int request; - int packet_size; - int *audio_streams,n_audio,*video_streams,n_video; - int audio_id, video_id; -} asf_http_networking_t; - - /* * Some macros to swap little endian structures read from an ASF file * into machine endian format Modified: mplayerxp/libmpstream/asf_mmst_streaming.cpp =================================================================== --- mplayerxp/libmpstream/asf_mmst_streaming.cpp 2012-12-11 11:31:23 UTC (rev 536) +++ mplayerxp/libmpstream/asf_mmst_streaming.cpp 2012-12-11 13:30:51 UTC (rev 537) @@ -498,7 +498,7 @@ int asf_header_len; int len, i, packet_length; char* path, *unescpath; - URL_t* url1 = networking->url; + URL* url1 = networking->url; tcp.close(); Modified: mplayerxp/libmpstream/asf_streaming.cpp =================================================================== --- mplayerxp/libmpstream/asf_streaming.cpp 2012-12-11 11:31:23 UTC (rev 536) +++ mplayerxp/libmpstream/asf_streaming.cpp 2012-12-11 13:30:51 UTC (rev 537) @@ -564,8 +564,8 @@ static HTTP_Header* asf_http_request(networking_t *networking) { HTTP_Header* http_hdr = new(zeromem) HTTP_Header; - URL_t *url = NULL; - URL_t *server_url = NULL; + URL *url = NULL; + URL *server_url = NULL; asf_http_networking_t *asf_http_ctrl; char str[250]; char *ptr; @@ -595,7 +595,7 @@ } http_hdr->set_uri(server_url->url ); sprintf( str, "Host: %.220s:%d", server_url->hostname, server_url->port ); - url_free( server_url ); + delete server_url; } else { http_hdr->set_uri(url->file ); sprintf( str, "Host: %.220s:%d", url->hostname, url->port ); @@ -719,7 +719,7 @@ static MPXP_Rc asf_http_networking_start(Tcp& tcp, networking_t *networking) { HTTP_Header *http_hdr=NULL; - URL_t *url = networking->url; + URL *url = networking->url; asf_http_networking_t *asf_http_ctrl; char buffer[BUFFER_SIZE]; int i, ret; @@ -735,7 +735,7 @@ asf_http_ctrl->request = 1; asf_http_ctrl->audio_streams = asf_http_ctrl->video_streams = NULL; asf_http_ctrl->n_audio = asf_http_ctrl->n_video = 0; - networking->data = (any_t*)asf_http_ctrl; + networking->data = asf_http_ctrl; do { done = 1; @@ -842,3 +842,5 @@ return MPXP_Ok; } +asf_http_networking_t::asf_http_networking_t() {} +asf_http_networking_t::~asf_http_networking_t() {} \ No newline at end of file Modified: mplayerxp/libmpstream/asf_streaming.h =================================================================== --- mplayerxp/libmpstream/asf_streaming.h 2012-12-11 11:31:23 UTC (rev 536) +++ mplayerxp/libmpstream/asf_streaming.h 2012-12-11 13:30:51 UTC (rev 537) @@ -1,10 +1,37 @@ #ifndef __ASF_STEAMING_H_INCLUDED #define __ASF_STEAMING_H_INCLUDED 1 +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; + #include "stream.h" namespace mpxp { class Tcp; } + +// Definition of the differents type of ASF streaming +enum ASF_StreamType_e { + ASF_Unknown_e, + ASF_Live_e, + ASF_Prerecorded_e, + ASF_Redirector_e, + ASF_PlainText_e, + ASF_Authenticate_e +}; + +struct asf_http_networking_t : public Opaque { + public: + asf_http_networking_t(); + virtual ~asf_http_networking_t(); + + ASF_StreamType_e networking_type; + int request; + int packet_size; + int *audio_streams,n_audio,*video_streams,n_video; + int audio_id, video_id; +}; + extern MPXP_Rc asf_networking_start(Tcp& fd, networking_t *networking); extern MPXP_Rc asf_mmst_networking_start(Tcp& fd, networking_t *networking); Modified: mplayerxp/libmpstream/cddb.cpp =================================================================== --- mplayerxp/libmpstream/cddb.cpp 2012-12-11 11:31:23 UTC (rev 536) +++ mplayerxp/libmpstream/cddb.cpp 2012-12-11 13:30:51 UTC (rev 537) @@ -145,7 +145,7 @@ char request[4096]; int ret = 0; Tcp tcp(cddb_data->libinput,-1); - URL_t *url; + URL *url; if( reply_parser==NULL || command==NULL || cddb_data==NULL ) return -1; @@ -183,7 +183,7 @@ } delete http_hdr; - url_free( url ); + delete url; return ret; } Modified: mplayerxp/libmpstream/librtsp/rtsp.cpp =================================================================== --- mplayerxp/libmpstream/librtsp/rtsp.cpp 2012-12-11 11:31:23 UTC (rev 536) +++ mplayerxp/libmpstream/librtsp/rtsp.cpp 2012-12-11 13:30:51 UTC (rev 537) @@ -68,7 +68,7 @@ #define HEADER_SIZE 1024 #define MAX_FIELDS 256 -struct rtsp_s { +struct rtsp_t { Tcp* tcp; Modified: mplayerxp/libmpstream/librtsp/rtsp.h =================================================================== --- mplayerxp/libmpstream/librtsp/rtsp.h 2012-12-11 11:31:23 UTC (rev 536) +++ mplayerxp/libmpstream/librtsp/rtsp.h 2012-12-11 13:30:51 UTC (rev 537) @@ -45,7 +45,7 @@ #define RTSP_METHOD_TEARDOWN "TEARDOWN" #define RTSP_METHOD_SET_PARAMETER "SET_PARAMETER" -typedef struct rtsp_s rtsp_t; +struct rtsp_t; rtsp_t* rtsp_connect (Tcp& tcp, char *mrl, char *path, char *host, int port, char *user_agent); Modified: mplayerxp/libmpstream/librtsp/rtsp_session.cpp =================================================================== --- mplayerxp/libmpstream/librtsp/rtsp_session.cpp 2012-12-11 11:31:23 UTC (rev 536) +++ mplayerxp/libmpstream/librtsp/rtsp_session.cpp 2012-12-11 13:30:51 UTC (rev 537) @@ -59,6 +59,7 @@ #include "realrtsp/xbuffer.h" #include "stream_msg.h" +namespace mpxp { /* #define LOG */ @@ -71,22 +72,16 @@ #define RTSP_SERVER_TYPE_HELIX "Helix" #define RTSP_SERVER_TYPE_UNKNOWN "unknown" -struct rtsp_session_s { - rtsp_t *s; - struct real_rtsp_session_t* real_session; - struct rtp_rtsp_session_t* rtp_session; -}; - -//rtsp_session_t *rtsp_session_start(char *mrl) { -rtsp_session_t *rtsp_session_start(Tcp& tcp, char **mrl, char *path, char *host, +//Rtsp_Session *rtsp_session_start(char *mrl) { +Rtsp_Session *rtsp_session_start(Tcp& tcp, char **mrl, char *path, char *host, int port, int *redir, uint32_t bandwidth, char *user, char *pass) { - rtsp_session_t *rtsp_session = NULL; + Rtsp_Session *rtsp_session = NULL; char *server; char *mrl_line = NULL; rmff_header_t *h; - rtsp_session = new rtsp_session_t; + rtsp_session = new Rtsp_Session; rtsp_session->s = NULL; rtsp_session->real_session = NULL; rtsp_session->rtp_session = NULL; @@ -219,75 +214,63 @@ return rtsp_session; } -int rtsp_session_read (Tcp& tcp,rtsp_session_t *self, char *data, int len) { +int Rtsp_Session::read(Tcp& tcp,char *data, int len) { - if (self->real_session) { - int to_copy=len; - char *dest=data; - char *source = - (char *) (self->real_session->recv + self->real_session->recv_read); - int fill = self->real_session->recv_size - self->real_session->recv_read; + if (real_session) { + int to_copy=len; + char *dest=data; + char *source = + (char *) (real_session->recv + real_session->recv_read); + int fill = real_session->recv_size - real_session->recv_read; - if(self->real_session->rdteof) - return -1; - if (len < 0) return 0; - if (self->real_session->recv_size < 0) return -1; - while (to_copy > fill) { - - memcpy(dest, source, fill); - to_copy -= fill; - dest += fill; - self->real_session->recv_read = 0; - self->real_session->recv_size = - real_get_rdt_chunk (self->s, (char **)&(self->real_session->recv), self->real_session->rdt_rawdata); - if (self->real_session->recv_size < 0) { - self->real_session->rdteof = 1; - self->real_session->recv_size = 0; - } - source = (char *) self->real_session->recv; - fill = self->real_session->recv_size; - - if (self->real_session->recv_size == 0) { + if(real_session->rdteof) return -1; + if(len < 0) return 0; + if(real_session->recv_size < 0) return -1; + while (to_copy > fill) { + memcpy(dest, source, fill); + to_copy -= fill; + dest += fill; + real_session->recv_read = 0; + real_session->recv_size = + real_get_rdt_chunk (s, (char **)&(real_session->recv), real_session->rdt_rawdata); + if (real_session->recv_size < 0) { + real_session->rdteof = 1; + real_session->recv_size = 0; + } + source = (char *) real_session->recv; + fill = real_session->recv_size; + if (real_session->recv_size == 0) { #ifdef LOG - MSG_INFO("librtsp: %d of %d bytes provided\n", len-to_copy, len); + MSG_INFO("librtsp: %d of %d bytes provided\n", len-to_copy, len); #endif - return len-to_copy; - } - } - - memcpy(dest, source, to_copy); - self->real_session->recv_read += to_copy; - + return len-to_copy; + } + } + memcpy(dest, source, to_copy); + real_session->recv_read += to_copy; #ifdef LOG - MSG_INFO("librtsp: %d bytes provided\n", len); + MSG_INFO("librtsp: %d bytes provided\n", len); #endif + return len; + } else if (rtp_session) { + int l = 0; + Tcp _tcp(tcp.get_libinput(),rtp_session->rtp_socket); - return len; - } - else if (self->rtp_session) - { - int l = 0; - Tcp _tcp(tcp.get_libinput(),self->rtp_session->rtp_socket); - - l = read_rtp_from_server (_tcp, data, len); - /* send RTSP and RTCP keepalive */ - rtcp_send_rr (self->s, self->rtp_session); - - if (l == 0) - rtsp_session_end (self); - - return l; - } - - return 0; + l = read_rtp_from_server (_tcp, data, len); + /* send RTSP and RTCP keepalive */ + rtcp_send_rr (s, rtp_session); + if (l == 0) end (); + return l; + } + return 0; } -void rtsp_session_end(rtsp_session_t *session) { - - rtsp_close(session->s); - if (session->real_session) - free_real_rtsp_session (session->real_session); - if (session->rtp_session) - rtp_session_free (session->rtp_session); - delete session; +void Rtsp_Session::end() { + rtsp_close(s); + if (real_session) free_real_rtsp_session (real_session); + if (rtp_session) rtp_session_free (rtp_session); } + +Rtsp_Session::Rtsp_Session() {} +Rtsp_Session::~Rtsp_Session() {} +} // namespace mpxp \ No newline at end of file Modified: mplayerxp/libmpstream/librtsp/rtsp_session.h =================================================================== --- mplayerxp/libmpstream/librtsp/rtsp_session.h 2012-12-11 11:31:23 UTC (rev 536) +++ mplayerxp/libmpstream/librtsp/rtsp_session.h 2012-12-11 13:30:51 UTC (rev 537) @@ -1,3 +1,6 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; /* * This file was ported to MPlayer from xine CVS rtsp_session.h,v 1.4 2003/01/31 14:06:18 */ @@ -31,13 +34,24 @@ #ifndef HAVE_RTSP_SESSION_H #define HAVE_RTSP_SESSION_H -typedef struct rtsp_session_s rtsp_session_t; +struct real_rtsp_session_t; +struct rtp_rtsp_session_t; +struct rtsp_t; +namespace mpxp { + struct Rtsp_Session : public Opaque { + public: + Rtsp_Session(); + virtual ~Rtsp_Session(); -rtsp_session_t *rtsp_session_start(Tcp& tcp, char **mrl, char *path, char *host, - int port, int *redir, uint32_t bandwidth, char *user, char *pass); + virtual int read(Tcp& tcp,char *data, int len); + virtual void end(); -int rtsp_session_read(Tcp& tcp,rtsp_session_t *session, char *data, int len); + rtsp_t* s; + real_rtsp_session_t* real_session; + rtp_rtsp_session_t* rtp_session; + }; -void rtsp_session_end(rtsp_session_t *session); - + Rtsp_Session* rtsp_session_start(Tcp& tcp, char **mrl, char *path, char *host, + int port, int *redir, uint32_t bandwidth, char *user, char *pass); +} // namespace mpxp #endif Modified: mplayerxp/libmpstream/network.cpp =================================================================== --- mplayerxp/libmpstream/network.cpp 2012-12-11 11:31:23 UTC (rev 536) +++ mplayerxp/libmpstream/network.cpp 2012-12-11 13:30:51 UTC (rev 537) @@ -111,15 +111,15 @@ void free_networking( networking_t *networking ) { if( networking==NULL ) return; - if( networking->url ) url_free( networking->url ); + if( networking->url ) delete networking->url; if( networking->buffer ) delete networking->buffer ; if( networking->data ) delete networking->data ; delete networking; } -URL_t* -check4proxies( URL_t *url ) { - URL_t *url_out = NULL; +URL* +check4proxies( URL *url ) { + URL *url_out = NULL; if( url==NULL ) return NULL; url_out = url_new( url->url ); if( !strcasecmp(url->protocol, "http_proxy") ) { @@ -134,8 +134,8 @@ // We got a proxy, build the URL to use it int len; char *new_url; - URL_t *tmp_url; - URL_t *proxy_url = url_new( proxy ); + URL *tmp_url; + URL *proxy_url = url_new( proxy ); if( proxy_url==NULL ) { MSG_WARN("Invalid proxy setting...Trying without proxy.\n"); @@ -162,18 +162,18 @@ if( tmp_url==NULL ) { return url_out; } - url_free( url_out ); + delete url_out; url_out = tmp_url; delete new_url ; - url_free( proxy_url ); + delete proxy_url; } } return url_out; } -MPXP_Rc http_send_request(Tcp& tcp, URL_t *url, off_t pos ) { +MPXP_Rc http_send_request(Tcp& tcp, URL *url, off_t pos ) { HTTP_Header& http_hdr = *new(zeromem) HTTP_Header; - URL_t *server_url; + URL *server_url; char str[256]; int ret; int proxy = 0; // Boolean @@ -219,7 +219,7 @@ if( url->port==0 ) url->port = 8080; // Default port for the proxy server tcp.close(); tcp.open(url->hostname, url->port, Tcp::IP4); - url_free( server_url ); + delete server_url; server_url = NULL; } else { if( server_url->port==0 ) server_url->port = 80; // Default port for the web server @@ -240,8 +240,7 @@ return MPXP_Ok; err_out: delete &http_hdr; - if (proxy && server_url) - url_free(server_url); + if (proxy && server_url) delete server_url; return MPXP_False; } @@ -271,7 +270,7 @@ } int -http_authenticate(HTTP_Header& http_hdr, URL_t *url, int *auth_retry) { +http_authenticate(HTTP_Header& http_hdr, URL *url, int *auth_retry) { const char *aut; if( *auth_retry==1 ) { @@ -368,7 +367,7 @@ const char *content_type; const char *next_url; - URL_t *url = networking->url; + URL *url = networking->url; do { next_url = NULL; @@ -400,7 +399,7 @@ http_hdr = http_read_response(tcp); if( http_hdr==NULL ) goto err_out; if( mp_conf.verbose ) http_hdr->debug_hdr(); - networking->data = (any_t*)http_hdr; + networking->data = http_hdr; // Check if we can make partial content requests and thus seek in http-streams if( http_hdr->get_status()==200 ) { @@ -558,7 +557,7 @@ MPXP_Rc nop_networking_start(Tcp& tcp,networking_t* networking ) { HTTP_Header *http_hdr = NULL; const char *next_url=NULL; - URL_t *rd_url=NULL; + URL *rd_url=NULL; MPXP_Rc ret; if( !tcp.established() ) { @@ -645,22 +644,23 @@ int pnm_networking_read(Tcp& tcp, char *buffer, int size, networking_t *stream_ctrl ) { + Pnm& pnm=*static_cast<Pnm*>(stream_ctrl->data); UNUSED(tcp); - return pnm_read(reinterpret_cast<pnm_t*>(stream_ctrl->data), buffer, size); + return pnm.read(buffer, size); } MPXP_Rc pnm_networking_start(Tcp& tcp,networking_t *networking ) { - pnm_t *pnm; + Pnm* pnm = new(zeromem) Pnm(tcp); tcp.open(networking->url->hostname, networking->url->port ? networking->url->port : 7070); if(!tcp.established()) return MPXP_False; - pnm = pnm_connect(tcp,networking->url->file); - if(!pnm) return MPXP_NA; - + if(pnm->connect(networking->url->file)!=MPXP_Ok) { + delete pnm; + return MPXP_NA; + } networking->data=pnm; - networking->networking_read = pnm_networking_read; networking->prebuffer_size = 8*1024; // 8 KBytes networking->buffering = 1; @@ -670,11 +670,12 @@ int realrtsp_networking_read( Tcp& tcp, char *buffer, int size, networking_t *networking ) { - return rtsp_session_read(tcp,reinterpret_cast<rtsp_session_t*>(networking->data), buffer, size); + Rtsp_Session& rtsp=*static_cast<Rtsp_Session*>(networking->data); + return rtsp.read(tcp, buffer, size); } MPXP_Rc realrtsp_networking_start( Tcp& tcp, networking_t *networking ) { - rtsp_session_t *rtsp; + Rtsp_Session* rtsp; char *mrl; char *file; int port; @@ -701,7 +702,7 @@ networking->url->password); if ( redirected == 1 ) { - url_free(networking->url); + delete networking->url; networking->url = url_new(mrl); tcp.close(); } @@ -751,7 +752,7 @@ } #endif -MPXP_Rc networking_start(Tcp& tcp,networking_t* networking, URL_t *url) { +MPXP_Rc networking_start(Tcp& tcp,networking_t* networking, URL *url) { MPXP_Rc rc; networking->url = check4proxies( url ); Modified: mplayerxp/libmpstream/network.h =================================================================== --- mplayerxp/libmpstream/network.h 2012-12-11 11:31:23 UTC (rev 536) +++ mplayerxp/libmpstream/network.h 2012-12-11 13:30:51 UTC (rev 537) @@ -58,7 +58,7 @@ }; struct networking_t { - URL_t *url; + URL *url; std::string mime; networking_status status; int buffering; // boolean @@ -69,23 +69,23 @@ unsigned int bandwidth; // The downstream available int (*networking_read)( Tcp& fd, char *buffer, int buffer_size, networking_t *stream_ctrl ); int (*networking_seek)( Tcp& fd, off_t pos, networking_t *stream_ctrl ); - any_t*data; + Opaque* data; }; extern void fixup_network_stream_cache(networking_t *s); -extern MPXP_Rc networking_start(Tcp& fd,networking_t *n, URL_t *url); +extern MPXP_Rc networking_start(Tcp& fd,networking_t *n, URL *url); extern int networking_bufferize(networking_t *networking,unsigned char *buffer, int size); extern networking_t *new_networking(); extern void free_networking( networking_t *networking ); -extern URL_t* check4proxies( URL_t *url ); +extern URL* check4proxies( URL* url ); int nop_networking_read(Tcp& fd, char *buffer, int size, networking_t *stream_ctrl ); int nop_networking_seek(Tcp& fd, off_t pos, networking_t *stream_ctrl ); -MPXP_Rc http_send_request(Tcp& tcp,URL_t *url, off_t pos); +MPXP_Rc http_send_request(Tcp& tcp,URL* url, off_t pos); HTTP_Header* http_read_response(Tcp& fd); -int http_authenticate(HTTP_Header& http_hdr, URL_t *url, int *auth_retry); +int http_authenticate(HTTP_Header& http_hdr, URL* url, int *auth_retry); /* * Joey Parrish <jo...@yu...>: Modified: mplayerxp/libmpstream/pnm.cpp =================================================================== --- mplayerxp/libmpstream/pnm.cpp 2012-12-11 11:31:23 UTC (rev 536) +++ mplayerxp/libmpstream/pnm.cpp 2012-12-11 13:30:51 UTC (rev 537) @@ -50,6 +50,7 @@ #include "tcp.h" #include "pnm.h" +namespace mpxp { #define FOURCC_TAG( ch0, ch1, ch2, ch3 ) \ (((long)(unsigned char)(ch3) ) | \ ( (long)(unsigned char)(ch2) << 8 ) | \ @@ -69,28 +70,6 @@ #define LOG */ -#define BUF_SIZE 4096 -#define HEADER_SIZE 4096 - -struct pnm_s { - Tcp* tcp; - char* path; - char buffer[BUF_SIZE]; /* scratch buffer */ - /* receive buffer */ - uint8_t recv[BUF_SIZE]; - int recv_size; - int recv_read; - - uint8_t header[HEADER_SIZE]; - int header_len; - int header_read; - unsigned seq_num[4]; /* two streams with two indices */ - unsigned seq_current[2]; /* seqs of last stream chunk read */ - uint32_t ts_current; /* timestamp of current chunk */ - uint32_t ts_last[2]; /* timestamps of last chunks */ - unsigned packet; /* number of last recieved packet */ -}; - /* * utility macros */ @@ -195,6 +174,9 @@ static void hexdump (char *buf, int length); +Pnm::Pnm(Tcp& _tcp):tcp(_tcp) {} +Pnm::~Pnm() {} + static int rm_write(Tcp& tcp, const char *buf, int len) { int total, timeout; @@ -281,10 +263,9 @@ * and returns number of bytes read */ -static unsigned int pnm_get_chunk(pnm_t *p, - unsigned int max, +unsigned int Pnm::get_chunk(unsigned int max, unsigned int *chunk_type, - char *data, int *need_response) { + char *data, int *need_response) const { unsigned int chunk_size; unsigned int n; @@ -294,11 +275,11 @@ return -1; /* get first PREAMBLE_SIZE bytes and ignore checksum */ - rm_read (*p->tcp, data, CHECKSUM_SIZE); + rm_read (tcp, data, CHECKSUM_SIZE); if (data[0] == 0x72) - rm_read (*p->tcp, data, PREAMBLE_SIZE); + rm_read (tcp, data, PREAMBLE_SIZE); else - rm_read (*p->tcp, data+CHECKSUM_SIZE, PREAMBLE_SIZE-CHECKSUM_SIZE); + rm_read (tcp, data+CHECKSUM_SIZE, PREAMBLE_SIZE-CHECKSUM_SIZE); max -= PREAMBLE_SIZE; @@ -311,7 +292,7 @@ ptr=data+PREAMBLE_SIZE; if (max < 1) return -1; - rm_read (*p->tcp, ptr++, 1); + rm_read (tcp, ptr++, 1); max -= 1; while(1) { @@ -319,19 +300,19 @@ if (max < 2) return -1; - rm_read (*p->tcp, ptr, 2); + rm_read (tcp, ptr, 2); max -= 2; if (*ptr == 'X') /* checking for server message */ { printf("input_pnm: got a message from server:\n"); if (max < 1) return -1; - rm_read (*p->tcp, ptr+2, 1); + rm_read (tcp, ptr+2, 1); max = -1; n=BE_16((uint8_t*)(ptr+1)); if (max < n) return -1; - rm_read (*p->tcp, ptr+3, n); + rm_read (tcp, ptr+3, n); max -= n; ptr[3+n]=0; printf("%s\n",ptr+3); @@ -353,14 +334,14 @@ n=ptr[1]; if (max < n) return -1; - rm_read (*p->tcp, ptr+2, n); + rm_read (tcp, ptr+2, n); max -= n; ptr+=(n+2); } /* the checksum of the next chunk is ignored here */ if (max < 1) return -1; - rm_read (*p->tcp, ptr+2, 1); + rm_read (tcp, ptr+2, 1); ptr+=3; chunk_size=ptr-data; break; @@ -372,12 +353,12 @@ if (chunk_size > max || chunk_size < PREAMBLE_SIZE) { printf("error: max chunk size exeeded (max was 0x%04x)\n", max); #ifdef LOG - n=rm_read (*p->tcp, &data[PREAMBLE_SIZE], 0x100 - PREAMBLE_SIZE); + n=rm_read (tcp, &data[PREAMBLE_SIZE], 0x100 - PREAMBLE_SIZE); hexdump(data,n+PREAMBLE_SIZE); #endif return -1; } - rm_read (*p->tcp, &data[PREAMBLE_SIZE], chunk_size-PREAMBLE_SIZE); + rm_read (tcp, &data[PREAMBLE_SIZE], chunk_size-PREAMBLE_SIZE); break; default: *chunk_type = 0; @@ -392,8 +373,8 @@ * writes a chunk to a buffer, returns number of bytes written */ -static int pnm_write_chunk(uint16_t chunk_id, uint16_t length, - const char *chunk, char *data) { +int Pnm::write_chunk(uint16_t chunk_id, uint16_t length, + const char *chunk, char *data) const { data[0]=(chunk_id>>8)%0xff; data[1]=chunk_id%0xff; @@ -408,93 +389,92 @@ * constructs a request and sends it */ -static void pnm_send_request(pnm_t *p, uint32_t bandwidth) { +void Pnm::send_request(uint32_t bandwidth) { UNUSED(bandwidth); uint16_t i16; int c=PNM_HEADER_SIZE; char fixme[]={0,1}; - memcpy(p->buffer,pnm_header,PNM_HEADER_SIZE); - c+=pnm_write_chunk(PNA_CLIENT_CHALLANGE,strlen(pnm_challenge), - pnm_challenge,&p->buffer[c]); - c+=pnm_write_chunk(PNA_CLIENT_CAPS,PNM_CLIENT_CAPS_SIZE, - reinterpret_cast<const char*>(pnm_client_caps),&p->buffer[c]); - c+=pnm_write_chunk(0x0a,0,NULL,&p->buffer[c]); - c+=pnm_write_chunk(0x0c,0,NULL,&p->buffer[c]); - c+=pnm_write_chunk(0x0d,0,NULL,&p->buffer[c]); - c+=pnm_write_chunk(0x16,2,fixme,&p->buffer[c]); - c+=pnm_write_chunk(PNA_TIMESTAMP,strlen(pnm_timestamp), - pnm_timestamp,&p->buffer[c]); - c+=pnm_write_chunk(PNA_BANDWIDTH,4, - (const char *)&pnm_default_bandwidth,&p->buffer[c]); - c+=pnm_write_chunk(0x08,0,NULL,&p->buffer[c]); - c+=pnm_write_chunk(0x0e,0,NULL,&p->buffer[c]); - c+=pnm_write_chunk(0x0f,0,NULL,&p->buffer[c]); - c+=pnm_write_chunk(0x11,0,NULL,&p->buffer[c]); - c+=pnm_write_chunk(0x10,0,NULL,&p->buffer[c]); - c+=pnm_write_chunk(0x15,0,NULL,&p->buffer[c]); - c+=pnm_write_chunk(0x12,0,NULL,&p->buffer[c]); - c+=pnm_write_chunk(PNA_GUID,strlen(pnm_guid), - pnm_guid,&p->buffer[c]); - c+=pnm_write_chunk(PNA_TWENTYFOUR,PNM_TWENTYFOUR_SIZE, - reinterpret_cast<char*>(pnm_twentyfour),&p->buffer[c]); + memcpy(buffer,pnm_header,PNM_HEADER_SIZE); + c+=write_chunk(PNA_CLIENT_CHALLANGE,strlen(pnm_challenge), + pnm_challenge,&buffer[c]); + c+=write_chunk(PNA_CLIENT_CAPS,PNM_CLIENT_CAPS_SIZE, + reinterpret_cast<const char*>(pnm_client_caps),&buffer[c]); + c+=write_chunk(0x0a,0,NULL,&buffer[c]); + c+=write_chunk(0x0c,0,NULL,&buffer[c]); + c+=write_chunk(0x0d,0,NULL,&buffer[c]); + c+=write_chunk(0x16,2,fixme,&buffer[c]); + c+=write_chunk(PNA_TIMESTAMP,strlen(pnm_timestamp), + pnm_timestamp,&buffer[c]); + c+=write_chunk(PNA_BANDWIDTH,4, + (const char *)&pnm_default_bandwidth,&buffer[c]); + c+=write_chunk(0x08,0,NULL,&buffer[c]); + c+=write_chunk(0x0e,0,NULL,&buffer[c]); + c+=write_chunk(0x0f,0,NULL,&buffer[c]); + c+=write_chunk(0x11,0,NULL,&buffer[c]); + c+=write_chunk(0x10,0,NULL,&buffer[c]); + c+=write_chunk(0x15,0,NULL,&buffer[c]); + c+=write_chunk(0x12,0,NULL,&buffer[c]); + c+=write_chunk(PNA_GUID,strlen(pnm_guid), + pnm_guid,&buffer[c]); + c+=write_chunk(PNA_TWENTYFOUR,PNM_TWENTYFOUR_SIZE, + reinterpret_cast<char*>(pnm_twentyfour),&buffer[c]); /* data after chunks */ - memcpy(&p->buffer[c],after_chunks,after_chunks_length); + memcpy(&buffer[c],after_chunks,after_chunks_length); c+=after_chunks_length; /* client id string */ - p->buffer[c]=PNA_CLIENT_STRING; + buffer[c]=PNA_CLIENT_STRING; i16=BE_16D((uint8_t*)((strlen(client_string)-1))); /* dont know why do we have -1 here */ - memcpy(&p->buffer[c+1],&i16,2); - memcpy(&p->buffer[c+3],client_string,strlen(client_string)+1); + memcpy(&buffer[c+1],&i16,2); + memcpy(&buffer[c+3],client_string,strlen(client_string)+1); c=c+3+strlen(client_string)+1; /* file path */ - p->buffer[c]=0; - p->buffer[c+1]=PNA_PATH_REQUEST; - i16=BE_16D((uint8_t*)(strlen(p->path))); - memcpy(&p->buffer[c+2],&i16,2); - memcpy(&p->buffer[c+4],p->path,strlen(p->path)); - c=c+4+strlen(p->path); + buffer[c]=0; + buffer[c+1]=PNA_PATH_REQUEST; + i16=BE_16D((uint8_t*)path.length()); + memcpy(&buffer[c+2],&i16,2); + memcpy(&buffer[c+4],path.c_str(),path.length()); + c=c+4+path.length(); /* some trailing bytes */ - p->buffer[c]='y'; - p->buffer[c+1]='B'; + buffer[c]='y'; + buffer[c+1]='B'; - rm_write(*p->tcp,p->buffer,c+2); + rm_write(tcp,buffer,c+2); } /* * pnm_send_response sends a response of a challenge */ -static void pnm_send_response(pnm_t *p, const char *response) { +void Pnm::send_response(const char *response) { int size=strlen(response); - p->buffer[0]=0x23; - p->buffer[1]=0; - p->buffer[2]=(unsigned char) size; + buffer[0]=0x23; + buffer[1]=0; + buffer[2]=(unsigned char) size; - memcpy(&p->buffer[3], response, size); + memcpy(&buffer[3], response, size); - rm_write (*p->tcp, p->buffer, size+3); + rm_write (tcp, buffer, size+3); } /* * get headers and challenge and fix headers - * write headers to p->header - * write challenge to p->buffer + * write headers to header + * write challenge to buffer * * return 0 on error. != 0 on success */ +int Pnm::get_headers(int *need_response) { -static int pnm_get_headers(pnm_t *p, int *need_response) { - uint32_t chunk_type; - char *ptr=reinterpret_cast<char*>(p->header); + char *ptr=reinterpret_cast<char*>(header); uint8_t *prop_hdr=NULL; int chunk_size,size=0; int nr; @@ -503,12 +483,12 @@ *need_response=0; while(1) { - if (HEADER_SIZE-size<=0) + if (Pnm::HEADER_SIZE-size<=0) { printf("input_pnm: header buffer overflow. exiting\n"); return 0; } - chunk_size=pnm_get_chunk(p,HEADER_SIZE-size,&chunk_type,ptr,&nr); + chunk_size=get_chunk(Pnm::HEADER_SIZE-size,&chunk_type,ptr,&nr); if (chunk_size < 0) return 0; if (chunk_type == 0) break; if (chunk_type == PNA_TAG) @@ -541,19 +521,19 @@ size++; /* read challenge */ - memcpy (p->buffer, ptr, PREAMBLE_SIZE); - rm_read (*p->tcp, &p->buffer[PREAMBLE_SIZE], 64); + memcpy (buffer, ptr, PREAMBLE_SIZE); + rm_read (tcp, &buffer[PREAMBLE_SIZE], 64); /* now write a data header */ memcpy(ptr, pnm_data_header, PNM_DATA_HEADER_SIZE); size+=PNM_DATA_HEADER_SIZE; /* - h=rmff_scan_header(p->header); + h=rmff_scan_header(header); rmff_fix_header(h); - p->header_len=rmff_get_header_size(h); - rmff_dump_header(h, p->header, HEADER_SIZE); + header_len=rmff_get_header_size(h); + rmff_dump_header(h, header, HEADER_SIZE); */ - p->header_len=size; + header_len=size; return 1; } @@ -562,61 +542,61 @@ * determine correct stream number by looking at indices */ -static int pnm_calc_stream(pnm_t *p) { +int Pnm::calc_stream() { char str0=0,str1=0; /* looking at the first index to * find possible stream types */ - if (p->seq_current[0]==p->seq_num[0]) str0=1; - if (p->seq_current[0]==p->seq_num[2]) str1=1; + if (seq_current[0]==seq_num[0]) str0=1; + if (seq_current[0]==seq_num[2]) str1=1; switch (str0+str1) { case 1: /* one is possible, good. */ if (str0) { - p->seq_num[0]++; - p->seq_num[1]=p->seq_current[1]+1; + seq_num[0]++; + seq_num[1]=seq_current[1]+1; return 0; } else { - p->seq_num[2]++; - p->seq_num[3]=p->seq_current[1]+1; + seq_num[2]++; + seq_num[3]=seq_current[1]+1; return 1; } break; case 0: case 2: /* both types or none possible, not so good */ /* try to figure out by second index */ - if ( (p->seq_current[1] == p->seq_num[1]) - &&(p->seq_current[1] != p->seq_num[3])) + if ( (seq_current[1] == seq_num[1]) + &&(seq_current[1] != seq_num[3])) { /* ok, only stream0 matches */ - p->seq_num[0]=p->seq_current[0]+1; - p->seq_num[1]++; + seq_num[0]=seq_current[0]+1; + seq_num[1]++; return 0; } - if ( (p->seq_current[1] == p->seq_num[3]) - &&(p->seq_current[1] != p->seq_num[1])) + if ( (seq_current[1] == seq_num[3]) + &&(seq_current[1] != seq_num[1])) { /* ok, only stream1 matches */ - p->seq_num[2]=p->seq_current[0]+1; - p->seq_num[3]++; + seq_num[2]=seq_current[0]+1; + seq_num[3]++; return 1; } /* wow, both streams match, or not. */ /* now we try to decide by timestamps */ - if (p->ts_current < p->ts_last[1]) + if (ts_current < ts_last[1]) return 0; - if (p->ts_current < p->ts_last[0]) + if (ts_current < ts_last[0]) return 1; /* does not help, we guess type 0 */ #ifdef LOG printf("guessing stream# 0\n"); #endif - p->seq_num[0]=p->seq_current[0]+1; - p->seq_num[1]=p->seq_current[1]+1; + seq_num[0]=seq_current[0]+1; + seq_num[1]=seq_current[1]+1; return 0; break; } @@ -628,7 +608,7 @@ * gets a stream chunk and writes it to a recieve buffer */ -static int pnm_get_stream_chunk(pnm_t *p) { +int Pnm::get_stream_chunk() { int n; char keepalive='!'; @@ -636,9 +616,9 @@ /* send a keepalive */ /* realplayer seems to do that every 43th package */ - if ((p->packet%43) == 42) + if ((packet%43) == 42) { - rm_write(*p->tcp,&keepalive,1); + rm_write(tcp,&keepalive,1); } /* data chunks begin with: 'Z' <o> <o> <i1> 'Z' <i2> @@ -647,13 +627,13 @@ * <i2> is a 8 bit index which counts from 0x10 to somewhere */ - n = rm_read (*p->tcp, p->buffer, 8); + n = rm_read (tcp, buffer, 8); if (n<8) return 0; /* skip 8 bytes if 0x62 is read */ - if (p->buffer[0] == 0x62) + if (buffer[0] == 0x62) { - n = rm_read (*p->tcp, p->buffer, 8); + n = rm_read (tcp, buffer, 8); if (n<8) return 0; #ifdef LOG printf("input_pnm: had to seek 8 bytes on 0x62\n"); @@ -661,16 +641,16 @@ } /* a server message */ - if (p->buffer[0] == 'X') + if (buffer[0] == 'X') { - int size=BE_16((uint8_t*)(&p->buffer[1])); + int size=BE_16((uint8_t*)(&buffer[1])); - rm_read (*p->tcp, &p->buffer[8], size-5); - p->buffer[size+3]=0; - printf("input_pnm: got message from server while reading stream:\n%s\n", &p->buffer[3]); + rm_read (tcp, &buffer[8], size-5); + buffer[size+3]=0; + printf("input_pnm: got message from server while reading stream:\n%s\n", &buffer[3]); return 0; } - if (p->buffer[0] == 'F') + if (buffer[0] == 'F') { printf("input_pnm: server error.\n"); return 0; @@ -681,12 +661,12 @@ * keepalives */ n=0; - while (p->buffer[0] != 0x5a) { + while (buffer[0] != 0x5a) { int i; for (i=1; i<8; i++) { - p->buffer[i-1]=p->buffer[i]; + buffer[i-1]=buffer[i]; } - rm_read (*p->tcp, &p->buffer[7], 1); + rm_read (tcp, &buffer[7], 1); n++; } @@ -695,16 +675,16 @@ #endif /* check for 'Z's */ - if ((p->buffer[0] != 0x5a)||(p->buffer[7] != 0x5a)) + if ((buffer[0] != 0x5a)||(buffer[7] != 0x5a)) { printf("input_pnm: bad boundaries\n"); - hexdump(p->buffer, 8); + hexdump(buffer, 8); return 0; } /* check offsets */ - fof1=BE_16((uint8_t*)(&p->buffer[1])); - fof2=BE_16((uint8_t*)(&p->buffer[3])); + fof1=BE_16((uint8_t*)(&buffer[1])); + fof2=BE_16((uint8_t*)(&buffer[3])); if (fof1 != fof2) { printf("input_pnm: frame offsets are different: 0x%04x 0x%04x\n",fof1,fof2); @@ -712,121 +692,110 @@ } /* get first index */ - p->seq_current[0]=BE_16((uint8_t*)(&p->buffer[5])); + seq_current[0]=BE_16((uint8_t*)(&buffer[5])); /* now read the rest of stream chunk */ - n = rm_read (*p->tcp, &p->recv[5], fof1-5); + n = rm_read (tcp, &recv[5], fof1-5); if (n<(fof1-5)) return 0; /* get second index */ - p->seq_current[1]=p->recv[5]; + seq_current[1]=recv[5]; /* get timestamp */ - p->ts_current=BE_32(&p->recv[6]); + ts_current=BE_32(&recv[6]); /* get stream number */ - stream=pnm_calc_stream(p); + stream=calc_stream(); /* saving timestamp */ - p->ts_last[stream]=p->ts_current; + ts_last[stream]=ts_current; /* constructing a data packet header */ - p->recv[0]=0; /* object version */ - p->recv[1]=0; + recv[0]=0; /* object version */ + recv[1]=0; fof2=BE_16((uint8_t*)(&fof2)); - memcpy(&p->recv[2], &fof2, 2); - /*p->recv[2]=(fof2>>8)%0xff;*/ /* length */ - /*p->recv[3]=(fof2)%0xff;*/ + memcpy(&recv[2], &fof2, 2); + /*recv[2]=(fof2>>8)%0xff;*/ /* length */ + /*recv[3]=(fof2)%0xff;*/ - p->recv[4]=0; /* stream number */ - p->recv[5]=stream; + recv[4]=0; /* stream number */ + recv[5]=stream; - p->recv[10]=p->recv[10] & 0xfe; /* streambox seems to do that... */ + recv[10]=recv[10] & 0xfe; /* streambox seems to do that... */ - p->packet++; + packet++; - p->recv_size=fof1; + recv_size=fof1; return fof1; } -// pnm_t *pnm_connect(const char *mrl) { -pnm_t *pnm_connect(Tcp& tcp,const char *path) { +// Pnm *pnm_connect(const char *mrl) { +MPXP_Rc Pnm::connect(const std::string& _path) { - pnm_t *p=new(zeromem) pnm_t; int need_response=0; - p->path=mp_strdup(path); - p->tcp=&tcp; + path=_path; - pnm_send_request(p,pnm_available_bandwidths[10]); - if (!pnm_get_headers(p, &need_response)) { + send_request(pnm_available_bandwidths[10]); + if (!get_headers(&need_response)) { printf ("input_pnm: failed to set up stream\n"); - delete p->path; - delete p; - return NULL; + return MPXP_False; } - if (need_response) pnm_send_response(p, pnm_response); - p->ts_last[0]=0; - p->ts_last[1]=0; + if (need_response) send_response(pnm_response); + ts_last[0]=0; + ts_last[1]=0; /* copy header to recv */ - memcpy(p->recv, p->header, p->header_len); - p->recv_size = p->header_len; - p->recv_read = 0; + memcpy(recv, header, header_len); + recv_size = header_len; + recv_read = 0; - return p; + return MPXP_Ok; } -int pnm_read (pnm_t *self, char *data, int len) { +int Pnm::read (char *data, int len) { - int to_copy=len; - char *dest=data; - char *source=reinterpret_cast<char*>(self->recv) + self->recv_read; - int fill=self->recv_size - self->recv_read; + int to_copy=len; + char *dest=data; + char *source=reinterpret_cast<char*>(recv) + recv_read; + int fill=recv_size - recv_read; - if (len < 0) return 0; - while (to_copy > fill) { + if (len < 0) return 0; + while (to_copy > fill) { - memcpy(dest, source, fill); - to_copy -= fill; - dest += fill; - self->recv_read=0; + memcpy(dest, source, fill); + to_copy -= fill; + dest += fill; + recv_read=0; - if (!pnm_get_stream_chunk (self)) { + if (!get_stream_chunk ()) { #ifdef LOG - printf ("input_pnm: %d of %d bytes provided\n", len-to_copy, len); + printf ("input_pnm: %d of %d bytes provided\n", len-to_copy, len); #endif - return len-to_copy; + return len-to_copy; + } + source = reinterpret_cast<char*>(recv); + fill = recv_size - recv_read; } - source = reinterpret_cast<char*>(self->recv); - fill = self->recv_size - self->recv_read; - } - - memcpy(dest, source, to_copy); - self->recv_read += to_copy; - + memcpy(dest, source, to_copy); + recv_read += to_copy; #ifdef LOG - printf ("input_pnm: %d bytes provided\n", len); + printf ("input_pnm: %d bytes provided\n", len); #endif - - return len; + return len; } -int pnm_peek_header (pnm_t *self, char *data) { +int Pnm::peek_header (char *data) const { - memcpy (data, self->header, self->header_len); - return self->header_len; + memcpy (data, header, header_len); + return header_len; } -void pnm_close(pnm_t *p) { - - if (p->tcp->established()) p->tcp->close(); - delete p->path; - delete p->tcp; - delete p; +void Pnm::close() { + if (tcp.established()) tcp.close(); } - +} // namespace mpxp Modified: mplayerxp/libmpstream/pnm.h =================================================================== --- mplayerxp/libmpstream/pnm.h 2012-12-11 11:31:23 UTC (rev 536) +++ mplayerxp/libmpstream/pnm.h 2012-12-11 13:30:51 UTC (rev 537) @@ -25,22 +25,55 @@ #ifndef HAVE_PNM_H #define HAVE_PNM_H +#include <string> #ifndef __CYGWIN__ #include <inttypes.h> #endif /*#include "xine_internal.h" */ -typedef struct pnm_s pnm_t; namespace mpxp { class Tcp; -} -pnm_t* pnm_connect (Tcp&,const char *url); + class Pnm : public Opaque { + public: + Pnm(Tcp& tcp); + virtual ~Pnm(); -int pnm_read (pnm_t *self, char *data, int len); -void pnm_close (pnm_t *self); + enum sizes { + BUF_SIZE=4096, + HEADER_SIZE=4096 + }; -int pnm_peek_header (pnm_t *self, char *data); + virtual MPXP_Rc connect(const std::string& path); + virtual int read (char *data, int len); + virtual void close (); + virtual int peek_header(char *data) const; + private: + unsigned int get_chunk(unsigned int max, unsigned int *chunk_type,char *data, int *need_response) const; + int write_chunk(uint16_t chunk_id, uint16_t length, const char *chunk, char *data) const; + void send_request(uint32_t bandwidth); + void send_response(const char *response); + int get_headers(int *need_response); + int calc_stream(); + int get_stream_chunk(); + Tcp& tcp; + std::string path; + char buffer[Pnm::BUF_SIZE]; /* scratch buffer */ + /* receive buffer */ + uint8_t recv[Pnm::BUF_SIZE]; + int recv_size; + int recv_read; + + uint8_t header[Pnm::HEADER_SIZE]; + int header_len; + int header_read; + unsigned seq_num[4]; /* two streams with two indices */ + unsigned seq_current[2]; /* seqs of last stream chunk read */ + uint32_t ts_current; /* timestamp of current chunk */ + uint32_t ts_last[2]; /* timestamps of last chunks */ + unsigned packet; /* number of last recieved packet */ + }; +} // namespace mpxp #endif Modified: mplayerxp/libmpstream/s_ftp.cpp =================================================================== --- mplayerxp/libmpstream/s_ftp.cpp 2012-12-11 11:31:23 UTC (rev 536) +++ mplayerxp/libmpstream/s_ftp.cpp 2012-12-11 13:30:51 UTC (rev 537) @@ -52,7 +52,7 @@ const char* host; int port; const char* filename; - URL_t* url; + URL* url; char* cput,*cget; Tcp tcp; @@ -341,14 +341,14 @@ tcp.open(host,port); if(!tcp.established()) { - url_free(url); + delete url; return MPXP_False; } // We got a connection, let's start serious things buf = new char [BUFSIZE]; if (readresp(NULL) == 0) { close(); - url_free(url); + delete url; return MPXP_False; } // Login @@ -361,13 +361,13 @@ if(resp != 2) { MSG_ERR("[ftp] command '%s' failed: %s\n",str,rsp_txt); close(); - url_free(url); + delete url; return MPXP_False; } } else if(resp != 2) { MSG_ERR("[ftp] command '%s' failed: %s\n",str,rsp_txt); close(); - url_free(url); + delete url; return MPXP_False; } @@ -376,7 +376,7 @@ if(resp != 2) { MSG_ERR("[ftp] command 'TYPE I' failed: %s\n",rsp_txt); close(); - url_free(url); + delete url; return MPXP_False; } @@ -385,7 +385,7 @@ if(resp != 2) { MSG_ERR("[ftp] command 'SYST' failed: %s\n",rsp_txt); close(); - url_free(url); + delete url; return MPXP_False; } MSG_INFO("[ftp] System: %s\n",rsp_txt); @@ -393,7 +393,7 @@ if(resp != 2) { MSG_ERR("[ftp] command 'STAT' failed: %s\n",rsp_txt); close(); - url_free(url); + delete url; return MPXP_False; } @@ -414,7 +414,7 @@ // because the connection would stay open in the main process, // preventing correct abort with many servers. - url_free(url); + delete url; return MPXP_Ok; } Stream::type_e Ftp_Stream_Interface::type() const { return file_len?Stream::Type_Seekable:Stream::Type_Stream; } Modified: mplayerxp/libmpstream/s_network.cpp =================================================================== --- mplayerxp/libmpstream/s_network.cpp 2012-12-11 11:31:23 UTC (rev 536) +++ mplayerxp/libmpstream/s_network.cpp 2012-12-11 13:30:51 UTC (rev 537) @@ -37,7 +37,7 @@ virtual off_t sector_size() const; virtual std::string mime_type() const; private: - URL_t* url; + URL* url; off_t spos; Tcp tcp; networking_t* networking; @@ -47,10 +47,7 @@ :Stream_Interface(libinput), tcp(libinput,-1) {} Network_Stream_Interface::~Network_Stream_Interface() { - if(url) { - url_free(url); - delete url; - } + if(url) delete url; } MPXP_Rc Network_Stream_Interface::open(const std::string& filename,unsigned flags) @@ -61,7 +58,7 @@ networking=new_networking(); if(networking_start(tcp,networking,url)!=MPXP_Ok){ MSG_ERR(MSGTR_UnableOpenURL, filename.c_str()); - url_free(url); + delete url; url=NULL; free_networking(networking); networking=NULL; Modified: mplayerxp/libmpstream/s_rtsp.cpp =================================================================== --- mplayerxp/libmpstream/s_rtsp.cpp 2012-12-11 11:31:23 UTC (rev 536) +++ mplayerxp/libmpstream/s_rtsp.cpp 2012-12-11 13:30:51 UTC (rev 537) @@ -58,7 +58,8 @@ int Rtsp_Stream_Interface::read(stream_packet_t*sp) { - return rtsp_session_read (tcp,reinterpret_cast<rtsp_session_t*>(networking->data), sp->buf, sp->len); + Rtsp_Session& rtsp = *static_cast<Rtsp_Session*>(networking->data); + return rtsp.read (tcp, sp->buf, sp->len); } off_t Rtsp_Stream_Interface::seek(off_t newpos) { return newpos; } @@ -73,19 +74,16 @@ void Rtsp_Stream_Interface::close() { - rtsp_session_t *rtsp = NULL; - - rtsp = reinterpret_cast<rtsp_session_t*>(networking->data); - if (rtsp) - rtsp_session_end (rtsp); - url_free(networking->url); + Rtsp_Session* rtsp = static_cast<Rtsp_Session*>(networking->data); + if (rtsp) rtsp->end (); + delete networking->url; free_networking(networking); networking=NULL; } MPXP_Rc Rtsp_Stream_Interface::start() { - rtsp_session_t *rtsp; + Rtsp_Session *rtsp; char *mrl; char *file; int port; @@ -119,7 +117,7 @@ networking->url->username, networking->url->password); if (redirected == 1) { - url_free (networking->url); + delete networking->url; networking->url = url_new (mrl); tcp.close(); } @@ -141,7 +139,7 @@ extern int index_mode; MPXP_Rc Rtsp_Stream_Interface::open(const std::string& filename,unsigned flags) { - URL_t *url; + URL *url; UNUSED(flags); if(filename.substr(0,7)!="rtsp://") return MPXP_False; Modified: mplayerxp/libmpstream/s_udp.cpp =================================================================== --- mplayerxp/libmpstream/s_udp.cpp 2012-12-11 11:31:23 UTC (rev 536) +++ mplayerxp/libmpstream/s_udp.cpp 2012-12-11 13:30:51 UTC (rev 537) @@ -72,7 +72,6 @@ void Udp_Stream_Interface::close() { - url_free(networking->url); free_networking(networking); networking=NULL; } @@ -94,7 +93,7 @@ MPXP_Rc Udp_Stream_Interface::open(const std::string& filename,unsigned flags) { - URL_t *url; + URL *url; UNUSED(flags); MSG_V("STREAM_UDP, URL: %s\n", filename.c_str()); networking = new_networking(); Modified: mplayerxp/libmpstream/udp.cpp =================================================================== --- mplayerxp/libmpstream/udp.cpp 2012-12-11 11:31:23 UTC (rev 536) +++ mplayerxp/libmpstream/udp.cpp 2012-12-11 13:30:51 UTC (rev 537) @@ -45,7 +45,7 @@ namespace mpxp { /* Start listening on a UDP port. If multicast, join the group. */ -void Udp::open(const URL_t *url,int reuse_socket) +void Udp::open(const URL *url,int reuse_socket) { int socket_server_fd, rxsockbufsz; int err; @@ -175,7 +175,7 @@ return; } } -Udp::Udp(const URL_t *url,int reuse_socket) +Udp::Udp(const URL *url,int reuse_socket) :_fd(-1) ,_error(0) { Modified: mplayerxp/libmpstream/udp.h =================================================================== --- mplayerxp/libmpstream/udp.h 2012-12-11 11:31:23 UTC (rev 536) +++ mplayerxp/libmpstream/udp.h 2012-12-11 13:30:51 UTC (rev 537) @@ -25,10 +25,10 @@ class Udp { public: Udp(net_fd_t fd); - Udp(const URL_t* url,int reuse_socket=0); + Udp(const URL* url,int reuse_socket=0); virtual ~Udp(); - void open(const URL_t* url,int reuse_socket=0); + void open(const URL* url,int reuse_socket=0); net_fd_t socket() const { return _fd; } int established() const; int error() const { return _error; } Modified: mplayerxp/libmpstream/url.cpp =================================================================== --- mplayerxp/libmpstream/url.cpp 2012-12-11 11:31:23 UTC (rev 536) +++ mplayerxp/libmpstream/url.cpp 2012-12-11 13:30:51 UTC (rev 537) @@ -21,33 +21,33 @@ #include "mplayerxp.h" namespace mpxp { -URL_t *url_redirect(URL_t **url, const char *redir) { - URL_t *u = *url; - URL_t *res; - if (!strchr(redir, '/') || *redir == '/') { +URL *url_redirect(URL **url, const std::string& _redir) { + std::string redir=_redir; + URL *u = *url; + URL *res; + if (redir.find('/')==std::string::npos || redir[0] == '/') { char *tmp; - char *newurl = new char [strlen(u->url) + strlen(redir) + 1]; - strcpy(newurl, u->url); - if (*redir == '/') { - redir++; - tmp = strstr(newurl, "://"); + std::string newurl; + newurl=u->url; + if (redir[0] == '/') { + redir=redir.substr(1); + tmp = strstr(const_cast<char*>(newurl.c_str()), "://"); if (tmp) tmp = strchr(tmp + 3, '/'); } else - tmp = strrchr(newurl, '/'); + tmp = strrchr(const_cast<char*>(newurl.c_str()), '/'); if (tmp) tmp[1] = 0; - strcat(newurl, redir); + newurl+=redir; res = url_new(newurl); - delete newurl; } else res = url_new(redir); - url_free(u); + delete u; *url = res; return res; } -URL_t* url_new(const std::string& url) { +URL* url_new(const std::string& url) { int pos1, pos2,v6addr = 0; - URL_t* Curl = NULL; + URL* Curl = NULL; char *escfilename=NULL; char *ptr1=NULL, *ptr2=NULL, *ptr3=NULL, *ptr4=NULL; int jumpSize = 3; @@ -65,15 +65,12 @@ } // Create the URL container - Curl = new(zeromem) URL_t; + Curl = new(zeromem) URL; if( Curl==NULL ) { MSG_FATAL("MemAllocFailed\n"); goto err_out; } - // Initialisation of the URL container members - memset( Curl, 0, sizeof(URL_t) ); - string2url(escfilename,url); // Copy the url in the URL container @@ -220,23 +217,20 @@ return Curl; err_out: if (escfilename) delete escfilename; - if (Curl) url_free(Curl); + if (Curl) delete Curl; return NULL; } -void -url_free(URL_t* url) { - if(!url) return; - if(url->url) delete url->url; - if(url->protocol) delete url->protocol; - if(url->hostname) delete url->hostname; - if(url->file) delete url->file; - if(url->username) delete url->username; - if(url->password) delete url->password; - delete url; +URL::URL() {} +URL::~URL() { + if(url) delete url; + if(protocol) delete protocol; + if(hostname) delete hostname; + if(file) delete file; + if(username) delete username; + if(password) delete password; } - /* Replace escape sequences in an URL (or a part of an URL) */ /* works like strcpy(), but without return argument */ void @@ -373,7 +367,7 @@ #ifdef __URL_DEBUG void -url_debug(const URL_t *url) { +url_debug(const URL *url) { if( url==NULL ) { printf("URL pointer NULL\n"); return; Modified: mplayerxp/libmpstream/url.h =================================================================== --- mplayerxp/libmpstream/url.h 2012-12-11 11:31:23 UTC (rev 536) +++ mplayerxp/libmpstream/url.h 2012-12-11 13:30:51 UTC (rev 537) @@ -10,25 +10,28 @@ //#define __URL_DEBUG namespace mpxp { - typedef struct { - char *url; - char *protocol; - char *hostname; - char *file; - unsigned int port; - char *username; - char *password; - } URL_t; + struct URL : public Opaque { + public: + URL(); + virtual ~URL(); - URL_t* url_new(const std::string& url); - void url_free(URL_t* url); + const char* url; + char* protocol; + char* hostname; + char* file; + unsigned int port; + char* username; + char* password; + }; - URL_t *url_redirect(URL_t **url, const char *redir); + URL* url_new(const std::string& url); + + URL *url_redirect(URL **url, const std::string& redir); void url2string(char *outbuf, const std::string& inbuf); void string2url(char *outbuf, const std::string& inbuf); #ifdef __URL_DEBUG - void url_debug(URL_t* url); + void url_debug(URL* url); #endif // __URL_DEBUG } // namespace #endif // __URL_H This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2012-12-11 15:24:59
|
Revision: 539 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=539&view=rev Author: nickols_k Date: 2012-12-11 15:24:51 +0000 (Tue, 11 Dec 2012) Log Message: ----------- anti-illegal patch cleanups: project compiled with -g3 lost >4MB of size. 117777K -> 112026K Modified Paths: -------------- mplayerxp/dump.cpp mplayerxp/libmpcodecs/ad_internal.h mplayerxp/libmpcodecs/dec_video.h mplayerxp/libmpcodecs/vd_internal.h mplayerxp/libmpdemux/demux_y4m.cpp mplayerxp/libmpdemux/demuxer.h mplayerxp/libmpdemux/demuxer_r.h mplayerxp/libmpdemux/demuxer_stream.cpp mplayerxp/libmpdemux/yuv4mpeg.cpp mplayerxp/libmpdemux/yuv4mpeg.h mplayerxp/libmpstream/asf_mmst_streaming.cpp mplayerxp/libmpstream/asf_streaming.cpp mplayerxp/libmpstream/librtsp/rtsp.h mplayerxp/libmpstream/network.cpp mplayerxp/libmpstream/s_dvdnav.cpp mplayerxp/libmpstream/stream.cpp mplayerxp/libplaytree/playtree.h mplayerxp/libvo/sub.cpp mplayerxp/postproc/af_crystality.cpp mplayerxp/xmpcore/xmp_aplayer.cpp mplayerxp/xmpcore/xmp_core.h mplayerxp/xmpcore/xmp_vplayer.cpp Modified: mplayerxp/dump.cpp =================================================================== --- mplayerxp/dump.cpp 2012-12-11 14:15:08 UTC (rev 538) +++ mplayerxp/dump.cpp 2012-12-11 15:24:51 UTC (rev 539) @@ -15,6 +15,7 @@ #include "input2/input.h" #include "mplayerxp.h" #include "libmpdemux/muxer.h" +#include "libmpstream/stream.h" #include "libmpstream/mrl.h" #define MSGT_CLASS MSGT_GLOBAL #include "mp_msg.h" Modified: mplayerxp/libmpcodecs/ad_internal.h =================================================================== --- mplayerxp/libmpcodecs/ad_internal.h 2012-12-11 14:15:08 UTC (rev 538) +++ mplayerxp/libmpcodecs/ad_internal.h 2012-12-11 15:24:51 UTC (rev 539) @@ -2,10 +2,7 @@ #include "loader/wine/msacm.h" #endif #include "libmpconf/codec-cfg.h" - -#include "libmpstream/stream.h" #include "libmpdemux/demuxer_r.h" -#include "libmpdemux/stheader.h" #include "ad.h" Modified: mplayerxp/libmpcodecs/dec_video.h =================================================================== --- mplayerxp/libmpcodecs/dec_video.h 2012-12-11 14:15:08 UTC (rev 538) +++ mplayerxp/libmpcodecs/dec_video.h 2012-12-11 15:24:51 UTC (rev 539) @@ -2,8 +2,6 @@ #define DEC_VIDEO_H_INCLUDED 1 #include "xmpcore/xmp_enums.h" #include "libmpdemux/demuxer_r.h" -#include "libmpstream/stream.h" -#include "libmpdemux/stheader.h" namespace mpxp { struct libinput_t; Modified: mplayerxp/libmpcodecs/vd_internal.h =================================================================== --- mplayerxp/libmpcodecs/vd_internal.h 2012-12-11 14:15:08 UTC (rev 538) +++ mplayerxp/libmpcodecs/vd_internal.h 2012-12-11 15:24:51 UTC (rev 539) @@ -2,10 +2,6 @@ #include "libmpconf/codec-cfg.h" #include "libvo/img_format.h" -#include "libmpstream/stream.h" -#include "libmpdemux/demuxer_r.h" -#include "libmpdemux/stheader.h" - #include "vd.h" #include "vd_msg.h" // prototypes: Modified: mplayerxp/libmpdemux/demux_y4m.cpp =================================================================== --- mplayerxp/libmpdemux/demux_y4m.cpp 2012-12-11 14:15:08 UTC (rev 538) +++ mplayerxp/libmpdemux/demux_y4m.cpp 2012-12-11 15:24:51 UTC (rev 539) @@ -17,6 +17,7 @@ #include "yuv4mpeg.h" //#include "stream.h" +#include "libmpstream/stream.h" #include "demuxer.h" #include "demuxer_internal.h" #include "stheader.h" Modified: mplayerxp/libmpdemux/demuxer.h =================================================================== --- mplayerxp/libmpdemux/demuxer.h 2012-12-11 14:15:08 UTC (rev 538) +++ mplayerxp/libmpdemux/demuxer.h 2012-12-11 15:24:51 UTC (rev 539) @@ -4,7 +4,6 @@ #include "osdep/mplib.h" using namespace mpxp; -#include "libmpstream/stream.h" #include "xmpcore/xmp_enums.h" #include "libmpconf/cfgparser.h" #include "demuxer_packet.h" Modified: mplayerxp/libmpdemux/demuxer_r.h =================================================================== --- mplayerxp/libmpdemux/demuxer_r.h 2012-12-11 14:15:08 UTC (rev 538) +++ mplayerxp/libmpdemux/demuxer_r.h 2012-12-11 15:24:51 UTC (rev 539) @@ -4,7 +4,6 @@ #include <pthread.h> #include <stdint.h> -#include "libmpstream/stream.h" #include "demuxer.h" #include "stheader.h" Modified: mplayerxp/libmpdemux/demuxer_stream.cpp =================================================================== --- mplayerxp/libmpdemux/demuxer_stream.cpp 2012-12-11 14:15:08 UTC (rev 538) +++ mplayerxp/libmpdemux/demuxer_stream.cpp 2012-12-11 15:24:51 UTC (rev 539) @@ -2,6 +2,7 @@ #include "osdep/mplib.h" using namespace mpxp; +#include "libmpstream/stream.h" #include "demuxer_stream.h" #include "demuxer.h" #include "demuxer_internal.h" Modified: mplayerxp/libmpdemux/yuv4mpeg.cpp =================================================================== --- mplayerxp/libmpdemux/yuv4mpeg.cpp 2012-12-11 14:15:08 UTC (rev 538) +++ mplayerxp/libmpdemux/yuv4mpeg.cpp 2012-12-11 15:24:51 UTC (rev 539) @@ -32,6 +32,7 @@ #include "yuv4mpeg.h" #include "demux_msg.h" #include "yuv4mpeg_intern.h" +#include "libmpstream/stream.h" /* quick test of two ratios for equality (i.e. identical components) */ #define Y4M_RATIO_EQL(a,b) ( ((a).n == (b).n) && ((a).d == (b).d) ) @@ -50,8 +51,6 @@ return old; } - - /************************************************************************* * * Convenience functions for fd read/write Modified: mplayerxp/libmpdemux/yuv4mpeg.h =================================================================== --- mplayerxp/libmpdemux/yuv4mpeg.h 2012-12-11 14:15:08 UTC (rev 538) +++ mplayerxp/libmpdemux/yuv4mpeg.h 2012-12-11 15:24:51 UTC (rev 539) @@ -28,9 +28,10 @@ #define __YUV4MPEG_H__ #include <stdlib.h> -#include "libmpstream/stream.h" - +namespace mpxp { + struct Stream; +} /************************************************************************ * error codes returned by y4m_* functions ************************************************************************/ Modified: mplayerxp/libmpstream/asf_mmst_streaming.cpp =================================================================== --- mplayerxp/libmpstream/asf_mmst_streaming.cpp 2012-12-11 14:15:08 UTC (rev 538) +++ mplayerxp/libmpstream/asf_mmst_streaming.cpp 2012-12-11 15:24:51 UTC (rev 539) @@ -20,7 +20,6 @@ #include "mplayerxp.h" #include "tcp.h" #include "url.h" -#include "libmpdemux/asf.h" #include "stream.h" #include "network.h" Modified: mplayerxp/libmpstream/asf_streaming.cpp =================================================================== --- mplayerxp/libmpstream/asf_streaming.cpp 2012-12-11 14:15:08 UTC (rev 538) +++ mplayerxp/libmpstream/asf_streaming.cpp 2012-12-11 15:24:51 UTC (rev 539) @@ -20,10 +20,10 @@ #include "url.h" #include "tcp.h" #include "http.h" -#include "libmpdemux/asf.h" #include "stream.h" #include "asf_streaming.h" +#include "libmpdemux/asf.h" #include "network.h" #include "stream_msg.h" Modified: mplayerxp/libmpstream/librtsp/rtsp.h =================================================================== --- mplayerxp/libmpstream/librtsp/rtsp.h 2012-12-11 14:15:08 UTC (rev 538) +++ mplayerxp/libmpstream/librtsp/rtsp.h 2012-12-11 15:24:51 UTC (rev 539) @@ -31,8 +31,8 @@ #ifndef HAVE_RTSP_H #define HAVE_RTSP_H +#include "libmpstream/tcp.h" - /* some codes returned by rtsp_request_* functions */ enum { RTSP_STATUS_SET_PARAMETER =10, Modified: mplayerxp/libmpstream/network.cpp =================================================================== --- mplayerxp/libmpstream/network.cpp 2012-12-11 14:15:08 UTC (rev 538) +++ mplayerxp/libmpstream/network.cpp 2012-12-11 15:24:51 UTC (rev 539) @@ -28,9 +28,7 @@ #endif #include "stream.h" -#include "libmpdemux/demuxer.h" #include "libmpconf/cfgparser.h" -#include "libmpdemux/mpdemux.h" #include "help_mp.h" #include "tcp.h" @@ -39,7 +37,6 @@ #include "cookies.h" #include "url.h" #include "udp.h" -#include "libmpdemux/asf.h" #include "pnm.h" #ifndef STREAMING_LIVE_DOT_COM #include "rtp.h" @@ -63,42 +60,6 @@ net_config_t::~net_config_t() {} net_config_t net_conf; -static const struct { - const char *mime_type; - int demuxer_type; -} mime_type_table[] = { - // MP3 networking, some MP3 networking server answer with audio/mpeg - { "audio/mpeg", Demuxer::Type_AUDIO }, - // MPEG networking - { "video/mpeg", Demuxer::Type_UNKNOWN }, - { "video/x-mpeg", Demuxer::Type_UNKNOWN }, - { "video/x-mpeg2", Demuxer::Type_UNKNOWN }, - // AVI ??? => video/x-msvideo - { "video/x-msvideo", Demuxer::Type_AVI }, - // MOV => video/quicktime - { "video/quicktime", Demuxer::Type_MOV }, - // ASF - { "audio/x-ms-wax", Demuxer::Type_ASF }, - { "audio/x-ms-wma", Demuxer::Type_ASF }, - { "video/x-ms-asf", Demuxer::Type_ASF }, - { "video/x-ms-afs", Demuxer::Type_ASF }, - { "video/x-ms-wvx", Demuxer::Type_ASF }, - { "video/x-ms-wmv", Demuxer::Type_ASF }, - { "video/x-ms-wma", Demuxer::Type_ASF }, - // Playlists - { "video/x-ms-wmx", Demuxer::Type_PLAYLIST }, - { "audio/x-scpls", Demuxer::Type_PLAYLIST }, - { "audio/x-mpegurl", Demuxer::Type_PLAYLIST }, - { "audio/x-pls", Demuxer::Type_PLAYLIST }, - // Real Media - { "audio/x-pn-realaudio", Demuxer::Type_REAL }, - // OGG Streaming - { "application/x-ogg", Demuxer::Type_OGG }, - // NullSoft Streaming Video - { "video/nsv", Demuxer::Type_NSV}, - { "misc/ultravox", Demuxer::Type_NSV} -}; - networking_t* new_networking() { networking_t *networking = new(zeromem) networking_t; if( networking==NULL ) { @@ -359,7 +320,6 @@ // we might be able to guess the networking type. static MPXP_Rc autodetectProtocol(networking_t *networking, Tcp& tcp) { HTTP_Header *http_hdr=NULL; - unsigned int i; int redirect; int auth_retry=0; MPXP_Rc seekable=MPXP_False; @@ -457,12 +417,6 @@ MSG_V("Content-Type: [%s]\n", content_type ); if( (content_length = http_hdr->get_field("Content-Length")) != NULL) MSG_V("Content-Length: [%s]\n", http_hdr->get_field("Content-Length")); - // Check in the mime type table for a demuxer type - for( i=0 ; i<(sizeof(mime_type_table)/sizeof(mime_type_table[0])) ; i++ ) { - if( !strcasecmp( content_type, mime_type_table[i].mime_type ) ) { - return seekable; - } - } } // Not found in the mime type table, don't fail, // we should try raw HTTP Modified: mplayerxp/libmpstream/s_dvdnav.cpp =================================================================== --- mplayerxp/libmpstream/s_dvdnav.cpp 2012-12-11 14:15:08 UTC (rev 538) +++ mplayerxp/libmpstream/s_dvdnav.cpp 2012-12-11 15:24:51 UTC (rev 539) @@ -12,7 +12,6 @@ #include "stream.h" #include "stream_internal.h" #include "help_mp.h" -#include "libmpdemux/demuxer.h" #include "libmpsub/spudec.h" #include "libvo/sub.h" #include "input2/input.h" Modified: mplayerxp/libmpstream/stream.cpp =================================================================== --- mplayerxp/libmpstream/stream.cpp 2012-12-11 14:15:08 UTC (rev 538) +++ mplayerxp/libmpstream/stream.cpp 2012-12-11 15:24:51 UTC (rev 539) @@ -24,7 +24,6 @@ #include "stream.h" #include "stream_internal.h" -#include "libmpdemux/demuxer.h" #include "stream_msg.h" namespace mpxp { Modified: mplayerxp/libplaytree/playtree.h =================================================================== --- mplayerxp/libplaytree/playtree.h 2012-12-11 14:15:08 UTC (rev 538) +++ mplayerxp/libplaytree/playtree.h 2012-12-11 15:24:51 UTC (rev 539) @@ -1,7 +1,10 @@ #ifndef __PLAYTREE_H #define __PLAYTREE_H -#include "libmpstream/stream.h" +namespace mpxp { + struct Stream; +} + enum { PLAY_TREE_ITER_ERROR=0, PLAY_TREE_ITER_ENTRY=1, Modified: mplayerxp/libvo/sub.cpp =================================================================== --- mplayerxp/libvo/sub.cpp 2012-12-11 14:15:08 UTC (rev 538) +++ mplayerxp/libvo/sub.cpp 2012-12-11 15:24:51 UTC (rev 539) @@ -7,6 +7,7 @@ #include <string.h> #include "mplayerxp.h" +#include "libmpstream/stream.h" // for nav_hl #include "xmpcore/xmp_core.h" #include "video_out.h" #include "font_load.h" Modified: mplayerxp/postproc/af_crystality.cpp =================================================================== --- mplayerxp/postproc/af_crystality.cpp 2012-12-11 14:15:08 UTC (rev 538) +++ mplayerxp/postproc/af_crystality.cpp 2012-12-11 15:24:51 UTC (rev 539) @@ -63,15 +63,12 @@ #include <math.h> #include <limits.h> +#include "libmpdemux/stheader.h" #include "mplayerxp.h" #include "af.h" #include "af_internal.h" #include "aflib.h" -#include "libmpstream/stream.h" -#include "libmpdemux/demuxer.h" -#include "libmpdemux/stheader.h" - #define SAMPLE_MAX 1.0f //#define SAMPLE_MAX 1.0 /* for float32 */ Modified: mplayerxp/xmpcore/xmp_aplayer.cpp =================================================================== --- mplayerxp/xmpcore/xmp_aplayer.cpp 2012-12-11 14:15:08 UTC (rev 538) +++ mplayerxp/xmpcore/xmp_aplayer.cpp 2012-12-11 15:24:51 UTC (rev 539) @@ -12,6 +12,7 @@ #include "mp_msg.h" #include "sig_hand.h" +#include "libmpdemux/demuxer.h" #include "libmpcodecs/dec_audio.h" #include "libao2/audio_out.h" Modified: mplayerxp/xmpcore/xmp_core.h =================================================================== --- mplayerxp/xmpcore/xmp_core.h 2012-12-11 14:15:08 UTC (rev 538) +++ mplayerxp/xmpcore/xmp_core.h 2012-12-11 15:24:51 UTC (rev 539) @@ -14,10 +14,8 @@ #include "osdep/mplib.h" using namespace mpxp; -#include "libmpdemux/demuxer_r.h" -#include "libmpstream/stream.h" -#include "libmpdemux/stheader.h" #include "libvo/video_out.h" +#include "libmpdemux/stheader.h" namespace mpxp { enum xp_modes { XP_NA=0, XP_UniCore, XP_DualCore, XP_TripleCore, XP_MultiCore }; Modified: mplayerxp/xmpcore/xmp_vplayer.cpp =================================================================== --- mplayerxp/xmpcore/xmp_vplayer.cpp 2012-12-11 14:15:08 UTC (rev 538) +++ mplayerxp/xmpcore/xmp_vplayer.cpp 2012-12-11 15:24:51 UTC (rev 539) @@ -11,8 +11,8 @@ #include "libao2/audio_out.h" #include "libvo/video_out.h" +#include "libmpdemux/demuxer_r.h" #include "osdep/timer.h" -#include "libmpdemux/demuxer.h" #include "mplayerxp.h" #include "xmp_core.h" #include "xmp_adecoder.h" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2012-12-11 16:33:11
|
Revision: 544 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=544&view=rev Author: nickols_k Date: 2012-12-11 16:32:57 +0000 (Tue, 11 Dec 2012) Log Message: ----------- rename libvo -> libvo2 (TRANSACTION END) Modified Paths: -------------- mplayerxp/Makefile mplayerxp/libao2/ao_wav.cpp mplayerxp/libmpcodecs/dec_video.cpp mplayerxp/libmpcodecs/vd.cpp mplayerxp/libmpcodecs/vd_divx4.cpp mplayerxp/libmpcodecs/vd_internal.h mplayerxp/libmpcodecs/vd_lavc.cpp mplayerxp/libmpcodecs/vd_libdv.cpp mplayerxp/libmpcodecs/vd_libmpeg2.cpp mplayerxp/libmpcodecs/vd_xanim.cpp mplayerxp/libmpcodecs/vd_xvid.cpp mplayerxp/libmpconf/codec-cfg.cpp mplayerxp/libmpconf/m_option.cpp mplayerxp/libmpdemux/demux_bmp.cpp mplayerxp/libmpdemux/demux_mkv.cpp mplayerxp/libmpdemux/demux_mpxp64.cpp mplayerxp/libmpdemux/demux_ogg.cpp mplayerxp/libmpdemux/demux_rawvideo.cpp mplayerxp/libmpdemux/demuxer.cpp mplayerxp/libmpdemux/sub_cc.cpp mplayerxp/libmpdemux/sub_ty.cpp mplayerxp/libmpstream2/s_dvdnav.cpp mplayerxp/libmpstream2/s_tv.cpp mplayerxp/libmpstream2/tvi/tvi_bsdbt848.cpp mplayerxp/libmpstream2/tvi/tvi_dummy.cpp mplayerxp/libmpstream2/tvi/tvi_v4l.cpp mplayerxp/libmpsub/find_sub.cpp mplayerxp/libmpsub/spudec.h mplayerxp/libmpsub/subreader.cpp mplayerxp/libvo2/Makefile mplayerxp/loader/dshow/mediatype.c mplayerxp/mplayerxp.cpp mplayerxp/mplayerxp.h mplayerxp/postproc/libmenu/menu.cpp mplayerxp/postproc/libmenu/menu_cmdlist.cpp mplayerxp/postproc/libmenu/menu_console.cpp mplayerxp/postproc/libmenu/menu_filesel.cpp mplayerxp/postproc/libmenu/menu_list.cpp mplayerxp/postproc/libmenu/menu_param.cpp mplayerxp/postproc/libmenu/menu_pt.cpp mplayerxp/postproc/libmenu/menu_txt.cpp mplayerxp/postproc/vf.cpp mplayerxp/postproc/vf.h mplayerxp/postproc/vf_1bpp.cpp mplayerxp/postproc/vf_2xsai.cpp mplayerxp/postproc/vf_aspect.cpp mplayerxp/postproc/vf_delogo.cpp mplayerxp/postproc/vf_denoise3d.cpp mplayerxp/postproc/vf_dint.cpp mplayerxp/postproc/vf_down3dright.cpp mplayerxp/postproc/vf_eq.cpp mplayerxp/postproc/vf_expand.cpp mplayerxp/postproc/vf_flip.cpp mplayerxp/postproc/vf_format.cpp mplayerxp/postproc/vf_framestep.cpp mplayerxp/postproc/vf_il.cpp mplayerxp/postproc/vf_menu.cpp mplayerxp/postproc/vf_mirror.cpp mplayerxp/postproc/vf_noise.cpp mplayerxp/postproc/vf_ow.cpp mplayerxp/postproc/vf_palette.cpp mplayerxp/postproc/vf_panscan.cpp mplayerxp/postproc/vf_perspective.cpp mplayerxp/postproc/vf_pp.cpp mplayerxp/postproc/vf_raw.cpp mplayerxp/postproc/vf_rgb2bgr.cpp mplayerxp/postproc/vf_rotate.cpp mplayerxp/postproc/vf_scale.cpp mplayerxp/postproc/vf_smartblur.cpp mplayerxp/postproc/vf_softpulldown.cpp mplayerxp/postproc/vf_swapuv.cpp mplayerxp/postproc/vf_test.cpp mplayerxp/postproc/vf_unsharp.cpp mplayerxp/postproc/vf_vo.cpp mplayerxp/postproc/vf_yuvcsp.cpp mplayerxp/postproc/vf_yuy2.cpp mplayerxp/postproc/vf_yvu9.cpp mplayerxp/xmpcore/mp_image.cpp mplayerxp/xmpcore/xmp_core.cpp mplayerxp/xmpcore/xmp_core.h mplayerxp/xmpcore/xmp_vplayer.cpp Modified: mplayerxp/Makefile =================================================================== --- mplayerxp/Makefile 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/Makefile 2012-12-11 16:32:57 UTC (rev 544) @@ -11,7 +11,7 @@ TARGET_EXE = $(PROGNAME) # these subdirectories required installation due binaries within them -SUBDIRS = libmpdemux libmpstream2 libmpsub libplaytree libmpcodecs libmpconf libao2 osdep postproc input2 nls libvo xmpcore +SUBDIRS = libmpdemux libmpstream2 libmpsub libplaytree libmpcodecs libmpconf libao2 osdep postproc input2 nls libvo2 xmpcore ifeq ($(ENABLE_WIN32LOADER),yes) SUBDIRS+=loader endif @@ -40,7 +40,7 @@ libao2/libao2.a \ postproc/libpostproc.a \ input2/libinput2.a \ - libvo/libvo.a \ + libvo2/libvo2.a \ osdep/libosdep.a \ nls/libnls.a \ libmpconf/libmpconf.a \ Modified: mplayerxp/libao2/ao_wav.cpp =================================================================== --- mplayerxp/libao2/ao_wav.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/libao2/ao_wav.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -30,7 +30,7 @@ #include "afmt.h" #include "audio_out.h" #include "audio_out_internal.h" -#include "libvo/video_out.h" +#include "libvo2/video_out.h" #include "help_mp.h" #include "ao_msg.h" Modified: mplayerxp/libmpcodecs/dec_video.cpp =================================================================== --- mplayerxp/libmpcodecs/dec_video.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/libmpcodecs/dec_video.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -24,7 +24,7 @@ #include "libmpconf/codec-cfg.h" -#include "libvo/video_out.h" +#include "libvo2/video_out.h" #include "postproc/vf.h" #include "vd.h" @@ -107,7 +107,7 @@ delete opaque; } -#include "libvo/video_out.h" +#include "libvo2/video_out.h" #define MPDEC_THREAD_COND (VF_FLAGS_THREADS|VF_FLAGS_SLICES) static unsigned smp_num_cpus=1; static unsigned use_vf_threads=0; @@ -448,7 +448,7 @@ } } -#include "libvo/video_out.h" +#include "libvo2/video_out.h" MPXP_Rc mpcodecs_config_vf(video_decoder_t *opaque, int w, int h){ decvideo_priv_t* priv=reinterpret_cast<decvideo_priv_t*>(opaque->vd_private); @@ -475,7 +475,7 @@ MSG_V("VDec: vo config request - %d x %d\n",w,h); csp_again: - // check if libvo and codec has common outfmt (no conversion): + // check if libvo2 and codec has common outfmt (no conversion): j=-1; for(i=0;i<CODECS_MAX_OUTFMT;i++){ int flags; Modified: mplayerxp/libmpcodecs/vd.cpp =================================================================== --- mplayerxp/libmpcodecs/vd.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/libmpcodecs/vd.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -10,7 +10,7 @@ #include "xmpcore/xmp_core.h" #include "libmpconf/codec-cfg.h" -#include "libvo/img_format.h" +#include "libvo2/img_format.h" #include "libmpstream2/stream.h" #include "libmpdemux/demuxer.h" Modified: mplayerxp/libmpcodecs/vd_divx4.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_divx4.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/libmpcodecs/vd_divx4.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -22,7 +22,7 @@ #include "vd_internal.h" #include "vd.h" #include "codecs_ld.h" -#include "libvo/video_out.h" +#include "libvo2/video_out.h" #include "osdep/bswap.h" static const vd_info_t info = { Modified: mplayerxp/libmpcodecs/vd_internal.h =================================================================== --- mplayerxp/libmpcodecs/vd_internal.h 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/libmpcodecs/vd_internal.h 2012-12-11 16:32:57 UTC (rev 544) @@ -1,6 +1,6 @@ #include "libmpconf/codec-cfg.h" -#include "libvo/img_format.h" +#include "libvo2/img_format.h" #include "vd.h" #include "vd_msg.h" Modified: mplayerxp/libmpcodecs/vd_lavc.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_lavc.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/libmpcodecs/vd_lavc.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -23,7 +23,7 @@ #include "codecs_ld.h" #include "postproc/postprocess.h" #include "postproc/vf.h" -#include "libvo/video_out.h" +#include "libvo2/video_out.h" #include "osdep/bswap.h" static const vd_info_t info = { @@ -79,7 +79,7 @@ #include "libavcodec/avcodec.h" #include "libavformat/riff.h" -#include "libvo/video_out.h" +#include "libvo2/video_out.h" static int vcodec_inited=0; Modified: mplayerxp/libmpcodecs/vd_libdv.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_libdv.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/libmpcodecs/vd_libdv.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -8,7 +8,7 @@ #include <unistd.h> #include <math.h> -#include "libvo/img_format.h" +#include "libvo2/img_format.h" #include "osdep/bswap.h" #include <libdv/dv.h> Modified: mplayerxp/libmpcodecs/vd_libmpeg2.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_libmpeg2.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/libmpcodecs/vd_libmpeg2.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -111,7 +111,7 @@ #include "libmpdemux/parse_es.h" -#include "libvo/video_out.h" +#include "libvo2/video_out.h" #ifdef ATTRIBUTE_ALIGNED_MAX #define ATTR_ALIGN(align) __attribute__ ((__aligned__ ((ATTRIBUTE_ALIGNED_MAX < align) ? ATTRIBUTE_ALIGNED_MAX : align))) #else Modified: mplayerxp/libmpcodecs/vd_xanim.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_xanim.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/libmpcodecs/vd_xanim.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -21,7 +21,7 @@ #include "libmpconf/codec-cfg.h" -#include "libvo/img_format.h" +#include "libvo2/img_format.h" #include "osdep/timer.h" #include "osdep/fastmemcpy.h" #include "vd_internal.h" Modified: mplayerxp/libmpcodecs/vd_xvid.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_xvid.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/libmpcodecs/vd_xvid.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -16,7 +16,7 @@ #include "vd_internal.h" #include "codecs_ld.h" -#include "libvo/video_out.h" +#include "libvo2/video_out.h" #include "osdep/bswap.h" static const vd_info_t info = { Modified: mplayerxp/libmpconf/codec-cfg.cpp =================================================================== --- mplayerxp/libmpconf/codec-cfg.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/libmpconf/codec-cfg.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -23,7 +23,7 @@ // for mmioFOURCC: #include "loader/wine/avifmt.h" -#include "libvo/img_format.h" +#include "libvo2/img_format.h" #include "codec-cfg.h" #define MSGT_CLASS MSGT_CODECCFG #include "mp_msg.h" Modified: mplayerxp/libmpconf/m_option.cpp =================================================================== --- mplayerxp/libmpconf/m_option.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/libmpconf/m_option.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -865,7 +865,7 @@ NULL }; -#include "libvo/img_format.h" +#include "libvo2/img_format.h" /* FIXME: snyc with img_format.h */ static struct { Modified: mplayerxp/libmpdemux/demux_bmp.cpp =================================================================== --- mplayerxp/libmpdemux/demux_bmp.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/libmpdemux/demux_bmp.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -18,7 +18,7 @@ #include "demuxer_internal.h" #include "stheader.h" -#include "libvo/img_format.h" +#include "libvo2/img_format.h" #include "osdep/fastmemcpy.h" #include "demux_msg.h" Modified: mplayerxp/libmpdemux/demux_mkv.cpp =================================================================== --- mplayerxp/libmpdemux/demux_mkv.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/libmpdemux/demux_mkv.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -35,7 +35,7 @@ #include "osdep/bswap.h" #include "libmpsub/vobsub.h" #include "libmpsub/subreader.h" -#include "libvo/sub.h" +#include "libvo2/sub.h" #include "libmpcodecs/codecs_ld.h" #include "libmpcodecs/libnuppelvideo/minilzo.h" #include "libao2/afmt.h" Modified: mplayerxp/libmpdemux/demux_mpxp64.cpp =================================================================== --- mplayerxp/libmpdemux/demux_mpxp64.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/libmpdemux/demux_mpxp64.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -24,7 +24,7 @@ #include "osdep/bswap.h" #include "aviheader.h" #include "libmpcodecs/dec_audio.h" -#include "libvo/sub.h" +#include "libvo2/sub.h" #include "aviprint.h" #include "mpxpav64.h" #include "demux_msg.h" Modified: mplayerxp/libmpdemux/demux_ogg.cpp =================================================================== --- mplayerxp/libmpdemux/demux_ogg.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/libmpdemux/demux_ogg.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -25,7 +25,7 @@ #include "aviprint.h" #include "libmpcodecs/codecs_ld.h" #include "libmpcodecs/dec_audio.h" -#include "libvo/video_out.h" +#include "libvo2/video_out.h" #include "libao2/afmt.h" #include "demux_msg.h" @@ -176,7 +176,7 @@ // - subtitles up in demuxer buffer... #include "libmpsub/subreader.h" -#include "libvo/sub.h" +#include "libvo2/sub.h" #define OGG_SUB_MAX_LINE 128 static subtitle ogg_sub; Modified: mplayerxp/libmpdemux/demux_rawvideo.cpp =================================================================== --- mplayerxp/libmpdemux/demux_rawvideo.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/libmpdemux/demux_rawvideo.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -12,7 +12,7 @@ #include "stheader.h" #include "libmpconf/cfgparser.h" -#include "libvo/img_format.h" +#include "libvo2/img_format.h" #include "demux_msg.h" struct rawvideo_conf_t { Modified: mplayerxp/libmpdemux/demuxer.cpp =================================================================== --- mplayerxp/libmpdemux/demuxer.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/libmpdemux/demuxer.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -17,7 +17,7 @@ #include "input2/input.h" #include "osdep/fastmemcpy.h" -#include "libvo/sub.h" +#include "libvo2/sub.h" #include "libao2/afmt.h" #include "demux_msg.h" Modified: mplayerxp/libmpdemux/sub_cc.cpp =================================================================== --- mplayerxp/libmpdemux/sub_cc.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/libmpdemux/sub_cc.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -25,8 +25,8 @@ #include "libmpsub/subreader.h" -#include "libvo/video_out.h" -#include "libvo/sub.h" +#include "libvo2/video_out.h" +#include "libvo2/sub.h" #define CC_MAX_LINE_LENGTH 64 Modified: mplayerxp/libmpdemux/sub_ty.cpp =================================================================== --- mplayerxp/libmpdemux/sub_ty.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/libmpdemux/sub_ty.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -20,7 +20,7 @@ #include "help_mp.h" #include "sub_cc.h" -#include "libvo/video_out.h" +#include "libvo2/video_out.h" #include "demux_msg.h" extern int sub_justify; Modified: mplayerxp/libmpstream2/s_dvdnav.cpp =================================================================== --- mplayerxp/libmpstream2/s_dvdnav.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/libmpstream2/s_dvdnav.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -13,7 +13,7 @@ #include "stream_internal.h" #include "help_mp.h" #include "libmpsub/spudec.h" -#include "libvo/sub.h" +#include "libvo2/sub.h" #include "input2/input.h" #include "mplayerxp.h" #include <algorithm> Modified: mplayerxp/libmpstream2/s_tv.cpp =================================================================== --- mplayerxp/libmpstream2/s_tv.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/libmpstream2/s_tv.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -33,7 +33,7 @@ #include "libmpdemux/stheader.h" #include "libao2/afmt.h" -#include "libvo/img_format.h" +#include "libvo2/img_format.h" #include "osdep/fastmemcpy.h" #include "libao2/audio_out.h" Modified: mplayerxp/libmpstream2/tvi/tvi_bsdbt848.cpp =================================================================== --- mplayerxp/libmpstream2/tvi/tvi_bsdbt848.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/libmpstream2/tvi/tvi_bsdbt848.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -56,7 +56,7 @@ #endif #endif -#include "../libvo/img_format.h" +#include "../libvo2/img_format.h" #include "tv.h" #include "stream_msg.h" Modified: mplayerxp/libmpstream2/tvi/tvi_dummy.cpp =================================================================== --- mplayerxp/libmpstream2/tvi/tvi_dummy.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/libmpstream2/tvi/tvi_dummy.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -7,7 +7,7 @@ #ifdef USE_TV #include <stdio.h> -#include "libvo/img_format.h" +#include "libvo2/img_format.h" #include "tv.h" #include "tvi_def.h" Modified: mplayerxp/libmpstream2/tvi/tvi_v4l.cpp =================================================================== --- mplayerxp/libmpstream2/tvi/tvi_v4l.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/libmpstream2/tvi/tvi_v4l.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -29,8 +29,7 @@ #include "libao2/afmt.h" #include "libao2/audio_out.h" -#include "libvo/img_format.h" -#include "libvo/fastmemcpy.h" +#include "libvo2/img_format.h" #include "tv.h" #include "stream_msg.h" Modified: mplayerxp/libmpsub/find_sub.cpp =================================================================== --- mplayerxp/libmpsub/find_sub.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/libmpsub/find_sub.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -8,8 +8,8 @@ #include <stdio.h> #include <limits.h> -#include "libvo/video_out.h" -#include "libvo/sub.h" +#include "libvo2/video_out.h" +#include "libvo2/sub.h" #include "subreader.h" #define MSGT_CLASS MSGT_FINDSUB #include "mp_msg.h" Modified: mplayerxp/libmpsub/spudec.h =================================================================== --- mplayerxp/libmpsub/spudec.h 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/libmpsub/spudec.h 2012-12-11 16:32:57 UTC (rev 544) @@ -1,8 +1,8 @@ #ifndef _MPLAYER_SPUDEC_H #define _MPLAYER_SPUDEC_H -#include "libvo/video_out.h" -#include "libvo/sub.h" +#include "libvo2/video_out.h" +#include "libvo2/sub.h" extern int spu_alignment; extern int spu_aamode; Modified: mplayerxp/libmpsub/subreader.cpp =================================================================== --- mplayerxp/libmpsub/subreader.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/libmpsub/subreader.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -15,7 +15,7 @@ #include <string.h> #include <ctype.h> #include "subreader.h" -#include "libvo/sub.h" +#include "libvo2/sub.h" #ifdef USE_ICONV #ifdef HAVE_GICONV Modified: mplayerxp/libvo2/Makefile =================================================================== --- mplayerxp/libvo2/Makefile 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/libvo2/Makefile 2012-12-11 16:32:57 UTC (rev 544) @@ -1,6 +1,6 @@ include ../mp_config.mak -LIBNAME = libvo.a +LIBNAME = libvo2.a CXXSRCS=video_out.cpp font_load.cpp img_format.cpp screenshot.cpp sub.cpp CXXSRCS+=osd_render.cpp aspect.cpp vo_null.cpp Modified: mplayerxp/loader/dshow/mediatype.c =================================================================== --- mplayerxp/loader/dshow/mediatype.c 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/loader/dshow/mediatype.c 2012-12-11 16:32:57 UTC (rev 544) @@ -26,7 +26,7 @@ #include "wine/winerror.h" #include "com.h" -#include "../libvo/img_format.h" +#include "../libvo2/img_format.h" #ifndef NOAVIFILE_HEADERS #include "audiodecoder.h" #include "except.h" Modified: mplayerxp/mplayerxp.cpp =================================================================== --- mplayerxp/mplayerxp.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/mplayerxp.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -53,9 +53,9 @@ #include "libmpsub/spudec.h" #include "libmpsub/vobsub.h" -#include "libvo/video_out.h" +#include "libvo2/video_out.h" -#include "libvo/sub.h" +#include "libvo2/sub.h" #include "libao2/audio_out.h" #include "libao2/afmt.h" Modified: mplayerxp/mplayerxp.h =================================================================== --- mplayerxp/mplayerxp.h 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/mplayerxp.h 2012-12-11 16:32:57 UTC (rev 544) @@ -11,7 +11,7 @@ #include "libmpconf/cfgparser.h" #include "libmpsub/subreader.h" #include "libao2/audio_out.h" -#include "libvo/video_out.h" +#include "libvo2/video_out.h" struct audio_decoder_t; struct video_decoder_t; Modified: mplayerxp/postproc/libmenu/menu.cpp =================================================================== --- mplayerxp/postproc/libmenu/menu.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/postproc/libmenu/menu.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -11,15 +11,15 @@ #include <fcntl.h> #include <unistd.h> -#include "libvo/osd_render.h" -#include "libvo/font_load.h" -#include "libvo/sub.h" +#include "libvo2/osd_render.h" +#include "libvo2/font_load.h" +#include "libvo2/sub.h" #include "osdep/keycodes.h" #include "libplaytree/asxparser.h" #include "nls/nls.h" -#include "libvo/img_format.h" -#include "libvo/video_out.h" +#include "libvo2/img_format.h" +#include "libvo2/video_out.h" #include "xmpcore/mp_image.h" #include "libmpconf/m_option.h" #include "libmpconf/m_struct.h" Modified: mplayerxp/postproc/libmenu/menu_cmdlist.cpp =================================================================== --- mplayerxp/postproc/libmenu/menu_cmdlist.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/postproc/libmenu/menu_cmdlist.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -9,7 +9,7 @@ #include <ctype.h> #include <string.h> -#include "libvo/img_format.h" +#include "libvo2/img_format.h" #include "xmpcore/mp_image.h" #include "libmpconf/m_option.h" @@ -18,7 +18,7 @@ #include "menu.h" #include "menu_list.h" -#include "libvo/font_load.h" +#include "libvo2/font_load.h" #include "input2/input.h" #include "version.h" Modified: mplayerxp/postproc/libmenu/menu_console.cpp =================================================================== --- mplayerxp/postproc/libmenu/menu_console.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/postproc/libmenu/menu_console.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -16,7 +16,7 @@ #include <unistd.h> #include <errno.h> -#include "libvo/img_format.h" +#include "libvo2/img_format.h" #include "xmpcore/mp_image.h" #include "libmpconf/cfgparser.h" @@ -24,7 +24,7 @@ #include "libmpconf/m_option.h" #include "menu.h" -#include "libvo/font_load.h" +#include "libvo2/font_load.h" #include "osdep/keycodes.h" #include "input2/input.h" #include "osdep/timer.h" Modified: mplayerxp/postproc/libmenu/menu_filesel.cpp =================================================================== --- mplayerxp/postproc/libmenu/menu_filesel.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/postproc/libmenu/menu_filesel.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -19,7 +19,7 @@ #include "libmpconf/m_option.h" #include "libmpconf/cfgparser.h" -#include "libvo/img_format.h" +#include "libvo2/img_format.h" #include "xmpcore/mp_image.h" #include "menu.h" Modified: mplayerxp/postproc/libmenu/menu_list.cpp =================================================================== --- mplayerxp/postproc/libmenu/menu_list.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/postproc/libmenu/menu_list.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -6,14 +6,14 @@ #include <ctype.h> #include <string.h> -#include "libvo/img_format.h" -#include "libvo/sub.h" +#include "libvo2/img_format.h" +#include "libvo2/sub.h" #include "xmpcore/mp_image.h" #include "libmpconf/m_struct.h" #include "menu.h" -#include "libvo/video_out.h" +#include "libvo2/video_out.h" #include "osdep/keycodes.h" #include "mplayerxp.h" // mpxp_context().video().output Modified: mplayerxp/postproc/libmenu/menu_param.cpp =================================================================== --- mplayerxp/postproc/libmenu/menu_param.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/postproc/libmenu/menu_param.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -19,7 +19,7 @@ #include "libmpconf/m_property.h" #include "libplaytree/asxparser.h" -#include "libvo/img_format.h" +#include "libvo2/img_format.h" #include "xmpcore/mp_image.h" #include "menu.h" Modified: mplayerxp/postproc/libmenu/menu_pt.cpp =================================================================== --- mplayerxp/postproc/libmenu/menu_pt.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/postproc/libmenu/menu_pt.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -7,7 +7,7 @@ #include "help_mp.h" -#include "libvo/img_format.h" +#include "libvo2/img_format.h" #include "xmpcore/mp_image.h" #include "libmpconf/m_struct.h" Modified: mplayerxp/postproc/libmenu/menu_txt.cpp =================================================================== --- mplayerxp/postproc/libmenu/menu_txt.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/postproc/libmenu/menu_txt.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -8,8 +8,8 @@ #include <stdio.h> #include <string.h> -#include "libvo/img_format.h" -#include "libvo/sub.h" +#include "libvo2/img_format.h" +#include "libvo2/sub.h" #include "xmpcore/mp_image.h" #include "libmpconf/cfgparser.h" @@ -17,7 +17,7 @@ #include "libmpconf/m_option.h" #include "menu.h" -#include "libvo/video_out.h" +#include "libvo2/video_out.h" #include "osdep/keycodes.h" #include "pp_msg.h" #include "mplayerxp.h" // mpxp_context().video().output Modified: mplayerxp/postproc/vf.cpp =================================================================== --- mplayerxp/postproc/vf.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/postproc/vf.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -9,8 +9,8 @@ #include "mplayerxp.h" #include "help_mp.h" -#include "libvo/img_format.h" -#include "libvo/video_out.h" +#include "libvo2/img_format.h" +#include "libvo2/video_out.h" #include "xmpcore/mp_image.h" #include "vf.h" #include "vf_internal.h" @@ -165,7 +165,7 @@ MSG_DBG2("passthru mode to %s\n",vf->next->info->name); return vf_get_new_image(vf->next,outfmt,mp_imgtype,mp_imgflag,w,h,xp_idx); } - // Note: we should call libvo first to check if it supports direct rendering + // Note: we should call libvo2 first to check if it supports direct rendering // and if not, then fallback to software buffers: switch(mp_imgtype){ case MP_IMGTYPE_IP: @@ -201,7 +201,7 @@ if(!mpi->bpp) mp_image_setfmt(mpi,outfmt); MSG_DBG2("vf_get_new_image setfmt. flags=0x%X\n",mpi->flags); if(!(mpi->flags&MP_IMGFLAG_ALLOCATED) && mpi->type>MP_IMGTYPE_EXPORT) { - // check libvo first! + // check libvo2 first! if(vf->get_image) vf->get_image(vf,mpi); MSG_DBG2("[vf->get_image] returns xp_idx=%u\n",mpi->xp_idx); Modified: mplayerxp/postproc/vf.h =================================================================== --- mplayerxp/postproc/vf.h 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/postproc/vf.h 2012-12-11 16:32:57 UTC (rev 544) @@ -3,7 +3,7 @@ #include <stdint.h> #include "xmpcore/xmp_enums.h" #include "xmpcore/mp_image.h" -#include "libvo/video_out.h" // for vo_flags_e +#include "libvo2/video_out.h" // for vo_flags_e #include "vfcap.h" struct vf_instance_t; Modified: mplayerxp/postproc/vf_1bpp.cpp =================================================================== --- mplayerxp/postproc/vf_1bpp.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/postproc/vf_1bpp.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -6,7 +6,7 @@ #include <string.h> #include <inttypes.h> -#include "libvo/img_format.h" +#include "libvo2/img_format.h" #include "xmpcore/mp_image.h" #include "vf.h" #include "vf_internal.h" Modified: mplayerxp/postproc/vf_2xsai.cpp =================================================================== --- mplayerxp/postproc/vf_2xsai.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/postproc/vf_2xsai.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -6,7 +6,7 @@ #include <string.h> #include <inttypes.h> -#include "libvo/img_format.h" +#include "libvo2/img_format.h" #include "xmpcore/mp_image.h" #include "vf.h" #include "vf_internal.h" Modified: mplayerxp/postproc/vf_aspect.cpp =================================================================== --- mplayerxp/postproc/vf_aspect.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/postproc/vf_aspect.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -6,7 +6,7 @@ #include <string.h> #include <inttypes.h> -#include "libvo/img_format.h" +#include "libvo2/img_format.h" #include "xmpcore/mp_image.h" #include "vf.h" #include "vf_internal.h" Modified: mplayerxp/postproc/vf_delogo.cpp =================================================================== --- mplayerxp/postproc/vf_delogo.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/postproc/vf_delogo.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -29,7 +29,7 @@ #include "osdep/cpudetect.h" -#include "libvo/img_format.h" +#include "libvo2/img_format.h" #include "xmpcore/mp_image.h" #include "vf.h" #include "vf_internal.h" Modified: mplayerxp/postproc/vf_denoise3d.cpp =================================================================== --- mplayerxp/postproc/vf_denoise3d.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/postproc/vf_denoise3d.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -25,7 +25,7 @@ #include <inttypes.h> #include <math.h> -#include "libvo/img_format.h" +#include "libvo2/img_format.h" #include "xmpcore/mp_image.h" #include "vf.h" #include "vf_internal.h" Modified: mplayerxp/postproc/vf_dint.cpp =================================================================== --- mplayerxp/postproc/vf_dint.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/postproc/vf_dint.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -9,7 +9,7 @@ #include "osdep/fastmemcpy.h" #include "xmpcore/mp_image.h" -#include "libvo/img_format.h" +#include "libvo2/img_format.h" #include "vf.h" #include "vf_internal.h" #include "pp_msg.h" Modified: mplayerxp/postproc/vf_down3dright.cpp =================================================================== --- mplayerxp/postproc/vf_down3dright.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/postproc/vf_down3dright.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -8,7 +8,7 @@ #include "osdep/cpudetect.h" -#include "libvo/img_format.h" +#include "libvo2/img_format.h" #include "xmpcore/mp_image.h" #include "vf.h" #include "vf_internal.h" Modified: mplayerxp/postproc/vf_eq.cpp =================================================================== --- mplayerxp/postproc/vf_eq.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/postproc/vf_eq.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -20,8 +20,8 @@ #include "osdep/cpudetect.h" -#include "libvo/img_format.h" -#include "libvo/video_out.h" +#include "libvo2/img_format.h" +#include "libvo2/video_out.h" #include "xmpcore/mp_image.h" #include "vf.h" #include "vf_internal.h" Modified: mplayerxp/postproc/vf_expand.cpp =================================================================== --- mplayerxp/postproc/vf_expand.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/postproc/vf_expand.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -7,7 +7,7 @@ #include <stdlib.h> #include <string.h> -#include "libvo/img_format.h" +#include "libvo2/img_format.h" #include "xmpcore/mp_image.h" #include "vf.h" #include "vf_internal.h" @@ -15,8 +15,8 @@ #include "osdep/fastmemcpy.h" #ifdef OSD_SUPPORT -#include "libvo/video_out.h" -#include "libvo/sub.h" +#include "libvo2/video_out.h" +#include "libvo2/sub.h" #endif #include "pp_msg.h" #include "mplayerxp.h" // mpxp_context().video().output Modified: mplayerxp/postproc/vf_flip.cpp =================================================================== --- mplayerxp/postproc/vf_flip.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/postproc/vf_flip.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -29,7 +29,7 @@ #include "vf.h" #include "vf_internal.h" -#include "libvo/video_out.h" +#include "libvo2/video_out.h" //===========================================================================// Modified: mplayerxp/postproc/vf_format.cpp =================================================================== --- mplayerxp/postproc/vf_format.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/postproc/vf_format.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -6,7 +6,7 @@ #include <string.h> #include <inttypes.h> -#include "libvo/img_format.h" +#include "libvo2/img_format.h" #include "xmpcore/mp_image.h" #include "vf.h" #include "vf_internal.h" Modified: mplayerxp/postproc/vf_framestep.cpp =================================================================== --- mplayerxp/postproc/vf_framestep.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/postproc/vf_framestep.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -57,7 +57,7 @@ #include "help_mp.h" #include "osdep/cpudetect.h" -#include "libvo/img_format.h" +#include "libvo2/img_format.h" #include "xmpcore/mp_image.h" #include "vf.h" #include "vf_internal.h" Modified: mplayerxp/postproc/vf_il.cpp =================================================================== --- mplayerxp/postproc/vf_il.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/postproc/vf_il.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -25,7 +25,7 @@ #include <inttypes.h> #include <assert.h> -#include "libvo/img_format.h" +#include "libvo2/img_format.h" #include "xmpcore/mp_image.h" #include "vf.h" #include "vf_internal.h" Modified: mplayerxp/postproc/vf_menu.cpp =================================================================== --- mplayerxp/postproc/vf_menu.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/postproc/vf_menu.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -10,14 +10,14 @@ #include "mplayerxp.h" -#include "libvo/img_format.h" +#include "libvo2/img_format.h" #include "xmpcore/mp_image.h" #include "vf.h" #include "vf_internal.h" #include "osdep/fastmemcpy.h" -#include "libvo/video_out.h" -#include "libvo/font_load.h" +#include "libvo2/video_out.h" +#include "libvo2/font_load.h" #include "input2/input.h" #include "libmpconf/m_struct.h" #include "libmenu/menu.h" Modified: mplayerxp/postproc/vf_mirror.cpp =================================================================== --- mplayerxp/postproc/vf_mirror.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/postproc/vf_mirror.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -6,7 +6,7 @@ #include <string.h> #include <inttypes.h> -#include "libvo/img_format.h" +#include "libvo2/img_format.h" #include "xmpcore/mp_image.h" #include "vf.h" #include "vf_internal.h" Modified: mplayerxp/postproc/vf_noise.cpp =================================================================== --- mplayerxp/postproc/vf_noise.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/postproc/vf_noise.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -27,7 +27,7 @@ #include "osdep/cpudetect.h" -#include "libvo/img_format.h" +#include "libvo2/img_format.h" #include "xmpcore/mp_image.h" #include "vf.h" #include "vf_internal.h" Modified: mplayerxp/postproc/vf_ow.cpp =================================================================== --- mplayerxp/postproc/vf_ow.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/postproc/vf_ow.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -33,7 +33,7 @@ #include <inttypes.h> #include <math.h> -#include "libvo/img_format.h" +#include "libvo2/img_format.h" #include "xmpcore/mp_image.h" #include "vf.h" #include "vf_internal.h" Modified: mplayerxp/postproc/vf_palette.cpp =================================================================== --- mplayerxp/postproc/vf_palette.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/postproc/vf_palette.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -6,7 +6,7 @@ #include <string.h> #include <inttypes.h> -#include "libvo/img_format.h" +#include "libvo2/img_format.h" #include "xmpcore/mp_image.h" #include "vf.h" #include "vf_internal.h" Modified: mplayerxp/postproc/vf_panscan.cpp =================================================================== --- mplayerxp/postproc/vf_panscan.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/postproc/vf_panscan.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -9,7 +9,7 @@ #include <stdlib.h> #include <string.h> -#include "libvo/img_format.h" +#include "libvo2/img_format.h" #include "xmpcore/mp_image.h" #include "vf.h" #include "vf_internal.h" @@ -17,7 +17,7 @@ #include "osdep/fastmemcpy.h" #ifdef OSD_SUPPORT -#include "libvo/sub.h" +#include "libvo2/sub.h" #endif #include "pp_msg.h" Modified: mplayerxp/postproc/vf_perspective.cpp =================================================================== --- mplayerxp/postproc/vf_perspective.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/postproc/vf_perspective.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -26,7 +26,7 @@ #include <assert.h> #include <math.h> -#include "libvo/img_format.h" +#include "libvo2/img_format.h" #include "xmpcore/mp_image.h" #include "vf.h" #include "vf_internal.h" Modified: mplayerxp/postproc/vf_pp.cpp =================================================================== --- mplayerxp/postproc/vf_pp.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/postproc/vf_pp.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -9,7 +9,7 @@ #include "osdep/cpudetect.h" -#include "libvo/img_format.h" +#include "libvo2/img_format.h" #include "xmpcore/mp_image.h" #include "vf.h" #include "vf_internal.h" Modified: mplayerxp/postproc/vf_raw.cpp =================================================================== --- mplayerxp/postproc/vf_raw.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/postproc/vf_raw.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -10,7 +10,7 @@ #include <string.h> #include <inttypes.h> -#include "libvo/img_format.h" +#include "libvo2/img_format.h" #include "xmpcore/mp_image.h" #include "vf.h" #include "vf_internal.h" Modified: mplayerxp/postproc/vf_rgb2bgr.cpp =================================================================== --- mplayerxp/postproc/vf_rgb2bgr.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/postproc/vf_rgb2bgr.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -6,7 +6,7 @@ #include <string.h> #include <inttypes.h> -#include "libvo/img_format.h" +#include "libvo2/img_format.h" #include "xmpcore/mp_image.h" #include "vf.h" #include "vf_internal.h" Modified: mplayerxp/postproc/vf_rotate.cpp =================================================================== --- mplayerxp/postproc/vf_rotate.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/postproc/vf_rotate.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -6,7 +6,7 @@ #include <string.h> #include <inttypes.h> -#include "libvo/img_format.h" +#include "libvo2/img_format.h" #include "xmpcore/mp_image.h" #include "vf.h" #include "vf_internal.h" Modified: mplayerxp/postproc/vf_scale.cpp =================================================================== --- mplayerxp/postproc/vf_scale.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/postproc/vf_scale.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -8,12 +8,12 @@ #include "osdep/cpudetect.h" -#include "libvo/img_format.h" +#include "libvo2/img_format.h" #include "xmpcore/mp_image.h" #include "vf.h" #include "vf_internal.h" -#include "libvo/video_out.h" +#include "libvo2/video_out.h" #include "osdep/fastmemcpy.h" #include "swscale.h" #include "libavutil/log.h" Modified: mplayerxp/postproc/vf_smartblur.cpp =================================================================== --- mplayerxp/postproc/vf_smartblur.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/postproc/vf_smartblur.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -29,7 +29,7 @@ #include <locale.h> #endif -#include "libvo/img_format.h" +#include "libvo2/img_format.h" #include "xmpcore/mp_image.h" #include "vf.h" #include "vf_internal.h" Modified: mplayerxp/postproc/vf_softpulldown.cpp =================================================================== --- mplayerxp/postproc/vf_softpulldown.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/postproc/vf_softpulldown.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -5,13 +5,13 @@ #include <stdlib.h> #include <string.h> -#include "libvo/img_format.h" +#include "libvo2/img_format.h" #include "xmpcore/mp_image.h" #include "vf.h" #include "vf_internal.h" #include "osdep/fastmemcpy.h" -#include "libvo/sub.h" +#include "libvo2/sub.h" #include "pp_msg.h" struct vf_priv_t { Modified: mplayerxp/postproc/vf_swapuv.cpp =================================================================== --- mplayerxp/postproc/vf_swapuv.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/postproc/vf_swapuv.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -25,7 +25,7 @@ #include <inttypes.h> #include <assert.h> -#include "libvo/img_format.h" +#include "libvo2/img_format.h" #include "xmpcore/mp_image.h" #include "vf.h" #include "vf_internal.h" Modified: mplayerxp/postproc/vf_test.cpp =================================================================== --- mplayerxp/postproc/vf_test.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/postproc/vf_test.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -25,7 +25,7 @@ #include <string.h> #include <inttypes.h> -#include "libvo/img_format.h" +#include "libvo2/img_format.h" #include "xmpcore/mp_image.h" #include "vf.h" #include "vf_internal.h" Modified: mplayerxp/postproc/vf_unsharp.cpp =================================================================== --- mplayerxp/postproc/vf_unsharp.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/postproc/vf_unsharp.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -33,7 +33,7 @@ #include <locale.h> #endif -#include "libvo/img_format.h" +#include "libvo2/img_format.h" #include "xmpcore/mp_image.h" #include "vf.h" #include "vf_internal.h" Modified: mplayerxp/postproc/vf_vo.cpp =================================================================== --- mplayerxp/postproc/vf_vo.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/postproc/vf_vo.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -9,8 +9,8 @@ #include "vf.h" #include "vf_internal.h" #include "vfcap.h" -#include "libvo/video_out.h" -#include "libvo/dri_vo.h" +#include "libvo2/video_out.h" +#include "libvo2/dri_vo.h" #include "pp_msg.h" #include "mplayerxp.h" // mpxp_context().video().output @@ -157,7 +157,7 @@ } extern const vf_info_t vf_info_vo = { - "libvo wrapper", + "libvo2 wrapper", "vo", "A'rpi", "for internal use", Modified: mplayerxp/postproc/vf_yuvcsp.cpp =================================================================== --- mplayerxp/postproc/vf_yuvcsp.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/postproc/vf_yuvcsp.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -6,7 +6,7 @@ #include <string.h> #include <inttypes.h> -#include "libvo/img_format.h" +#include "libvo2/img_format.h" #include "xmpcore/mp_image.h" #include "vf.h" #include "vf_internal.h" Modified: mplayerxp/postproc/vf_yuy2.cpp =================================================================== --- mplayerxp/postproc/vf_yuy2.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/postproc/vf_yuy2.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -6,7 +6,7 @@ #include <string.h> #include <inttypes.h> -#include "libvo/img_format.h" +#include "libvo2/img_format.h" #include "xmpcore/mp_image.h" #include "vf.h" #include "vf_internal.h" Modified: mplayerxp/postproc/vf_yvu9.cpp =================================================================== --- mplayerxp/postproc/vf_yvu9.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/postproc/vf_yvu9.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -6,7 +6,7 @@ #include <string.h> #include <inttypes.h> -#include "libvo/img_format.h" +#include "libvo2/img_format.h" #include "xmpcore/mp_image.h" #include "vf.h" #include "vf_internal.h" Modified: mplayerxp/xmpcore/mp_image.cpp =================================================================== --- mplayerxp/xmpcore/mp_image.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/xmpcore/mp_image.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -6,7 +6,7 @@ #include <string.h> #include "mplayerxp.h" -#include "libvo/img_format.h" +#include "libvo2/img_format.h" #include "mp_image.h" #include "osdep/fastmemcpy.h" #define MSGT_CLASS MSGT_CPLAYER Modified: mplayerxp/xmpcore/xmp_core.cpp =================================================================== --- mplayerxp/xmpcore/xmp_core.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/xmpcore/xmp_core.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -20,7 +20,7 @@ #include "xmp_core.h" #include "libao2/audio_out.h" -#include "libvo/video_out.h" +#include "libvo2/video_out.h" #include "libmpcodecs/dec_video.h" #include "libmpcodecs/dec_audio.h" Modified: mplayerxp/xmpcore/xmp_core.h =================================================================== --- mplayerxp/xmpcore/xmp_core.h 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/xmpcore/xmp_core.h 2012-12-11 16:32:57 UTC (rev 544) @@ -14,7 +14,7 @@ #include "osdep/mplib.h" using namespace mpxp; -#include "libvo/video_out.h" +#include "libvo2/video_out.h" #include "libmpdemux/stheader.h" namespace mpxp { Modified: mplayerxp/xmpcore/xmp_vplayer.cpp =================================================================== --- mplayerxp/xmpcore/xmp_vplayer.cpp 2012-12-11 16:20:06 UTC (rev 543) +++ mplayerxp/xmpcore/xmp_vplayer.cpp 2012-12-11 16:32:57 UTC (rev 544) @@ -9,7 +9,7 @@ #include "sig_hand.h" #include "libao2/audio_out.h" -#include "libvo/video_out.h" +#include "libvo2/video_out.h" #include "libmpdemux/demuxer_r.h" #include "osdep/timer.h" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2012-12-12 15:25:29
|
Revision: 550 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=550&view=rev Author: nickols_k Date: 2012-12-12 15:25:16 +0000 (Wed, 12 Dec 2012) Log Message: ----------- use class ASX_Attrib instead of char*** in ASX_Parser + memory leak-- Modified Paths: -------------- mplayerxp/libmpconf/m_option.cpp mplayerxp/libmpconf/m_option.h mplayerxp/libmpconf/m_property.cpp mplayerxp/libmpconf/m_property.h mplayerxp/libmpconf/m_struct.cpp mplayerxp/libmpconf/m_struct.h mplayerxp/libplaytree/asxparser.cpp mplayerxp/libplaytree/asxparser.h mplayerxp/postproc/libmenu/menu.cpp mplayerxp/postproc/libmenu/menu.h mplayerxp/postproc/libmenu/menu_cmdlist.cpp mplayerxp/postproc/libmenu/menu_param.cpp mplayerxp/postproc/vf_menu.cpp Modified: mplayerxp/libmpconf/m_option.cpp =================================================================== --- mplayerxp/libmpconf/m_option.cpp 2012-12-12 12:24:11 UTC (rev 549) +++ mplayerxp/libmpconf/m_option.cpp 2012-12-12 15:25:16 UTC (rev 550) @@ -41,7 +41,7 @@ // Default function that just does a memcpy -static void copy_opt(const m_option_t* opt,any_t* dst,any_t* src) { +static void copy_opt(const m_option_t* opt,any_t* dst,const any_t* src) { if(dst && src) memcpy(dst,src,opt->type->size); } @@ -77,7 +77,7 @@ #define VAL(x) (*(int*)(x)) -static int parse_flag(const m_option_t* opt,const char *name, char *param, any_t* dst, int src) { +static int parse_flag(const m_option_t* opt,const char *name,const char *param, any_t* dst, int src) { if (src == M_CONFIG_FILE) { if(!param) return M_OPT_MISSING_PARAM; if (!strcasecmp(param, "yes") || /* any other language? */ @@ -115,7 +115,7 @@ } } -static char* print_flag(const m_option_t* opt, any_t* val) { +static char* print_flag(const m_option_t* opt,const any_t* val) { if(VAL(val) == opt->min) return mp_strdup("no"); else @@ -137,7 +137,7 @@ // Integer -static int parse_int(const m_option_t* opt,const char *name, char *param, any_t* dst, int src) { +static int parse_int(const m_option_t* opt,const char *name,const char *param, any_t* dst, int src) { long tmp_int; char *endptr; src = 0; @@ -168,7 +168,7 @@ return 1; } -static char* print_int(const m_option_t* opt, any_t* val) { +static char* print_int(const m_option_t* opt,const any_t* val) { opt = NULL; return dup_printf("%d",VAL(val)); } @@ -191,7 +191,7 @@ #undef VAL #define VAL(x) (*(double*)(x)) -static int parse_double(const m_option_t* opt,const char *name, char *param, any_t* dst, int src) { +static int parse_double(const m_option_t* opt,const char *name,const char *param, any_t* dst, int src) { double tmp_float; char* endptr; src = 0; @@ -240,7 +240,7 @@ return 1; } -static char* print_double(const m_option_t* opt, any_t* val) { +static char* print_double(const m_option_t* opt,const any_t* val) { opt = NULL; return dup_printf("%f",VAL(val)); } @@ -261,14 +261,14 @@ #undef VAL #define VAL(x) (*(float*)(x)) -static int parse_float(const m_option_t* opt,const char *name, char *param, any_t* dst, int src) { +static int parse_float(const m_option_t* opt,const char *name,const char *param, any_t* dst, int src) { double tmp; int r= parse_double(opt, name, param, &tmp, src); if(r==1 && dst) VAL(dst) = tmp; return r; } -static char* print_float(const m_option_t* opt, any_t* val) { +static char* print_float(const m_option_t* opt,const any_t* val) { opt = NULL; return dup_printf("%f",VAL(val)); } @@ -290,7 +290,8 @@ #undef VAL #define VAL(x) (*(off_t*)(x)) -static int parse_position(const m_option_t* opt,const char *name, char *param, any_t* dst, int src) { +static int parse_position(const m_option_t* opt,const char *name,const char *param, any_t* dst, int src) { + UNUSED(src); off_t tmp_off; char dummy; @@ -320,7 +321,7 @@ return 1; } -static char* print_position(const m_option_t* opt, any_t* val) { +static char* print_position(const m_option_t* opt,const any_t* val) { UNUSED(opt); return dup_printf("%d",(int64_t)VAL(val)); } @@ -344,7 +345,7 @@ #undef VAL #define VAL(x) (*(char**)(x)) -static int parse_str(const m_option_t* opt,const char *name, char *param, any_t* dst, int src) { +static int parse_str(const m_option_t* opt,const char *name,const char *param, any_t* dst, int src) { UNUSED(src); UNUSED(name); UNUSED(opt); @@ -374,13 +375,13 @@ } -static char* print_str(const m_option_t* opt, any_t* val) { +static char* print_str(const m_option_t* opt,const any_t* val) { UNUSED(opt); UNUSED(val); return (val && VAL(val) && strlen(VAL(val)) > 0) ? mp_strdup(VAL(val)) : NULL; } -static void copy_str(const m_option_t* opt,any_t* dst, any_t* src) { +static void copy_str(const m_option_t* opt,any_t* dst,const any_t* src) { UNUSED(opt); if(dst && src) { #ifndef NO_FREE @@ -390,7 +391,7 @@ } } -static void free_str(any_t* src) { +static void free_str(const any_t* src) { if(src && VAL(src)){ #ifndef NO_FREE delete VAL(src); //FIXME!!! @@ -424,7 +425,7 @@ #define OP_DEL 3 #define OP_CLR 4 -static void free_str_list(any_t* dst) { +static void free_str_list(const any_t* dst) { char** d; int i; @@ -440,7 +441,7 @@ VAL(dst) = NULL; } -static int str_list_add(char** add, int n,any_t* dst,int pre) { +static int str_list_add(const char** add, int n,any_t* dst,int pre) { char** lst = VAL(dst); int ln; @@ -465,7 +466,7 @@ return 1; } -static int str_list_del(char** del, int n,any_t* dst) { +static int str_list_del(char** del, int n,const any_t* dst) { char **lst,*ep,**d; int i,ln,s; long idx; @@ -516,8 +517,20 @@ return 1; } +static const char *get_nextsep(const char *ptr, char sep) { + const char *last_ptr = ptr; + for(;;){ + ptr = strchr(ptr, sep); + if(ptr && ptr>last_ptr && ptr[-1]=='\\'){ + ptr++; + }else + break; + } + return ptr; +} + static char *get_nextsep(char *ptr, char sep, int modify) { - char *last_ptr = ptr; + const char *last_ptr = ptr; for(;;){ ptr = strchr(ptr, sep); if(ptr && ptr>last_ptr && ptr[-1]=='\\'){ @@ -529,10 +542,11 @@ return ptr; } -static int parse_str_list(const m_option_t* opt,const char *name, char *param, any_t* dst, int src) { +static int parse_str_list(const m_option_t* opt,const char *name,const char *param, any_t* dst, int src) { int n = 0,len = strlen(opt->name); char *str; - char *ptr = param, *last_ptr, **res; + const char *ptr = param; + char *last_ptr, **res; int op = OP_NONE; UNUSED(src); @@ -563,7 +577,7 @@ while(ptr[0] != '\0') { - ptr = get_nextsep(ptr, LIST_SEPARATOR, 0); + ptr = get_nextsep(ptr, LIST_SEPARATOR); if(!ptr) { n++; break; @@ -584,8 +598,8 @@ n = 0; while(1) { - last_ptr = ptr; - ptr = get_nextsep(ptr, LIST_SEPARATOR, 1); + last_ptr = const_cast<char*>(ptr); + ptr = get_nextsep(last_ptr, LIST_SEPARATOR, 1); if(!ptr) { res[n] = mp_strdup(last_ptr); n++; @@ -603,9 +617,9 @@ switch(op) { case OP_ADD: - return str_list_add(res,n,dst,0); + return str_list_add(const_cast<const char**>(res),n,dst,0); case OP_PRE: - return str_list_add(res,n,dst,1); + return str_list_add(const_cast<const char**>(res),n,dst,1); case OP_DEL: return str_list_del(res,n,dst); } @@ -617,7 +631,7 @@ return 1; } -static void copy_str_list(const m_option_t* opt,any_t* dst, any_t* src) { +static void copy_str_list(const m_option_t* opt,any_t* dst,const any_t* src) { int n; char **d,**s; UNUSED(opt); @@ -642,7 +656,7 @@ VAL(dst) = d; } -static char* print_str_list(const m_option_t* opt, any_t* src) { +static char* print_str_list(const m_option_t* opt,const any_t* src) { char **lst = NULL; char *ret = NULL,*last = NULL; int i; @@ -698,7 +712,7 @@ /////////////////// Print -static int parse_print(const m_option_t* opt,const char *name, char *param, any_t* dst, int src) { +static int parse_print(const m_option_t* opt,const char *name,const char *param, any_t* dst, int src) { UNUSED(src); UNUSED(dst); UNUSED(param); @@ -757,7 +771,7 @@ #undef VAL #define VAL(x) (*(char***)(x)) -static int parse_subconf(const m_option_t* opt,const char *name, char *param, any_t* dst, int src) { +static int parse_subconf(const m_option_t* opt,const char *name,const char *param, any_t* dst, int src) { char *subparam; char *subopt; int nr = 0,i,r; @@ -798,7 +812,7 @@ } else if (p[0] == '%') { p = &p[1]; optlen = (int)strtol(p, (char**)&p, 0); - if (!p || p[0] != '%' || (optlen > strlen(p) - 1)) { + if (!p || p[0] != '%' || (unsigned(optlen) > strlen(p) - 1)) { MSG_ERR("Invalid length %i for '%s'\n", optlen, subopt); return M_OPT_INVALID; } @@ -929,7 +943,7 @@ { NULL, 0 } }; -static int parse_imgfmt(const m_option_t* opt,const char *name, char *param, any_t* dst, int src) { +static int parse_imgfmt(const m_option_t* opt,const char *name,const char *param, any_t* dst, int src) { uint32_t fmt = 0; int i; UNUSED(src); @@ -1011,7 +1025,7 @@ { NULL, 0 } }; -static int parse_afmt(const m_option_t* opt,const char *name, char *param, any_t* dst, int src) { +static int parse_afmt(const m_option_t* opt,const char *name,const char *param, any_t* dst, int src) { uint32_t fmt = 0; int i; UNUSED(src); @@ -1075,7 +1089,7 @@ return -1e100; } -static int parse_time(const m_option_t* opt,const char *name, char *param, any_t* dst, int src) +static int parse_time(const m_option_t* opt,const char *name,const char *param, any_t* dst, int src) { double time; UNUSED(src); @@ -1112,7 +1126,7 @@ // Time or size (-endpos) -static int parse_time_size(const m_option_t* opt,const char *name, char *param, any_t* dst, int src) { +static int parse_time_size(const m_option_t* opt,const char *name,const char *param, any_t* dst, int src) { m_time_size_t ts; char unit[4]; double end_at; @@ -1344,7 +1358,7 @@ } static int parse_obj_params(const m_option_t* opt,const char *name, - char *param, any_t* dst, int src) { + const char *param, any_t* dst, int src) { char** opts; int r; m_obj_params_t* p = reinterpret_cast<m_obj_params_t*>(opt->priv); @@ -1456,9 +1470,9 @@ return 1; } -static void free_obj_settings_list(any_t* dst); +static void free_obj_settings_list(const any_t* dst); -static int obj_settings_list_del(const char *opt_name,char *param,any_t* dst, int src) { +static int obj_settings_list_del(const char *opt_name,const char *param,any_t* dst, int src) { char** str_list = NULL; int r,i,idx_max = 0; const char* rem_id = "_removed_marker_"; @@ -1517,7 +1531,7 @@ } static int parse_obj_settings_list(const m_option_t* opt,const char *name, - char *param, any_t* dst, int src) { + const char *param, any_t* dst, int src) { int n = 0,r,len = strlen(opt->name); char *str; char *ptr, *last_ptr; @@ -1654,7 +1668,7 @@ return 1; } -static void free_obj_settings_list(any_t* dst) { +static void free_obj_settings_list(const any_t* dst) { int n; m_obj_settings_t *d; @@ -1671,7 +1685,7 @@ VAL(dst) = NULL; } -static void copy_obj_settings_list(const m_option_t* opt,any_t* dst, any_t* src) { +static void copy_obj_settings_list(const m_option_t* opt,any_t* dst,const any_t* src) { m_obj_settings_t *d,*s; int n; UNUSED(opt); @@ -1712,7 +1726,7 @@ }; static int parse_obj_presets(const m_option_t* opt,const char *name, - char *param, any_t* dst, int src) { + const char *param, any_t* dst, int src) { m_obj_presets_t* obj_p = (m_obj_presets_t*)opt->priv; m_struct_t *in_desc,*out_desc; int s,i; @@ -1785,7 +1799,7 @@ #ifdef HAVE_STREAMING static int parse_custom_url(const m_option_t* opt,const char *name, - char *url, any_t* dst, int src) { + const char *url, any_t* dst, int src) { int pos1, pos2, r, v6addr = 0; char *ptr1=NULL, *ptr2=NULL, *ptr3=NULL, *ptr4=NULL; m_struct_t* desc = reinterpret_cast<m_struct_t*>(opt->priv); @@ -1796,7 +1810,7 @@ } // extract the protocol - ptr1 = strstr(url, "://"); + ptr1 = strstr(const_cast<char*>(url), "://"); if( ptr1==NULL ) { // Filename only if(m_option_list_find(desc->fields,"filename")) { Modified: mplayerxp/libmpconf/m_option.h =================================================================== --- mplayerxp/libmpconf/m_option.h 2012-12-12 12:24:11 UTC (rev 549) +++ mplayerxp/libmpconf/m_option.h 2012-12-12 15:25:16 UTC (rev 550) @@ -161,7 +161,7 @@ * \return On error a negative value is returned, on success the number of arguments * consumed. For details see \ref OptionParserReturn. */ - int (*parse)(const m_option_t* opt,const char *name, char *param, any_t* dst, int src); + int (*parse)(const m_option_t* opt,const char *name,const char *param, any_t* dst, int src); /// Print back a value in string form. /** \param opt The option to print. @@ -169,7 +169,7 @@ * \return An allocated string containing the text value or (any_t*)-1 * on error. */ - char* (*print)(const m_option_t* opt, any_t* val); + char* (*print)(const m_option_t* opt,const any_t* val); /** \name * These functions are called to save/set/restore the status of the @@ -184,21 +184,21 @@ * \param dst Pointer to the destination memory. * \param src Pointer to the source memory. */ - void (*save)(const m_option_t* opt,any_t* dst, any_t* src); + void (*save)(const m_option_t* opt,any_t* dst,const any_t* src); /// Set the value in the program (dst) from a save slot. /** \param opt The option to copy. * \param dst Pointer to the destination memory. * \param src Pointer to the source memory. */ - void (*set)(const m_option_t* opt,any_t* dst, any_t* src); + void (*set)(const m_option_t* opt,any_t* dst,const any_t* src); /// Copy the data between two save slots. If NULL and size is > 0 a memcpy will be used. /** \param opt The option to copy. * \param dst Pointer to the destination memory. * \param src Pointer to the source memory. */ - void (*copy)(const m_option_t* opt,any_t* dst, any_t* src); + void (*copy)(const m_option_t* opt,any_t* dst,const any_t* src); //@} /// Free the data allocated for a save slot. @@ -206,7 +206,7 @@ * \param dst Pointer to the data, usually a pointer that should be freed and * set to NULL. */ - void (*mp_free)(any_t* dst); + void (*mp_free)(const any_t* dst); }; ///@} @@ -354,13 +354,13 @@ /// Helper to parse options, see \ref m_option_type::parse. inline static int -m_option_parse(const m_option_t* opt,const char *name, char *param, any_t* dst, int src) { +m_option_parse(const m_option_t* opt,const char *name,const char *param, any_t* dst, int src) { return opt->type->parse(opt,name,param,dst,src); } /// Helper to print options, see \ref m_option_type::print. inline static char* -m_option_print(const m_option_t* opt, any_t* val_ptr) { +m_option_print(const m_option_t* opt,const any_t* val_ptr) { if(opt->type->print) return opt->type->print(opt,val_ptr); else @@ -369,21 +369,21 @@ /// Helper around \ref m_option_type::save. inline static void -m_option_save(const m_option_t* opt,any_t* dst, any_t* src) { +m_option_save(const m_option_t* opt,any_t* dst,const any_t* src) { if(opt->type->save) opt->type->save(opt,dst,src); } /// Helper around \ref m_option_type::set. inline static void -m_option_set(const m_option_t* opt,any_t* dst, any_t* src) { +m_option_set(const m_option_t* opt,any_t* dst,const any_t* src) { if(opt->type->set) opt->type->set(opt,dst,src); } /// Helper around \ref m_option_type::copy. inline static void -m_option_copy(const m_option_t* opt,any_t* dst, any_t* src) { +m_option_copy(const m_option_t* opt,any_t* dst,const any_t* src) { if(opt->type->copy) opt->type->copy(opt,dst,src); else if(opt->type->size > 0) @@ -392,7 +392,7 @@ /// Helper around \ref m_option_type::mp_free. inline static void -m_option_free(const m_option_t* opt,any_t* dst) { +m_option_free(const m_option_t* opt,const any_t* dst) { if(opt->type->mp_free) opt->type->mp_free(dst); } Modified: mplayerxp/libmpconf/m_property.cpp =================================================================== --- mplayerxp/libmpconf/m_property.cpp 2012-12-12 12:24:11 UTC (rev 549) +++ mplayerxp/libmpconf/m_property.cpp 2012-12-12 15:25:16 UTC (rev 550) @@ -99,10 +99,10 @@ return do_action(prop_list,name,action,arg,ctx); } -char* m_properties_expand_string(m_option_t* prop_list,char* str, any_t*ctx) { +char* m_properties_expand_string(m_option_t* prop_list,const char* str, any_t*ctx) { int l,fr=0,pos=0,size=strlen(str)+512; - char *e,*ret = new char [size], num_val; - const char* p=NULL; + char *ret = new char [size], num_val; + const char* e,*p=NULL; int skip = 0, lvl = 0, skip_lvl = 0; while(str[0]) { Modified: mplayerxp/libmpconf/m_property.h =================================================================== --- mplayerxp/libmpconf/m_property.h 2012-12-12 12:24:11 UTC (rev 549) +++ mplayerxp/libmpconf/m_property.h 2012-12-12 15:25:16 UTC (rev 550) @@ -103,7 +103,7 @@ * \param str The string to expand. * \return The newly allocated expanded string. */ -char* m_properties_expand_string(m_option_t* prop_list,char* str, any_t*ctx); +char* m_properties_expand_string(m_option_t* prop_list,const char* str, any_t*ctx); // Helpers to use MPlayer's properties Modified: mplayerxp/libmpconf/m_struct.cpp =================================================================== --- mplayerxp/libmpconf/m_struct.cpp 2012-12-12 12:24:11 UTC (rev 549) +++ mplayerxp/libmpconf/m_struct.cpp 2012-12-12 15:25:16 UTC (rev 550) @@ -52,7 +52,7 @@ } int -m_struct_set(const m_struct_t* st, any_t* obj,const char* field, char* param) { +m_struct_set(const m_struct_t* st, any_t* obj,const char* field,const char* param) { const m_option_t* f = m_struct_get_field(st,field); if(!f) { Modified: mplayerxp/libmpconf/m_struct.h =================================================================== --- mplayerxp/libmpconf/m_struct.h 2012-12-12 12:24:11 UTC (rev 549) +++ mplayerxp/libmpconf/m_struct.h 2012-12-12 15:25:16 UTC (rev 550) @@ -67,7 +67,7 @@ * \return 0 on error, 1 on success. */ int -m_struct_set(const m_struct_t* st, any_t* obj,const char* field, char* param); +m_struct_set(const m_struct_t* st, any_t* obj,const char* field,const char* param); /// Reset a field (or all if field == NULL) to defaults. /** \param st Struct definition. Modified: mplayerxp/libplaytree/asxparser.cpp =================================================================== --- mplayerxp/libplaytree/asxparser.cpp 2012-12-12 12:24:11 UTC (rev 549) +++ mplayerxp/libplaytree/asxparser.cpp 2012-12-12 15:25:16 UTC (rev 550) @@ -16,139 +16,17 @@ #define MSGT_CLASS MSGT_PLAYTREE #include "mp_msg.h" -////// List utils namespace mpxp { -static void __FASTCALL__ asx_list_add(any_t* list_ptr,any_t* entry){ - any_t** list = *(any_t***)list_ptr; - int c = 0; - if(list != NULL) - for( ; list[c] != NULL; c++) ; - - list = (any_t**)mp_realloc(list,sizeof(any_t*)*(c+2)); - - list[c] = entry; - list[c+1] = NULL; - - *(any_t***)list_ptr = list; -} - - -static void __FASTCALL__ asx_list_remove(any_t* list_ptr,any_t* entry,ASX_FreeFunc free_func) { - any_t** list = *(any_t***)list_ptr; - int c,e = -1; - - if(list == NULL) return; - - for(c = 0 ; list[c] != NULL; c++){ - if(list[c] == entry) e = c; - } - - if(e == -1) return; // Not found - - if(free_func != NULL) free_func(list[e]); - - if(c == 1) { // Only one entry, we drop all - delete list; - *(any_t**)list_ptr = NULL; - return; - } - - if(c > e) // If c==e the memmove is not needed - memmove(list+e,list+e+1,(c-e)*sizeof(any_t*)); - - list = (any_t**)mp_realloc(list,(c-1)*sizeof(any_t*)); - list[c-1] = NULL; - - *(any_t***)list_ptr = list; -} - -void __FASTCALL__ asx_list_free(any_t* list_ptr,ASX_FreeFunc free_func) { - any_t** ptr = *(any_t***)list_ptr; - if(ptr == NULL) return; - if(free_func != NULL) { - for( ; *ptr != NULL ; ptr++) - free_func(*ptr); - } - delete *(any_t**)list_ptr; - *(any_t**)list_ptr = NULL; -} - -/////// Attribs utils - -char* __FASTCALL__ asx_get_attrib(const char* attrib,char** attribs) { - char** ptr; - - if(attrib == NULL || attribs == NULL) return NULL; - for(ptr = attribs; ptr[0] != NULL; ptr += 2){ - if(strcasecmp(ptr[0],attrib) == 0) return mp_strdup(ptr[1]); - } - return NULL; -} - -int __FASTCALL__ asx_attrib_to_enum(const char* val,const char** valid_vals) { - const char** ptr; - int r = 0; - - if(valid_vals == NULL || val == NULL) return -2; - for(ptr = valid_vals ; ptr[0] != NULL ; ptr++) { - if(strcasecmp(val,ptr[0]) == 0) return r; - r++; - } - return -1; -} - -void ASX_Parser::warning_attrib_invalid(char* elem, char* attrib, - const char** valid_vals,char* val) const -{ - char *str,*vals; - const char **ptr; - int len; - - if(valid_vals == NULL || valid_vals[0] == NULL) return; - - len = strlen(valid_vals[0]) + 1; - for(ptr = valid_vals+1 ; ptr[0] != NULL; ptr++) { - len += strlen(ptr[0]); - len += ((ptr[1] == NULL) ? 4 : 2); - } - str = vals = new char[len]; - vals += sprintf(vals,"%s",valid_vals[0]); - for(ptr = valid_vals + 1 ; ptr[0] != NULL ; ptr++) { - if(ptr[1] == NULL) vals += sprintf(vals," or %s",ptr[0]); - else vals += sprintf(vals,", %s",ptr[0]); - } - MSG_ERR("at line %d : attribute %s of element %s is invalid (%s). Valid values are %s", - line,attrib,elem,val,str); - delete str; -} - -int ASX_Parser::get_yes_no_attrib(char* element, char* attrib,char** cattribs,int def) const { - char* val = asx_get_attrib(attrib,cattribs); - const char* valids[] = { "NO", "YES", NULL }; - int r; - - if(val == NULL) return def; - r = asx_attrib_to_enum(val,valids); - - if(r < 0) { - warning_attrib_invalid(element,attrib,valids,val); - r = def; - } - delete val; - return r; -} - void ASX_Parser::warning_attrib_required(const char *e, const char *a) const { MSG_WARN("At line %d : element %s don't have the required attribute %s",line,e,a); } void ASX_Parser::warning_body_parse_error(const char *e) const { MSG_WARN("At line %d : error while parsing %s body",line,e); } ASX_Parser::ASX_Parser() {} ASX_Parser::~ASX_Parser() { if(ret_stack) delete ret_stack; } -int ASX_Parser::parse_attribs(char* buffer,char*** _attribs) const { +int ASX_Parser::parse_attribs(char* buffer,ASX_Attrib& _attribs) const { char *ptr1, *ptr2, *ptr3; int n_attrib = 0; - char **cattribs = NULL; char *attrib, *val; ptr1 = buffer; @@ -177,7 +55,7 @@ ptr1++; ptr2 = strchr(ptr1,'"'); if (ptr2 == NULL) { - MSG_WARN("At line %d : value of attribute %s isn't finished",line,attrib); + MSG_WARN("At line %d : value of attribute %s isn't finished\n",line,attrib); delete attrib; break; } @@ -186,16 +64,11 @@ val[ptr2-ptr1] = '\0'; n_attrib++; - cattribs = (char**)mp_realloc(cattribs,(2*n_attrib+1)*sizeof(char*)); - cattribs[n_attrib*2-2] = attrib; - cattribs[n_attrib*2-1] = val; + _attribs.set(attrib,val); ptr1 = ptr2+1; } pa_end: - if(n_attrib > 0) - cattribs[n_attrib*2-0] = NULL; - *_attribs = cattribs; return n_attrib; } @@ -203,7 +76,7 @@ * Return -1 on error, 0 when nothing is found, 1 on sucess */ int ASX_Parser::get_element(const char** _buffer, char** _element, - char** _body,char*** _attribs) { + char** _body,ASX_Attrib& _attribs) { const char *ptr1,*ptr2, *ptr3, *ptr4; char *cattribs = NULL; char *element = NULL, *body = NULL; @@ -212,13 +85,13 @@ int n_attrib = 0; int body_line = 0,attrib_line,ret_line,in = 0; - if(_buffer == NULL || _element == NULL || _body == NULL || _attribs == NULL) { + if(_buffer == NULL || _element == NULL || _body == NULL) { MSG_ERR("At line %d : asx_get_element called with invalid value",line); return -1; } + _attribs.clear(); *_body = *_element = NULL; - *_attribs = NULL; buffer = *_buffer; if(buffer == NULL) return 0; @@ -402,8 +275,7 @@ delete body; return -1; } - } else - *_attribs = NULL; + } else _attribs.clear(); *_element = element; *_body = body; @@ -420,48 +292,43 @@ return 1; } -void ASX_Parser::param(char** cattribs, play_tree_t* pt) const { - const char *name,*val; +void ASX_Parser::param(ASX_Attrib& cattribs, play_tree_t* pt) const { + std::string name,val; - name = asx_get_attrib("NAME",cattribs); - if(!name) { + name = cattribs.get("NAME"); + if(name.empty()) { warning_attrib_required("PARAM" ,"NAME" ); return; } - val = asx_get_attrib("VALUE",cattribs); - if(m_config_get_option(mpxp_context().mconfig,name) == NULL) { - MSG_WARN("Found unknow param in asx: %s",name); - if(val) MSG_WARN("=%s\n",val); - else MSG_WARN("\n"); + val = cattribs.get("VALUE"); + if(m_config_get_option(mpxp_context().mconfig,name.c_str()) == NULL) { + MSG_WARN("Found unknow param in asx: %s",name.c_str()); + if(!val.empty())MSG_WARN("=%s\n",val.c_str()); + else MSG_WARN("\n"); return; } - play_tree_set_param(pt,name,val); + play_tree_set_param(pt,mp_strdup(name.c_str()),mp_strdup(val.c_str())); } -void ASX_Parser::ref(char** cattribs, play_tree_t* pt) const { - char *href; +void ASX_Parser::ref(ASX_Attrib& cattribs, play_tree_t* pt) const { + std::string href; - href = asx_get_attrib("HREF",cattribs); - if(href == NULL) { + href = cattribs.get("HREF"); + if(href.empty()) { warning_attrib_required("REF" ,"HREF" ); return; } // replace http my mmshttp to avoid infinite loops - if (strncmp(href, "http://", 7) == 0) { - char *newref = new char [3 + strlen(href) + 1]; - strcpy(newref, "mms"); - strcpy(newref + 3, href); - delete href; - href = newref; + if (href.substr(0,7)=="http://") { + href = "mms"+href; } - play_tree_add_file(pt,href); - MSG_V("Adding file %s to element entry\n",href); - delete href; + play_tree_add_file(pt,mp_strdup(href.c_str())); + MSG_V("Adding file %s to element entry\n",href.c_str()); } -play_tree_t* ASX_Parser::entryref(libinput_t* libinput,char* buffer,char** _attribs) const { +play_tree_t* ASX_Parser::entryref(libinput_t* libinput,char* buffer,ASX_Attrib& _attribs) const { play_tree_t* pt; - char *href; + std::string href; Stream* stream; play_tree_parser_t* ptp; int f; @@ -469,23 +336,23 @@ if(deep > 0) return NULL; - href = asx_get_attrib("HREF",_attribs); - if(href == NULL) { + href = _attribs.get("HREF"); + if(href.empty()) { warning_attrib_required("ENTRYREF" ,"HREF" ); return NULL; } stream=new(zeromem) Stream; if(stream->open(libinput,href,&f)!=MPXP_Ok) { - MSG_WARN("Can't open playlist %s\n",href); + MSG_WARN("Can't open playlist %s\n",href.c_str()); delete stream; return NULL; } if(!(stream->type() & Stream::Type_Text)) { - MSG_WARN("URL %s dont point to a playlist\n",href); + MSG_WARN("URL %s dont point to a playlist\n",href.c_str()); delete stream; return NULL; } - MSG_V("Adding playlist %s to element entryref\n",href); + MSG_V("Adding playlist %s to element entryref\n",href.c_str()); ptp = play_tree_parser_new(stream,deep+1); pt = play_tree_parser_get_play_tree(libinput,ptp); play_tree_parser_free(ptp); @@ -494,8 +361,9 @@ return pt; } -play_tree_t* ASX_Parser::entry(const char* buffer,char** _attribs) { - char *celement,*body,**cattribs; +play_tree_t* ASX_Parser::entry(const char* buffer,ASX_Attrib& _attribs) { + char *celement,*body; + ASX_Attrib cattribs; int r,nref=0; play_tree_t *pt_ref; UNUSED(_attribs); @@ -503,7 +371,7 @@ pt_ref = play_tree_new(); while(buffer && buffer[0] != '\0') { - r = get_element(&buffer,&celement,&body,&cattribs); + r = get_element(&buffer,&celement,&body,cattribs); if(r < 0) { warning_body_parse_error("ENTRY"); return NULL; @@ -514,7 +382,6 @@ nref++; } else MSG_DBG2("Ignoring element %s\n",celement); if(body) delete body; - asx_free_attribs(cattribs); } if(nref <= 0) { play_tree_free(pt_ref,1); @@ -523,27 +390,27 @@ return pt_ref; } -play_tree_t* ASX_Parser::repeat(libinput_t*libinput,const char* buffer,char** _attribs) { - char *element,*body,**cattribs; +play_tree_t* ASX_Parser::repeat(libinput_t*libinput,const char* buffer,ASX_Attrib& _attribs) { + char *element,*body; + ASX_Attrib cattribs; play_tree_t *pt_repeat, *list=NULL, *pt_entry; - char* count; + std::string count; int r; pt_repeat = play_tree_new(); - count = asx_get_attrib("COUNT",_attribs); - if(count == NULL) { + count = _attribs.get("COUNT"); + if(count.empty()) { MSG_DBG2("Setting element repeat loop to infinit\n"); pt_repeat->loop = -1; // Infinit } else { - pt_repeat->loop = atoi(count); - delete count; + pt_repeat->loop = ::atoi(count.c_str()); if(pt_repeat->loop == 0) pt_repeat->loop = 1; MSG_DBG2("Setting element repeat loop to %d\n",pt_repeat->loop); } while(buffer && buffer[0] != '\0') { - r = get_element(&buffer,&element,&body,&cattribs); + r = get_element(&buffer,&element,&body,cattribs); if(r < 0) { warning_body_parse_error("REPEAT"); return NULL; @@ -573,7 +440,6 @@ param(cattribs,pt_repeat); } else MSG_DBG2("Ignoring element %s\n",element); if(body) delete body; - asx_free_attribs(cattribs); } if(!list) { @@ -585,7 +451,8 @@ } play_tree_t* ASX_Parser::build_tree(libinput_t*libinput,const char* buffer,int deep) { - char *element,*asx_body,**asx_attribs,*body, **attribs; + char *element,*asx_body,*body; + ASX_Attrib asx_attribs,attribs; int r; play_tree_t *asx,*pt_entry,*list = NULL; ASX_Parser& parser = *new(zeromem) ASX_Parser; @@ -593,7 +460,7 @@ parser.line = 1; parser.deep = deep; - r = parser.get_element(&buffer,&element,&asx_body,&asx_attribs); + r = parser.get_element(&buffer,&element,&asx_body,asx_attribs); if(r < 0) { MSG_ERR("At line %d : Syntax error ???",parser.line); delete &parser; @@ -606,7 +473,6 @@ if(strcasecmp(element,"ASX") != 0) { MSG_ERR("first element isn't ASX, it's %s\n",element); - asx_free_attribs(asx_attribs); if(body) delete body; delete &parser; return NULL; @@ -614,7 +480,6 @@ if(!asx_body) { MSG_ERR("ASX element is empty"); - asx_free_attribs(asx_attribs); delete &parser; return NULL; } @@ -622,7 +487,7 @@ asx = play_tree_new(); buffer = asx_body; while(buffer && buffer[0] != '\0') { - r = parser.get_element(&buffer,&element,&body,&attribs); + r = parser.get_element(&buffer,&element,&body,attribs); if(r < 0) { parser.warning_body_parse_error("ASX"); delete &parser; @@ -651,11 +516,9 @@ } } else MSG_DBG2("Ignoring element %s\n",element); if(body) delete body; - asx_free_attribs(attribs); } delete asx_body; - asx_free_attribs(asx_attribs); delete &parser; if(!list) { Modified: mplayerxp/libplaytree/asxparser.h =================================================================== --- mplayerxp/libplaytree/asxparser.h 2012-12-12 12:24:11 UTC (rev 549) +++ mplayerxp/libplaytree/asxparser.h 2012-12-12 15:25:16 UTC (rev 550) @@ -1,17 +1,33 @@ #ifndef ASXPARSER_H #define ASXPARSER_H 1 - #include "osdep/mplib.h" #include "playtree.h" - using namespace mpxp; +#include <string> +#include <map> + namespace mpxp { struct ASX_LineSave_t { const char* buffer; int line; }; + class ASX_Attrib { + public: + ASX_Attrib() {} + ~ASX_Attrib() {} + + struct stricomp { int operator() (const std::string& lhs, const std::string& rhs) const { return strcasecmp(lhs.c_str(),rhs.c_str()); }}; + + std::string get(const std::string& key) { return _attrib[key]; } + void set(const std::string& key,const std::string& value) { _attrib[key]=value; } + void clear() { _attrib.clear(); } + std::map<std::string,std::string,ASX_Attrib::stricomp>& map() { return _attrib; } + private: + std::map<std::string,std::string,ASX_Attrib::stricomp> _attrib; + }; + class ASX_Parser : public Opaque { public: ASX_Parser(); @@ -19,42 +35,26 @@ static play_tree_t* build_tree(libinput_t* libinput,const char* buffer, int ref); - virtual int parse_attribs(char* buffer,char*** _attribs) const; + virtual int parse_attribs(char* buffer,ASX_Attrib& _attribs) const; /* * Return -1 on error, 0 when nothing is found, 1 on sucess */ - virtual int get_element(const char** _buffer,char** _element,char** _body,char*** _attribs); + virtual int get_element(const char** _buffer,char** _element,char** _body,ASX_Attrib& _attribs); int get_line() const { return line; } private: - play_tree_t* repeat(libinput_t*libinput,const char* buffer,char** _attribs); - void warning_attrib_invalid(char* elem, char* attrib,const char** valid_vals,char* val) const; + play_tree_t* repeat(libinput_t*libinput,const char* buffer,ASX_Attrib& _attribs); void warning_attrib_required(const char *e, const char *a) const; void warning_body_parse_error(const char *e) const; - int get_yes_no_attrib(char* element, char* attrib,char** attribs,int def) const; - void param(char** attribs, play_tree_t* pt) const; - void ref(char** attribs, play_tree_t* pt) const; - play_tree_t* entryref(libinput_t* libinput,char* buffer,char** _attribs) const; - play_tree_t* entry(const char* buffer,char** _attribs); + void param(ASX_Attrib& attribs, play_tree_t* pt) const; + void ref(ASX_Attrib& attribs, play_tree_t* pt) const; + play_tree_t* entryref(libinput_t* libinput,char* buffer,ASX_Attrib& _attribs) const; + play_tree_t* entry(const char* buffer,ASX_Attrib& _attribs); int line; // Curent line ASX_LineSave_t* ret_stack; int ret_stack_size; char* last_body; int deep; -}; - -/////// Attribs utils - -extern char* __FASTCALL__ asx_get_attrib(const char* attrib,char** attribs); - -extern int __FASTCALL__ asx_attrib_to_enum(const char* val,char** valid_vals); - -////// List utils - -typedef void (* __FASTCALL__ ASX_FreeFunc)(any_t* arg); - -extern void __FASTCALL__ asx_list_free(any_t* list_ptr,ASX_FreeFunc free_func); - -static inline void asx_free_attribs(any_t*a) { asx_list_free(&a,mp_free); } + }; } // namespace mpxp #endif Modified: mplayerxp/postproc/libmenu/menu.cpp =================================================================== --- mplayerxp/postproc/libmenu/menu.cpp 2012-12-12 12:24:11 UTC (rev 549) +++ mplayerxp/postproc/libmenu/menu.cpp 2012-12-12 15:25:16 UTC (rev 550) @@ -47,10 +47,10 @@ }; typedef struct menu_def_st { - char* name; + const char* name; menu_info_t* type; any_t* cfg; - char* args; + const char* args; } menu_def_t; static struct MPContext *menu_ctx = NULL; @@ -59,13 +59,15 @@ static int menu_parse_config(const char* buffer) { - char *element,*body, **attribs, *name; + char *element,*body; + std::string name; + ASX_Attrib attribs; menu_info_t* minfo = NULL; int r,i; ASX_Parser& parser = *new(zeromem) ASX_Parser; while(1) { - r = parser.get_element(&buffer,&element,&body,&attribs); + r = parser.get_element(&buffer,&element,&body,attribs); if(r < 0) { MSG_WARN("[libmenu] Syntax error at line: %i\n",parser.get_line()); delete &parser; @@ -75,12 +77,11 @@ return 1; } // Has it a name ? - name = asx_get_attrib("name",attribs); - if(!name) { + name = attribs.get("name"); + if(name.empty()) { MSG_WARN("[libmenu] Menu definitions need a name attrib: %i\n",parser.get_line()); delete element; if(body) delete body; - asx_free_attribs(attribs); continue; } @@ -93,28 +94,31 @@ } // Got it : add this to our list if(minfo) { - menu_list = (menu_def_t*)mp_realloc(menu_list,(menu_count+2)*sizeof(menu_def_t)); - menu_list[menu_count].name = name; - menu_list[menu_count].type = minfo; - menu_list[menu_count].cfg = m_struct_alloc(&minfo->priv_st); - menu_list[menu_count].args = body; - // Setup the attribs - for(i = 0 ; attribs[2*i] ; i++) { - if(strcasecmp(attribs[2*i],"name") == 0) continue; - if(!m_struct_set(&minfo->priv_st,menu_list[menu_count].cfg,attribs[2*i], attribs[2*i+1])) - MSG_WARN("[libmenu] Bad attrib: %s %s %s %i\n",attribs[2*i],attribs[2*i+1], - name,parser.get_line()); - } - menu_count++; - memset(&menu_list[menu_count],0,sizeof(menu_def_t)); + menu_list = (menu_def_t*)mp_realloc(menu_list,(menu_count+2)*sizeof(menu_def_t)); + menu_list[menu_count].name = mp_strdup(name.c_str()); + menu_list[menu_count].type = minfo; + menu_list[menu_count].cfg = m_struct_alloc(&minfo->priv_st); + menu_list[menu_count].args = body; + std::map<std::string,std::string,ASX_Attrib::stricomp>::iterator it; + std::map<std::string,std::string,ASX_Attrib::stricomp>& _map = attribs.map(); + for(it=_map.begin();it!=_map.end();it++) { + std::string sfirst,ssecond; + sfirst=(*it).first; + ssecond=(*it).second; + if(strcasecmp(sfirst.c_str(),"name") == 0) continue; + // Setup the attribs + if(!m_struct_set(&minfo->priv_st,menu_list[menu_count].cfg,mp_strdup(sfirst.c_str()),mp_strdup(ssecond.c_str()))) + MSG_WARN("[libmenu] Bad attrib: %s %s %s %i\n" + ,sfirst.c_str(),ssecond.c_str(),name.c_str(),parser.get_line()); + } + menu_count++; + memset(&menu_list[menu_count],0,sizeof(menu_def_t)); } else { - MSG_WARN("[libmenu] Unknown menu type: %s %i\n",element,parser.get_line()); - delete name; - if(body) delete body; + MSG_WARN("[libmenu] Unknown menu type: %s %i\n",element,parser.get_line()); + if(body) delete body; } delete element; - asx_free_attribs(attribs); } delete &parser; return 0; @@ -169,7 +173,7 @@ } // Destroy all this stuff -void menu_unint(void) { +void menu_uninit(void) { int i; for(i = 0 ; menu_list && menu_list[i].name ; i++) { delete menu_list[i].name; @@ -219,8 +223,7 @@ return NULL; } for(i = 0 ; menu_list[i].name != NULL ; i++) { - if(strcmp(name,menu_list[i].name) == 0) - break; + if(strcmp(name,menu_list[i].name) == 0) break; } if(menu_list[i].name == NULL) { MSG_WARN("[libmenu] Menu not found: %s\n",name); Modified: mplayerxp/postproc/libmenu/menu.h =================================================================== --- mplayerxp/postproc/libmenu/menu.h 2012-12-12 12:24:11 UTC (rev 549) +++ mplayerxp/postproc/libmenu/menu.h 2012-12-12 15:25:16 UTC (rev 550) @@ -45,7 +45,7 @@ }; /// Global init/uninit int menu_init(struct MPContext *mpctx,const char* cfg_file); -void menu_unint(void); +void menu_uninit(void); /// Open a menu defined in the config file menu_t* menu_open(const char *name,libinput_t*libinput); Modified: mplayerxp/postproc/libmenu/menu_cmdlist.cpp =================================================================== --- mplayerxp/postproc/libmenu/menu_cmdlist.cpp 2012-12-12 12:24:11 UTC (rev 549) +++ mplayerxp/postproc/libmenu/menu_cmdlist.cpp 2012-12-12 15:25:16 UTC (rev 550) @@ -27,10 +27,10 @@ struct list_entry_s { struct list_entry p; - char* ok; - char* cancel; - char* left; - char* right; + const char* ok; + const char* cancel; + const char* left; + const char* right; }; struct menu_priv_s { @@ -109,13 +109,15 @@ } static int parse_args(menu_t* menu,const char* args) { - char *element,*body, **attribs, *name; + char *element,*body; + ASX_Attrib attribs; + std::string name; list_entry_t* m = NULL; int r; ASX_Parser& parser = *new(zeromem) ASX_Parser; while(1) { - r = parser.get_element(&args,&element,&body,&attribs); + r = parser.get_element(&args,&element,&body,attribs); if(r < 0) { MSG_WARN("[libmenu] Syntax error at line: %i\n",parser.get_line()); delete &parser; @@ -127,25 +129,23 @@ return m ? 1 : 0; } // Has it a name ? - name = asx_get_attrib("name",attribs); - if(!name) { + name = attribs.get("name"); + if(name.empty()) { MSG_WARN("[libmenu] ListMenu entry definitions need a name: %i\n",parser.get_line()); delete element; if(body) delete body; - asx_free_attribs(attribs); continue; } m = new(zeromem) struct list_entry_s; - m->p.txt = name; - m->ok = asx_get_attrib("ok",attribs); - m->cancel = asx_get_attrib("cancel",attribs); - m->left = asx_get_attrib("left",attribs); - m->right = asx_get_attrib("right",attribs); + m->p.txt = mp_strdup(name.c_str()); + m->ok = mp_strdup(attribs.get("ok").c_str()); + m->cancel = mp_strdup(attribs.get("cancel").c_str()); + m->left = mp_strdup(attribs.get("left").c_str()); + m->right = mp_strdup(attribs.get("right").c_str()); menu_list_add_entry(menu,m); delete element; if(body) delete body; - asx_free_attribs(attribs); } delete &parser; return -1; Modified: mplayerxp/postproc/libmenu/menu_param.cpp =================================================================== --- mplayerxp/postproc/libmenu/menu_param.cpp 2012-12-12 12:24:11 UTC (rev 549) +++ mplayerxp/postproc/libmenu/menu_param.cpp 2012-12-12 15:25:16 UTC (rev 550) @@ -30,11 +30,11 @@ struct list_entry_s { struct list_entry p; - char* name; - char* txt; - char* prop; + const char* name; + const char* txt; + const char* prop; m_option_t* opt; - char* menu; + const char* menu; }; struct menu_priv_s { @@ -65,7 +65,7 @@ #define mpriv (menu->priv) static void entry_set_text(menu_t* menu, list_entry_t* e) { - const char* val = e->txt ? m_properties_expand_string(reinterpret_cast<m_option_t*>(e->prop), e->txt, menu->ctx) : + const char* val = e->txt ? m_properties_expand_string(e->opt, e->txt, menu->ctx) : mp_property_print(e->prop, menu->ctx); int l,edit = (mpriv->edit && e == mpriv->p.current); if(!val || !val[0]) { @@ -92,14 +92,16 @@ } static int parse_args(menu_t* menu,const char* args) { - char *element,*body, **attribs, *name, *txt; + char *element,*body; + ASX_Attrib attribs; + std::string name,txt; list_entry_t* m = NULL; int r; m_option_t* opt; ASX_Parser& parser = *new(zeromem) ASX_Parser; while(1) { - r = parser.get_element(&args,&element,&body,&attribs); + r = parser.get_element(&args,&element,&body,attribs); if(r < 0) { MSG_ERR("[libmenu] Syntax error at line: %s\n",parser.get_line()); delete &parser; @@ -114,38 +116,36 @@ return 1; } if(!strcmp(element,"menu")) { - name = asx_get_attrib("menu",attribs); - if(!name) { + name = attribs.get("menu"); + if(name.empty()) { MSG_WARN("[libmenu] Submenu definition need a menu attribut\n"); goto next_element; } m = new(zeromem) struct list_entry_s; - m->menu = name; - name = NULL; // we want to keep it - m->p.txt = asx_get_attrib("name",attribs); + m->menu = mp_strdup(name.c_str()); + m->p.txt = mp_strdup(attribs.get("name").c_str()); if(!m->p.txt) m->p.txt = mp_strdup(m->menu); menu_list_add_entry(menu,m); goto next_element; } - name = asx_get_attrib("property",attribs); + name = attribs.get("property"); opt = NULL; - if(name && mp_property_do(name,M_PROPERTY_GET_TYPE,&opt,menu->ctx) <= 0) { + if(!name.empty() && mp_property_do(name.c_str(),M_PROPERTY_GET_TYPE,&opt,menu->ctx) <= 0) { MSG_WARN("[libmenu] Invalid property: %s %i\n", - name,parser.get_line()); + name.c_str(),parser.get_line()); goto next_element; } - txt = asx_get_attrib("txt",attribs); - if(!(name || txt)) { + txt = attribs.get("txt"); + if(name.empty() || txt.empty()) { MSG_WARN("[libmenu] PrefMenu entry definitions need: %i\n",parser.get_line()); - if(txt) { delete txt; txt = NULL; } goto next_element; } m = new(zeromem) struct list_entry_s; m->opt = opt; - m->txt = txt; txt = NULL; - m->prop = name; name = NULL; - m->name = asx_get_attrib("name",attribs); + m->txt = mp_strdup(txt.c_str()); + m->prop = mp_strdup(name.c_str()); + m->name = mp_strdup(attribs.get("name").c_str()); if(!m->name) m->name = mp_strdup(opt ? opt->name : "-"); entry_set_text(menu,m); menu_list_add_entry(menu,m); @@ -153,8 +153,6 @@ next_element: delete element; if(body) delete body; - if(name) delete name; - asx_free_attribs(attribs); } delete &parser; return -1; Modified: mplayerxp/postproc/vf_menu.cpp =================================================================== --- mplayerxp/postproc/vf_menu.cpp 2012-12-12 12:24:11 UTC (rev 549) +++ mplayerxp/postproc/vf_menu.cpp 2012-12-12 15:25:16 UTC (rev 550) @@ -218,6 +218,7 @@ free_mp_image(pause_mpi); pause_mpi = NULL; } + menu_uninit(); } static int __FASTCALL__ vf_config(vf_instance_t* vf, int width, int height, int d_width, int d_height, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2012-12-13 07:22:51
|
Revision: 554 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=554&view=rev Author: nickols_k Date: 2012-12-13 07:22:44 +0000 (Thu, 13 Dec 2012) Log Message: ----------- cleanups + constantization Modified Paths: -------------- mplayerxp/libmpconf/m_option.cpp mplayerxp/libmpconf/m_option.h mplayerxp/libmpconf/m_struct.h mplayerxp/mplayerxp.cpp mplayerxp/postproc/libmenu/menu.cpp mplayerxp/postproc/libmenu/menu.h mplayerxp/postproc/libmenu/menu_cmdlist.cpp mplayerxp/postproc/libmenu/menu_console.cpp mplayerxp/postproc/libmenu/menu_filesel.cpp mplayerxp/postproc/libmenu/menu_param.cpp mplayerxp/postproc/libmenu/menu_pt.cpp mplayerxp/postproc/libmenu/menu_txt.cpp mplayerxp/postproc/vf.cpp Modified: mplayerxp/libmpconf/m_option.cpp =================================================================== --- mplayerxp/libmpconf/m_option.cpp 2012-12-12 17:36:49 UTC (rev 553) +++ mplayerxp/libmpconf/m_option.cpp 2012-12-13 07:22:44 UTC (rev 554) @@ -1410,7 +1410,7 @@ {"end", M_ST_OFF(m_span_t,end), MCONF_TYPE_INT, M_OPT_MIN , 1 ,0, NULL}, { NULL, NULL, 0, 0, 0, 0, NULL } }; -static const struct m_struct_st m_span_opts = { +static const struct m_struct_t m_span_opts = { "m_span", sizeof(m_span_t), &m_span_params_dflts, Modified: mplayerxp/libmpconf/m_option.h =================================================================== --- mplayerxp/libmpconf/m_option.h 2012-12-12 17:36:49 UTC (rev 553) +++ mplayerxp/libmpconf/m_option.h 2012-12-13 07:22:44 UTC (rev 554) @@ -12,7 +12,7 @@ /// \ingroup OptionTypes typedef struct m_option_type m_option_type_t; typedef struct m_option m_option_t; -struct m_struct_st; +struct m_struct_t; /// \defgroup OptionTypes Options types /// \ingroup Options @@ -74,8 +74,8 @@ /// Extra definition needed for \ref m_option_type_obj_presets options. typedef struct { - struct m_struct_st* in_desc; /// Description of the struct holding the presets. - struct m_struct_st* out_desc; /// Description of the struct that should be set by the presets. + struct m_struct_t* in_desc; /// Description of the struct holding the presets. + struct m_struct_t* out_desc; /// Description of the struct that should be set by the presets. any_t* presets; /// Pointer to an array of structs defining the various presets. any_t* name_off; /// Offset of the preset's name inside the in_struct. } m_obj_presets_t; @@ -98,7 +98,7 @@ #endif /// Extra definition needed for \ref m_option_type_obj_params options. typedef struct { - const struct m_struct_st* desc; /// Field descriptions. + const struct m_struct_t* desc; /// Field descriptions. char separator; /// Field separator to use. } m_obj_params_t; Modified: mplayerxp/libmpconf/m_struct.h =================================================================== --- mplayerxp/libmpconf/m_struct.h 2012-12-12 17:36:49 UTC (rev 553) +++ mplayerxp/libmpconf/m_struct.h 2012-12-13 07:22:44 UTC (rev 554) @@ -11,7 +11,7 @@ struct m_option; /// Struct definition -typedef struct m_struct_st { +struct m_struct_t { const char* name; /// For error messages and debugging unsigned int size; /// size of the whole struct const any_t* defaults; /// Pointer to a struct filled with the default settings @@ -20,7 +20,7 @@ * of the member in the struct (use M_ST_OFF macro for this). */ const struct m_option* fields; -} m_struct_t; +}; // From glib.h (modified ;-) Modified: mplayerxp/mplayerxp.cpp =================================================================== --- mplayerxp/mplayerxp.cpp 2012-12-12 17:36:49 UTC (rev 553) +++ mplayerxp/mplayerxp.cpp 2012-12-13 07:22:44 UTC (rev 554) @@ -29,7 +29,6 @@ #include "mplayerxp.h" #include "xmpcore/sig_hand.h" -#include "postproc/swscale.h" #include "postproc/af.h" #include "postproc/vf.h" #define HELP_MP_DEFINE_STATIC @@ -37,12 +36,9 @@ #include "libmpstream2/stream.h" #include "libmpdemux/demuxer.h" -#include "libmpdemux/stheader.h" -#include "libmpdemux/parse_es.h" #include "libmpconf/cfgparser.h" #include "libmpconf/codec-cfg.h" -#include "libmpconf/m_struct.h" #include "libmpcodecs/dec_video.h" #include "libmpcodecs/dec_audio.h" @@ -55,15 +51,13 @@ #include "libvo2/video_out.h" -#include "libvo2/sub.h" #include "libao2/audio_out.h" #include "libao2/afmt.h" -#include "osdep/keycodes.h" -#include "osdep/shmem.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" @@ -75,8 +69,6 @@ #include "xmpcore/xmp_core.h" #include "xmpcore/xmp_vplayer.h" #include "xmpcore/xmp_adecoder.h" -#include "osdep/timer.h" -#include "osdep/getch2.h" #include "xmpcore/PointerProtector.h" #include "dump.h" @@ -302,7 +294,6 @@ } static void mpxp_init_structs(void) { - mpxp_context().engine().MPXPSys = new(zeromem) MPXPSystem; #if defined( ARCH_X86 ) || defined(ARCH_X86_64) memset(&x86,-1,sizeof(x86_features_t)); #endif @@ -902,7 +893,7 @@ 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:"")!=NULL)?1:0; + vo_inited = (mpxp_context().video().output->init(mp_conf.video_driver?mp_conf.video_driver:"")==MPXP_Ok)?1:0; if(!vo_inited){ MSG_FATAL(MSGTR_InvalidVOdriver,mp_conf.video_driver?mp_conf.video_driver:"?"); @@ -1685,19 +1676,21 @@ secure_keys=ptr_protector.protect(new(zeromem) MPXPSecureKeys(10)); mpxp_init_structs(); - MPXPSystem& MPXPSys=*mpxp_context().engine().MPXPSys; + mpxp_context().video().output=new(zeromem) Video_Output; init_signal_handling(); xmp_init(); xmp_register_main(exit_sighandler); - MPXPSys.init_keyboard_fifo(); - mpxp_print_init(mp_conf.verbose+MSGL_STATUS); MSG_INFO("%s",banner_text); - /* Test for cpu capabilities (and corresponding OS support) for optimizing */ + /* currently it's lowest point of MPXPSystem initialization */ + mpxp_context().engine().MPXPSys = new(zeromem) MPXPSystem; + MPXPSystem& MPXPSys=*mpxp_context().engine().MPXPSys; + MPXPSys.init_keyboard_fifo(); + MPXPSys.playtree = play_tree_new(); mpxp_context().mconfig = m_config_new(MPXPSys.playtree,MPXPSys.libinput()); @@ -1724,10 +1717,6 @@ #if defined( ARCH_X86 ) || defined(ARCH_X86_64) get_mmx_optimizations(); #endif - if(!sws_init()) { - MSG_ERR("MPlayerXP requires working copy of libswscaler\n"); - exit_player(MSGTR_Exit_quit); - } if(mp_conf.shuffle_playback) MPXPSys.playtree->flags|=PLAY_TREE_RND; else MPXPSys.playtree->flags&=~PLAY_TREE_RND; Modified: mplayerxp/postproc/libmenu/menu.cpp =================================================================== --- mplayerxp/postproc/libmenu/menu.cpp 2012-12-12 17:36:49 UTC (rev 553) +++ mplayerxp/postproc/libmenu/menu.cpp 2012-12-13 07:22:44 UTC (rev 554) @@ -94,7 +94,7 @@ menu_list = (menu_def_t*)mp_realloc(menu_list,(menu_count+2)*sizeof(menu_def_t)); menu_list[menu_count].name = mp_strdup(name.c_str()); menu_list[menu_count].type = minfo; - menu_list[menu_count].cfg = m_struct_alloc(&minfo->priv_st); + menu_list[menu_count].cfg = m_struct_alloc(minfo->priv_st); menu_list[menu_count].args = mp_strdup(element.body().c_str()); std::map<std::string,std::string,ASX_Attrib::stricomp>::iterator it; std::map<std::string,std::string,ASX_Attrib::stricomp>& _map = element.attribs().map(); @@ -104,7 +104,7 @@ ssecond=(*it).second; if(strcasecmp(sfirst.c_str(),"name") == 0) continue; // Setup the attribs - if(!m_struct_set(&minfo->priv_st,menu_list[menu_count].cfg,mp_strdup(sfirst.c_str()),mp_strdup(ssecond.c_str()))) + if(!m_struct_set(minfo->priv_st,menu_list[menu_count].cfg,mp_strdup(sfirst.c_str()),mp_strdup(ssecond.c_str()))) MSG_WARN("[libmenu] Bad attrib: %s %s %s %i\n" ,sfirst.c_str(),ssecond.c_str(),name.c_str(),parser.get_line()); } @@ -171,7 +171,7 @@ int i; for(i = 0 ; menu_list && menu_list[i].name ; i++) { delete menu_list[i].name; - m_struct_free(&menu_list[i].type->priv_st,menu_list[i].cfg); + m_struct_free(menu_list[i].type->priv_st,menu_list[i].cfg); if(menu_list[i].args) delete menu_list[i].args; } delete menu_list; @@ -228,7 +228,7 @@ return NULL; } m = new(zeromem) menu_t(libinput); - m->priv_st = &(menu_list[i].type->priv_st); + m->priv_st = menu_list[i].type->priv_st; m->priv = (menu_priv_s*)m_struct_copy(m->priv_st,menu_list[i].cfg); m->ctx = menu_ctx; if(menu_list[i].type->mopen(m,menu_list[i].args)) Modified: mplayerxp/postproc/libmenu/menu.h =================================================================== --- mplayerxp/postproc/libmenu/menu.h 2012-12-12 17:36:49 UTC (rev 553) +++ mplayerxp/postproc/libmenu/menu.h 2012-12-13 07:22:44 UTC (rev 554) @@ -6,6 +6,7 @@ } struct menu_priv_s; +struct m_struct_t; struct menu_t { menu_t(libinput_t& _libinput):libinput(_libinput) {} @@ -16,7 +17,7 @@ void (*read_cmd)(menu_t* menu,int cmd); void (*read_key)(menu_t* menu,int cmd); void (*close)(menu_t* menu); - m_struct_t* priv_st; + const m_struct_t* priv_st; struct menu_priv_s* priv; int show; // Draw it ? int cl; // Close request (user sent a close cmd or @@ -29,7 +30,7 @@ const char *name; const char *author; const char *comment; - m_struct_t priv_st; // Config struct definition + const m_struct_t* priv_st; // Config struct definition // cfg is a config struct as defined in cfg_st, it may be used as a priv struct // cfg is filled from the attributs found in the cfg file // the args param hold the content of the balise in the cfg file (if any) Modified: mplayerxp/postproc/libmenu/menu_cmdlist.cpp =================================================================== --- mplayerxp/postproc/libmenu/menu_cmdlist.cpp 2012-12-12 17:36:49 UTC (rev 553) +++ mplayerxp/postproc/libmenu/menu_cmdlist.cpp 2012-12-13 07:22:44 UTC (rev 554) @@ -162,16 +162,19 @@ return 1; } +static const m_struct_t m_priv = +{ + "cmdlist_cfg", + sizeof(struct menu_priv_s), + &cfg_dflt, + cfg_fields +}; + extern const menu_info_t menu_info_cmdlist = { "Command list menu", "cmdlist", "Albeu", "", - { - "cmdlist_cfg", - sizeof(struct menu_priv_s), - &cfg_dflt, - cfg_fields - }, + &m_priv, open_cmdlist }; Modified: mplayerxp/postproc/libmenu/menu_console.cpp =================================================================== --- mplayerxp/postproc/libmenu/menu_console.cpp 2012-12-12 17:36:49 UTC (rev 553) +++ mplayerxp/postproc/libmenu/menu_console.cpp 2012-12-13 07:22:44 UTC (rev 554) @@ -484,16 +484,19 @@ return 1; } +static const m_struct_t m_priv = +{ + "console_cfg", + sizeof(struct menu_priv_s), + &cfg_dflt, + cfg_fields +}; + extern const menu_info_t menu_info_console = { "MPlayer console", "console", "Albeu", "", - { - "console_cfg", - sizeof(struct menu_priv_s), - &cfg_dflt, - cfg_fields - }, + &m_priv, openMenu, }; Modified: mplayerxp/postproc/libmenu/menu_filesel.cpp =================================================================== --- mplayerxp/postproc/libmenu/menu_filesel.cpp 2012-12-12 17:36:49 UTC (rev 553) +++ mplayerxp/postproc/libmenu/menu_filesel.cpp 2012-12-13 07:22:44 UTC (rev 554) @@ -44,12 +44,12 @@ char* dir; // current dir /// Cfg fields char* path; - char* title; - char* file_action; - char* dir_action; + const char* title; + const char* file_action; + const char* dir_action; int auto_close; char** actions; - char* filter; + const char* filter; }; static struct menu_priv_s cfg_dflt = { @@ -86,14 +86,15 @@ delete entry; } -static char* replace_path(char* title , char* dir) { - char *p = strstr(title,"%p"); +static const char* replace_path(const char* title,const char* dir) { + const char *p = strstr(title,"%p"); if(p) { int tl = strlen(title); int dl = strlen(dir); int t1l = p-title; int l = tl - 2 + dl; - char *r, *n, *d = dir; + char *r, *n; + const char *d = dir; char term = *(p-1); do { @@ -116,7 +117,7 @@ typedef int (*kill_warn)(const any_t*, const any_t*); -static int mylstat(char *dir, char *file,struct stat* st) { +static int mylstat(const char *dir,const char *file,struct stat* st) { int l = strlen(dir) + strlen(file); char s[l+2]; sprintf(s,"%s/%s",dir,file); @@ -182,7 +183,7 @@ } } -static int open_dir(menu_t* menu,char* args) { +static int open_dir(menu_t* menu,const char* args) { char **namelist, **tp; struct dirent *dp; struct stat st; @@ -201,7 +202,7 @@ mpriv->dir = mp_strdup(args); if(mpriv->p.title && mpriv->p.title != mpriv->title && mpriv->p.title != cfg_dflt.p.title) delete mpriv->p.title; - p = strstr(mpriv->title,"%p"); + p = strstr(const_cast<char*>(mpriv->title),"%p"); mpriv->p.title = replace_path(mpriv->title,mpriv->dir); @@ -309,7 +310,7 @@ if(mpriv->dir_action) { int fname_len = strlen(mpriv->dir) + strlen(mpriv->p.current->p.txt) + 1; char filename[fname_len]; - char* str; + const char* str; sprintf(filename,"%s%s",mpriv->dir,mpriv->p.current->p.txt); str = replace_path(mpriv->dir_action,filename); c = mp_input_parse_cmd(str); @@ -343,7 +344,7 @@ } else { // Files int fname_len = strlen(mpriv->dir) + strlen(mpriv->p.current->p.txt) + 1; char filename[fname_len]; - char *str; + const char *str; sprintf(filename,"%s%s",mpriv->dir,mpriv->p.current->p.txt); str = replace_path(mpriv->file_action,filename); c = mp_input_parse_cmd(str); @@ -359,7 +360,7 @@ case MENU_CMD_ACTION: { int fname_len = strlen(mpriv->dir) + strlen(mpriv->p.current->p.txt) + 1; char filename[fname_len]; - char *str; + const char *str; sprintf(filename,"%s%s",mpriv->dir,mpriv->p.current->p.txt); str = replace_path(action, filename); mp_input_queue_cmd(menu->libinput,mp_input_parse_cmd(str)); @@ -450,16 +451,19 @@ return r; } +static struct m_struct_t m_priv = +{ + "fs_cfg", + sizeof(struct menu_priv_s), + &cfg_dflt, + cfg_fields +}; + extern const menu_info_t menu_info_filesel = { "File seletor menu", "filesel", "Albeu", "", - { - "fs_cfg", - sizeof(struct menu_priv_s), - &cfg_dflt, - cfg_fields - }, + &m_priv, open_fs }; Modified: mplayerxp/postproc/libmenu/menu_param.cpp =================================================================== --- mplayerxp/postproc/libmenu/menu_param.cpp 2012-12-12 17:36:49 UTC (rev 553) +++ mplayerxp/postproc/libmenu/menu_param.cpp 2012-12-13 07:22:44 UTC (rev 554) @@ -256,16 +256,19 @@ return parse_args(menu,args); } +static const m_struct_t m_priv = +{ + "pref_cfg", + sizeof(struct menu_priv_s), + &cfg_dflt, + cfg_fields +}; + extern const menu_info_t menu_info_pref = { "Preferences menu", "pref", "Albeu", "", - { - "pref_cfg", - sizeof(struct menu_priv_s), - &cfg_dflt, - cfg_fields - }, + &m_priv, openMenu }; Modified: mplayerxp/postproc/libmenu/menu_pt.cpp =================================================================== --- mplayerxp/postproc/libmenu/menu_pt.cpp 2012-12-12 17:36:49 UTC (rev 553) +++ mplayerxp/postproc/libmenu/menu_pt.cpp 2012-12-13 07:22:44 UTC (rev 554) @@ -31,7 +31,7 @@ struct menu_priv_s { menu_list_priv_t p; - char* title; + const char* title; }; static struct menu_priv_s cfg_dflt = { @@ -141,16 +141,19 @@ return 1; } +static const m_struct_t m_priv = +{ + "pt_cfg", + sizeof(struct menu_priv_s), + &cfg_dflt, + cfg_fields +}; + extern const menu_info_t menu_info_pt = { "Playtree menu", "pt", "Albeu", "", - { - "pt_cfg", - sizeof(struct menu_priv_s), - &cfg_dflt, - cfg_fields - }, + &m_priv, op }; Modified: mplayerxp/postproc/libmenu/menu_txt.cpp =================================================================== --- mplayerxp/postproc/libmenu/menu_txt.cpp 2012-12-12 17:36:49 UTC (rev 553) +++ mplayerxp/postproc/libmenu/menu_txt.cpp 2012-12-13 07:22:44 UTC (rev 554) @@ -187,16 +187,19 @@ return 1; } +static const m_struct_t m_priv = +{ + "txt_cfg", + sizeof(struct menu_priv_s), + &cfg_dflt, + cfg_fields +}; + extern const menu_info_t menu_info_txt = { "Text file viewer", "txt", "Albeu", "", - { - "txt_cfg", - sizeof(struct menu_priv_s), - &cfg_dflt, - cfg_fields - }, + &m_priv, open_txt, }; Modified: mplayerxp/postproc/vf.cpp =================================================================== --- mplayerxp/postproc/vf.cpp 2012-12-12 17:36:49 UTC (rev 553) +++ mplayerxp/postproc/vf.cpp 2012-12-13 07:22:44 UTC (rev 554) @@ -14,6 +14,7 @@ #include "xmpcore/mp_image.h" #include "vf.h" #include "vf_internal.h" +#include "swscale.h" #include "osdep/fastmemcpy.h" #include "libmpconf/codec-cfg.h" @@ -677,6 +678,10 @@ } 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); + } vf_stream_t* s = new(zeromem) vf_stream_t(libinput); vf_instance_t* first; s->first=first=vf_init_filter(libinput,conf); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2012-12-13 09:34:40
|
Revision: 555 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=555&view=rev Author: nickols_k Date: 2012-12-13 09:34:32 +0000 (Thu, 13 Dec 2012) Log Message: ----------- use more object-oriented programming in HTTP_Header + infinite.loop-- Modified Paths: -------------- mplayerxp/libmpdemux/demuxer.cpp mplayerxp/libmpstream2/asf_streaming.cpp mplayerxp/libmpstream2/cookies.cpp mplayerxp/libmpstream2/http.cpp mplayerxp/libmpstream2/http.h mplayerxp/libmpstream2/network.cpp Modified: mplayerxp/libmpdemux/demuxer.cpp =================================================================== --- mplayerxp/libmpdemux/demuxer.cpp 2012-12-13 07:22:44 UTC (rev 554) +++ mplayerxp/libmpdemux/demuxer.cpp 2012-12-13 09:34:32 UTC (rev 555) @@ -366,6 +366,7 @@ unsigned i=0; while(mime_type_table[i].driver!=&demux_null) { if(name==mime_type_table[i].mime_type) return mime_type_table[i].driver; + i++; } return &demux_null; } Modified: mplayerxp/libmpstream2/asf_streaming.cpp =================================================================== --- mplayerxp/libmpstream2/asf_streaming.cpp 2012-12-13 07:22:44 UTC (rev 554) +++ mplayerxp/libmpstream2/asf_streaming.cpp 2012-12-13 09:34:32 UTC (rev 555) @@ -583,7 +583,7 @@ // Common header for all requests. http_hdr->set_field("Accept: */*" ); http_hdr->set_field("User-Agent: NSPlayer/4.1.0.3856" ); - http_hdr->add_basic_authentication(url->username, url->password ); + http_hdr->add_basic_authentication(url->username?url->username:"", url->password?url->password:"" ); // Check if we are using a proxy if( !strcasecmp( url->protocol, "http_proxy" ) ) { @@ -721,7 +721,7 @@ HTTP_Header *http_hdr=NULL; URL *url = networking->url; asf_http_networking_t *asf_http_ctrl; - char buffer[BUFFER_SIZE]; + uint8_t buffer[BUFFER_SIZE]; int i, ret; int done; int auth_retry = 0; @@ -762,7 +762,7 @@ delete http_hdr; http_hdr = new(zeromem) HTTP_Header; do { - i = tcp.read((uint8_t*)buffer, BUFFER_SIZE); + i = tcp.read(buffer, BUFFER_SIZE); if( i<=0 ) { perror("read"); delete http_hdr; Modified: mplayerxp/libmpstream2/cookies.cpp =================================================================== --- mplayerxp/libmpstream2/cookies.cpp 2012-12-13 07:22:44 UTC (rev 554) +++ mplayerxp/libmpstream2/cookies.cpp 2012-12-13 09:34:32 UTC (rev 555) @@ -221,7 +221,7 @@ } /* Take an HTTP_header_t, and insert the correct headers. The cookie files are read if necessary. */ -void HTTP_Header::cookies_set(const char *domain, const char *url) +void HTTP_Header::cookies_set(const std::string& domain, const std::string& url) { int found_cookies = 0; struct cookie_list_type *cookies[MAX_COOKIES]; @@ -230,7 +230,7 @@ const char *path; char *buf; - path = strchr(url, '/'); + path = strchr(url.c_str(), '/'); if (!path) path = ""; @@ -243,7 +243,7 @@ /* Find which cookies we want, removing duplicates. Cookies with the longest domain, then longest path take priority */ while (list) { /* Check the cookie domain and path. Also, we never send "secure" cookies. These should only be sent over HTTPS. */ - if ((right_hand_strcmp(list->domain, domain) == 0) + if ((right_hand_strcmp(list->domain, domain.c_str()) == 0) && (left_hand_strcmp(list->path, path) == 0) && !list->secure) { int replacing = 0; for (i = 0; i < found_cookies; i++) { Modified: mplayerxp/libmpstream2/http.cpp =================================================================== --- mplayerxp/libmpstream2/http.cpp 2012-12-13 07:22:44 UTC (rev 554) +++ mplayerxp/libmpstream2/http.cpp 2012-12-13 09:34:32 UTC (rev 555) @@ -21,18 +21,17 @@ namespace mpxp { HTTP_Header::HTTP_Header() {} HTTP_Header::~HTTP_Header() { - if( reason_phrase!=NULL ) delete reason_phrase ; if( buffer!=NULL ) delete buffer ; } -int HTTP_Header::response_append(const char *response, int length ) { - if( response==NULL || length<0 ) return -1; +int HTTP_Header::response_append(const uint8_t* response, size_t length ) { + if( response==NULL) return -1; if( (unsigned)length > std::numeric_limits<size_t>::max() - buffer_size - 1) { MSG_FATAL("Bad size in memory (re)allocation\n"); return -1; } - buffer = (char*)mp_realloc( buffer, buffer_size+length+1 ); + buffer = (uint8_t*)mp_realloc( buffer, buffer_size+length+1 ); if(buffer ==NULL ) { MSG_FATAL("Memory allocation failed\n"); return -1; @@ -46,8 +45,8 @@ int HTTP_Header::is_header_entire() const { if( buffer==NULL ) return 0; // empty - if( strstr(buffer, "\r\n\r\n")==NULL && - strstr(buffer, "\n\n")==NULL ) return 0; + if( strstr((char*)buffer, "\r\n\r\n")==NULL && + strstr((char*)buffer, "\n\n")==NULL ) return 0; return 1; } @@ -59,13 +58,13 @@ if( is_parsed ) return 0; // Get the protocol - hdr_ptr = strstr( buffer, " " ); + hdr_ptr = strstr( (char*)buffer, " " ); if( hdr_ptr==NULL ) { MSG_FATAL("Malformed answer. No space separator found.\n"); return -1; } - len = hdr_ptr-buffer; - protocol.assign(buffer,len); + len = hdr_ptr-(char*)buffer; + protocol.assign((char*)buffer,len); std::string sstr=protocol.substr(0,4); std::transform(sstr.begin(), sstr.end(),sstr.begin(), ::toupper); if(sstr=="HTTP") { @@ -89,32 +88,28 @@ return -1; } len = ptr-hdr_ptr; - reason_phrase = new char[len+1]; - if( reason_phrase==NULL ) { - MSG_FATAL("Memory allocation failed\n"); - return -1; - } - strncpy( reason_phrase, hdr_ptr, len ); + reason_phrase.assign(hdr_ptr, len); if( reason_phrase[len-1]=='\r' ) { len--; + reason_phrase.resize(len); } reason_phrase[len]='\0'; // Set the position of the header separator: \r\n\r\n hdr_sep_len = 4; - ptr = strstr( buffer, "\r\n\r\n" ); + ptr = strstr( (char*)buffer, "\r\n\r\n" ); if( ptr==NULL ) { - ptr = strstr( buffer, "\n\n" ); + ptr = strstr( (char*)buffer, "\n\n" ); if( ptr==NULL ) { MSG_ERR("Header may be incomplete. No CRLF CRLF found.\n"); return -1; } hdr_sep_len = 2; } - pos_hdr_sep = ptr-buffer; + pos_hdr_sep = ptr-(char*)buffer; // Point to the first line after the method line. - hdr_ptr = strstr( buffer, "\n" )+1; + hdr_ptr = strstr( (char*)buffer, "\n" )+1; do { ptr = hdr_ptr; while( *ptr!='\r' && *ptr!='\n' ) ptr++; @@ -129,14 +124,13 @@ field[len]='\0'; set_field( field ); hdr_ptr = ptr+((*ptr=='\r')?2:1); - } while( hdr_ptr<(buffer+pos_hdr_sep) ); + } while( hdr_ptr<((char*)buffer+pos_hdr_sep) ); if( field!=NULL ) delete field ; if( pos_hdr_sep+hdr_sep_len<buffer_size ) { // Response has data! - body = buffer+pos_hdr_sep+hdr_sep_len; - body_size = buffer_size-(pos_hdr_sep+hdr_sep_len); + body.assign((char*)buffer+pos_hdr_sep+hdr_sep_len,buffer_size-(pos_hdr_sep+hdr_sep_len)); } is_parsed = 1; @@ -159,15 +153,15 @@ // Add the CRLF len += 2; // Add the body - if( body!=NULL ) { - len += body_size; + if( !body.empty() ) { + len += body.length(); } // Free the buffer if it was previously used if( buffer!=NULL ) { delete buffer ; buffer = NULL; } - buffer = new char [len+1]; + buffer = new uint8_t [len+1]; if( buffer==NULL ) { MSG_FATAL("Memory allocation failed\n"); return NULL; @@ -175,21 +169,21 @@ buffer_size = len; //*** Building the request - ptr = buffer; + ptr = (char*)buffer; // Add the method line ptr += sprintf( ptr, "%s %s HTTP/1.%d\r\n", method.c_str(),uri.c_str(), http_minor_version ); // Add the field for(unsigned i=0;i<sz;i++) ptr += sprintf( ptr, "%s\r\n", fields[i].c_str()); ptr += sprintf( ptr, "\r\n" ); // Add the body - if( body!=NULL ) { - memcpy( ptr, body, body_size ); + if( !body.empty()) { + memcpy( ptr, body.c_str(), body.size()); } - return buffer; + return (char *)buffer; } -const char* HTTP_Header::get_field(const char *field_name ) { +const char* HTTP_Header::get_field(const std::string& field_name ) { search_pos=0; field_search=field_name; return get_next_field(); @@ -215,36 +209,34 @@ return NULL; } -void HTTP_Header::set_field(const char *field_name ) { - if( field_name==NULL ) return; +void HTTP_Header::set_field(const std::string& field_name ) { + if(field_name.empty()) return; fields.push_back(field_name); } -void HTTP_Header::set_method( const char *_method ) { - if( _method==NULL ) return; +void HTTP_Header::set_method( const std::string& _method ) { method=_method; } -void HTTP_Header::set_uri(const char *_uri ) { - if(_uri==NULL ) return; +void HTTP_Header::set_uri(const std::string& _uri ) { uri=_uri; } -int HTTP_Header::add_basic_authentication( const char *username, const char *password ) { +int HTTP_Header::add_basic_authentication( const std::string& username, const std::string& password ) { char *auth=NULL, *usr_pass=NULL, *b64_usr_pass=NULL; int encoded_len, pass_len=0, out_len; int res = -1; - if( username==NULL ) return -1; + if( username.empty() ) return -1; - if( password!=NULL ) pass_len = strlen(password); + if( !password.empty() ) pass_len = password.length(); - usr_pass = new char [strlen(username)+pass_len+2]; + usr_pass = new char [username.length()+pass_len+2]; if( usr_pass==NULL ) { MSG_FATAL("Memory allocation failed\n"); goto out; } - sprintf( usr_pass, "%s:%s", username, (password==NULL)?"":password ); + sprintf( usr_pass, "%s:%s", username.c_str(), password.c_str() ); // Base 64 encode with at least 33% more data than the original size encoded_len = strlen(usr_pass)*2; @@ -280,8 +272,7 @@ } void HTTP_Header::erase_body() { - body=NULL; - body_size=0; + body.clear(); } void HTTP_Header::debug_hdr( ) { @@ -300,8 +291,8 @@ ,uri.c_str() ,method.c_str() ,status_code - ,reason_phrase - ,body_size ); + ,reason_phrase.c_str() + ,body.length() ); MSG_V("Fields:\n"); std::vector<std::string>::size_type sz = fields.size(); Modified: mplayerxp/libmpstream2/http.h =================================================================== --- mplayerxp/libmpstream2/http.h 2012-12-13 07:22:44 UTC (rev 554) +++ mplayerxp/libmpstream2/http.h 2012-12-13 09:34:32 UTC (rev 555) @@ -10,6 +10,7 @@ #include <string> #include <vector> +#include <stdint.h> namespace mpxp { class HTTP_Header : public Opaque { @@ -17,33 +18,33 @@ HTTP_Header(); virtual ~HTTP_Header(); - virtual int response_append(const char *data, int length ); + virtual int response_append(const uint8_t* data,size_t length); virtual int response_parse(); virtual int is_header_entire() const; virtual const char* build_request(); - virtual const char* get_field(const char *field_name ); + virtual const char* get_field(const std::string& field_name ); virtual const char* get_next_field(); - virtual void set_field(const char *field_name ); - virtual void set_method(const char *method ); - virtual void set_uri(const char *uri ); - virtual int add_basic_authentication(const char *username, const char *password ); + virtual void set_field(const std::string& field_name ); + virtual void set_method(const std::string& method ); + virtual void set_uri(const std::string& uri ); + virtual int add_basic_authentication(const std::string& username, const std::string& password ); virtual void debug_hdr(); - virtual void cookies_set(const char *hostname, const char *url); + virtual void cookies_set(const std::string& hostname, const std::string& url); - const char* get_reason_phrase() const { return reason_phrase; } + const char* get_reason_phrase() const { return reason_phrase.c_str(); } const char* get_protocol() const { return protocol.c_str(); } unsigned get_status() const { return status_code; } - const char* get_body() const { return body; } - size_t get_body_size() const { return body_size; } + const char* get_body() const { return body.c_str(); } + size_t get_body_size() const { return body.length(); } virtual void erase_body(); - const char* get_buffer() const { return buffer; } + const uint8_t* get_buffer() const { return buffer; } size_t get_buffer_size() const { return buffer_size; } private: std::string protocol; std::string method; std::string uri; - char* reason_phrase; + std::string reason_phrase; unsigned int http_minor_version; // Field variables std::vector<std::string> fields; @@ -51,11 +52,10 @@ std::vector<std::string>::size_type search_pos; // Body variables unsigned int status_code; - char* body; - size_t body_size; + std::string body; unsigned int is_parsed; - char* buffer; - size_t buffer_size; + uint8_t* buffer; + unsigned buffer_size; }; extern int base64_encode(const any_t*enc, int encLen, char *out, int outMax); Modified: mplayerxp/libmpstream2/network.cpp =================================================================== --- mplayerxp/libmpstream2/network.cpp 2012-12-13 07:22:44 UTC (rev 554) +++ mplayerxp/libmpstream2/network.cpp 2012-12-13 09:34:32 UTC (rev 555) @@ -171,7 +171,7 @@ if (net_conf.cookies_enabled) http_hdr.cookies_set( server_url->hostname, server_url->url ); http_hdr.set_field( "Connection: closed"); - http_hdr.add_basic_authentication( url->username, url->password ); + http_hdr.add_basic_authentication( url->username?url->username:"", url->password?url->password:""); if( http_hdr.build_request( )==NULL ) { goto err_out; } @@ -207,13 +207,13 @@ HTTP_Header* http_read_response( Tcp& tcp ) { HTTP_Header* http_hdr = new(zeromem) HTTP_Header; - char response[BUFFER_SIZE]; + uint8_t response[BUFFER_SIZE]; int i; if( http_hdr==NULL ) return NULL; do { - i = tcp.read((uint8_t*)response, BUFFER_SIZE); + i = tcp.read(response, BUFFER_SIZE); if( i<0 ) { MSG_ERR("Read failed\n"); delete http_hdr; @@ -224,7 +224,7 @@ delete http_hdr; return NULL; } - http_hdr->response_append(response, i ); + http_hdr->response_append(response,i); } while( !http_hdr->is_header_entire() ); http_hdr->response_parse(); return http_hdr; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2012-12-13 11:45:35
|
Revision: 557 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=557&view=rev Author: nickols_k Date: 2012-12-13 11:45:25 +0000 (Thu, 13 Dec 2012) Log Message: ----------- split mplayer_opts from mplayerxp.cpp Modified Paths: -------------- mplayerxp/Makefile mplayerxp/libmpconf/cfgparser.h mplayerxp/mplayerxp.cpp mplayerxp/mplayerxp.h mplayerxp/postproc/af.h mplayerxp/postproc/vf.cpp mplayerxp/postproc/vf.h mplayerxp/xmpcore/Makefile Added Paths: ----------- mplayerxp/xmpcore/xmp_context.cpp mplayerxp/xmpcore/xmp_context.h Removed Paths: ------------- mplayerxp/cfg-mplayerxp.h mplayerxp/mp-opt-reg.cpp Modified: mplayerxp/Makefile =================================================================== --- mplayerxp/Makefile 2012-12-13 10:49:20 UTC (rev 556) +++ mplayerxp/Makefile 2012-12-13 11:45:25 UTC (rev 557) @@ -21,7 +21,7 @@ MANDIR = ${prefix}/man LDFLAGS += -Wl,-rpath,${CODECDIR}/codecs -SRCS = mplayerxp.cpp mp-opt-reg.cpp dump.cpp mp_msg.cpp +SRCS = mplayerxp.cpp dump.cpp mp_msg.cpp OBJS = $(SRCS:.cpp=.o) Deleted: mplayerxp/cfg-mplayerxp.h =================================================================== --- mplayerxp/cfg-mplayerxp.h 2012-12-13 10:49:20 UTC (rev 556) +++ mplayerxp/cfg-mplayerxp.h 2012-12-13 11:45:25 UTC (rev 557) @@ -1,266 +0,0 @@ -/* - * config for cfgparser - */ - -extern const char *oss_mixer_device; -#ifdef HAVE_SDL -//extern char *sdl_driver; -extern int sdl_noxv; -extern int sdl_forcexv; -extern int sdl_forcegl; -//extern char *sdl_adriver; -#endif - -extern af_cfg_t af_cfg; // Configuration for audio filters -extern vf_cfg_t vf_cfg; // Configuration for audio filters - -static const config_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"}, - {"nogomp", &mp_conf.gomp, CONF_TYPE_FLAG, 0, 1, 0, "disables usage of OpenMP extensions"}, - {"xp_buffs", &vo_conf.xp_buffs, CONF_TYPE_INT, CONF_RANGE, 4, 1024, "specifies number of buffers for decoding-ahead in XP mode"}, - {"cache", &mp_conf.s_cache_size, CONF_TYPE_INT, CONF_RANGE, 4, 65536, "specifies amount of memory for precaching a file/URL"}, - {"nocache", &mp_conf.s_cache_size, CONF_TYPE_FLAG, 0, 1, 0, "disables precaching a file/URL"}, - {"autoq", &mp_conf.autoq, CONF_TYPE_INT, CONF_RANGE, 0, 100, "dynamically changes the level of postprocessing depending on spare CPU time available"}, - {"speed", &mp_conf.playbackspeed_factor, CONF_TYPE_FLOAT, CONF_RANGE, 0.01, 100.0, "sets playback speed factor"}, - {"benchmark", &mp_conf.benchmark, CONF_TYPE_FLAG, 0, 0, 1, "performs benchmarking to estimate performance of MPlayerXP"}, - {"test-av", &mp_conf.test_av, CONF_TYPE_FLAG, 0, 0, 1, "test antiviral protection of MPlayerXP"}, - {"malloc-debug", &mp_conf.malloc_debug, CONF_TYPE_INT, CONF_RANGE, 0, 3, "debugs malloc() calls in MPlayerXP"}, - {"max-trace", &mp_conf.max_trace, CONF_TYPE_INT, CONF_RANGE, 1, 1024, "maximal number of backtrace stack"}, - {NULL, NULL, 0, 0, 0, 0, NULL}, -}; - -#ifdef HAVE_STREAMING -static const config_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"}, -#else - {"ipv6", "MPlayerXP was compiled without IPv6 support.\n", CONF_TYPE_PRINT, 0, 0, 0, NULL}, -#endif /* HAVE_AF_INET6 */ - {"ipv4-only-proxy", &net_conf.ipv4_only_proxy, CONF_TYPE_FLAG, 0, 0, 1, "skip the proxy for IPv6 addresses"}, - {"user", &net_conf.username, CONF_TYPE_STRING, 0, 0, 0, "specifies username for HTTP authentication"}, - {"passwd", &net_conf.password, CONF_TYPE_STRING, 0, 0, 0, "specifies password for HTTP authentication"}, - {"bandwidth", &net_conf.bandwidth, CONF_TYPE_INT, CONF_MIN, 0, 0, "specifies the maximum bandwidth for network streaming"}, - {"user-agent", &net_conf.useragent, CONF_TYPE_STRING, 0, 0, 0, "specifies string as user agent for HTTP streaming"}, - {"cookies", &net_conf.cookies_enabled, CONF_TYPE_FLAG, 0, 0, 1, "send cookies when making HTTP requests"}, - {"cookies-file", &net_conf.cookies_file, CONF_TYPE_STRING, 0, 0, 0, "Read HTTP cookies from file"}, - {NULL, NULL, 0, 0, 0, 0, NULL}, -}; -#endif - -#if defined( ARCH_X86 ) || defined(ARCH_X86_64) -static const config_t cpu_config[]={ - {"simd", &x86.simd, CONF_TYPE_FLAG, 0, 0, 1, "enables using of SIMD extensions of CPU"}, - {"nosimd", &x86.simd, CONF_TYPE_FLAG, 0, 1, 0, "disables using of SIMD extensions of CPU"}, - {"mmx", &x86.mmx, CONF_TYPE_FLAG, 0, 0, 1, "enables using of MMX extensions of CPU"}, - {"nommx", &x86.mmx, CONF_TYPE_FLAG, 0, 1, 0, "disables using of MMX extensions of CPU"}, - {"mmx2", &x86.mmx2, CONF_TYPE_FLAG, 0, 0, 1, "enables using of MMX2 extensions of CPU"}, - {"nommx2", &x86.mmx2, CONF_TYPE_FLAG, 0, 1, 0, "disables using of MMX2 extensions of CPU"}, - {"3dnow", &x86._3dnow, CONF_TYPE_FLAG, 0, 0, 1, "enables using of 3DNow! extensions of CPU"}, - {"no3dnow", &x86._3dnow, CONF_TYPE_FLAG, 0, 1, 0, "disables using of 3DNow! extensions of CPU"}, - {"3dnow2", &x86._3dnow2, CONF_TYPE_FLAG, 0, 0, 1, "enables using of 3DNow-2! extensions of CPU"}, - {"no3dnow2", &x86._3dnow2, CONF_TYPE_FLAG, 0, 1, 0, "disables using of 3DNow-2! extensions of CPU"}, - {"sse", &x86.sse, CONF_TYPE_FLAG, 0, 0, 1, "enables using of SSE extensions of CPU"}, - {"nosse", &x86.sse, CONF_TYPE_FLAG, 0, 1, 0, "disables using of SSE extensions of CPU"}, - {"sse2", &x86.sse2, CONF_TYPE_FLAG, 0, 0, 1, "enables using of SSE2 extensions of CPU"}, - {"nosse2", &x86.sse2, CONF_TYPE_FLAG, 0, 1, 0, "disables using of SSE2 extensions of CPU"}, - {"sse3", &x86.sse3, CONF_TYPE_FLAG, 0, 0, 1, "enables using of SSE3 extensions of CPU"}, - {"nosse3", &x86.sse3, CONF_TYPE_FLAG, 0, 1, 0, "disables using of SSE3 extensions of CPU"}, - {"ssse3", &x86.ssse3, CONF_TYPE_FLAG, 0, 0, 1, "enables using of SSSE3 extensions of CPU"}, - {"nossse3", &x86.ssse3, CONF_TYPE_FLAG, 0, 1, 0, "disables using of SSSE3 extensions of CPU"}, - {"sse41", &x86.sse41, CONF_TYPE_FLAG, 0, 0, 1, "enables using of SSE41 extensions of CPU"}, - {"nosse41", &x86.sse41, CONF_TYPE_FLAG, 0, 1, 0, "disables using of SSE41 extensions of CPU"}, - {"sse42", &x86.sse42, CONF_TYPE_FLAG, 0, 0, 1, "enables using of SSE42 extensions of CPU"}, - {"nosse42", &x86.sse42, CONF_TYPE_FLAG, 0, 1, 0, "disables using of SSE42 extensions of CPU"}, - {"aes", &x86.aes, CONF_TYPE_FLAG, 0, 0, 1, "enables using of AES extensions of CPU"}, - {"noaes", &x86.aes, CONF_TYPE_FLAG, 0, 1, 0, "disables using of AES extensions of CPU"}, - {"avx", &x86.avx, CONF_TYPE_FLAG, 0, 0, 1, "enables using of AVX extensions of CPU"}, - {"noavx", &x86.avx, CONF_TYPE_FLAG, 0, 1, 0, "disables using of AVX extensions of CPU"}, - {"fma", &x86.fma, CONF_TYPE_FLAG, 0, 0, 1, "enables using of FMA extensions of CPU"}, - {"nofma", &x86.fma, CONF_TYPE_FLAG, 0, 1, 0, "disables using of FMA extensions of CPU"}, - {NULL, NULL, 0, 0, 0, 0, NULL}, -}; -#endif - -static const config_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"}, - {"ffactor", &mp_conf.font_factor, CONF_TYPE_FLOAT, CONF_RANGE, 0.0, 10.0, "specifies resampling of alphamap of the font"}, - {"spualign", &spu_alignment, CONF_TYPE_INT, CONF_RANGE, -1, 2, "specifies align position of SPU (DVD-VOBsub) subtitles"}, - {"spuaa", &spu_aamode, CONF_TYPE_INT, CONF_RANGE, 0, 31, "specifies antialiasing/scaling mode for SPU"}, - {"spugauss", &spu_gaussvar, CONF_TYPE_FLOAT, CONF_RANGE, 0.0, 3.0, "specifies variance parameter of gaussian for -spuaa"}, -#endif - {NULL, NULL, 0, 0, 0, 0, NULL}, -}; - -static const config_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"}, - {"hue",&vo_conf.gamma.hue, CONF_TYPE_INT, CONF_RANGE, -1000, 1000, "specifies hue of gamma-correction for output image"}, - {"red",&vo_conf.gamma.red_intensity, CONF_TYPE_INT, CONF_RANGE, -1000, 1000, "specifies intensity of red component for output image"}, - {"green",&vo_conf.gamma.green_intensity, CONF_TYPE_INT, CONF_RANGE, -1000, 1000, "specifies intensity of green component for output image"}, - {"blue",&vo_conf.gamma.blue_intensity, CONF_TYPE_INT, CONF_RANGE, -1000, 1000, "specifies intensity of blue component for output image"}, - {NULL, NULL, 0, 0, 0, 0, NULL}, -}; - - -static const config_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"}, - {"pts", &mp_conf.av_sync_pts, CONF_TYPE_FLAG, 0, 0, 1, "use PTS-based method of A/V synchronization"}, - {"nopts", &mp_conf.av_sync_pts, CONF_TYPE_FLAG, 0, 1, 0, "use BPS-based method of A/V synchronization"}, - {"force_pts_fix", &mp_conf.av_force_pts_fix, CONF_TYPE_FLAG, 0, 0, 1, "force PTS fixing for \"bad\" files"}, - {"noforce_pts_fix", &mp_conf.av_force_pts_fix, CONF_TYPE_FLAG, 0, 1, 0, "disable PTS fixing for \"bad\" files"}, - {"force_pts_fix2", &mp_conf.av_force_pts_fix2, CONF_TYPE_FLAG, 0, 0, 1, "force PTS fixing for \"bad\" files without PTS changing"}, - {"noforce_pts_fix2", &mp_conf.av_force_pts_fix2, CONF_TYPE_FLAG, 0, 1, 0, "disable PTS fixing for \"bad\" files without PTS changing"}, - {"frame_reorder", &mp_conf.frame_reorder, CONF_TYPE_FLAG, 0, 0, 1, "recalc PTS of frames as they were added to the buffer"}, - {"noframe_reorder", &mp_conf.frame_reorder, CONF_TYPE_FLAG, 0, 1, 0, "keep original PTS of each frame"}, - {"softsleep", &mp_conf.softsleep, CONF_TYPE_FLAG, 0, 0, 1, "enables high quality software timers for A/V synchronization"}, -#ifdef HAVE_RTC - {"rtc", &mp_conf.nortc, CONF_TYPE_FLAG, 0, 1, 0, "enables using of /dev/rtc (real-time clock chip) to compute PTS"}, - {"nortc", &mp_conf.nortc, CONF_TYPE_FLAG, 0, 0, 1, "disables using of /dev/rtc (real-time clock chip) to compute PTS"}, -#endif - {"fps", &mp_conf.force_fps, CONF_TYPE_FLOAT, CONF_MIN, 0, 0, "forces frame rate (if value is wrong in the header)"}, - {"vsync", &vo_conf.vsync, CONF_TYPE_FLAG, 0, 0, 1, "forces video hardware to wait VSYNC signal before frame switching"}, - {"novsync", &vo_conf.vsync, CONF_TYPE_FLAG, 0, 1, 0, "disables video hardware to wait VSYNC signal before frame switching"}, - {NULL, NULL, 0, 0, 0, 0, NULL}, -}; - -static const config_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"}, - {"vobid", &mp_conf.vobsub_id, CONF_TYPE_INT, CONF_RANGE, 0, 31, "specifies the VobSub subtitle id"}, -#ifdef USE_SUB - {"file", &mp_conf.sub_name, CONF_TYPE_STRING, 0, 0, 0, "specifies the subtitle file"}, -#ifdef USE_ICONV - {"cp", &sub_data.cp, CONF_TYPE_STRING, 0, 0, 0, "specifies codepage of subtitles"}, -#endif - {"fps", &mp_conf.sub_fps, CONF_TYPE_FLOAT, 0, 0.0, 10.0, "specifies frame/sec rate of subtitle file"}, - {"noauto", &mp_conf.sub_auto, CONF_TYPE_FLAG, 0, 1, 0, "disable autodetection of vobsub for textsubs if vobsub found"}, - {"unicode", &sub_data.unicode, CONF_TYPE_FLAG, 0, 0, 1, "tells MPlayerXP to handle the subtitle file as UNICODE"}, - {"nounicode", &sub_data.unicode, CONF_TYPE_FLAG, 0, 1, 0, "tells MPlayerXP to handle the subtitle file as non-UNICODE"}, - {"utf8", &sub_data.utf8, CONF_TYPE_FLAG, 0, 0, 1, "tells MPlayerXP to handle the subtitle file as UTF8"}, - {"noutf8", &sub_data.utf8, CONF_TYPE_FLAG, 0, 1, 0, "tells MPlayerXP to handle the subtitle file as non-UTF8"}, - {"pos",&sub_data.pos, CONF_TYPE_INT, CONF_RANGE, 0, 100, "specifies vertical shift of subtitles"}, -#endif - {"cc", &mp_conf.subcc_enabled, CONF_TYPE_FLAG, 0, 0, 1, "enable DVD Closed Caption (CC) subtitles"}, - {"nocc", &mp_conf.subcc_enabled, CONF_TYPE_FLAG, 0, 1, 0, "disable DVD Closed Caption (CC) subtitles"}, - {"id", &mp_conf.dvdsub_id, CONF_TYPE_INT, CONF_RANGE, 0, 31, "selects subtitle channel"}, - {"lang", &mp_conf.dvdsub_lang, CONF_TYPE_STRING, 0, 0, 0, "specifies language of DVD-subtitle stream as two-letter country code(s)"}, - {"ifo", &mp_conf.spudec_ifo, CONF_TYPE_STRING, 0, 0, 0, "specifies .ifo file for DVD subtitles"}, - {NULL, NULL, 0, 0, 0, 0, NULL}, -}; - -#ifdef HAVE_X11 -static const config_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"}, -#endif - {NULL, NULL, 0, 0, 0, 0, NULL}, -}; -#endif - -static const config_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"}, - {"channels", &mp_conf.ao_channels, CONF_TYPE_INT, CONF_RANGE, 2, 8, "select number of audio output channels to be used"}, - {"rate", &mp_conf.force_srate, CONF_TYPE_INT, CONF_RANGE, 1000, 8*48000, "specifies Hz for audio playback"}, - {"lang", &mp_conf.audio_lang, CONF_TYPE_STRING, 0, 0, 0, "specifies language of DVD-audio stream as two-letter country code(s)"}, - {"id", &mp_conf.audio_id, CONF_TYPE_INT, CONF_RANGE, 0, 255, "selects audio channel"}, - {NULL, NULL, 0, 0, 0, 0, NULL}, -}; - -static const config_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)"}, - {"height", &vo_conf.image_height, CONF_TYPE_INT, CONF_RANGE, 0, 4096, "scale output image to height (if driver supports)"}, - {"zoom", &vo_conf.image_zoom, CONF_TYPE_FLOAT, CONF_RANGE, 0, 4096, "scale output image by given factor"}, - {"aspect", &vo_conf.movie_aspect, CONF_TYPE_FLOAT, CONF_RANGE, 0.2, 3.0, "sets aspect-ratio of movies (autodetect)"}, - {"noaspect", &vo_conf.movie_aspect, CONF_TYPE_FLAG, 0, 0, 0, "unsets aspect-ratio of movies"}, - {"aspect-ratio", &vo_conf.softzoom, CONF_TYPE_FLAG, 0, 0, 1, "keeps aspect-ratio of the movie during window resize"}, - {"noaspect-ratio", &vo_conf.softzoom, CONF_TYPE_FLAG, 0, 1, 0, "render movie to the user-defined window's geometry"}, - {"monitorpixelaspect", &mp_conf.monitor_pixel_aspect, CONF_TYPE_FLOAT, CONF_RANGE, 0.2, 9.0, "sets the aspect-ratio of a single pixel of TV screen"}, - {"vm", &vo_conf.vidmode, CONF_TYPE_FLAG, 0, 0, 1, "enables video-mode changing during playback"}, - {"novm", &vo_conf.vidmode, CONF_TYPE_FLAG, 0, 1, 0, "disables video-mode changing during playback"}, - {"fs", &vo_conf.fullscreen, CONF_TYPE_FLAG, 0, 0, 1, "fullscreen playback"}, - {"nofs", &vo_conf.fullscreen, CONF_TYPE_FLAG, 0, 1, 0, "windowed playback"}, - {"fsmode", &vo_conf.fsmode, CONF_TYPE_INT, CONF_RANGE, 0, 15, "enables workaround for some fullscreen related problems"}, - {"flip", &vo_conf.flip, CONF_TYPE_FLAG, 0, -1, 1, "flip output image upside-down"}, - {"noflip", &vo_conf.flip, CONF_TYPE_FLAG, 0, -1, 0, "render output image as is"}, - {"bpp", &vo_conf.dbpp, CONF_TYPE_INT, CONF_RANGE, 0, 32, "use different color depth than autodetect"}, - {"bm", &vo_conf.use_bm, CONF_TYPE_FLAG, 0, 0, 1, "enables using of bus-mastering (if it available for given OS/videocard)"}, - {"bm2", &vo_conf.use_bm, CONF_TYPE_FLAG, 0, 0, 2, "enables using of bus-mastering to store all decoded-ahead frames in video-memory"}, - {"nobm", &vo_conf.use_bm, CONF_TYPE_FLAG, 0, 1, 0, "disables using of bus-mastering"}, - {"id", &mp_conf.video_id, CONF_TYPE_INT, CONF_RANGE, 0, 255, "selects video channel"}, - {"pp", &mp_conf.npp_options, CONF_TYPE_STRING, 0, 0, 0, "specifies options of post-processing"}, -#ifdef HAVE_PNG - {"z", &mp_conf.z_compression, CONF_TYPE_INT, CONF_RANGE, 0, 9, "specifies compression level for PNG output"}, -#endif -#ifdef HAVE_SDL - {"noxv", &sdl_noxv, CONF_TYPE_FLAG, 0, 0, 1, "disable XVideo hardware acceleration for SDL"}, - {"forcexv", &sdl_forcexv, CONF_TYPE_FLAG, 0, 0, 1, "force XVideo hardware acceleration for SDL"}, - {"forcegl", &sdl_forcegl, CONF_TYPE_FLAG, 0, 0, 1, "force OpenGL hardware acceleration for SDL"}, -#endif - {"eq",(any_t*)&veq_config, CONF_TYPE_SUBCONFIG, 0, 0, 0, "Video-equalizer specific options"}, - {NULL, NULL, 0, 0, 0, 0, NULL}, -}; - -static const config_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"}, - {"noloop", &mp_conf.loop_times, CONF_TYPE_FLAG, 0, 0, -1, "disable loop of playback"}, - {"shuffle",&mp_conf.shuffle_playback, CONF_TYPE_FLAG, 0, 0, 1, "play files in random order"}, - {"noshuffle",&mp_conf.shuffle_playback, CONF_TYPE_FLAG, 0, 1, 0, "play files in regular order"}, - {"list", NULL, CONF_TYPE_STRING, 0, 0, 0, "specifies playlist (1 file/row or Winamp or ASX format)"}, - {"frames", &mp_conf.play_n_frames, CONF_TYPE_INT, CONF_MIN, 0, 0, "play given number of frames and exit"}, - {NULL, NULL, 0, 0, 0, 0, NULL}, -}; - - -static const config_t mplayer_opts[]={ - /* 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!!! */ - -//---------------------- libao/libvo/mplayer options ------------------------ - {"vo", &mp_conf.video_driver, CONF_TYPE_STRING, 0, 0, 0, "select video output driver and optinaly device"}, - {"ao", &mp_conf.audio_driver, CONF_TYPE_STRING, 0, 0, 0, "select audio output driver and optinaly device"}, - {"af", &af_cfg.list, CONF_TYPE_STRING, 0, 0, 0, "selects audio filter"}, - {"vf", &vf_cfg.list, CONF_TYPE_STRING, 0, 0, 0, "selects video filter"}, - {"afm", &mp_conf.audio_family, CONF_TYPE_STRING, 0, 0, 0, "forces usage of specified audio-decoders family"}, - {"vfm", &mp_conf.video_family, CONF_TYPE_STRING, 0, 0, 0, "forces usage of specified video-decoders family"}, - {"ac", &mp_conf.audio_codec, CONF_TYPE_STRING, 0, 0, 0, "forces usage of specified audio-decoder"}, - {"vc", &mp_conf.video_codec, CONF_TYPE_STRING, 0, 0, 0, "forces usage of specified video-decoder"}, -/*UD*/ {"verbose", &mp_conf.verbose, CONF_TYPE_INT, CONF_RANGE|CONF_GLOBAL, 0, 100, "verbose output"}, - {"v", &mp_conf.verbose, CONF_TYPE_INC, 0, 0, 0, "verbose output (more -v means more verbosity)"}, - {"msgfilter", &mp_conf.msg_filter, CONF_TYPE_INT, CONF_RANGE, 0, 0xFFFFFFFF, "specifies filter for verbosed messages"}, - - {"core", (any_t*)&xpcore_config, CONF_TYPE_SUBCONFIG, 0, 0, 0, "XP-core related options" }, - {"play", (any_t*)&playback_config, CONF_TYPE_SUBCONFIG, 0, 0, 0, "Playback specific options" }, - {"audio", (any_t*)&audio_config, CONF_TYPE_SUBCONFIG, 0, 0, 0, "Audio related options" }, - {"video", (any_t*)&video_config, CONF_TYPE_SUBCONFIG, 0, 0, 0, "Video related options" }, - {"sub", (any_t*)&subtitle_config, CONF_TYPE_SUBCONFIG, 0, 0, 0, "Subtitle related options" }, -#ifdef HAVE_X11 - {"x", (any_t*)&x11_config, CONF_TYPE_SUBCONFIG, 0, 0, 0, "X11-specific options" }, -#endif - {"osd", (any_t*)&osd_config, CONF_TYPE_SUBCONFIG, 0, 0, 0, "OSD-related options"}, - {"sync", (any_t*)&avsync_config, CONF_TYPE_SUBCONFIG, 0, 0, 0, "AV-synchronization related options" }, -#if defined( ARCH_X86 ) || defined(ARCH_X86_64) - {"cpu", (any_t*)&cpu_config, CONF_TYPE_SUBCONFIG, 0, 0, 0, "CPU specific options" }, -#endif -// ------------------------- stream options -------------------- -#ifdef HAVE_STREAMING - { "net", (any_t*)&net_config, CONF_TYPE_SUBCONFIG, 0, 0, 0, "Network specific options" }, -#endif -// ------------------------- codec/pp options -------------------- - {NULL, NULL, 0, 0, 0, 0, NULL} -}; Modified: mplayerxp/libmpconf/cfgparser.h =================================================================== --- mplayerxp/libmpconf/cfgparser.h 2012-12-13 10:49:20 UTC (rev 556) +++ mplayerxp/libmpconf/cfgparser.h 2012-12-13 11:45:25 UTC (rev 557) @@ -37,15 +37,12 @@ CONF_GLOBAL =(1<<4), CONF_NOSAVE =(1<<5) }; -typedef struct config config_t; typedef struct m_config m_config_t; typedef struct config_save config_save_t; #include "libplaytree/playtree.h" -typedef void (*cfg_default_func_t)(config_t *,const char*); - -struct config { +struct config_t { const char *name; any_t* const p; unsigned int type; @@ -53,6 +50,7 @@ float min,max; const char *help; }; +typedef void (*cfg_default_func_t)(config_t*,const char*); struct m_config { m_config(libinput_t& _libinput):libinput(_libinput) {} Deleted: mplayerxp/mp-opt-reg.cpp =================================================================== --- mplayerxp/mp-opt-reg.cpp 2012-12-13 10:49:20 UTC (rev 556) +++ mplayerxp/mp-opt-reg.cpp 2012-12-13 11:45:25 UTC (rev 557) @@ -1,33 +0,0 @@ -#include "mp_config.h" -#include "osdep/mplib.h" -using namespace mpxp; -#include <stdlib.h> -#include <stdio.h> - -#include "libmpstream2/stream.h" -#include "libmpconf/cfgparser.h" - - -extern void libmpcodecs_ad_register_options(m_config_t* cfg); -extern void libmpcodecs_vd_register_options(m_config_t* cfg); - -namespace mpxp { -#ifdef HAVE_LIBCDIO -extern void cdda_register_options(m_config_t* 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) -{ - mp_input_register_options(cfg); - libmpdemux_register_options(cfg); - demuxer_register_options(cfg); -#ifdef HAVE_LIBCDIO - cdda_register_options(cfg); -#endif - libmpcodecs_ad_register_options(cfg); - libmpcodecs_vd_register_options(cfg); -} - -} // namespace mpxp Modified: mplayerxp/mplayerxp.cpp =================================================================== --- mplayerxp/mplayerxp.cpp 2012-12-13 10:49:20 UTC (rev 556) +++ mplayerxp/mplayerxp.cpp 2012-12-13 11:45:25 UTC (rev 557) @@ -35,25 +35,18 @@ #include "help_mp.h" #include "libmpstream2/stream.h" -#include "libmpstream2/network.h" #include "libmpdemux/demuxer.h" -#include "libmpconf/cfgparser.h" #include "libmpconf/codec-cfg.h" #include "libmpcodecs/dec_video.h" #include "libmpcodecs/dec_audio.h" -#ifdef USE_SUB -#include "libmpsub/subreader.h" -#endif #include "libmpsub/spudec.h" #include "libmpsub/vobsub.h" #include "libvo2/video_out.h" - #include "libao2/audio_out.h" -#include "libao2/afmt.h" #include "osdep/get_path.h" #include "osdep/cpudetect.h" @@ -70,6 +63,7 @@ #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" @@ -78,31 +72,9 @@ Private data **************************************************************************/ static volatile char antiviral_hole1[__VM_PAGE_SIZE__] __PAGE_ALIGNED__; -#if defined( ARCH_X86 ) || defined(ARCH_X86_64) -typedef struct x86_features_s { - int simd; - int mmx; - int mmx2; - int _3dnow; - int _3dnow2; - int sse; - int sse2; - int sse3; - int ssse3; - int sse41; - int sse42; - int aes; - int avx; - int fma; -}x86_features_t; -static x86_features_t x86; -#endif -} -#include "cfg-mplayerxp.h" /************************************************************************** Config file **************************************************************************/ -namespace mpxp { enum { INITED_VO =0x00000001, INITED_AO =0x00000002, @@ -296,7 +268,7 @@ static void mpxp_init_structs(void) { #if defined( ARCH_X86 ) || defined(ARCH_X86_64) - memset(&x86,-1,sizeof(x86_features_t)); + memset(&mp_conf.x86,-1,sizeof(x86_features_t)); #endif } @@ -510,20 +482,20 @@ { GetCpuCaps(&gCpuCaps); - if(x86.simd) { - if(x86.mmx != -1) gCpuCaps.hasMMX=x86.mmx; - if(x86.mmx2 != -1) gCpuCaps.hasMMX2=x86.mmx2; - if(x86._3dnow != -1) gCpuCaps.has3DNow=x86._3dnow; - if(x86._3dnow2 != -1) gCpuCaps.has3DNowExt=x86._3dnow2; - if(x86.sse != -1) gCpuCaps.hasSSE=x86.sse; - if(x86.sse2 != -1) gCpuCaps.hasSSE2=x86.sse2; - if(x86.sse3 != -1) gCpuCaps.hasSSE2=x86.sse3; - if(x86.ssse3 != -1) gCpuCaps.hasSSSE3=x86.ssse3; - if(x86.sse41 != -1) gCpuCaps.hasSSE41=x86.sse41; - if(x86.sse42 != -1) gCpuCaps.hasSSE42=x86.sse42; - if(x86.aes != -1) gCpuCaps.hasAES=x86.aes; - if(x86.avx != -1) gCpuCaps.hasAVX=x86.avx; - if(x86.fma != -1) gCpuCaps.hasFMA=x86.fma; + 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= Modified: mplayerxp/mplayerxp.h =================================================================== --- mplayerxp/mplayerxp.h 2012-12-13 10:49:20 UTC (rev 556) +++ mplayerxp/mplayerxp.h 2012-12-13 11:45:25 UTC (rev 557) @@ -32,6 +32,25 @@ Module_MPContext }; +#if defined( ARCH_X86 ) || defined(ARCH_X86_64) + struct x86_features_t { + int simd; + int mmx; + int mmx2; + int _3dnow; + int _3dnow2; + int sse; + int sse2; + int sse3; + int ssse3; + int sse41; + int sse42; + int aes; + int avx; + int fma; + }; +#endif + struct MP_Config { MP_Config(); ~MP_Config() {} @@ -98,6 +117,9 @@ unsigned ao_channels; int z_compression; float monitor_pixel_aspect; +#if defined( ARCH_X86 ) || defined(ARCH_X86_64) + x86_features_t x86; +#endif }; extern MP_Config mp_conf; Modified: mplayerxp/postproc/af.h =================================================================== --- mplayerxp/postproc/af.h 2012-12-13 10:49:20 UTC (rev 556) +++ mplayerxp/postproc/af.h 2012-12-13 11:45:25 UTC (rev 557) @@ -73,6 +73,7 @@ char* list; /* list of names of filters that are added to filter list during first initialization of stream */ }; +extern af_cfg_t af_cfg; // Configuration for audio filters struct af_instance_t; // Current audio stream Modified: mplayerxp/postproc/vf.cpp =================================================================== --- mplayerxp/postproc/vf.cpp 2012-12-13 10:49:20 UTC (rev 556) +++ mplayerxp/postproc/vf.cpp 2012-12-13 11:45:25 UTC (rev 557) @@ -456,7 +456,6 @@ } } -extern vf_cfg_t vf_cfg; vf_instance_t* __FASTCALL__ vf_init_filter(libinput_t& libinput,const vf_conf_t* conf) { char *vf_last=NULL,*vf_name=vf_cfg.list; @@ -759,4 +758,5 @@ vf_instance_t* first=s->first; return first->info->name; } +vf_cfg_t vf_cfg; } // namespace mpxp Modified: mplayerxp/postproc/vf.h =================================================================== --- mplayerxp/postproc/vf.h 2012-12-13 10:49:20 UTC (rev 556) +++ mplayerxp/postproc/vf.h 2012-12-13 11:45:25 UTC (rev 557) @@ -38,6 +38,7 @@ char* list; /* list of names of filters that are added to filter list during first initialization of stream */ }; + extern vf_cfg_t vf_cfg; // Configuration for audio filters struct vf_conf_t { unsigned w; Modified: mplayerxp/xmpcore/Makefile =================================================================== --- mplayerxp/xmpcore/Makefile 2012-12-13 10:49:20 UTC (rev 556) +++ mplayerxp/xmpcore/Makefile 2012-12-13 11:45:25 UTC (rev 557) @@ -2,7 +2,13 @@ LIBNAME = libxmpcore.a -SRCS=xmp_core.cpp xmp_aplayer.cpp xmp_vplayer.cpp xmp_vdecoder.cpp xmp_adecoder.cpp +SRCS=xmp_context.cpp \ + xmp_core.cpp \ + xmp_aplayer.cpp \ + xmp_vplayer.cpp \ + xmp_vdecoder.cpp \ + xmp_adecoder.cpp + SRCS+=sig_hand.cpp mp_image.cpp mp_aframe.cpp OBJS=$(SRCS:.cpp=.o) Added: mplayerxp/xmpcore/xmp_context.cpp =================================================================== --- mplayerxp/xmpcore/xmp_context.cpp (rev 0) +++ mplayerxp/xmpcore/xmp_context.cpp 2012-12-13 11:45:25 UTC (rev 557) @@ -0,0 +1,297 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; + +#include "mplayerxp.h" +#include "xmp_context.h" +#include "libmpconf/cfgparser.h" +#include "postproc/af.h" +#include "postproc/vf.h" +#include "libmpsub/spudec.h" +#include "libmpstream2/network.h" + +extern const char *oss_mixer_device; +#ifdef HAVE_SDL +//extern char *sdl_driver; +extern int sdl_noxv; +extern int sdl_forcexv; +extern int sdl_forcegl; +//extern char *sdl_adriver; +#endif + +namespace mpxp { +static const config_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"}, + {"nogomp", &mp_conf.gomp, CONF_TYPE_FLAG, 0, 1, 0, "disables usage of OpenMP extensions"}, + {"xp_buffs", &vo_conf.xp_buffs, CONF_TYPE_INT, CONF_RANGE, 4, 1024, "specifies number of buffers for decoding-ahead in XP mode"}, + {"cache", &mp_conf.s_cache_size, CONF_TYPE_INT, CONF_RANGE, 4, 65536, "specifies amount of memory for precaching a file/URL"}, + {"nocache", &mp_conf.s_cache_size, CONF_TYPE_FLAG, 0, 1, 0, "disables precaching a file/URL"}, + {"autoq", &mp_conf.autoq, CONF_TYPE_INT, CONF_RANGE, 0, 100, "dynamically changes the level of postprocessing depending on spare CPU time available"}, + {"speed", &mp_conf.playbackspeed_factor, CONF_TYPE_FLOAT, CONF_RANGE, 0.01, 100.0, "sets playback speed factor"}, + {"benchmark", &mp_conf.benchmark, CONF_TYPE_FLAG, 0, 0, 1, "performs benchmarking to estimate performance of MPlayerXP"}, + {"test-av", &mp_conf.test_av, CONF_TYPE_FLAG, 0, 0, 1, "test antiviral protection of MPlayerXP"}, + {"malloc-debug", &mp_conf.malloc_debug, CONF_TYPE_INT, CONF_RANGE, 0, 3, "debugs malloc() calls in MPlayerXP"}, + {"max-trace", &mp_conf.max_trace, CONF_TYPE_INT, CONF_RANGE, 1, 1024, "maximal number of backtrace stack"}, + {NULL, NULL, 0, 0, 0, 0, NULL}, +}; + +#ifdef HAVE_STREAMING +static const config_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"}, +#else + {"ipv6", "MPlayerXP was compiled without IPv6 support.\n", CONF_TYPE_PRINT, 0, 0, 0, NULL}, +#endif /* HAVE_AF_INET6 */ + {"ipv4-only-proxy", &net_conf.ipv4_only_proxy, CONF_TYPE_FLAG, 0, 0, 1, "skip the proxy for IPv6 addresses"}, + {"user", &net_conf.username, CONF_TYPE_STRING, 0, 0, 0, "specifies username for HTTP authentication"}, + {"passwd", &net_conf.password, CONF_TYPE_STRING, 0, 0, 0, "specifies password for HTTP authentication"}, + {"bandwidth", &net_conf.bandwidth, CONF_TYPE_INT, CONF_MIN, 0, 0, "specifies the maximum bandwidth for network streaming"}, + {"user-agent", &net_conf.useragent, CONF_TYPE_STRING, 0, 0, 0, "specifies string as user agent for HTTP streaming"}, + {"cookies", &net_conf.cookies_enabled, CONF_TYPE_FLAG, 0, 0, 1, "send cookies when making HTTP requests"}, + {"cookies-file", &net_conf.cookies_file, CONF_TYPE_STRING, 0, 0, 0, "Read HTTP cookies from file"}, + {NULL, NULL, 0, 0, 0, 0, NULL}, +}; +#endif + +#if defined( ARCH_X86 ) || defined(ARCH_X86_64) +static const config_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"}, + {"nommx", &mp_conf.x86.mmx, CONF_TYPE_FLAG, 0, 1, 0, "disables using of MMX extensions of CPU"}, + {"mmx2", &mp_conf.x86.mmx2, CONF_TYPE_FLAG, 0, 0, 1, "enables using of MMX2 extensions of CPU"}, + {"nommx2", &mp_conf.x86.mmx2, CONF_TYPE_FLAG, 0, 1, 0, "disables using of MMX2 extensions of CPU"}, + {"3dnow", &mp_conf.x86._3dnow, CONF_TYPE_FLAG, 0, 0, 1, "enables using of 3DNow! extensions of CPU"}, + {"no3dnow", &mp_conf.x86._3dnow, CONF_TYPE_FLAG, 0, 1, 0, "disables using of 3DNow! extensions of CPU"}, + {"3dnow2", &mp_conf.x86._3dnow2, CONF_TYPE_FLAG, 0, 0, 1, "enables using of 3DNow-2! extensions of CPU"}, + {"no3dnow2", &mp_conf.x86._3dnow2, CONF_TYPE_FLAG, 0, 1, 0, "disables using of 3DNow-2! extensions of CPU"}, + {"sse", &mp_conf.x86.sse, CONF_TYPE_FLAG, 0, 0, 1, "enables using of SSE extensions of CPU"}, + {"nosse", &mp_conf.x86.sse, CONF_TYPE_FLAG, 0, 1, 0, "disables using of SSE extensions of CPU"}, + {"sse2", &mp_conf.x86.sse2, CONF_TYPE_FLAG, 0, 0, 1, "enables using of SSE2 extensions of CPU"}, + {"nosse2", &mp_conf.x86.sse2, CONF_TYPE_FLAG, 0, 1, 0, "disables using of SSE2 extensions of CPU"}, + {"sse3", &mp_conf.x86.sse3, CONF_TYPE_FLAG, 0, 0, 1, "enables using of SSE3 extensions of CPU"}, + {"nosse3", &mp_conf.x86.sse3, CONF_TYPE_FLAG, 0, 1, 0, "disables using of SSE3 extensions of CPU"}, + {"ssse3", &mp_conf.x86.ssse3, CONF_TYPE_FLAG, 0, 0, 1, "enables using of SSSE3 extensions of CPU"}, + {"nossse3", &mp_conf.x86.ssse3, CONF_TYPE_FLAG, 0, 1, 0, "disables using of SSSE3 extensions of CPU"}, + {"sse41", &mp_conf.x86.sse41, CONF_TYPE_FLAG, 0, 0, 1, "enables using of SSE41 extensions of CPU"}, + {"nosse41", &mp_conf.x86.sse41, CONF_TYPE_FLAG, 0, 1, 0, "disables using of SSE41 extensions of CPU"}, + {"sse42", &mp_conf.x86.sse42, CONF_TYPE_FLAG, 0, 0, 1, "enables using of SSE42 extensions of CPU"}, + {"nosse42", &mp_conf.x86.sse42, CONF_TYPE_FLAG, 0, 1, 0, "disables using of SSE42 extensions of CPU"}, + {"aes", &mp_conf.x86.aes, CONF_TYPE_FLAG, 0, 0, 1, "enables using of AES extensions of CPU"}, + {"noaes", &mp_conf.x86.aes, CONF_TYPE_FLAG, 0, 1, 0, "disables using of AES extensions of CPU"}, + {"avx", &mp_conf.x86.avx, CONF_TYPE_FLAG, 0, 0, 1, "enables using of AVX extensions of CPU"}, + {"noavx", &mp_conf.x86.avx, CONF_TYPE_FLAG, 0, 1, 0, "disables using of AVX extensions of CPU"}, + {"fma", &mp_conf.x86.fma, CONF_TYPE_FLAG, 0, 0, 1, "enables using of FMA extensions of CPU"}, + {"nofma", &mp_conf.x86.fma, CONF_TYPE_FLAG, 0, 1, 0, "disables using of FMA extensions of CPU"}, + {NULL, NULL, 0, 0, 0, 0, NULL}, +}; +#endif + +static const config_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"}, + {"ffactor", &mp_conf.font_factor, CONF_TYPE_FLOAT, CONF_RANGE, 0.0, 10.0, "specifies resampling of alphamap of the font"}, + {"spualign", &spu_alignment, CONF_TYPE_INT, CONF_RANGE, -1, 2, "specifies align position of SPU (DVD-VOBsub) subtitles"}, + {"spuaa", &spu_aamode, CONF_TYPE_INT, CONF_RANGE, 0, 31, "specifies antialiasing/scaling mode for SPU"}, + {"spugauss", &spu_gaussvar, CONF_TYPE_FLOAT, CONF_RANGE, 0.0, 3.0, "specifies variance parameter of gaussian for -spuaa"}, +#endif + {NULL, NULL, 0, 0, 0, 0, NULL}, +}; + +static const config_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"}, + {"hue",&vo_conf.gamma.hue, CONF_TYPE_INT, CONF_RANGE, -1000, 1000, "specifies hue of gamma-correction for output image"}, + {"red",&vo_conf.gamma.red_intensity, CONF_TYPE_INT, CONF_RANGE, -1000, 1000, "specifies intensity of red component for output image"}, + {"green",&vo_conf.gamma.green_intensity, CONF_TYPE_INT, CONF_RANGE, -1000, 1000, "specifies intensity of green component for output image"}, + {"blue",&vo_conf.gamma.blue_intensity, CONF_TYPE_INT, CONF_RANGE, -1000, 1000, "specifies intensity of blue component for output image"}, + {NULL, NULL, 0, 0, 0, 0, NULL}, +}; + + +static const config_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"}, + {"pts", &mp_conf.av_sync_pts, CONF_TYPE_FLAG, 0, 0, 1, "use PTS-based method of A/V synchronization"}, + {"nopts", &mp_conf.av_sync_pts, CONF_TYPE_FLAG, 0, 1, 0, "use BPS-based method of A/V synchronization"}, + {"force_pts_fix", &mp_conf.av_force_pts_fix, CONF_TYPE_FLAG, 0, 0, 1, "force PTS fixing for \"bad\" files"}, + {"noforce_pts_fix", &mp_conf.av_force_pts_fix, CONF_TYPE_FLAG, 0, 1, 0, "disable PTS fixing for \"bad\" files"}, + {"force_pts_fix2", &mp_conf.av_force_pts_fix2, CONF_TYPE_FLAG, 0, 0, 1, "force PTS fixing for \"bad\" files without PTS changing"}, + {"noforce_pts_fix2", &mp_conf.av_force_pts_fix2, CONF_TYPE_FLAG, 0, 1, 0, "disable PTS fixing for \"bad\" files without PTS changing"}, + {"frame_reorder", &mp_conf.frame_reorder, CONF_TYPE_FLAG, 0, 0, 1, "recalc PTS of frames as they were added to the buffer"}, + {"noframe_reorder", &mp_conf.frame_reorder, CONF_TYPE_FLAG, 0, 1, 0, "keep original PTS of each frame"}, + {"softsleep", &mp_conf.softsleep, CONF_TYPE_FLAG, 0, 0, 1, "enables high quality software timers for A/V synchronization"}, +#ifdef HAVE_RTC + {"rtc", &mp_conf.nortc, CONF_TYPE_FLAG, 0, 1, 0, "enables using of /dev/rtc (real-time clock chip) to compute PTS"}, + {"nortc", &mp_conf.nortc, CONF_TYPE_FLAG, 0, 0, 1, "disables using of /dev/rtc (real-time clock chip) to compute PTS"}, +#endif + {"fps", &mp_conf.force_fps, CONF_TYPE_FLOAT, CONF_MIN, 0, 0, "forces frame rate (if value is wrong in the header)"}, + {"vsync", &vo_conf.vsync, CONF_TYPE_FLAG, 0, 0, 1, "forces video hardware to wait VSYNC signal before frame switching"}, + {"novsync", &vo_conf.vsync, CONF_TYPE_FLAG, 0, 1, 0, "disables video hardware to wait VSYNC signal before frame switching"}, + {NULL, NULL, 0, 0, 0, 0, NULL}, +}; + +static const config_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"}, + {"vobid", &mp_conf.vobsub_id, CONF_TYPE_INT, CONF_RANGE, 0, 31, "specifies the VobSub subtitle id"}, +#ifdef USE_SUB + {"file", &mp_conf.sub_name, CONF_TYPE_STRING, 0, 0, 0, "specifies the subtitle file"}, +#ifdef USE_ICONV + {"cp", &sub_data.cp, CONF_TYPE_STRING, 0, 0, 0, "specifies codepage of subtitles"}, +#endif + {"fps", &mp_conf.sub_fps, CONF_TYPE_FLOAT, 0, 0.0, 10.0, "specifies frame/sec rate of subtitle file"}, + {"noauto", &mp_conf.sub_auto, CONF_TYPE_FLAG, 0, 1, 0, "disable autodetection of vobsub for textsubs if vobsub found"}, + {"unicode", &sub_data.unicode, CONF_TYPE_FLAG, 0, 0, 1, "tells MPlayerXP to handle the subtitle file as UNICODE"}, + {"nounicode", &sub_data.unicode, CONF_TYPE_FLAG, 0, 1, 0, "tells MPlayerXP to handle the subtitle file as non-UNICODE"}, + {"utf8", &sub_data.utf8, CONF_TYPE_FLAG, 0, 0, 1, "tells MPlayerXP to handle the subtitle file as UTF8"}, + {"noutf8", &sub_data.utf8, CONF_TYPE_FLAG, 0, 1, 0, "tells MPlayerXP to handle the subtitle file as non-UTF8"}, + {"pos",&sub_data.pos, CONF_TYPE_INT, CONF_RANGE, 0, 100, "specifies vertical shift of subtitles"}, +#endif + {"cc", &mp_conf.subcc_enabled, CONF_TYPE_FLAG, 0, 0, 1, "enable DVD Closed Caption (CC) subtitles"}, + {"nocc", &mp_conf.subcc_enabled, CONF_TYPE_FLAG, 0, 1, 0, "disable DVD Closed Caption (CC) subtitles"}, + {"id", &mp_conf.dvdsub_id, CONF_TYPE_INT, CONF_RANGE, 0, 31, "selects subtitle channel"}, + {"lang", &mp_conf.dvdsub_lang, CONF_TYPE_STRING, 0, 0, 0, "specifies language of DVD-subtitle stream as two-letter country code(s)"}, + {"ifo", &mp_conf.spudec_ifo, CONF_TYPE_STRING, 0, 0, 0, "specifies .ifo file for DVD subtitles"}, + {NULL, NULL, 0, 0, 0, 0, NULL}, +}; + +#ifdef HAVE_X11 +static const config_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"}, +#endif + {NULL, NULL, 0, 0, 0, 0, NULL}, +}; +#endif + +static const config_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"}, + {"channels", &mp_conf.ao_channels, CONF_TYPE_INT, CONF_RANGE, 2, 8, "select number of audio output channels to be used"}, + {"rate", &mp_conf.force_srate, CONF_TYPE_INT, CONF_RANGE, 1000, 8*48000, "specifies Hz for audio playback"}, + {"lang", &mp_conf.audio_lang, CONF_TYPE_STRING, 0, 0, 0, "specifies language of DVD-audio stream as two-letter country code(s)"}, + {"id", &mp_conf.audio_id, CONF_TYPE_INT, CONF_RANGE, 0, 255, "selects audio channel"}, + {NULL, NULL, 0, 0, 0, 0, NULL}, +}; + +static const config_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)"}, + {"height", &vo_conf.image_height, CONF_TYPE_INT, CONF_RANGE, 0, 4096, "scale output image to height (if driver supports)"}, + {"zoom", &vo_conf.image_zoom, CONF_TYPE_FLOAT, CONF_RANGE, 0, 4096, "scale output image by given factor"}, + {"aspect", &vo_conf.movie_aspect, CONF_TYPE_FLOAT, CONF_RANGE, 0.2, 3.0, "sets aspect-ratio of movies (autodetect)"}, + {"noaspect", &vo_conf.movie_aspect, CONF_TYPE_FLAG, 0, 0, 0, "unsets aspect-ratio of movies"}, + {"aspect-ratio", &vo_conf.softzoom, CONF_TYPE_FLAG, 0, 0, 1, "keeps aspect-ratio of the movie during window resize"}, + {"noaspect-ratio", &vo_conf.softzoom, CONF_TYPE_FLAG, 0, 1, 0, "render movie to the user-defined window's geometry"}, + {"monitorpixelaspect", &mp_conf.monitor_pixel_aspect, CONF_TYPE_FLOAT, CONF_RANGE, 0.2, 9.0, "sets the aspect-ratio of a single pixel of TV screen"}, + {"vm", &vo_conf.vidmode, CONF_TYPE_FLAG, 0, 0, 1, "enables video-mode changing during playback"}, + {"novm", &vo_conf.vidmode, CONF_TYPE_FLAG, 0, 1, 0, "disables video-mode changing during playback"}, + {"fs", &vo_conf.fullscreen, CONF_TYPE_FLAG, 0, 0, 1, "fullscreen playback"}, + {"nofs", &vo_conf.fullscreen, CONF_TYPE_FLAG, 0, 1, 0, "windowed playback"}, + {"fsmode", &vo_conf.fsmode, CONF_TYPE_INT, CONF_RANGE, 0, 15, "enables workaround for some fullscreen related problems"}, + {"flip", &vo_conf.flip, CONF_TYPE_FLAG, 0, -1, 1, "flip output image upside-down"}, + {"noflip", &vo_conf.flip, CONF_TYPE_FLAG, 0, -1, 0, "render output image as is"}, + {"bpp", &vo_conf.dbpp, CONF_TYPE_INT, CONF_RANGE, 0, 32, "use different color depth than autodetect"}, + {"bm", &vo_conf.use_bm, CONF_TYPE_FLAG, 0, 0, 1, "enables using of bus-mastering (if it available for given OS/videocard)"}, + {"bm2", &vo_conf.use_bm, CONF_TYPE_FLAG, 0, 0, 2, "enables using of bus-mastering to store all decoded-ahead frames in video-memory"}, + {"nobm", &vo_conf.use_bm, CONF_TYPE_FLAG, 0, 1, 0, "disables using of bus-mastering"}, + {"id", &mp_conf.video_id, CONF_TYPE_INT, CONF_RANGE, 0, 255, "selects video channel"}, + {"pp", &mp_conf.npp_options, CONF_TYPE_STRING, 0, 0, 0, "specifies options of post-processing"}, +#ifdef HAVE_PNG + {"z", &mp_conf.z_compression, CONF_TYPE_INT, CONF_RANGE, 0, 9, "specifies compression level for PNG output"}, +#endif +#ifdef HAVE_SDL + {"noxv", &sdl_noxv, CONF_TYPE_FLAG, 0, 0, 1, "disable XVideo hardware acceleration for SDL"}, + {"forcexv", &sdl_forcexv, CONF_TYPE_FLAG, 0, 0, 1, "force XVideo hardware acceleration for SDL"}, + {"forcegl", &sdl_forcegl, CONF_TYPE_FLAG, 0, 0, 1, "force OpenGL hardware acceleration for SDL"}, +#endif + {"eq",(any_t*)&veq_config, CONF_TYPE_SUBCONFIG, 0, 0, 0, "Video-equalizer specific options"}, + {NULL, NULL, 0, 0, 0, 0, NULL}, +}; + +static const config_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"}, + {"noloop", &mp_conf.loop_times, CONF_TYPE_FLAG, 0, 0, -1, "disable loop of playback"}, + {"shuffle",&mp_conf.shuffle_playback, CONF_TYPE_FLAG, 0, 0, 1, "play files in random order"}, + {"noshuffle",&mp_conf.shuffle_playback, CONF_TYPE_FLAG, 0, 1, 0, "play files in regular order"}, + {"list", NULL, CONF_TYPE_STRING, 0, 0, 0, "specifies playlist (1 file/row or Winamp or ASX format)"}, + {"frames", &mp_conf.play_n_frames, CONF_TYPE_INT, CONF_MIN, 0, 0, "play given number of frames and exit"}, + {NULL, NULL, 0, 0, 0, 0, NULL}, +}; + +static const config_t mplayer_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!!! */ + +//---------------------- libao/libvo/mplayer options ------------------------ + {"vo", &mp_conf.video_driver, CONF_TYPE_STRING, 0, 0, 0, "select video output driver and optinaly device"}, + {"ao", &mp_conf.audio_driver, CONF_TYPE_STRING, 0, 0, 0, "select audio output driver and optinaly device"}, + {"af", &af_cfg.list, CONF_TYPE_STRING, 0, 0, 0, "selects audio filter"}, + {"vf", &vf_cfg.list, CONF_TYPE_STRING, 0, 0, 0, "selects video filter"}, + {"afm", &mp_conf.audio_family, CONF_TYPE_STRING, 0, 0, 0, "forces usage of specified audio-decoders family"}, + {"vfm", &mp_conf.video_family, CONF_TYPE_STRING, 0, 0, 0, "forces usage of specified video-decoders family"}, + {"ac", &mp_conf.audio_codec, CONF_TYPE_STRING, 0, 0, 0, "forces usage of specified audio-decoder"}, + {"vc", &mp_conf.video_codec, CONF_TYPE_STRING, 0, 0, 0, "forces usage of specified video-decoder"}, +/*UD*/ {"verbose", &mp_conf.verbose, CONF_TYPE_INT, CONF_RANGE|CONF_GLOBAL, 0, 100, "verbose output"}, + {"v", &mp_conf.verbose, CONF_TYPE_INC, 0, 0, 0, "verbose output (more -v means more verbosity)"}, + {"msgfilter", &mp_conf.msg_filter, CONF_TYPE_INT, CONF_RANGE, 0, 0xFFFFFFFF, "specifies filter for verbosed messages"}, + + {"core", (any_t*)&xpcore_config, CONF_TYPE_SUBCONFIG, 0, 0, 0, "XP-core related options" }, + {"play", (any_t*)&playback_config, CONF_TYPE_SUBCONFIG, 0, 0, 0, "Playback specific options" }, + {"audio", (any_t*)&audio_config, CONF_TYPE_SUBCONFIG, 0, 0, 0, "Audio related options" }, + {"video", (any_t*)&video_config, CONF_TYPE_SUBCONFIG, 0, 0, 0, "Video related options" }, + {"sub", (any_t*)&subtitle_config, CONF_TYPE_SUBCONFIG, 0, 0, 0, "Subtitle related options" }, +#ifdef HAVE_X11 + {"x", (any_t*)&x11_config, CONF_TYPE_SUBCONFIG, 0, 0, 0, "X11-specific options" }, +#endif + {"osd", (any_t*)&osd_config, CONF_TYPE_SUBCONFIG, 0, 0, 0, "OSD-related options"}, + {"sync", (any_t*)&avsync_config, CONF_TYPE_SUBCONFIG, 0, 0, 0, "AV-synchronization related options" }, +#if defined( ARCH_X86 ) || defined(ARCH_X86_64) + {"cpu", (any_t*)&cpu_config, CONF_TYPE_SUBCONFIG, 0, 0, 0, "CPU specific options" }, +#endif +// ------------------------- stream options -------------------- +#ifdef HAVE_STREAMING + { "net", (any_t*)&net_config, CONF_TYPE_SUBCONFIG, 0, 0, 0, "Network specific options" }, +#endif +// ------------------------- codec/pp options -------------------- + {NULL, NULL, 0, 0, 0, 0, NULL} +}; +const config_t* mplayer_opts=mplayer_options; + +} // namespace mpxp +extern void libmpcodecs_ad_register_options(m_config_t* cfg); +extern void libmpcodecs_vd_register_options(m_config_t* cfg); + +namespace mpxp { +#ifdef HAVE_LIBCDIO +extern void cdda_register_options(m_config_t* 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) +{ + mp_input_register_options(cfg); + libmpdemux_register_options(cfg); + demuxer_register_options(cfg); +#ifdef HAVE_LIBCDIO + cdda_register_options(cfg); +#endif + libmpcodecs_ad_register_options(cfg); + libmpcodecs_vd_register_options(cfg); +} + +} // namespace mpxp Property changes on: mplayerxp/xmpcore/xmp_context.cpp ___________________________________________________________________ Added: svn:eol-style + native Copied: mplayerxp/xmpcore/xmp_context.h (from rev 555, mplayerxp/cfg-mplayerxp.h) =================================================================== --- mplayerxp/xmpcore/xmp_context.h (rev 0) +++ mplayerxp/xmpcore/xmp_context.h 2012-12-13 11:45:25 UTC (rev 557) @@ -0,0 +1,9 @@ +#ifndef _XMP_CONTEXT_H_INCLUDED +#define _XMP_CONTEXT_H_INCLUDED 1 + +struct config_t; +namespace mpxp { + extern const config_t* mplayer_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-13 14:55:28
|
Revision: 559 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=559&view=rev Author: nickols_k Date: 2012-12-13 14:55:16 +0000 (Thu, 13 Dec 2012) Log Message: ----------- c++ way: decrease number of typedef Modified Paths: -------------- mplayerxp/libao2/audio_out.h mplayerxp/libmpcodecs/ad.h mplayerxp/libmpcodecs/vd.h mplayerxp/libmpconf/cfgparser.h mplayerxp/libmpconf/m_option.h mplayerxp/libmpconf/m_property.h mplayerxp/libmpconf/m_struct.h mplayerxp/libmpconf/subopt-helper.h mplayerxp/libmpdemux/demuxer.h mplayerxp/libmpdemux/demuxer_r.h mplayerxp/libmpdemux/matroska.h mplayerxp/libmpdemux/mpeg_hdr.h mplayerxp/libmpdemux/mpxpav64.h mplayerxp/libmpdemux/muxer.h mplayerxp/libmpsub/spudec.cpp mplayerxp/libmpsub/subreader.h mplayerxp/libmpsub/vobsub.cpp mplayerxp/libplaytree/playtree.h mplayerxp/libplaytree/playtreeparser.cpp mplayerxp/libplaytree/playtreeparser.h mplayerxp/libvo2/dri_vo.h mplayerxp/libvo2/font_load.h mplayerxp/libvo2/img_format.h mplayerxp/libvo2/jpeg_enc.h mplayerxp/libvo2/sub.h mplayerxp/libvo2/video_out.h mplayerxp/libvo2/x11_system.h mplayerxp/mp_msg.cpp mplayerxp/mplayerxp.h mplayerxp/osdep/cpudetect.h mplayerxp/osdep/vbelib.h mplayerxp/xmpcore/mp_aframe.h mplayerxp/xmpcore/mp_image.h Modified: mplayerxp/libao2/audio_out.h =================================================================== --- mplayerxp/libao2/audio_out.h 2012-12-13 13:52:35 UTC (rev 558) +++ mplayerxp/libao2/audio_out.h 2012-12-13 14:55:16 UTC (rev 559) @@ -4,16 +4,16 @@ #include "xmpcore/xmp_enums.h" /** Text description of AO-driver */ -typedef struct ao_info_s +struct ao_info_t { const char *name; /**< driver name ("alsa driver") */ const char *short_name; /**< short name (for config strings) ("alsa") */ const char *author; /**< author ("Aaron Holtzman <aho...@es...>") */ const char *comment;/**< any additional comments */ -} ao_info_t; +}; /** Global data used by mplayerxp and plugins */ -typedef struct ao_data_s +struct ao_data_t { char* subdevice; char antiviral_hole[RND_CHAR2]; @@ -26,10 +26,10 @@ float pts; /**< PTS of audio buffer */ any_t* opaque; /**< for internal use */ any_t* priv; -} ao_data_t; +}; /** AO-driver interface */ -typedef struct ao_functions_s +struct ao_functions_t { const ao_info_t *info; /**< text-info about this driver */ @@ -80,7 +80,7 @@ /** Resumes playing, after audio_pause() */ void (* __FASTCALL__ resume)(ao_data_t*); -} ao_functions_t; +}; enum { AOCONTROL_SET_DEVICE =1, /**< Sets new audio device (example: /dev/dsp2) */ @@ -91,10 +91,11 @@ AOCONTROL_GET_VOLUME =6, /**< Query volume level */ AOCONTROL_SET_VOLUME =7 /**< Sets new volume level */ }; -typedef struct ao_control_vol_s { + +struct ao_control_vol_t { float left; float right; -} ao_control_vol_t; +}; /* prototypes */ extern const char * __FASTCALL__ ao_format_name(int format); Modified: mplayerxp/libmpcodecs/ad.h =================================================================== --- mplayerxp/libmpcodecs/ad.h 2012-12-13 13:52:35 UTC (rev 558) +++ mplayerxp/libmpcodecs/ad.h 2012-12-13 14:55:16 UTC (rev 559) @@ -8,13 +8,12 @@ #include "xmpcore/xmp_enums.h" #include "libao2/afmt.h" -typedef struct ad_info_s -{ +struct ad_info_t { const char *descr; /* driver description ("Autodesk FLI/FLC Animation decoder" */ const char *driver_name; /* driver name ("dshow") */ const char *author; /* interface author/maintainer */ const char *url; /* URL of homepage */ -} ad_info_t; +}; enum { ADCTRL_RESYNC_STREAM=0, @@ -32,13 +31,13 @@ ACodecStatus_NotWorking =0, }acodec_status_e; -typedef struct audio_probe_s { +struct audio_probe_t { const char* driver; const char* codec_dll; uint32_t wtag; acodec_status_e status; unsigned sample_fmt[Audio_MaxOutSample]; -}audio_probe_t; +}; struct audio_filter_info_t { af_stream_t* afilter; @@ -47,7 +46,7 @@ /* interface of video decoder drivers */ struct ad_private_t; -typedef struct ad_functions_s +struct ad_functions_t { const ad_info_t* info; const config_t* options;/**< Optional: MPlayerXP's option related */ @@ -57,7 +56,7 @@ void (* __FASTCALL__ uninit)(ad_private_t *ctx); MPXP_Rc (*control_ad)(ad_private_t *ctx,int cmd,any_t* arg, ...); unsigned (* __FASTCALL__ decode)(ad_private_t *ctx,unsigned char *buf,unsigned minlen,unsigned maxlen,float *pts); -} ad_functions_t; +}; extern const ad_functions_t* afm_find_driver(const char *name); extern const audio_probe_t* afm_probe_driver(ad_private_t*ctx,sh_audio_t*sh,audio_filter_info_t* afi); Modified: mplayerxp/libmpcodecs/vd.h =================================================================== --- mplayerxp/libmpcodecs/vd.h 2012-12-13 13:52:35 UTC (rev 558) +++ mplayerxp/libmpcodecs/vd.h 2012-12-13 14:55:16 UTC (rev 559) @@ -30,22 +30,21 @@ VCodecStatus_NotWorking =0, }vcodec_status_e; -typedef struct video_probe_s { +struct video_probe_t { const char* driver; const char* codec_dll; uint32_t fourcc; vcodec_status_e status; uint32_t pix_fmt[Video_MaxOutFmt]; video_flags_e flags[Video_MaxOutFmt]; -}video_probe_t; +}; -typedef struct vd_info_s -{ +struct vd_info_t { const char *descr; /* driver description ("Autodesk FLI/FLC Animation decoder" */ const char *driver_name; /* driver name ("dshow") */ const char *author; /* interface author/maintainer */ const char *url; /* URL of homepage */ -} vd_info_t; +}; struct put_slice_info_t { int vf_flags; @@ -53,8 +52,7 @@ }; /* interface of video decoder drivers */ struct vd_private_t; -typedef struct vd_functions_s -{ +struct vd_functions_t { const vd_info_t* info; const config_t* options;/**< Optional: MPlayerXP's option related */ const video_probe_t*(*__FASTCALL__ probe)(uint32_t fourcc); @@ -63,7 +61,7 @@ void (*__FASTCALL__ uninit)(vd_private_t *ctx); MPXP_Rc (*control_vd)(vd_private_t *ctx,int cmd,any_t* arg, ...); mp_image_t* (*__FASTCALL__ decode)(vd_private_t *ctx,const enc_frame_t* frame); -} vd_functions_t; +}; extern const vd_functions_t* vfm_find_driver(const char *name); extern const video_probe_t* vfm_driver_probe(vd_private_t*ctx,sh_video_t *sh,put_slice_info_t* psi); Modified: mplayerxp/libmpconf/cfgparser.h =================================================================== --- mplayerxp/libmpconf/cfgparser.h 2012-12-13 13:52:35 UTC (rev 558) +++ mplayerxp/libmpconf/cfgparser.h 2012-12-13 14:55:16 UTC (rev 559) @@ -37,8 +37,6 @@ CONF_GLOBAL =(1<<4), CONF_NOSAVE =(1<<5) }; -typedef struct m_config m_config_t; -typedef struct config_save config_save_t; struct config_t { const char *name; @@ -50,9 +48,10 @@ }; typedef void (*cfg_default_func_t)(config_t*,const char*); -struct m_config { - m_config(libinput_t& _libinput):libinput(_libinput) {} - ~m_config() {} +struct config_save_t; +struct m_config_t { + m_config_t(libinput_t& _libinput):libinput(_libinput) {} + ~m_config_t() {} const config_t** opt_list; config_save_t** config_stack; @@ -69,7 +68,7 @@ libinput_t& libinput; }; -struct config_save { +struct config_save_t { const config_t* opt; union { int as_int; Modified: mplayerxp/libmpconf/m_option.h =================================================================== --- mplayerxp/libmpconf/m_option.h 2012-12-13 13:52:35 UTC (rev 558) +++ mplayerxp/libmpconf/m_option.h 2012-12-13 14:55:16 UTC (rev 559) @@ -10,8 +10,8 @@ /// \file m_option.h /// \ingroup OptionTypes -typedef struct m_option_type m_option_type_t; -typedef struct m_option m_option_t; +struct m_option_type_t; +struct m_option_t; struct m_struct_t; /// \defgroup OptionTypes Options types @@ -46,24 +46,25 @@ END_AT_TIME=1, END_AT_SIZE=2 }; -typedef struct { + +struct m_time_size_t { double pos; int type; -} m_time_size_t; +}; /// Extra definition needed for \ref m_option_type_obj_settings_list options. -typedef struct { +struct m_obj_list_t { any_t** list; /// Pointer to an array of pointer to some object type description struct. any_t* name_off; /// Offset of the object type name (char*) in the description struct. any_t* info_off; /// Offset of the object type info string (char*) in the description struct. any_t* desc_off; /// \brief Offset of the object type parameter description (\ref m_struct_st) in the description struct. -} m_obj_list_t; +}; /// The data type used by \ref m_option_type_obj_settings_list. -typedef struct m_obj_settings { +struct m_obj_settings_t { const char* name; /// Type of the object. char** attribs; /// NULL terminated array of parameter/value pairs. -} m_obj_settings_t; +}; /// A parser to set up a list of objects. /** It creates a NULL terminated array \ref m_obj_settings. The option priv @@ -73,12 +74,12 @@ extern const m_option_type_t m_option_type_obj_settings_list; /// Extra definition needed for \ref m_option_type_obj_presets options. -typedef struct { +struct m_obj_presets_t { struct m_struct_t* in_desc; /// Description of the struct holding the presets. struct m_struct_t* out_desc; /// Description of the struct that should be set by the presets. any_t* presets; /// Pointer to an array of structs defining the various presets. any_t* name_off; /// Offset of the preset's name inside the in_struct. -} m_obj_presets_t; +}; /// Set several fields in a struct at once. /** For this two struct descriptions are used. One for the struct holding the @@ -97,10 +98,10 @@ extern const m_option_type_t m_option_type_custom_url; #endif /// Extra definition needed for \ref m_option_type_obj_params options. -typedef struct { +struct m_obj_params_t { const struct m_struct_t* desc; /// Field descriptions. char separator; /// Field separator to use. -} m_obj_params_t; +}; /// Parse a set of parameters. /** Parameters are separated by the given separator and each one @@ -109,10 +110,10 @@ */ extern const m_option_type_t m_option_type_obj_params; -typedef struct { +struct m_span_t { int start; int end; -} m_span_t; +}; /// Ready made settings to parse a \ref m_span_t with a start-end syntax. extern const m_obj_params_t m_span_params_def; @@ -143,7 +144,7 @@ ///////////////////////////////////////////////////////////////////////////////////////////// /// Option type description -struct m_option_type { +struct m_option_type_t { const char* name; const char* comments; /// Syntax description, etc unsigned int size; /// Size needed for the data. @@ -214,7 +215,7 @@ /// Option description /** \ingroup Options */ -struct m_option { +struct m_option_t { const char *name; /// Option name. /** The suboption parser and func types do use it. They should instead * use the priv field but this was inherited from older versions of the Modified: mplayerxp/libmpconf/m_property.h =================================================================== --- mplayerxp/libmpconf/m_property.h 2012-12-13 13:52:35 UTC (rev 558) +++ mplayerxp/libmpconf/m_property.h 2012-12-13 14:55:16 UTC (rev 559) @@ -52,11 +52,11 @@ ///@{ /// Argument for \ref M_PROPERTY_KEY_ACTION -typedef struct { +struct m_property_action_t { const char* key; int action; const any_t* arg; -} m_property_action_t; +}; ///@} Modified: mplayerxp/libmpconf/m_struct.h =================================================================== --- mplayerxp/libmpconf/m_struct.h 2012-12-13 13:52:35 UTC (rev 558) +++ mplayerxp/libmpconf/m_struct.h 2012-12-13 14:55:16 UTC (rev 559) @@ -8,7 +8,7 @@ /// \file m_struct.h -struct m_option; +struct m_option_t; /// Struct definition struct m_struct_t { @@ -19,7 +19,7 @@ /** The p field of the \ref m_option struct must contain the offset * of the member in the struct (use M_ST_OFF macro for this). */ - const struct m_option* fields; + const struct m_option_t* fields; }; @@ -97,7 +97,7 @@ * \param f Name of the field. * \return The \ref m_option struct describing the field or NULL if not found. */ -const struct m_option* +const struct m_option_t* m_struct_get_field(const m_struct_t* st,const char* f); ///@} Modified: mplayerxp/libmpconf/subopt-helper.h =================================================================== --- mplayerxp/libmpconf/subopt-helper.h 2012-12-13 13:52:35 UTC (rev 558) +++ mplayerxp/libmpconf/subopt-helper.h 2012-12-13 14:55:16 UTC (rev 559) @@ -19,26 +19,23 @@ typedef int (*opt_test_f)(any_t*); /** simple structure for defining the option name, type and storage location */ -typedef struct opt_s -{ +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 ) -} opt_t; +}; /** 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_s -{ +typedef struct strarg_t { int len; ///< length of the string determined by the parser char const * str; ///< pointer to position inside the parse string -} strarg_t; +}; - int int_non_neg( int * i ); int int_pos( int * i ); Modified: mplayerxp/libmpdemux/demuxer.h =================================================================== --- mplayerxp/libmpdemux/demuxer.h 2012-12-13 13:52:35 UTC (rev 558) +++ mplayerxp/libmpdemux/demuxer.h 2012-12-13 14:55:16 UTC (rev 559) @@ -37,10 +37,10 @@ DEMUX_SEEK_PERCENTS =0x02 }; - typedef struct seek_args_s { + struct seek_args_t { float secs; unsigned flags; - }seek_args_t; + }; struct sh_audio_t; struct sh_video_t; Modified: mplayerxp/libmpdemux/demuxer_r.h =================================================================== --- mplayerxp/libmpdemux/demuxer_r.h 2012-12-13 13:52:35 UTC (rev 558) +++ mplayerxp/libmpdemux/demuxer_r.h 2012-12-13 14:55:16 UTC (rev 559) @@ -12,14 +12,14 @@ VideoFrame=RND_NUMBER1 }enc_frame_type_e; -typedef struct enc_frame_s { +struct enc_frame_t { enc_frame_type_e type; float pts; float duration; unsigned len; uint8_t* data; unsigned flags; // codec specific flags. filled by video_decode -}enc_frame_t; +}; extern enc_frame_t* new_enc_frame(enc_frame_type_e type,unsigned len,float pts,float duration); extern void free_enc_frame(enc_frame_t* frame); Modified: mplayerxp/libmpdemux/matroska.h =================================================================== --- mplayerxp/libmpdemux/matroska.h 2012-12-13 13:52:35 UTC (rev 558) +++ mplayerxp/libmpdemux/matroska.h 2012-12-13 14:55:16 UTC (rev 559) @@ -154,7 +154,7 @@ MATROSKA_SUBTYPE_VOBSUB =3 }; -typedef struct { +struct mkv_sh_sub_t { char type; // t = text, v = VobSub int has_palette; // If we have a valid palette unsigned int palette[16]; // for VobSubs @@ -162,7 +162,7 @@ int custom_colors; unsigned int colors[4]; int forced_subs_only; -} mkv_sh_sub_t; +}; #if 0 int demux_mkv_num_subs(demuxer_t *demuxer); Modified: mplayerxp/libmpdemux/mpeg_hdr.h =================================================================== --- mplayerxp/libmpdemux/mpeg_hdr.h 2012-12-13 13:52:35 UTC (rev 558) +++ mplayerxp/libmpdemux/mpeg_hdr.h 2012-12-13 14:55:16 UTC (rev 559) @@ -1,5 +1,5 @@ -typedef struct { +struct mp_mpeg_header_t { // video info: int mpeg1; // 0=mpeg2 1=mpeg1 int display_picture_width; @@ -18,7 +18,7 @@ //the following are for mpeg4 int timeinc_resolution, timeinc_bits, timeinc_unit; int picture_type; -} mp_mpeg_header_t; +}; int mp_header_process_sequence_header (mp_mpeg_header_t * picture, unsigned char * buffer); int mp_header_process_extension (mp_mpeg_header_t * picture, unsigned char * buffer); Modified: mplayerxp/libmpdemux/mpxpav64.h =================================================================== --- mplayerxp/libmpdemux/mpxpav64.h 2012-12-13 13:52:35 UTC (rev 558) +++ mplayerxp/libmpdemux/mpxpav64.h 2012-12-13 14:55:16 UTC (rev 559) @@ -8,7 +8,7 @@ MPXPAV64_FP_FCNT_UTF16 =0x00000002ULL, MPXPAV64_FP_FCNT_UTF32 =0x00000003ULL }; -typedef struct __attribute__((__packed__)) mpxpav64FileProperties_s /* FPRP */ +struct __attribute__((__packed__)) mpxpav64FileProperties_t /* FPRP */ { uint64_t num_packets; //Number of 'DATx' packets uint64_t num_bytes; //Number of 'DATx' bytes @@ -18,19 +18,19 @@ uint32_t MaxBitrate; //Maximum bitrate of the media (sum of all the stream) uint32_t AveBitrate; //Average bitrate of the media (sum of all the stream) uint16_t StreamCount; //Number of StreamProp Objects -}mpxpav64FileProperties_t; -#define le2me_mpxpav64FileProperties(h) { \ - (h)->num_packets = le2me_64((h)->num_packets); \ - (h)->num_bytes = le2me_64((h)->num_bytes); \ - (h)->flags = le2me_64((h)->flags); \ - (h)->PlayDuration = le2me_64((h)->PlayDuration); \ - (h)->Preroll = le2me_32((h)->Preroll); \ - (h)->MaxBitrate = le2me_32((h)->MaxBitrate); \ - (h)->AveBitrate = le2me_32((h)->AveBitrate); \ - (h)->StreamCount = le2me_16((h)->StreamCount); \ +}; +inline void le2me_mpxpav64FileProperties(mpxpav64FileProperties_t* h) { + h->num_packets = le2me_64(h->num_packets); + h->num_bytes = le2me_64(h->num_bytes); + h->flags = le2me_64(h->flags); + h->PlayDuration = le2me_64(h->PlayDuration); + h->Preroll = le2me_32(h->Preroll); + h->MaxBitrate = le2me_32(h->MaxBitrate); + h->AveBitrate = le2me_32(h->AveBitrate); + h->StreamCount = le2me_16(h->StreamCount); } -typedef struct __attribute__((__packed__)) mpxpav64StreamProperties_s +struct __attribute__((__packed__)) mpxpav64StreamProperties_t { uint64_t num_packets; //Number of 'DATx' packets of this stream type uint64_t num_bytes; //Number of 'DATx' bytes of this stream type @@ -50,24 +50,24 @@ uint64_t size_scaler; //Numerator of SIZE fields to get size in bytes (default: 1) uint8_t mimetype_len; //length of mime-type uint8_t ascii[0];//mime-type: video/x-video audio/x-audio text/x-text -}mpxpav64StreamProperties_t; -#define le2me_mpxpav64StreamProperties(h) { \ - (h)->num_packets = le2me_64((h)->num_packets); \ - (h)->num_bytes = le2me_64((h)->num_bytes); \ - (h)->flags = le2me_64((h)->flags); \ - (h)->PlayDuration = le2me_64((h)->PlayDuration); \ - (h)->Preroll = le2me_32((h)->Preroll); \ - (h)->MaxPacketSize = le2me_32((h)->MaxPacketSize); \ - (h)->AvePacketSize = le2me_32((h)->AvePacketSize); \ - (h)->MinPacketSize = le2me_32((h)->MinPacketSize); \ - (h)->MaxFrameDuration = le2me_32((h)->MaxFrameDuration); \ - (h)->AveFrameDuration = le2me_32((h)->AveFrameDuration); \ - (h)->MinFrameDuration = le2me_32((h)->MinFrameDuration); \ - (h)->MaxBitrate = le2me_32((h)->MaxBitrate); \ - (h)->AveBitrate = le2me_32((h)->AveBitrate); \ - (h)->MinBitrate = le2me_32((h)->MinBitrate); \ - (h)->pts_rate = le2me_64((h)->pts_rate); \ - (h)->size_scaler = le2me_64((h)->size_scaler); \ +}; +static void le2me_mpxpav64StreamProperties(mpxpav64StreamProperties_t *h) { + h->num_packets = le2me_64(h->num_packets); + h->num_bytes = le2me_64(h->num_bytes); + h->flags = le2me_64(h->flags); + h->PlayDuration = le2me_64(h->PlayDuration); + h->Preroll = le2me_32(h->Preroll); + h->MaxPacketSize = le2me_32(h->MaxPacketSize); + h->AvePacketSize = le2me_32(h->AvePacketSize); + h->MinPacketSize = le2me_32(h->MinPacketSize); + h->MaxFrameDuration = le2me_32(h->MaxFrameDuration); + h->AveFrameDuration = le2me_32(h->AveFrameDuration); + h->MinFrameDuration = le2me_32(h->MinFrameDuration); + h->MaxBitrate = le2me_32(h->MaxBitrate); + h->AveBitrate = le2me_32(h->AveBitrate); + h->MinBitrate = le2me_32(h->MinBitrate); + h->pts_rate = le2me_64(h->pts_rate); + h->size_scaler = le2me_64(h->size_scaler); } #endif Modified: mplayerxp/libmpdemux/muxer.h =================================================================== --- mplayerxp/libmpdemux/muxer.h 2012-12-13 13:52:35 UTC (rev 558) +++ mplayerxp/libmpdemux/muxer.h 2012-12-13 14:55:16 UTC (rev 559) @@ -16,18 +16,18 @@ }; #include "demuxer_r.h" -typedef struct muxer_packet_s{ +struct muxer_packet_t { float pts; any_t*data; unsigned length; unsigned flags; - struct muxer_packet_s *next; -}muxer_packet_t; + muxer_packet_t *next; +}; muxer_packet_t* new_muxer_packet(float pts,any_t*data,unsigned length,unsigned flags); void free_muxer_packet(muxer_packet_t *packet); -typedef struct { +struct muxer_stream_t { // muxer data: int type; // audio or video int id; // stream no @@ -54,14 +54,14 @@ muxer_packet_t *first; muxer_packet_t *last; any_t*priv; -} muxer_stream_t; +}; -typedef struct { +struct muxer_info_t { uint32_t id; const char *text; -} muxer_info_t; +}; -typedef struct muxer_t{ +struct muxer_t { // encoding: MainAVIHeader avih; muxer_stream_t* def_v; // default video stream (for general headers) @@ -73,7 +73,7 @@ muxer_stream_t* (*cont_new_stream)(struct muxer_t *,int); FILE* file; any_t*priv; -} muxer_t; +}; 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) Modified: mplayerxp/libmpsub/spudec.cpp =================================================================== --- mplayerxp/libmpsub/spudec.cpp 2012-12-13 13:52:35 UTC (rev 558) +++ mplayerxp/libmpsub/spudec.cpp 2012-12-13 14:55:16 UTC (rev 559) @@ -42,7 +42,6 @@ int spu_alignment = -1; float spu_gaussvar = 1.0; -typedef struct packet_t packet_t; struct packet_t { unsigned char *packet; unsigned int palette[4]; @@ -59,7 +58,7 @@ packet_t *next; }; -typedef struct { +struct spudec_handle_t { packet_t *queue_head; packet_t *queue_tail; unsigned int global_palette[16]; @@ -92,7 +91,7 @@ int spu_changed; unsigned int forced_subs_only; /* flag: 0=display all subtitle, !0 display only forced subtitles */ unsigned int is_forced_sub; /* true if current subtitle is a forced subtitle */ -} spudec_handle_t; +}; static void __FASTCALL__ spudec_queue_packet(spudec_handle_t *self, packet_t *packet) { @@ -670,13 +669,12 @@ return alpha ? 256 - alpha : 0; } -typedef struct { +struct scale_pixel { unsigned position; unsigned left_up; unsigned right_down; -}scale_pixel; +}; - static void __FASTCALL__ scale_table(unsigned int start_src, unsigned int start_tar, unsigned int end_src, unsigned int end_tar, scale_pixel * table) { unsigned int t; Modified: mplayerxp/libmpsub/subreader.h =================================================================== --- mplayerxp/libmpsub/subreader.h 2012-12-13 13:52:35 UTC (rev 558) +++ mplayerxp/libmpsub/subreader.h 2012-12-13 14:55:16 UTC (rev 559) @@ -27,15 +27,14 @@ SUB_MAX_TEXT =5 }; -typedef struct { - +struct subtitle { int lines; unsigned long start; unsigned long end; char *text[SUB_MAX_TEXT]; -} subtitle; +}; extern subtitle* sub_read_file (const char *filename, float pts); extern char * sub_filename(const char *path,const char *fname); Modified: mplayerxp/libmpsub/vobsub.cpp =================================================================== --- mplayerxp/libmpsub/vobsub.cpp 2012-12-13 13:52:35 UTC (rev 558) +++ mplayerxp/libmpsub/vobsub.cpp 2012-12-13 14:55:16 UTC (rev 559) @@ -73,7 +73,7 @@ * MPEG parsing **********************************************************************/ -typedef struct { +struct mpeg_t { Stream *stream; unsigned int pts; int aid; @@ -81,7 +81,7 @@ unsigned int packet_reserve; unsigned int packet_size; int fd; -} mpeg_t; +}; static mpeg_t * __FASTCALL__ mpeg_open(const char *filename) { @@ -290,20 +290,20 @@ * Packet queue **********************************************************************/ -typedef struct { +struct packet_t { unsigned int pts100; off_t filepos; unsigned int size; unsigned char *data; -} packet_t; +}; -typedef struct { +struct packet_queue_t { char *id; packet_t *packets; unsigned int packets_reserve; unsigned int packets_size; unsigned int current_index; -} packet_queue_t; +}; static void __FASTCALL__ packet_construct(packet_t *pkt) { @@ -397,7 +397,7 @@ * Vosub **********************************************************************/ -typedef struct { +struct vobsub_t { unsigned int palette[16]; unsigned int cuspal[4]; int delay; @@ -410,7 +410,7 @@ packet_queue_t *spu_streams; unsigned int spu_streams_size; unsigned int spu_streams_current; -} vobsub_t; +}; /* Make sure that the spu stream idx exists. */ static int __FASTCALL__ vobsub_ensure_spu_stream(vobsub_t *vob, unsigned int _index) Modified: mplayerxp/libplaytree/playtree.h =================================================================== --- mplayerxp/libplaytree/playtree.h 2012-12-13 13:52:35 UTC (rev 558) +++ mplayerxp/libplaytree/playtree.h 2012-12-13 14:55:16 UTC (rev 559) @@ -1,8 +1,10 @@ #ifndef __PLAYTREE_H #define __PLAYTREE_H +struct m_config_t; namespace mpxp { struct Stream; + struct libinput_t; } enum { @@ -37,20 +39,6 @@ /// \defgroup Playtree ///@{ -#include "libmpconf/cfgparser.h" - -#if 0 -typedef struct play_tree_info play_tree_info_t; -// TODO : a attrib,val pair system and not something hardcoded -struct play_tree_info { - char* title; - char* author; - char* copyright; - char* abstract; - // Some more ?? -} -#endif - struct play_tree_param_t { char* name; char* value; Modified: mplayerxp/libplaytree/playtreeparser.cpp =================================================================== --- mplayerxp/libplaytree/playtreeparser.cpp 2012-12-13 13:52:35 UTC (rev 558) +++ mplayerxp/libplaytree/playtreeparser.cpp 2012-12-13 14:55:16 UTC (rev 559) @@ -192,11 +192,11 @@ return i+1; } -typedef struct pls_entry { +struct pls_entry_t { char* file; char* title; char* length; -} pls_entry_t; +}; static int __FASTCALL__ pls_read_entry(char* line,pls_entry_t** _e,int* _max_entry,char** val) { int num,max_entry = (*_max_entry); Modified: mplayerxp/libplaytree/playtreeparser.h =================================================================== --- mplayerxp/libplaytree/playtreeparser.h 2012-12-13 13:52:35 UTC (rev 558) +++ mplayerxp/libplaytree/playtreeparser.h 2012-12-13 14:55:16 UTC (rev 559) @@ -3,14 +3,13 @@ #include "playtree.h" -typedef struct play_tree_parser { +struct play_tree_parser_t { Stream* stream; char *buffer,*iter,*line; int buffer_size , buffer_end; int deep,keep; -} play_tree_parser_t; +}; - play_tree_parser_t* play_tree_parser_new(Stream * stream,int deep); void play_tree_parser_free(play_tree_parser_t* p); Modified: mplayerxp/libvo2/dri_vo.h =================================================================== --- mplayerxp/libvo2/dri_vo.h 2012-12-13 13:52:35 UTC (rev 558) +++ mplayerxp/libvo2/dri_vo.h 2012-12-13 14:55:16 UTC (rev 559) @@ -22,22 +22,20 @@ DRI_CAP_HWOSD =0x00000100UL,/**< Driver supports OSD painting */ DRI_CAP_BUSMASTERING=0x80000000UL /**< Means: final video buffer but allocated in RAM */ }; -typedef struct dri_surface_cap_s -{ +struct dri_surface_cap_t { unsigned caps; /**< Capabilities of surface (see DRI_CAP_* for detail) */ unsigned fourcc; /**< real fourcc of vo2 surface */ unsigned width,height; /**< specify total dimension of surface */ unsigned x,y,w,h; /**< specify movie position within surface */ unsigned strides[4]; /**< drv->app:specify strides of each plane */ -}dri_surface_cap_t; +}; enum { MAX_DRI_BUFFERS=1024 /**< Maximal number of surfaces */ }; /** Contains surface address */ -typedef struct dri_surface_s -{ +struct dri_surface_t { unsigned idx; /**< app->drv:specify number of surface (0 default for single buffering) */ uint8_t* planes[4]; /**< drv->app:specify planes (include alpha channel) */ -}dri_surface_t; +}; #endif Modified: mplayerxp/libvo2/font_load.h =================================================================== --- mplayerxp/libvo2/font_load.h 2012-12-13 13:52:35 UTC (rev 558) +++ mplayerxp/libvo2/font_load.h 2012-12-13 14:55:16 UTC (rev 559) @@ -1,13 +1,13 @@ #ifndef __FONT_LOAD_H #define __FONT_LOAD_H 1 -typedef struct { +struct raw_file { unsigned char *bmp; unsigned char *pal; int w,h,c; -} raw_file; +}; -typedef struct { +struct font_desc_t { char *name; char *fpath; int spacewidth; @@ -20,7 +20,7 @@ short font[65536]; int start[65536]; short width[65536]; -} font_desc_t; +}; raw_file* load_raw(const char *name,int verbose); font_desc_t* read_font_desc(const char* fname,float factor,int verbose); Modified: mplayerxp/libvo2/img_format.h =================================================================== --- mplayerxp/libvo2/img_format.h 2012-12-13 13:52:35 UTC (rev 558) +++ mplayerxp/libvo2/img_format.h 2012-12-13 14:55:16 UTC (rev 559) @@ -142,12 +142,12 @@ static inline int IMGFMT_IS_XVMC(uint32_t fmt) { return ((fmt)&IMGFMT_XVMC_MASK)==IMGFMT_XVMC; } static inline int IMGFMT_IS_VDPAU(uint32_t fmt) { return ((fmt)&IMGFMT_VDPAU_MASK)==IMGFMT_VDPAU; } -typedef struct { +struct vo_mpegpes_t { any_t* data; int size; int id; // stream id. usually 0x1E0 int timestamp; // pts, 90000 Hz counter based -} vo_mpegpes_t; +}; /** Returns human-readable fourcc description * @param format fourcc of image Modified: mplayerxp/libvo2/jpeg_enc.h =================================================================== --- mplayerxp/libvo2/jpeg_enc.h 2012-12-13 13:52:35 UTC (rev 558) +++ mplayerxp/libvo2/jpeg_enc.h 2012-12-13 14:55:16 UTC (rev 559) @@ -23,7 +23,7 @@ */ -typedef struct { +struct jpeg_enc_t { struct MpegEncContext *s; int cheap_upsample; int bw; @@ -33,7 +33,7 @@ int y_rs; int u_rs; int v_rs; -} jpeg_enc_t; +}; jpeg_enc_t *jpeg_enc_init(int w, int h, int y_psize, int y_rsize, int u_psize, int u_rsize, int v_psize, int v_rsize, Modified: mplayerxp/libvo2/sub.h =================================================================== --- mplayerxp/libvo2/sub.h 2012-12-13 13:52:35 UTC (rev 558) +++ mplayerxp/libvo2/sub.h 2012-12-13 14:55:16 UTC (rev 559) @@ -4,9 +4,9 @@ #include "osd_render.h" namespace mpxp { - typedef struct mp_osd_bbox_s { + struct mp_osd_bbox_t { int x1,y1,x2,y2; - } mp_osd_bbox_t; + }; enum { OSDTYPE_OSD =1, @@ -31,8 +31,8 @@ MAX_UCSLINES =16 }; - typedef struct mp_osd_obj_s { - struct mp_osd_obj_s* next; + struct mp_osd_obj_t { + mp_osd_obj_t* next; unsigned char type; unsigned char alignment; // 2 bits: x;y percents, 2 bits: x;y relative to parent; 2 bits: alignment left/right/center unsigned short flags; @@ -56,7 +56,7 @@ int allocated; unsigned char *alpha_buffer; unsigned char *bitmap_buffer; - } mp_osd_obj_t; + }; enum { OSD_PLAY =0x01, @@ -78,14 +78,14 @@ OSD_PB_1 =0x13 }; - typedef struct sub_data_s { + struct sub_data_t { char * cp; int unicode; int utf8; int pos; int bg_color; /* subtitles background color */ int bg_alpha; - }sub_data_t; + }; extern sub_data_t sub_data; class Video_Output; Modified: mplayerxp/libvo2/video_out.h =================================================================== --- mplayerxp/libvo2/video_out.h 2012-12-13 13:52:35 UTC (rev 558) +++ mplayerxp/libvo2/video_out.h 2012-12-13 14:55:16 UTC (rev 559) @@ -75,14 +75,14 @@ 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 */ - typedef struct vo_query_fourcc_s { + struct vo_query_fourcc_t { uint32_t fourcc; /**< Fourcc of decoded image */ unsigned w,h; /**< Width and height of decoded image */ unsigned flags; /**< Flags for this fourcc VOCAP_* */ - }vo_query_fourcc_t; + }; /** Named video equalizer */ - typedef struct vo_videq_s { + struct vo_videq_t { #define VO_EC_BRIGHTNESS "Brightness" #define VO_EC_CONTRAST "Contrast" #define VO_EC_GAMMA "Gamma" @@ -93,9 +93,9 @@ #define VO_EC_BLUE_INTENSITY "BlueIntensity" const char *name; /**< name of equalizer control */ int value; /**< value of equalizer control in range -1000 +1000 */ - }vo_videq_t; + }; - typedef struct vo_gamma_s{ + struct vo_gamma_t{ int brightness; int saturation; int contrast; @@ -103,11 +103,11 @@ int red_intensity; int green_intensity; int blue_intensity; - }vo_gamma_t; + }; - typedef struct vo_rect_s { + struct vo_rect_t { unsigned x,y,w,h; - }vo_rect_t; + }; struct vo_rect2 { int left, right, top, bottom, width, height; @@ -242,12 +242,12 @@ vo_adjust_size_t adjust_size; }; /** Contains geometry of fourcc */ - typedef struct s_vo_format_desc { + struct vo_format_desc { unsigned bpp; /* in some strange fourccs (NV12) horz period != vert period of UV */ unsigned x_mul[4],x_div[4]; unsigned y_mul[4],y_div[4]; - }vo_format_desc; + }; extern int __FASTCALL__ vo_describe_fourcc(uint32_t fourcc,vo_format_desc *vd); } // namespace mpxp #endif Modified: mplayerxp/libvo2/x11_system.h =================================================================== --- mplayerxp/libvo2/x11_system.h 2012-12-13 13:52:35 UTC (rev 558) +++ mplayerxp/libvo2/x11_system.h 2012-12-13 14:55:16 UTC (rev 559) @@ -21,13 +21,13 @@ #include "dri_vo.h" namespace mpxp { - typedef struct { + struct MotifWmHints_t { long flags; long functions; long decorations; long input_mode; long state; - }MotifWmHints_t; + }; class X11_System { public: Modified: mplayerxp/mp_msg.cpp =================================================================== --- mplayerxp/mp_msg.cpp 2012-12-13 13:52:35 UTC (rev 558) +++ mplayerxp/mp_msg.cpp 2012-12-13 14:55:16 UTC (rev 559) @@ -13,14 +13,14 @@ #include "mp_msg.h" namespace mpxp { -#define _bg(x) ((x) >> 4) -#define _fg(x) ((x) & 0x0f) -typedef struct priv_s { +inline int _bg(int x) { return x >> 4; } +inline int _fg(int x) { return x & 0x0f; } +struct priv_t { int _color[8]; char vtmp[100]; char scol[9][20]; pthread_mutex_t mp_msg_mutex; -}priv_t; +}; const char hl[9] = { 0xC, 0x4, 0xE, 0xA, 0xB, 0x7, 0x9, 0x3, 0x7 }; static char *_2ansi(unsigned char attr) Modified: mplayerxp/mplayerxp.h =================================================================== --- mplayerxp/mplayerxp.h 2012-12-13 13:52:35 UTC (rev 558) +++ mplayerxp/mplayerxp.h 2012-12-13 14:55:16 UTC (rev 559) @@ -125,7 +125,7 @@ extern MP_Config mp_conf; /* Benchmarking */ - typedef struct time_usage_s { + struct time_usage_t { double video; double vout; double audio_decode_correction; @@ -146,7 +146,7 @@ double cur_vout; double min_vout; double total_start; - }time_usage_t; + }; struct MPXPSystem; struct xp_core_t; Modified: mplayerxp/osdep/cpudetect.h =================================================================== --- mplayerxp/osdep/cpudetect.h 2012-12-13 13:52:35 UTC (rev 558) +++ mplayerxp/osdep/cpudetect.h 2012-12-13 14:55:16 UTC (rev 559) @@ -38,7 +38,7 @@ CPUTYPE_I686=6 }; - typedef struct cpucaps_s { + struct CpuCaps { int cpuType; int cpuStepping; int hasMMX; @@ -56,7 +56,7 @@ int hasAVX; int isX86; unsigned cl_size; /* size of cache line */ - } CpuCaps; + }; extern CpuCaps gCpuCaps; Modified: mplayerxp/osdep/vbelib.h =================================================================== --- mplayerxp/osdep/vbelib.h 2012-12-13 13:52:35 UTC (rev 558) +++ mplayerxp/osdep/vbelib.h 2012-12-13 14:55:16 UTC (rev 559) @@ -13,10 +13,10 @@ /* Note: every pointer within structures is 32-bit protected mode pointer. So you don't need to convert it from real mode. */ - typedef struct tagFarPtr { + struct FarPtr { unsigned short off; unsigned short seg; - }FarPtr; + }; enum { VBE_DAC_8BIT =(1 << 0), Modified: mplayerxp/xmpcore/mp_aframe.h =================================================================== --- mplayerxp/xmpcore/mp_aframe.h 2012-12-13 13:52:35 UTC (rev 558) +++ mplayerxp/xmpcore/mp_aframe.h 2012-12-13 14:55:16 UTC (rev 559) @@ -62,7 +62,7 @@ MP_AFLG_FINALIZED =0x80000000 }; - typedef struct mp_audio_frame_s { + struct mp_aframe_t { unsigned flags; /* currently unused */ float pts; /* PTS if this frame */ unsigned xp_idx;/* index in ring buffer */ @@ -72,7 +72,7 @@ unsigned rate; /* rate of audio */ unsigned nch; /* number of channels */ mpaf_format_e format;/* PCM format of audio */ - }mp_aframe_t; + }; mp_aframe_t* new_mp_aframe(unsigned rate,unsigned nch,mpaf_format_e format,unsigned xp_idx); mp_aframe_t* new_mp_aframe_genome(const mp_aframe_t* in); Modified: mplayerxp/xmpcore/mp_image.h =================================================================== --- mplayerxp/xmpcore/mp_image.h 2012-12-13 13:52:35 UTC (rev 558) +++ mplayerxp/xmpcore/mp_image.h 2012-12-13 14:55:16 UTC (rev 559) @@ -65,7 +65,7 @@ }; enum { XP_IDX_INVALID=UINT_MAX }; - typedef struct mp_image_s { + struct mp_image_t { unsigned xp_idx; /* index of xp_frame associated with this image */ unsigned int flags; unsigned char type; @@ -87,7 +87,7 @@ int chroma_x_shift; // horizontal int chroma_y_shift; // vertical any_t* priv; /* for private use by filter or vo driver (to store buffer id or dmpi) */ - } mp_image_t; + }; void mp_image_setfmt(mp_image_t* mpi,unsigned int out_fmt); mp_image_t* new_mp_image(unsigned w,unsigned h,unsigned xp_idx); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2012-12-14 14:52:43
|
Revision: 560 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=560&view=rev Author: nickols_k Date: 2012-12-14 14:52:33 +0000 (Fri, 14 Dec 2012) Log Message: ----------- convert struct ao_functions_t into class AO_Interface Modified Paths: -------------- mplayerxp/libao2/ao_alsa9.cpp mplayerxp/libao2/ao_arts.cpp mplayerxp/libao2/ao_esd.cpp mplayerxp/libao2/ao_jack.cpp mplayerxp/libao2/ao_nas.cpp mplayerxp/libao2/ao_null.cpp mplayerxp/libao2/ao_openal.cpp mplayerxp/libao2/ao_oss.cpp mplayerxp/libao2/ao_sdl.cpp mplayerxp/libao2/ao_wav.cpp mplayerxp/libao2/audio_out.cpp mplayerxp/libao2/audio_out.h mplayerxp/libao2/audio_out_internal.h mplayerxp/mplayerxp.cpp mplayerxp/postproc/af.cpp mplayerxp/postproc/af_ao2.cpp mplayerxp/xmpcore/xmp_context.cpp Modified: mplayerxp/libao2/ao_alsa9.cpp =================================================================== --- mplayerxp/libao2/ao_alsa9.cpp 2012-12-13 14:55:16 UTC (rev 559) +++ mplayerxp/libao2/ao_alsa9.cpp 2012-12-14 14:52:33 UTC (rev 560) @@ -31,25 +31,7 @@ #include "ao_msg.h" #include "libmpstream2/mrl.h" -static ao_info_t info = -{ - "ALSA-1.x audio output", - "alsa", - "Alex Beregszaszi <al...@na...>, Joy Winter <jo...@pi...>", - "under developement" -}; - -LIBAO_EXTERN(alsa) - -typedef struct priv_s { - snd_pcm_t* handler; - snd_pcm_format_t format; - snd_pcm_hw_params_t*hwparams; - snd_pcm_sw_params_t*swparams; - size_t bytes_per_sample; - int first; -}priv_t; - +namespace mpxp { typedef struct priv_conf_s { int mmap; int noblock; @@ -60,15 +42,78 @@ { "noblock", &priv_conf.noblock, MRL_TYPE_BOOL, 0, 1 }, { NULL, NULL, 0, 0, 0 } }; +class Alsa_AO_Interface : public AO_Interface { + public: + Alsa_AO_Interface(const std::string& subdevice); + virtual ~Alsa_AO_Interface(); + virtual MPXP_Rc open(unsigned flags); + virtual MPXP_Rc configure(unsigned rate,unsigned channels,unsigned format); + virtual unsigned samplerate() const; + virtual unsigned channels() const; + virtual unsigned format() const; + virtual unsigned buffersize() const; + virtual unsigned outburst() const; + virtual MPXP_Rc test_rate(unsigned r) const; + virtual MPXP_Rc test_channels(unsigned c) const; + virtual MPXP_Rc test_format(unsigned f) const; + virtual void reset(); + virtual unsigned get_space(); + virtual float get_delay(); + virtual unsigned play(const any_t* data,unsigned len,unsigned flags); + virtual void pause(); + virtual void resume(); + virtual MPXP_Rc ctrl(int cmd,long arg) const; + private: + unsigned _channels,_samplerate,_format; + unsigned _buffersize,_outburst; + unsigned bps() const { return _channels*_samplerate*afmt2bps(_format); } + void show_caps(unsigned device) const; + int xrun(const char *str_mode) const; + unsigned play_normal(const any_t* data, unsigned len); + unsigned play_mmap(const any_t* data, unsigned len); + snd_pcm_format_t fmt2alsa(unsigned format) const; + + snd_pcm_t* handler; + snd_pcm_format_t snd_format; + snd_pcm_hw_params_t* hwparams; + snd_pcm_sw_params_t* swparams; + size_t bytes_per_sample; + int first; +}; + +Alsa_AO_Interface::Alsa_AO_Interface(const std::string& _subdevice) + :AO_Interface(_subdevice) {} +Alsa_AO_Interface::~Alsa_AO_Interface() { + int err; + if(!handler) { + MSG_ERR("alsa-uninit: no handler defined!\n"); + return; + } + if (!priv_conf.noblock) { + if ((err = snd_pcm_drain(handler)) < 0) { + MSG_ERR("alsa-uninit: pcm drain error: %s\n", snd_strerror(err)); + return; + } + } + if ((err = snd_pcm_close(handler)) < 0) { + MSG_ERR("alsa-uninit: pcm close error: %s\n", snd_strerror(err)); + return; + } else { + handler = NULL; + MSG_V("alsa-uninit: pcm closed\n"); + } + snd_pcm_hw_params_free(hwparams); + snd_pcm_sw_params_free(swparams); +} + #define ALSA_DEVICE_SIZE 48 #define BUFFERTIME // else SET_CHUNK_SIZE #undef USE_POLL -static snd_pcm_format_t __FASTCALL__ fmt2alsa(unsigned format) -{ - switch (format) +snd_pcm_format_t Alsa_AO_Interface::fmt2alsa(unsigned f) const { + switch (f) { case AFMT_S8: return SND_PCM_FORMAT_S8; @@ -132,23 +177,8 @@ } /* to set/get/query special features/parameters */ -static MPXP_Rc __FASTCALL__ control_ao(const ao_data_t* ao,int cmd, long arg) -{ - priv_t*priv=reinterpret_cast<priv_t*>(ao->priv); - int rval; +MPXP_Rc Alsa_AO_Interface::ctrl(int cmd, long arg) const { switch(cmd) { - case AOCONTROL_QUERY_FORMAT: - rval=fmt2alsa(arg); - return snd_pcm_hw_params_test_format(priv->handler, priv->hwparams,snd_pcm_format_t(rval))==0? - MPXP_True:MPXP_False; - case AOCONTROL_QUERY_CHANNELS: - rval=arg; - return snd_pcm_hw_params_test_channels(priv->handler, priv->hwparams,rval)==0? - MPXP_True:MPXP_False; - case AOCONTROL_QUERY_RATE: - rval=arg; - return snd_pcm_hw_params_test_rate(priv->handler, priv->hwparams,rval,0)==0? - MPXP_True:MPXP_False; case AOCONTROL_GET_VOLUME: case AOCONTROL_SET_VOLUME: #ifndef WORDS_BIGENDIAN @@ -167,7 +197,7 @@ long get_vol, set_vol; float calc_vol, diff, f_multi; - if(ao->format == AFMT_AC3) return MPXP_True; + if(_format == AFMT_AC3) return MPXP_True; //allocate simple id snd_mixer_selem_id_alloca(&sid); @@ -244,8 +274,7 @@ return MPXP_Unknown; } -static void __FASTCALL__ show_caps(unsigned device) -{ +void Alsa_AO_Interface::show_caps(unsigned device) const { snd_pcm_info_t *alsa_info; snd_pcm_t *pcm; snd_pcm_hw_params_t *hw_params; @@ -264,20 +293,17 @@ sdmin=snd_pcm_info_get_subdevice(alsa_info); sdmax=sdmin+snd_pcm_info_get_subdevices_count(alsa_info); MSG_INFO("AO-INFO: show caps for device %i:%i-%i\n",device,sdmin,sdmax); - for(j=sdmin;j<=sdmax;j++) - { + for(j=sdmin;j<=sdmax;j++) { int i; snd_pcm_info_set_subdevice(alsa_info,j); sprintf(adevice,"hw:%u,%u",snd_pcm_info_get_device(alsa_info),snd_pcm_info_get_subdevice(alsa_info)); MSG_INFO("AO-INFO: %s %s.%s.%s\n\n",adevice,snd_pcm_info_get_id(alsa_info),snd_pcm_info_get_name(alsa_info),snd_pcm_info_get_subdevice_name(alsa_info)); - if(snd_pcm_open(&pcm,adevice,SND_PCM_STREAM_PLAYBACK,SND_PCM_NONBLOCK)<0) - { + if(snd_pcm_open(&pcm,adevice,SND_PCM_STREAM_PLAYBACK,SND_PCM_NONBLOCK)<0) { MSG_ERR("alsa-init: playback open error: %s\n", snd_strerror(err)); return; } snd_pcm_hw_params_malloc(&hw_params); - if(snd_pcm_hw_params_any(pcm, hw_params)<0) - { + if(snd_pcm_hw_params_any(pcm, hw_params)<0) { MSG_ERR("alsa-init: can't get initial parameters: %s\n", snd_strerror(err)); return; } @@ -311,8 +337,7 @@ open & setup audio device return: 1=success 0=fail */ -static MPXP_Rc __FASTCALL__ init(ao_data_t* ao,unsigned flags) -{ +MPXP_Rc Alsa_AO_Interface::open(unsigned flags) { int err; int cards = -1; snd_pcm_info_t *alsa_info; @@ -321,21 +346,18 @@ char *alsa_port=NULL; char alsa_device[ALSA_DEVICE_SIZE]; UNUSED(flags); - priv_t*priv; - priv=new(zeromem) priv_t; - ao->priv=priv; - priv->first=1; + first=1; - priv->handler = NULL; + handler = NULL; alsa_device[0]='\0'; MSG_V("alsa-init: compiled for ALSA-%s\n", SND_LIB_VERSION_STR); - if (ao->subdevice) { + if (!subdevice.empty()) { const char *param; char *p; // example: -ao alsa:hw:0#mmap=1 - param=mrl_parse_line(ao->subdevice,NULL,NULL,&alsa_dev,&alsa_port); + param=mrl_parse_line(subdevice,NULL,NULL,&alsa_dev,&alsa_port); mrl_parse_params(param,alsaconf); if(alsa_port) { p=strchr(alsa_port,','); @@ -395,12 +417,12 @@ str_block_mode = "block-mode"; } - if (!priv->handler) { + if (!handler) { //modes = 0, SND_PCM_NONBLOCK, SND_PCM_ASYNC - if ((err = snd_pcm_open(&priv->handler, alsa_device, SND_PCM_STREAM_PLAYBACK, open_mode)) < 0) { + if ((err = snd_pcm_open(&handler, alsa_device, SND_PCM_STREAM_PLAYBACK, open_mode)) < 0) { if (priv_conf.noblock) { MSG_ERR("alsa-init: open in nonblock-mode failed, trying to open in block-mode\n"); - if ((err = snd_pcm_open(&priv->handler, alsa_device, SND_PCM_STREAM_PLAYBACK, 0)) < 0) { + if ((err = snd_pcm_open(&handler, alsa_device, SND_PCM_STREAM_PLAYBACK, 0)) < 0) { MSG_ERR("alsa-init: playback open error: %s\n", snd_strerror(err)); alsa_device[0]='\0'; return MPXP_False; @@ -414,128 +436,118 @@ return MPXP_False; } } - alsa_device[0]='\0'; - if ((err = snd_pcm_nonblock(priv->handler, block_mode)) < 0) { - MSG_ERR("alsa-init: error set block-mode %s\n", snd_strerror(err)); - } - else MSG_V("alsa-init: pcm opend in %s\n", str_block_mode); + alsa_device[0]='\0'; + if ((err = snd_pcm_nonblock(handler, block_mode)) < 0) { + MSG_ERR("alsa-init: error set block-mode %s\n", snd_strerror(err)); + } else MSG_V("alsa-init: pcm opend in %s\n", str_block_mode); - snd_pcm_hw_params_malloc(&priv->hwparams); - snd_pcm_sw_params_malloc(&priv->swparams); + snd_pcm_hw_params_malloc(&hwparams); + snd_pcm_sw_params_malloc(&swparams); - // setting hw-parameters - if ((err = snd_pcm_hw_params_any(priv->handler, priv->hwparams)) < 0) - { - MSG_ERR("alsa-init: unable to get initial parameters: %s\n", + // setting hw-parameters + if ((err = snd_pcm_hw_params_any(handler, hwparams)) < 0) { + MSG_ERR("alsa-init: unable to get initial parameters: %s\n", snd_strerror(err)); - return MPXP_False; + return MPXP_False; } - MSG_DBG2("snd_pcm_hw_params_any()\n"); - if (priv_conf.mmap) { - snd_pcm_access_mask_t *mask = (snd_pcm_access_mask_t*)alloca(snd_pcm_access_mask_sizeof()); - snd_pcm_access_mask_none(mask); - snd_pcm_access_mask_set(mask, SND_PCM_ACCESS_MMAP_INTERLEAVED); - snd_pcm_access_mask_set(mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED); - snd_pcm_access_mask_set(mask, SND_PCM_ACCESS_MMAP_COMPLEX); - err = snd_pcm_hw_params_set_access_mask(priv->handler, priv->hwparams, mask); - MSG_ERR("alsa-init: mmap set\n"); - } else { - err = snd_pcm_hw_params_set_access(priv->handler, priv->hwparams,SND_PCM_ACCESS_RW_INTERLEAVED); - MSG_DBG2("snd_pcm_hw_params_set_access(SND_PCM_ACCESS_RW_INTERLEAVED)\n"); - } - if (err < 0) { - MSG_ERR("alsa-init: unable to set access type: %s\n", snd_strerror(err)); - return MPXP_False; - } + MSG_DBG2("snd_pcm_hw_params_any()\n"); + if (priv_conf.mmap) { + snd_pcm_access_mask_t *mask = (snd_pcm_access_mask_t*)alloca(snd_pcm_access_mask_sizeof()); + snd_pcm_access_mask_none(mask); + snd_pcm_access_mask_set(mask, SND_PCM_ACCESS_MMAP_INTERLEAVED); + snd_pcm_access_mask_set(mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED); + snd_pcm_access_mask_set(mask, SND_PCM_ACCESS_MMAP_COMPLEX); + err = snd_pcm_hw_params_set_access_mask(handler, hwparams, mask); + MSG_ERR("alsa-init: mmap set\n"); + } else { + err = snd_pcm_hw_params_set_access(handler, hwparams,SND_PCM_ACCESS_RW_INTERLEAVED); + MSG_DBG2("snd_pcm_hw_params_set_access(SND_PCM_ACCESS_RW_INTERLEAVED)\n"); + } + if (err < 0) { + MSG_ERR("alsa-init: unable to set access type: %s\n", snd_strerror(err)); + return MPXP_False; + } } // end switch priv->handler (spdif) return MPXP_Ok; } // end init -static MPXP_Rc __FASTCALL__ config_ao(ao_data_t* ao,unsigned rate_hz,unsigned channels,unsigned format) -{ - priv_t*priv=reinterpret_cast<priv_t*>(ao->priv); +MPXP_Rc Alsa_AO_Interface::configure(unsigned r,unsigned c,unsigned f) { int err,i; size_t chunk_size=0,chunk_bytes,bits_per_sample,bits_per_frame; snd_pcm_uframes_t dummy; - MSG_V("alsa-conf: requested format: %d Hz, %d channels, %s\n", rate_hz, - channels, ao_format_name(format)); + MSG_V("alsa-conf: requested format: %d Hz, %d channels, %s\n", r, + c, ao_format_name(f)); - ao->samplerate = rate_hz; - ao->bps = channels * rate_hz; - ao->format = format; - ao->channels = channels; - ao->outburst = OUTBURST; + _samplerate = r; + _format = f; + _channels = c; + _outburst = OUTBURST; //ao->buffersize = MAX_OUTBURST; // was 16384 - priv->format=fmt2alsa(format); + snd_format=fmt2alsa(_format); - switch(priv->format) { + switch(snd_format) { case SND_PCM_FORMAT_S16_LE: case SND_PCM_FORMAT_U16_LE: case SND_PCM_FORMAT_S16_BE: case SND_PCM_FORMAT_U16_BE: - ao->bps *= 2; - break; case SND_PCM_FORMAT_S32_LE: case SND_PCM_FORMAT_S32_BE: case SND_PCM_FORMAT_U32_LE: case SND_PCM_FORMAT_U32_BE: case SND_PCM_FORMAT_FLOAT_BE: case SND_PCM_FORMAT_FLOAT_LE: - ao->bps *= 4; - break; case SND_PCM_FORMAT_S24_LE: case SND_PCM_FORMAT_S24_BE: case SND_PCM_FORMAT_U24_LE: case SND_PCM_FORMAT_U24_BE: - ao->bps *= 3; break; case -1: MSG_ERR("alsa-conf: invalid format (%s) requested - output disabled\n", - ao_format_name(format)); + ao_format_name(_format)); return MPXP_False; default: break; } - priv->bytes_per_sample = ao->bps / ao->samplerate; + bytes_per_sample = bps() / _samplerate; - if ((err = snd_pcm_hw_params_set_format(priv->handler, priv->hwparams, - priv->format)) < 0) { + if ((err = snd_pcm_hw_params_set_format(handler, hwparams, + snd_format)) < 0) { MSG_ERR("alsa-conf: unable to set format(%s): %s\n", - snd_pcm_format_name(priv->format), + snd_pcm_format_name(snd_format), snd_strerror(err)); MSG_HINT("Please try one of: "); for(i=0;i<SND_PCM_FORMAT_LAST;i++) - if (!(snd_pcm_hw_params_test_format(priv->handler, priv->hwparams, snd_pcm_format_t(i)))) + if (!(snd_pcm_hw_params_test_format(handler, hwparams, snd_pcm_format_t(i)))) MSG_HINT("%s ",snd_pcm_format_name(snd_pcm_format_t(i))); MSG_HINT("\n"); return MPXP_False; } - MSG_DBG2("snd_pcm_hw_params_set_format(%i)\n",priv->format); + MSG_DBG2("snd_pcm_hw_params_set_format(%i)\n",snd_format); - if ((err = snd_pcm_hw_params_set_rate_near(priv->handler, priv->hwparams, &ao->samplerate, 0)) < 0) { + if ((err = snd_pcm_hw_params_set_rate_near(handler, hwparams, &_samplerate, 0)) < 0) { MSG_ERR("alsa-conf: unable to set samplerate %u: %s\n", - ao->samplerate, + _samplerate, snd_strerror(err)); return MPXP_False; } - MSG_DBG2("snd_pcm_hw_params_set_rate_near(%i)\n",ao->samplerate); + MSG_DBG2("snd_pcm_hw_params_set_rate_near(%i)\n",_samplerate); - if ((err = snd_pcm_hw_params_set_channels(priv->handler, priv->hwparams, - ao->channels)) < 0) { + if ((err = snd_pcm_hw_params_set_channels(handler, hwparams, + _channels)) < 0) { MSG_ERR("alsa-conf: unable to set %u channels: %s\n", - ao->channels, + _channels, snd_strerror(err)); return MPXP_False; } - MSG_DBG2("snd_pcm_hw_params_set_channels(%i)\n",ao->channels); + MSG_DBG2("snd_pcm_hw_params_set_channels(%i)\n",_channels); #ifdef BUFFERTIME { int dir; unsigned period_time,alsa_buffer_time = 500000; /* buffer time in us */ - if ((err = snd_pcm_hw_params_set_buffer_time_near(priv->handler, priv->hwparams, &alsa_buffer_time, &dir)) < 0) { + if ((err = snd_pcm_hw_params_set_buffer_time_near(handler, hwparams, &alsa_buffer_time, &dir)) < 0) { MSG_ERR("alsa-init: unable to set buffer time near: %s\n", snd_strerror(err)); return MPXP_False; @@ -543,7 +555,7 @@ MSG_DBG2("snd_pcm_hw_set_buffer_time_near(%i)\n",alsa_buffer_time); period_time = alsa_buffer_time/4; - if ((err = snd_pcm_hw_params_set_period_time_near(priv->handler, priv->hwparams, &period_time, &dir)) < 0) { + if ((err = snd_pcm_hw_params_set_period_time_near(handler, hwparams, &period_time, &dir)) < 0) { /* original: alsa_buffer_time/ao->bps */ MSG_ERR("alsa-init: unable to set period time: %s\n", snd_strerror(err)); @@ -557,14 +569,14 @@ int dir=0; unsigned period_time=100000; /* period time in us */ snd_pcm_uframes_t size; - if ((err = snd_pcm_hw_params_set_period_time_near(priv->handler, priv->hwparams, &period_time, &dir)) < 0) { + if ((err = snd_pcm_hw_params_set_period_time_near(handler, hwparams, &period_time, &dir)) < 0) { MSG_ERR("alsa-init: unable to set period_time: %s\n", snd_strerror(err)); return MPXP_False; } MSG_DBG2("snd_pcm_hw_set_period_time(%i)\n",period_time); //get chunksize - if ((err = snd_pcm_hw_params_get_period_size(priv->hwparams, &size, &dir)) < 0) { + if ((err = snd_pcm_hw_params_get_period_size(hwparams, &size, &dir)) < 0) { MSG_ERR("alsa-init: unable to get period_size: %s\n", snd_strerror(err)); return MPXP_False; } @@ -573,23 +585,23 @@ } #endif // gets buffersize for control_ao - if ((err = snd_pcm_hw_params_get_buffer_size(priv->hwparams,&dummy)) < 0) { + if ((err = snd_pcm_hw_params_get_buffer_size(hwparams,&dummy)) < 0) { MSG_ERR("alsa-conf: unable to get buffersize: %s\n", snd_strerror(err)); return MPXP_False; } else { - ao->buffersize = dummy * priv->bytes_per_sample; - MSG_V("alsa-conf: got buffersize=%i\n", ao->buffersize); + _buffersize = dummy * bytes_per_sample; + MSG_V("alsa-conf: got buffersize=%i\n", _buffersize); } MSG_DBG2("snd_pcm_hw_params_get_buffer_size(%i)\n",dummy); - bits_per_sample = snd_pcm_format_physical_width(priv->format); + bits_per_sample = snd_pcm_format_physical_width(snd_format); MSG_DBG2("%i=snd_pcm_hw_format_pohysical_width()\n",bits_per_sample); - bits_per_frame = bits_per_sample * channels; + bits_per_frame = bits_per_sample * _channels; chunk_bytes = chunk_size * bits_per_frame / 8; MSG_V("alsa-conf: bits per sample (bps)=%i, bits per frame (bpf)=%i, chunk_bytes=%i\n",bits_per_sample,bits_per_frame,chunk_bytes); /* finally install hardware parameters */ - if ((err = snd_pcm_hw_params(priv->handler, priv->hwparams)) < 0) { + if ((err = snd_pcm_hw_params(handler, hwparams)) < 0) { MSG_ERR("alsa-conf: unable to set hw-parameters: %s\n", snd_strerror(err)); return MPXP_False; @@ -597,76 +609,42 @@ MSG_DBG2("snd_pcm_hw_params()\n"); // setting sw-params (only avail-min) if noblocking mode was choosed if (priv_conf.noblock) { - if ((err = snd_pcm_sw_params_current(priv->handler, priv->swparams)) < 0) { + if ((err = snd_pcm_sw_params_current(handler, swparams)) < 0) { MSG_ERR("alsa-conf: unable to get parameters: %s\n",snd_strerror(err)); return MPXP_False; } //set min available frames to consider pcm ready (4) //increased for nonblock-mode should be set dynamically later - if ((err = snd_pcm_sw_params_set_avail_min(priv->handler, priv->swparams, 4)) < 0) { + if ((err = snd_pcm_sw_params_set_avail_min(handler, swparams, 4)) < 0) { MSG_ERR("alsa-conf: unable to set avail_min %s\n",snd_strerror(err)); return MPXP_False; } - if ((err = snd_pcm_sw_params(priv->handler, priv->swparams)) < 0) { + if ((err = snd_pcm_sw_params(handler, swparams)) < 0) { MSG_ERR("alsa-conf: unable to install sw-params\n"); return MPXP_False; } }//end swparams - if ((err = snd_pcm_prepare(priv->handler)) < 0) { + if ((err = snd_pcm_prepare(handler)) < 0) { MSG_ERR("alsa-conf: pcm prepare error: %s\n", snd_strerror(err)); return MPXP_False; } // end setting hw-params MSG_V("alsa-conf: %d Hz/%d channels/%d bpf/%d bytes buffer/%s\n", - ao->samplerate, ao->channels, priv->bytes_per_sample, ao->buffersize, - snd_pcm_format_description(priv->format)); + _samplerate, _channels, bytes_per_sample, _buffersize, + snd_pcm_format_description(snd_format)); return MPXP_Ok; } // end config_ao -/* close audio device */ -static void uninit(ao_data_t* ao) -{ +void Alsa_AO_Interface::pause() { int err; - priv_t*priv=reinterpret_cast<priv_t*>(ao->priv); - if(!priv->handler) { - MSG_ERR("alsa-uninit: no handler defined!\n"); - delete priv; - return; - } if (!priv_conf.noblock) { - if ((err = snd_pcm_drain(priv->handler)) < 0) { - MSG_ERR("alsa-uninit: pcm drain error: %s\n", snd_strerror(err)); - delete priv; - return; - } - } - - if ((err = snd_pcm_close(priv->handler)) < 0) { - MSG_ERR("alsa-uninit: pcm close error: %s\n", snd_strerror(err)); - delete priv; - return; - } else { - priv->handler = NULL; - MSG_V("alsa-uninit: pcm closed\n"); - } - snd_pcm_hw_params_free(priv->hwparams); - snd_pcm_sw_params_free(priv->swparams); - delete priv; -} - -static void audio_pause(ao_data_t* ao) -{ - priv_t*priv=reinterpret_cast<priv_t*>(ao->priv); - int err; - - if (!priv_conf.noblock) { //drain causes error in nonblock-mode! - if ((err = snd_pcm_drain(priv->handler)) < 0) { + if ((err = snd_pcm_drain(handler)) < 0) { MSG_ERR("alsa-pause: pcm drain error: %s\n", snd_strerror(err)); return; } @@ -676,28 +654,24 @@ } } -static void audio_resume(ao_data_t* ao) -{ - priv_t*priv=reinterpret_cast<priv_t*>(ao->priv); +void Alsa_AO_Interface::resume() { int err; - if ((err = snd_pcm_prepare(priv->handler)) < 0) { + if ((err = snd_pcm_prepare(handler)) < 0) { MSG_ERR("alsa-resume: pcm prepare error: %s\n", snd_strerror(err)); return; } } /* stop playing and empty buffers (for seeking/pause) */ -static void reset(ao_data_t* ao) -{ - priv_t*priv=reinterpret_cast<priv_t*>(ao->priv); +void Alsa_AO_Interface::reset() { int err; - if ((err = snd_pcm_drop(priv->handler)) < 0) { + if ((err = snd_pcm_drop(handler)) < 0) { MSG_ERR("alsa-reset: pcm drop error: %s\n", snd_strerror(err)); return; } - if ((err = snd_pcm_prepare(priv->handler)) < 0) { + if ((err = snd_pcm_prepare(handler)) < 0) { MSG_ERR("alsa-reset: pcm prepare error: %s\n", snd_strerror(err)); return; } @@ -718,28 +692,23 @@ } #endif -#ifndef timersub -#define timersub(a, b, result) \ -do { \ - (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ - (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ - if ((result)->tv_usec < 0) { \ - --(result)->tv_sec; \ - (result)->tv_usec += 1000000; \ - } \ -} while (0) -#endif +static void _timersub(const struct timeval*a,const struct timeval* b,struct timeval* result) { + result->tv_sec = a->tv_sec - b->tv_sec; + result->tv_usec = a->tv_usec - b->tv_usec; + if (result->tv_usec < 0) { + --result->tv_sec; + result->tv_usec += 1000000; + } +} /* I/O error handler */ -static int __FASTCALL__ xrun(const ao_data_t* ao,const char *str_mode) -{ - priv_t*priv=reinterpret_cast<priv_t*>(ao->priv); +int Alsa_AO_Interface::xrun(const char *str_mode) const { int err; snd_pcm_status_t *status; snd_pcm_status_alloca(&status); - if ((err = snd_pcm_status(priv->handler, status))<0) { + if ((err = snd_pcm_status(handler, status))<0) { MSG_ERR("status error: %s", snd_strerror(err)); return 0; } @@ -748,13 +717,13 @@ struct timeval now, diff, tstamp; gettimeofday(&now, 0); snd_pcm_status_get_trigger_tstamp(status, &tstamp); - timersub(&now, &tstamp, &diff); + _timersub(&now, &tstamp, &diff); MSG_V("alsa-%s: xrun of at least %.3f msecs. resetting stream\n", str_mode, diff.tv_sec * 1000 + diff.tv_usec / 1000.0); } - if ((err = snd_pcm_prepare(priv->handler))<0) { + if ((err = snd_pcm_prepare(handler))<0) { MSG_ERR("xrun: prepare error: %s", snd_strerror(err)); return 0; } @@ -762,16 +731,12 @@ return 1; /* ok, data should be accepted again */ } -static unsigned __FASTCALL__ play_normal(ao_data_t* ao,const any_t* data, unsigned len); -static unsigned __FASTCALL__ play_mmap(ao_data_t* ao,const any_t* data, unsigned len); - -static unsigned __FASTCALL__ play(ao_data_t* ao,const any_t* data, unsigned len, unsigned flags) -{ +unsigned Alsa_AO_Interface::play(const any_t* data, unsigned len, unsigned flags) { unsigned result; UNUSED(flags); MSG_DBG2("[ao_alsa] %s playing %i bytes\n",priv_conf.mmap?"mmap":"normal",len); - if (priv_conf.mmap) result = play_mmap(ao,data, len); - else result = play_normal(ao,data, len); + if (priv_conf.mmap) result = play_mmap(data, len); + else result = play_normal(data, len); return result; } @@ -782,36 +747,33 @@ thanxs for marius <ma...@ro...> for giving us the light ;) */ -static unsigned __FASTCALL__ play_normal(ao_data_t* ao,const any_t* data, unsigned len) -{ - priv_t*priv=reinterpret_cast<priv_t*>(ao->priv); - //priv->bytes_per_sample is always 4 for 2 chn S16_LE - unsigned num_frames = len / priv->bytes_per_sample; - char *output_samples = (char *)data; +unsigned Alsa_AO_Interface::play_normal(const any_t* data, unsigned len) { + unsigned num_frames = len / bytes_per_sample; + const char *output_samples = (const char *)data; snd_pcm_sframes_t res = 0; //fprintf(stderr,"alsa-play: frames=%i, len=%i\n",num_frames,len); - if (!priv->handler) { + if (!handler) { MSG_ERR("alsa-play: device configuration error"); return 0; } while (num_frames > 0) { - res = snd_pcm_writei(priv->handler, (any_t*)output_samples, num_frames); + res = snd_pcm_writei(handler, (any_t*)output_samples, num_frames); if (res == -EAGAIN) { - snd_pcm_wait(priv->handler, 1000); + snd_pcm_wait(handler, 1000); } else if (res == -EPIPE) { /* underrun */ - if (xrun(ao,"play") <= 0) { + if (xrun("play") <= 0) { MSG_ERR("alsa-play: xrun reset error"); return 0; } } else if (res == -ESTRPIPE) { /* suspend */ MSG_WARN("alsa-play: pcm in suspend mode. trying to resume\n"); - while ((res = snd_pcm_resume(priv->handler)) == -EAGAIN) sleep(1); + while ((res = snd_pcm_resume(handler)) == -EAGAIN) ::sleep(1); } else if (res < 0) { MSG_ERR("alsa-play: unknown status, trying to reset soundcard\n"); - if ((res = snd_pcm_prepare(priv->handler)) < 0) { + if ((res = snd_pcm_prepare(handler)) < 0) { MSG_ERR("alsa-play: snd prepare error"); return 0; break; @@ -820,7 +782,7 @@ if (res > 0) { /* output_samples += ao->channels * res; */ - output_samples += res * priv->bytes_per_sample; + output_samples += res * bytes_per_sample; num_frames -= res; } } //end while @@ -836,51 +798,49 @@ * 'An overview of the ALSA API' http://people.debian.org/~joshua/x66.html * and some help by Paul Davis <pb...@op...> */ -static unsigned __FASTCALL__ play_mmap(ao_data_t* ao,const any_t* data, unsigned len) -{ - priv_t*priv=reinterpret_cast<priv_t*>(ao->priv); +unsigned Alsa_AO_Interface::play_mmap(const any_t* data, unsigned len) { snd_pcm_sframes_t commitres, frames_available; snd_pcm_uframes_t frames_transmit, size, offset; const snd_pcm_channel_area_t *area; - any_t*outbuffer; + any_t* outbuffer; unsigned result; #ifdef USE_POLL //seems not really be needed struct pollfd *ufds; int count; - count = snd_pcm_poll_descriptors_count (priv->handler); + count = snd_pcm_poll_descriptors_count (handler); ufds = mp_malloc(sizeof(struct pollfd) * count); - snd_pcm_poll_descriptors(priv->handler, ufds, count); + snd_pcm_poll_descriptors(handler, ufds, count); //first wait_for_poll - if (err = (wait_for_poll(priv->handler, ufds, count) < 0)) { - if (snd_pcm_state(priv->handler) == SND_PCM_STATE_XRUN || - snd_pcm_state(priv->handler) == SND_PCM_STATE_SUSPENDED) { + if (err = (wait_for_poll(handler, ufds, count) < 0)) { + if (snd_pcm_state(handler) == SND_PCM_STATE_XRUN || + snd_pcm_state(handler) == SND_PCM_STATE_SUSPENDED) { xrun("play"); } } #endif - outbuffer = alloca(ao->buffersize); + outbuffer = alloca(_buffersize); //don't trust get_space() ;) - frames_available = snd_pcm_avail_update(priv->handler) * priv->bytes_per_sample; - if (frames_available < 0) xrun(ao,"play"); + frames_available = snd_pcm_avail_update(handler) * bytes_per_sample; + if (frames_available < 0) xrun("play"); if (frames_available < 4) { - if (priv->first) { - priv->first = 0; - snd_pcm_start(priv->handler); + if (first) { + first = 0; + snd_pcm_start(handler); } else { //FIXME should break and return 0? - snd_pcm_wait(priv->handler, -1); - priv->first = 1; + snd_pcm_wait(handler, -1); + first = 1; } } /* len is simply the available bufferspace got by get_space() * but real avail_buffer in frames is ab/priv->bytes_per_sample */ - size = len / priv->bytes_per_sample; + size = len / bytes_per_sample; //if (verbose) //printf("len: %i size %i, f_avail %i, bps %i ...\n", len, size, frames_available, priv->bytes_per_sample); @@ -890,43 +850,26 @@ /* prepare areas and set sw-pointers * frames_transmit returns the real available buffer-size * sometimes != frames_available cause of ringbuffer 'emulation' */ - snd_pcm_mmap_begin(priv->handler, &area, &offset, &frames_transmit); + snd_pcm_mmap_begin(handler, &area, &offset, &frames_transmit); /* this is specific to interleaved streams (or non-interleaved * streams with only one channel) */ outbuffer = ((char *) area->addr + (area->first + area->step * offset) / 8); //8 //write data - memcpy(outbuffer, data, (frames_transmit * priv->bytes_per_sample)); - commitres = snd_pcm_mmap_commit(priv->handler, offset, frames_transmit); + memcpy(outbuffer, data, (frames_transmit * bytes_per_sample)); + commitres = snd_pcm_mmap_commit(handler, offset, frames_transmit); if (commitres < 0 || (snd_pcm_uframes_t)commitres != frames_transmit) { - if (snd_pcm_state(priv->handler) == SND_PCM_STATE_XRUN || - snd_pcm_state(priv->handler) == SND_PCM_STATE_SUSPENDED) { - xrun(ao,"play"); + if (snd_pcm_state(handler) == SND_PCM_STATE_XRUN || + snd_pcm_state(handler) == SND_PCM_STATE_SUSPENDED) { + xrun("play"); } } - //if (verbose) - //printf("mmap ft: %i, cres: %i\n", frames_transmit, commitres); - - /* err = snd_pcm_area_copy(&area, offset, &data, offset, len, priv->format); */ - /* if (err < 0) { */ - /* printf("area-copy-error\n"); */ - /* return 0; */ - /* } */ - //calculate written frames! - result = commitres * priv->bytes_per_sample; + result = commitres * bytes_per_sample; - - /* if (verbose) { */ - /* if (len == result) */ - /* printf("result: %i, frames written: %i ...\n", result, frames_transmit); */ - /* else */ - /* printf("result: %i, frames written: %i, result != len ...\n", result, frames_transmit); */ - /* } */ - //mplayer doesn't like -result if ((int)result < 0) result = 0; @@ -946,9 +889,7 @@ GET_SPACE_UNDEFINED }space_status; /* how many byes are mp_free in the buffer */ -static unsigned get_space(const ao_data_t* ao) -{ - priv_t*priv=reinterpret_cast<priv_t*>(ao->priv); +unsigned Alsa_AO_Interface::get_space() { snd_pcm_status_t *status; int ret,st; space_status e_status=GET_SPACE_UNDEFINED; @@ -960,7 +901,7 @@ return 0; } - if ((ret = snd_pcm_status(priv->handler, status)) < 0) { + if ((ret = snd_pcm_status(handler, status)) < 0) { MSG_ERR("alsa-space: cannot get pcm status: %s\n", snd_strerror(ret)); return 0; } @@ -971,14 +912,14 @@ case SND_PCM_STATE_PREPARED: if (e_status!=GET_SPACE_OPEN) { e_status = GET_SPACE_PREPARED; - priv->first = 1; - ret = snd_pcm_status_get_avail(status) * priv->bytes_per_sample; + first = 1; + ret = snd_pcm_status_get_avail(status) * bytes_per_sample; if (ret == 0) //ugly workaround for hang in mmap-mode ret = 10; break; } case SND_PCM_STATE_RUNNING: - ret = snd_pcm_status_get_avail(status) * priv->bytes_per_sample; + ret = snd_pcm_status_get_avail(status) * bytes_per_sample; //avail_frames = snd_pcm_avail_update(priv->handler) * priv->bytes_per_sample; if (e_status!=GET_SPACE_OPEN && e_status!=GET_SPACE_PREPARED) e_status = GET_SPACE_RUNNING; @@ -989,16 +930,16 @@ ret = 0; break; case SND_PCM_STATE_XRUN: - xrun(ao,"space"); + xrun("space"); e_status = GET_SPACE_XRUN; - priv->first = 1; + first = 1; ret = 0; break; default: e_status = GET_SPACE_UNDEFINED; - ret = snd_pcm_status_get_avail(status) * priv->bytes_per_sample; + ret = snd_pcm_status_get_avail(status) * bytes_per_sample; if (ret <= 0) { - xrun(ao,"space"); + xrun("space"); } } @@ -1015,10 +956,9 @@ } /* delay in seconds between first and last sample in buffer */ -static float get_delay(const ao_data_t* ao) +float Alsa_AO_Interface::get_delay() { - priv_t*priv=reinterpret_cast<priv_t*>(ao->priv); - if (priv->handler) { + if (handler) { snd_pcm_status_t *status; int r; float ret; @@ -1028,7 +968,7 @@ return 0; } - if ((ret = snd_pcm_status(priv->handler, status)) < 0) { + if ((ret = snd_pcm_status(handler, status)) < 0) { MSG_ERR("alsa-delay: cannot get pcm status: %s\n", snd_strerror(ret)); return 0; } @@ -1038,7 +978,7 @@ case SND_PCM_STATE_PREPARED: case SND_PCM_STATE_RUNNING: r=snd_pcm_status_get_delay(status); - ret = (float)r/(float)ao->samplerate; + ret = (float)r/(float)_samplerate; break; default: ret = 0; @@ -1049,3 +989,36 @@ return ret; } else return 0; } + +unsigned Alsa_AO_Interface::samplerate() const { return _samplerate; } +unsigned Alsa_AO_Interface::channels() const { return _channels; } +unsigned Alsa_AO_Interface::format() const { return _format; } +unsigned Alsa_AO_Interface::buffersize() const { return _buffersize; } +unsigned Alsa_AO_Interface::outburst() const { return _outburst; } +MPXP_Rc Alsa_AO_Interface::test_channels(unsigned c) const { + return snd_pcm_hw_params_test_channels(handler, hwparams,c)==0? + MPXP_True:MPXP_False; +} +MPXP_Rc Alsa_AO_Interface::test_rate(unsigned r) const { + return snd_pcm_hw_params_test_rate(handler, hwparams,r,0)==0? + MPXP_True:MPXP_False; +} +MPXP_Rc Alsa_AO_Interface::test_format(unsigned f) const { + snd_pcm_format_t rval; + rval=fmt2alsa(f); + return snd_pcm_hw_params_test_format(handler, hwparams,snd_pcm_format_t(rval))==0? + MPXP_True:MPXP_False; +} + +static AO_Interface* query_interface(const std::string& sd) { return new Alsa_AO_Interface(sd); } + +extern const ao_info_t audio_out_alsa = +{ + "ALSA-1.x audio output", + "alsa", + "Alex Beregszaszi <al...@na...>, Joy Winter <jo...@pi...>", + "under developement", + query_interface +}; +} //namespace mpxp + Modified: mplayerxp/libao2/ao_arts.cpp =================================================================== --- mplayerxp/libao2/ao_arts.cpp 2012-12-13 14:55:16 UTC (rev 559) +++ mplayerxp/libao2/ao_arts.cpp 2012-12-14 14:52:33 UTC (rev 560) @@ -32,33 +32,57 @@ #include "afmt.h" #include "ao_msg.h" +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 */ +class Arts_AO_Interface : public AO_Interface { + public: + Arts_AO_Interface(const std::string& subdevice); + virtual ~Arts_AO_Interface(); -static const ao_info_t info = -{ - "aRts audio output", - "arts", - "Michele Balistreri <br...@gm...>", - "" + virtual MPXP_Rc open(unsigned flags); + virtual MPXP_Rc configure(unsigned rate,unsigned channels,unsigned format); + virtual unsigned samplerate() const; + virtual unsigned channels() const; + virtual unsigned format() const; + virtual unsigned buffersize() const; + virtual unsigned outburst() const; + virtual MPXP_Rc test_rate(unsigned r) const; + virtual MPXP_Rc test_channels(unsigned c) const; + virtual MPXP_Rc test_format(unsigned f) const; + virtual void reset(); + virtual unsigned get_space(); + virtual float get_delay(); + virtual unsigned play(const any_t* data,unsigned len,unsigned flags); + virtual void pause(); + virtual void resume(); + virtual MPXP_Rc ctrl(int cmd,long arg) const; + private: + unsigned _channels,_samplerate,_format; + unsigned _buffersize,_outburst; + unsigned bps() const { return _channels*_samplerate*afmt2bps(_format); } + + arts_stream_t stream; }; -LIBAO_EXTERN(arts) +Arts_AO_Interface::Arts_AO_Interface(const std::string& _subdevice) + :AO_Interface(_subdevice) {} +Arts_AO_Interface::~Arts_AO_Interface() { + arts_close_stream(stream); + arts_free(); +} -static MPXP_Rc control_ao(const ao_data_t* ao,int cmd, long arg) -{ - UNUSED(ao); +MPXP_Rc Arts_AO_Interface::ctrl(int cmd, long arg) const { UNUSED(cmd); UNUSED(arg); return MPXP_Unknown; } -static MPXP_Rc init(ao_data_t* ao,unsigned flags) +MPXP_Rc Arts_AO_Interface::open(unsigned flags) { int err; - UNUSED(ao); UNUSED(flags); if( (err=arts_init()) ) { @@ -70,9 +94,7 @@ return MPXP_Ok; } -static MPXP_Rc __FASTCALL__ config_ao(ao_data_t* ao,unsigned rate,unsigned channels,unsigned format) -{ - arts_stream_t stream; +MPXP_Rc Arts_AO_Interface::configure(unsigned r,unsigned c,unsigned f) { unsigned frag_spec,samplesize; /* * arts supports 8bit unsigned and 16bit signed sample formats @@ -82,10 +104,13 @@ * Unsupported formats are translated to one of these two formats * using mplayer's audio filters. */ - switch (format) { + _samplerate=r; + _channels=c; + _format=f; + switch (f) { case AFMT_U8: case AFMT_S8: - format = AFMT_U8; + _format = AFMT_U8; samplesize=1; break; #if 0 @@ -93,31 +118,25 @@ case AFMT_S24_BE: case AFMT_U24_LE: case AFMT_U24_BE: - format = AFMT_S24_LE; + _format = AFMT_S24_LE; samplesize=3; break; case AFMT_S32_LE: case AFMT_S32_BE: case AFMT_U32_LE: case AFMT_U32_BE: - format = AFMT_S32_LE; + _format = AFMT_S32_LE; samplesize=4; break; #endif default: samplesize=2; - format = AFMT_S16_LE; /* artsd always expects little endian?*/ + _format = AFMT_S16_LE; /* artsd always expects little endian?*/ break; } - ao->format = format; - ao->channels = channels; - ao->samplerate = rate; - ao->bps = rate*channels*samplesize; + stream=arts_play_stream(_samplerate, samplesize*8, _channels, "MPlayerXP"); - stream=arts_play_stream(rate, samplesize*8, channels, "MPlayerXP"); - ao->priv=stream; - if(stream == NULL) { MSG_ERR("[aRts] Can't open stream\n"); arts_free(); @@ -129,47 +148,61 @@ arts_stream_set(stream, ARTS_P_BLOCKING, 1); frag_spec = ARTS_PACKET_SIZE_LOG2 | ARTS_PACKETS << 16; arts_stream_set(stream, ARTS_P_PACKET_SETTINGS, frag_spec); - ao->buffersize = arts_stream_get(stream, ARTS_P_BUFFER_SIZE); + _buffersize = arts_stream_get(stream, ARTS_P_BUFFER_SIZE); MSG_INFO("[aRts] Stream opened\n"); - MSG_V("[aRts] buffersize=%u\n",ao->buffersize); + MSG_V("[aRts] buffersize=%u\n",_buffersize); MSG_V("[aRts] buffersize=%u\n", arts_stream_get(stream, ARTS_P_PACKET_SIZE)); return MPXP_Ok; } -static void uninit(ao_data_t* ao) +unsigned Arts_AO_Interface::play(const any_t* data,unsigned len,unsigned flags) { - arts_stream_t stream=ao->priv; - arts_close_stream(stream); - arts_free(); -} - -static unsigned play(ao_data_t* ao,const any_t* data,unsigned len,unsigned flags) -{ - arts_stream_t stream=ao->priv; UNUSED(flags); return arts_write(stream, data, len); } -static void audio_pause(ao_data_t* ao) -{ - UNUSED(ao); +void Arts_AO_Interface::pause() {} +void Arts_AO_Interface::resume() {} +void Arts_AO_Interface::reset() {} +unsigned Arts_AO_Interface::get_space() { + return arts_stream_get(stream, ARTS_P_BUFFER_SPACE); } -static void audio_resume(ao_data_t* ao) { UNUSED(ao); } -static void reset(ao_data_t* ao) { UNUSED(ao); } +float Arts_AO_Interface::get_delay() { + return ((float) (_buffersize - arts_stream_get(stream, + ARTS_P_BUFFER_SPACE))) / ((float) bps()); +} -static unsigned get_space(const ao_data_t* ao) -{ - arts_stream_t stream=ao->priv; - return arts_stream_get(stream, ARTS_P_BUFFER_SPACE); +unsigned Arts_AO_Interface::samplerate() const { return _samplerate; } +unsigned Arts_AO_Interface::channels() const { return _channels; } +unsigned Arts_AO_Interface::format() const { return _format; } +unsigned Arts_AO_Interface::buffersize() const { return _buffersize; } +unsigned Arts_AO_Interface::outburst() const { return _outburst; } +MPXP_Rc Arts_AO_Interface::test_channels(unsigned c) const { UNUSED(c); return MPXP_Ok; } +MPXP_Rc Arts_AO_Interface::test_rate(unsigned r) const { UNUSED(r); return MPXP_Ok; } +MPXP_Rc Arts_AO_Interface::test_format(unsigned f) const { + switch (f) { + case AFMT_U8: + case AFMT_S8: + case AFMT_U16_LE: + case AFMT_S16_LE: + case AFMT_U16_BE: + case AFMT_S16_BE: return MPXP_Ok; + default: break; + } + return MPXP_False; } -static float get_delay(const ao_data_t* ao) +static AO_Interface* query_interface(const std::string& sd) { return new Arts_AO_Interface(sd); } + +extern const ao_info_t audio_out_arts = { - arts_stream_t stream=ao->priv; - return ((float) (ao->buffersize - arts_stream_get(stream, - ARTS_P_BUFFER_SPACE))) / ((float) ao->bps); -} - + "aRts audio output", + "arts", + "Michele Balistreri <br...@gm...>", + "", + query_interface +}; +} // namespace mpxp Modified: mplayerxp/libao2/ao_esd.cpp =================================================================== --- mplayerxp/libao2/ao_esd.cpp 2012-12-13 14:55:16 UTC (rev 559) +++ mplayerxp/libao2/ao_esd.cpp 2012-12-14 14:52:33 UTC (rev 560) @@ -56,6 +56,8 @@ #include "afmt.h" #include "ao_msg.h" + +namespace mpxp { #define ESD_RESAMPLES 0 #define ESD_DEBUG 0 @@ -65,37 +67,68 @@ #define dprintf(...) /**/ #endif - #define ESD_CLIENT_NAME "MPlayerXP" #define ESD_MAX_DELAY (1.0f) /* max amount of data buffered in esd (#sec) */ -static const ao_info_t info = -{ - "EsounD audio output", - "esd", - "Juergen Keil <jk...@to...>", - "" +class Esd_AO_Interface : public AO_Interface { + public: + Esd_AO_Interface(const std::string& subdevice); + virtual ~Esd_AO_Interface(); + + virtual MPXP_Rc open(unsigned flags); + virtual MPXP_Rc configure(unsigned rate,unsigned channels,unsigned format); + virtual unsigned samplerate() const; + virtual unsigned channels() const; + virtual unsigned format() const; + virtual unsigned buffersize() const; + virtual unsigned outburst() const; + virtual MPXP_Rc test_rate(unsigned r) const; + virtual MPXP_Rc test_channels(unsigned c) const; + virtual MPXP_Rc test_format(unsigned f) const; + virtual void reset(); + virtual unsigned get_space(); + virtual float get_delay(); + virtual unsigned play(const any_t* data,unsigned len,unsigned flags); + virtual void pause(); + virtual void resume(); + virtual MPXP_Rc ctrl(int cmd,long arg) const; + private: + unsigned _channels,_samplerate,_format; + unsigned _buffersize,_outburst; + unsigned bps() const { return _channels*_samplerate*afmt2bps(_format); } + + int fd; + int play_fd; + esd_server_info_t*svinfo; + int latency; + int bytes_per_sample; + unsigned long samples_written; + struct timeval play_start; + float audio_delay; }; -LIBAO_EXTERN(esd) +Esd_AO_Interface::Esd_AO_Interface(const std::string& _subdevice) + :AO_Interface(_subdevice) {} +Esd_AO_Interface::~Esd_AO_Interface() { + if (play_fd >= 0) { + esd_close(play_fd); + play_fd = -1; + } -typedef struct priv_s { - int fd; - int play_fd; - esd_server_info_t* svinfo; - int latency; - int bytes_per_sample; - unsigned long samples_written; - struct timeval play_start; - float audio_delay; -}priv_t; + if (svinfo) { + esd_free_server_info(svinfo); + svinfo = NULL; + } + if (fd >= 0) { + esd_close(fd); + fd = -1; + } +} /* * to set/get/query special features/parameters */ -static MPXP_Rc control_ao(const ao_data_t* ao,int cmd, long arg) -{ - priv_t*priv=reinterpret_cast<priv_t*>(ao->priv); +MPXP_Rc Esd_AO_Interface::ctrl(int cmd, long arg) const { esd_player_info_t *esd_pi; esd_info_t *esd_i; time_t now; @@ -111,7 +144,7 @@ } dprintf("esd: get vol\n"); - if ((esd_i = esd_get_all_info(priv->fd)) == NULL) + if ((esd_i = esd_get_all_info(fd)) == NULL) return MPXP_Error; for (esd_pi = esd_i->player_list; esd_pi != NULL; esd_pi = esd_pi->next) @@ -132,7 +165,7 @@ case AOCONTROL_SET_VOLUME: dprintf("esd: set vol\n"); - if ((esd_i = esd_get_all_info(priv->fd)) == NULL) + if ((esd_i = esd_get_all_info(fd)) == NULL) return MPXP_Error; for (esd_pi = esd_i->player_list; esd_pi != NULL; esd_pi = esd_pi->next) @@ -141,7 +174,7 @@ if (esd_pi != NULL) { ao_control_vol_t *vol = (ao_control_vol_t *)arg; - esd_set_stream_pan(priv->fd, esd_pi->source_id, + esd_set_stream_pan(fd, esd_pi->source_id, vol->left * ESD_VOLUME_BASE / 100, vol->right * ESD_VOLUME_BASE / 100); @@ -161,17 +194,12 @@ * open & setup audio device * return: 1=success 0=fail */ -static MPXP_Rc init(ao_data_t* ao,unsigned flags) -{ - priv_t*priv; - ao->priv=new(zeromem) priv_t; - ao->priv=priv; - priv->fd=priv->play_fd=-1; - char *server = ao->subdevice; /* NULL for localhost */ +MPXP_Rc Esd_AO_Interface::open(unsigned flags) { + fd=play_fd=-1; UNUSED(flags); - if (priv->fd < 0) { - priv->fd = esd_open_sound(server); - if (priv->fd < 0) { + if (fd < 0) { + fd = esd_open_sound(subdevice.c_str()); + if (fd < 0) { MSG_ERR("ESD: Can't open sound: %s\n", strerror(errno)); return MPXP_False; } @@ -179,67 +207,60 @@ return MPXP_Ok; } -static MPXP_Rc config_ao(ao_data_t* ao,unsigned rate_hz,unsigned channels,unsigned format) +MPXP_Rc Esd_AO_Interface::configure(unsigned r,unsigned c,unsigned f) { - priv_t*priv=reinterpret_cast<priv_t*>(ao->priv); - char *server = ao->subdevice; /* NULL for localhost */ + std::string server = subdevice; /* NULL for localhost */ esd_format_t esd_fmt; - int bytes_per_sample; + int _bytes_per_sample; int fl; float lag_seconds, lag_net, lag_serv; struct timeval proto_start, proto_end; - /* get server info, and measure network latency */ - gettimeofday(&proto_start, NULL); - priv->svinfo = esd_get_server_info(priv->fd); - if(server) { - gettimeofday(&proto_end, NULL); - lag_net = (proto_end.tv_sec - proto_start.tv_sec) + - (proto_end.tv_usec - proto_start.tv_usec) / 1000000.0; - lag_net /= 2.0; /* round trip -> one way */ - } else - lag_net = 0.0; /* no network lag */ - /* - if (priv->svinfo) { - mp_msg(MSGT_AO, MSGL_INFO, "AO: [esd] server info:\n"); - esd_print_server_info(priv->svinfo); - } - */ + /* get server info, and measure network latency */ + gettimeofday(&proto_start, NULL); + svinfo = esd_get_server_info(fd); + if(!server.empty()) { + gettimeofday(&proto_end, NULL); + lag_net = (proto_end.tv_sec - proto_start.tv_sec) + + (proto_end.tv_usec - proto_start.tv_usec) / 1000000.0; + lag_net /= 2.0; /* round trip -> one way */ + } else + lag_net = 0.0; /* no network lag */ esd_fmt = ESD_STREAM | ESD_PLAY; #if ESD_RESAMPLES /* let the esd daemon convert sample rate */ #else /* let mplayer's audio filter convert the sample rate */ - if (priv->svinfo != NULL) - rate_hz = priv->svinfo->rate; + if (svinfo != NULL) + r = svinfo->rate; #endif - ao->samplerate = rate_hz; + _samplerate = r; - /* EsounD can play mono or stereo */ - switch (channels) { - case 1: - esd_fmt |= ESD_MONO; - ao->channels = bytes_per_sample = 1; + /* EsounDscan play mono or stereo */ + switch (c) { + case 1: + esd_fmt |= ESD_MONO; + _channels = _bytes_per_sample = 1; + break; + default: + esd_fmt |= ESD_STEREO; + _channels = _bytes_per_sample = 2; break; - default: - esd_fmt |= ESD_STEREO; - ao->channels = bytes_per_sample = 2; - break; } /* EsounD can play 8bit unsigned and 16bit signed native */ - switch (format) { - case AFMT_S8: - case AFMT_U8: - esd_fmt |= ESD_BITS8; - ao->format = AFMT_U8; - break; - default: - esd_fmt |= ESD_BITS16; - ao->format = AFMT_S16_NE; - bytes_per_sample *= 2; - break; + switch (f) { + case AFMT_S8: + case AFMT_U8: + esd_fmt |= ESD_BITS8; + _format = AFMT_U8; + break; + default: + esd_fmt |= ESD_BITS16; + _format = AFMT_S16_NE; + _bytes_per_sample *= 2; + break; } /* modify priv->audio_delay depending on priv->latency @@ -247,86 +268,57 @@ * adjust according to rate_hz & bytes_per_sample */ #ifdef CONFIG_ESD_LATENCY - priv->latency = esd_get_latency(priv->fd); + latency = esd_get_latency(fd); #else - priv->latency = ((channels == 1 ? 2 : 1) * ESD_DEFAULT_RATE * - (ESD_BUF_SIZE + 64 * (4.0f / bytes_per_sample)) - ) / rate_hz; - priv->latency += ESD_BUF_SIZE * 2; + latency = ((_channels == 1 ? 2 : 1) * ESD_DEFAULT_RATE * + (ESD_BUF_SIZE + 64 * (4.0f / _bytes_per_sample)) + ) / _samplerate; + latency += ESD_BUF_SIZE * 2; #endif - if(priv->latency > 0) { - lag_serv = (priv->latency * 4.0f) / (bytes_per_sample * rate_hz); + if(latency > 0) { + lag_serv = (latency * 4.0f) / (_bytes_per_sample * _samplerate); lag_seconds = lag_net + lag_serv; - priv->audio_delay += lag_seconds; + audio_delay += lag_seconds; MSG_INFO("ESD: LatencyInfo: %f %f %f\n",lag_serv, lag_net, lag_seconds); } - priv->play_fd = esd_play_stream_fallback(esd_fmt, rate_hz, - server, ESD_CLIENT_NAME); - if (priv->play_fd < 0) { + play_fd = esd_play_stream_fallback(esd_fmt, _samplerate, + server.c_str(), ESD_CLIENT_NAME); + if (play_fd < 0) { MSG_ERR("ESD: Can't open play stream: %s\n", strerror(errno)); return MPXP_False; } /* enable non-blocking i/o on the socket connection to the esd server */ - if ((fl = fcntl(priv->play_fd, F_GETFL)) >= 0) - fcntl(priv->play_fd, F_SETFL, O_NDELAY|fl); + if ((fl = ::fcntl(play_fd, F_GETFL)) >= 0) ::fcntl(play_fd, F_SETFL, O_NDELAY|fl); #if ESD_DEBUG { int sbuf, rbuf, len; len = sizeof(sbuf); - getsockopt(priv->play_fd, SOL_SOCKET, SO_SNDBUF, &sbuf, &len); + getsockopt(play_fd, SOL_SOCKET, SO_SNDBUF, &sbuf, &len); len = sizeof(rbuf); - getsockopt(priv->play_fd, SOL_SOCKET, SO_RCVBUF, &rbuf, &len); + getsockopt(play_fd, SOL_SOCKET, SO_RCVBUF, &rbuf, &len); dprintf("esd: send/receive socket buffer space %d/%d bytes\n", sbuf, rbuf); } #endif - ao->bps = bytes_per_sample * rate_hz; - ao->outburst = ao->bps > 100000 ? 4*ESD_BUF_SIZE : 2*ESD_BUF_SIZE; + _outburst = bps() > 100000 ? 4*ESD_BUF_SIZE : 2*ESD_BUF_SIZE; - priv->play_start.tv_sec = 0; - priv->samples_written = 0; - priv->bytes_per_sample = bytes_per_sample; + play_start.tv_sec = 0; + samples_written = 0; + bytes_per_sample = _bytes_per_sample; return MPXP_Ok; } - /* - * close audio device - */ -static void uninit(ao_data_t* ao) -{ - priv_t*priv=reinterpret_cast<priv_t*>(ao->priv); - if (priv->play_fd >= 0) { - esd_close(priv->play_fd); - priv->play_fd = -1; - } - - if (priv->svinfo) { - esd_free_server_info(priv->svinfo); - priv->svinfo = NULL; - } - - if (priv->fd >= 0) { - esd_close(priv->fd); - priv->fd = -1; - } - delete priv; -} - - -/* * plays 'len' bytes of 'data' * it should round it down to outburst*n * return: number of bytes played */ -static unsigned play(ao_data_t* ao,const any_t* data, unsigned len, unsigned flags) -{ - priv_t*priv=reinterpret_cast<priv_t*>(ao->priv); +unsigned Esd_AO_Interface::play(const any_t* data, unsigned len, unsigned flags) { unsigned offs; unsigned nwritten; int nsamples; @@ -337,14 +329,14 @@ #define SINGLE_WRITE 0 #if SINGLE_WRITE - nwritten = write(priv->play_fd, data, len); + nwritten = ::write(play_fd, data, len); #else for (offs = 0, nwritten=0; offs + ESD_BUF_SIZE <= len; offs += ESD_BUF_SIZE) { /* * note: we're writing to a non-blocking socket here. * A partial write means, that the socket buffer is full. */ - n = write(priv->play_fd, (char*)data + offs, ESD_BUF_SIZE); + n = ::write(play_fd, (char*)data + offs, ESD_BUF_SIZE); if ( n < 0 ) { if ( errno != EAGAIN ) { dprintf("esd play: write failed: %s\n", strerror(errno)); @@ -359,39 +351,26 @@ #endif if (nwritten > 0) { - if (!priv->play_start.tv_sec) - gettimeofday(&priv->play_start, NULL); - nsamples = nwritten / priv->bytes_per_sample; - priv->samples_written += nsamples; + if (!play_start.tv_sec) + ::gettimeofday(&play_start, NULL); + nsamples = nwritten / bytes_per_sample; + samples_written += nsamples; - dprintf("esd play: %d %lu\n", nsamples, priv->samples_written); + dprintf("esd play: %d %lu\n", nsamples, samples_written); } else { - dprintf("esd play: blocked / %lu\n", priv->samples_written); + dprintf("esd play: blocked / %lu\n", samples_written); } - return nwritten; } - /* * stop playing, keep buffers (for pause) */ -static void audio_pause(ao_data_t* ao) -{ - /* - * not possible with priv-> the esd daemom will continue playing - * buffered data (not more than ESD_MAX_DELAY seconds of samples) - */ - UNUSED(ao); -} - - +void Esd_AO_Interface::pause() {} /* * resume playing, after audio_pause() */ -static void audio_resume(ao_data_t* ao) -{ - priv_t*priv=reinterpret_cast<priv_t*>(ao->priv); +void Esd_AO_Interface::resume() { /* * not possible with priv-> * @@ -399,33 +378,25 @@ * buffered data; we restart our time based delay computation * for an audio resume. */ - priv->play_start.tv_sec = 0; - priv->samples_written = 0; + play_start.tv_sec = 0; + samples_written = 0; } - /* * stop playing and empty buffers (for seeking/pause) */ -static void reset(ao_data_t* ao) -{ +void Esd_AO_Interface::reset() { #ifdef __svr4__ - priv_t*priv=reinterpret_cast<priv_t*>(ao->priv); /* throw away data buffered in the esd connection */ - if (ioctl(priv->play_fd, I_FLUSH, FLUSHW)) - perror("I_FLUSH"); -#else - UNUSED(ao); + if (::ioctl(play_fd, I_FLUSH, FLUSHW)) perror("I_FLUSH"); #endif } - /* * return: how many bytes can be played without blocking */ -static unsigned get_space(const ao_data_t* ao) +unsigned Esd_AO_Interface::get_space() { - priv_t*priv=reinterpret_cast<priv_t*>(ao->priv); struct timeval tmout; fd_set wfds; float current_delay; @@ -438,24 +409,24 @@ * device, and the consequence is a huge slow down for things like * esd_get_all_info(). */ - if ((current_delay = get_delay(ao)) >= ESD_MAX_DELAY) { + if ((current_delay = get_delay()) >= ESD_MAX_DELAY) { dprintf("esd get_space: too much data buffered\n"); return 0; } FD_ZERO(&wfds); - FD_SET(priv->play_fd, &wfds); + FD_SET(play_fd, &wfds); tmout.tv_sec = 0; tmout.tv_usec = 0; - if (select(priv->play_fd + 1, NULL, &wfds, NULL, &tmout) != 1) + if (::select(play_fd + 1, NULL, &wfds, NULL, &tmout) != 1) return 0; - if (!FD_ISSET(priv->play_fd, &wfds)) + if (!FD_ISSET(play_fd, &wfds)) return 0; /* try to fill 50% of the remaining "mp_free" buffer space */ - space = (ESD_MAX_DELAY - current_delay) * ao->bps * 0.5f; + space = (ESD_MAX_DELAY - current_delay) * bps() * 0.5f; /* round up to next multiple of ESD_BUF_SIZE */ space = (space + ESD_BUF_SIZE-1) / ESD_BUF_SIZE * ESD_BUF_SIZE; @@ -464,34 +435,50 @@ return space; } - /* * return: delay in seconds between first and last sample in buffer */ -static float get_delay(const ao_data_t* ao) -{ - priv_t*priv=reinterpret_cast<priv_t*>(ao->priv); +float Esd_AO_Interface::get_delay() { struct timeval now; double buffered_samples_time; double play_time; - if (!priv->play_start.tv_sec) - return 0; + if (!play_start.tv_sec) return 0; - buffered_samples_time = (float)priv->samples_written / ao->samplerate; - gettimeofday(&now, NULL); - play_time = now.tv_sec - priv->play_start.tv_sec; - play_time += (now.tv_usec - priv->play_start.tv_usec) / 1000000.; + buffered_samples_time = (float)samples_written / _samplerate; + ::gettimeofday(&now, NULL); + play_time = now.tv_sec - play_start.tv_sec; + play_time += (now.tv_usec - play_start.tv_usec) / 1000000.; /* dprintf("esd delay: %f %f\n", play_time, buffered_samples_time); */ if (play_time > buffered_samples_time) { dprintf("esd: underflow\n"); - priv->play_start.tv_sec = 0; - priv->samples_written = 0; + play_start.tv_sec = 0; + samples_written = 0; return 0; } dprintf("esd: get_delay %f\n", buffered_samples_time - play_time); return buffered_samples_time - play_time; } + +unsigned Esd_AO_Interface::samplerate() const { return _samplerate; } +unsigned Esd_AO_Interface::channels() const { return _channels; } +unsigned Esd_AO_Interface::format() const { return _format; } +unsigned Esd_AO_Interface::buffersize() const { return _buffersize; } +unsigned Esd_AO_Interface::outburst() const { return _outburst; } +MPXP_Rc Esd_AO_Interface::test_channels(unsigned c) const { UNUSED(c); return MPXP_Ok; } +MPXP_Rc Esd_AO_Interface::test_rate(unsigned r) const { UNUSED(r); return MPXP_Ok; } +MPXP_Rc Esd_AO_Interface::test_format(unsigned f) const { UNUSED(f); return MPXP_Ok; } + +static AO_Interface* query_interface(const std::string& sd) { return new Esd_AO_Interface(sd); } + +extern const ao_info_t audio_out_esd = { + "EsounD audio output", + "esd", + "Juergen Keil <jk...@to...>", + "", + query_interface +}; +} // namespace mpxp Modified: mplayerxp/libao2/ao_jack.cpp =================================================================== --- mplayerxp/libao2/ao_jack.cpp 2012-12-13 14:55:16 UTC (rev 559) +++ mplayerxp/libao2/ao_jack.cpp 2012-12-14 14:52:33 UTC (rev 560) @@ -39,42 +39,71 @@ #include "mp_conf_lavc.h" #include <jack/jack.h> -static const ao_info_t info = -{ - "JACK audio output", - "jack", - "Reimar Döffinger <Rei...@st...>", - "based on ao_sdl.c" -}; +namespace mpxp { -LIBAO_EXTERN(jack) - //! maximum number of channels supported, avoids lots of mallocs #define MAX_CHANS 6 -typedef struct priv_s { - jack_port_t * ports[MAX_CHANS]; - unsigned num_ports; ///< Number of used ports == number of channels - jack_client_t * client; - float latency; - int estimate; - volatile int paused; ///< set if paused - volatile int underrun; ///< signals if an priv->underrun occured +class Jack_AO_Interface : public AO_Interface { + public: + Jack_AO_Interface(const std::string& subdevice); + virtual ~Jack_AO_Interface(); - volatile float callback_interval; - volatile float callback_time; + virtual MPXP_Rc open(unsigned flags); + virtual MPXP_Rc configure(unsigned rate,unsigned channels,unsigned format); + virtual unsigned samplerate() const; + virtual unsigned channels() const; + virtual unsigned format() const; + virtual unsigned buffersize() const; + virtual unsigned outburst() const; + virtual MPXP_Rc test_rate(unsigned r) const; + virtual MPXP_Rc test_channels(unsigned c) const; + virtual MPXP_Rc test_format(unsigned f) const; + virtual void reset(); + virtual unsigned get_space(); + virtual float get_delay(); + virtual unsigned play(const any_t* data,unsigned len,unsigned flags); + virtual void pause(); + virtual void resume(); + virtual MPXP_Rc ctrl(int cmd,long arg) const; + static void deinterleave_data(any_t*_info, any_t*src, int len); + static int outputaudio(jack_nframes_t nframes, any_t* _ao); + private: + unsigned _channels,_samplerate,_format; + unsigned _buffersize,_outburst; + unsigned bps() const { return _channels*_samplerate*afmt2bps(_format); } + unsigned read_buffer(float **bufs, unsigned cnt, unsigned num_bufs); + int write_buffer(const unsigned char* data, int len); + static void silence(float **bufs, int cnt, int num_bufs); - AVFifoBuffer * buffer; //! buffer for audio data -}priv_t; + jack_port_t * ports[MAX_CHANS]; + unsigned num_ports; ///< Number of used ports == number of channels + jack_client_t * client; + float latency; + int estimate; + volatile int paused; ///< set if paused + volatile int underrun; ///< signals if an priv->underrun occur... [truncated message content] |
From: <nic...@us...> - 2012-12-15 11:18:16
|
Revision: 562 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=562&view=rev Author: nickols_k Date: 2012-12-15 11:18:09 +0000 (Sat, 15 Dec 2012) Log Message: ----------- segfault-- About illegal patch: Breakpoint 1, int16_to_int32_SSE3 (in_data=0x7fffe8000b90, out_data= 0x7fffe8002ba0, inlen=8192, final=0) at ./aflib_accel.h:89 89 unsigned i,insamples = inlen/sizeof(int16_t); (gdb) s 98 i=0; (gdb) print inlen $1 = 8192 (gdb) print insamples $2 = 8192 (gdb) q Modified Paths: -------------- mplayerxp/libmpcodecs/ad_mp3.cpp mplayerxp/postproc/aflib.cpp mplayerxp/postproc/aflib.h mplayerxp/postproc/aflib_accel.h Modified: mplayerxp/libmpcodecs/ad_mp3.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_mp3.cpp 2012-12-14 15:13:41 UTC (rev 561) +++ mplayerxp/libmpcodecs/ad_mp3.cpp 2012-12-15 11:18:09 UTC (rev 562) @@ -346,11 +346,14 @@ void uninit(ad_private_t *priv) { - mpg123_close(priv->mh); - mpg123_delete(priv->mh); - mpg123_exit(); + if(priv->mh) { + mpg123_close(priv->mh); + mpg123_delete(priv->mh); + mpg123_exit(); + } delete priv; - dlclose(dll_handle); + if(dll_handle) dlclose(dll_handle); + dll_handle=NULL; } MPXP_Rc control_ad(ad_private_t *priv,int cmd,any_t* arg, ...) Modified: mplayerxp/postproc/aflib.cpp =================================================================== --- mplayerxp/postproc/aflib.cpp 2012-12-14 15:13:41 UTC (rev 561) +++ mplayerxp/postproc/aflib.cpp 2012-12-15 11:18:09 UTC (rev 562) @@ -19,7 +19,7 @@ #define __USE_ISOC99 1 #include <math.h> #ifndef HAVE_LRINTF -#define lrintf(x) ((int)(x)) +template <class T> int lrintf ( T x ) { return (int)x; } #endif #include "aflib.h" Modified: mplayerxp/postproc/aflib.h =================================================================== --- mplayerxp/postproc/aflib.h 2012-12-14 15:13:41 UTC (rev 561) +++ mplayerxp/postproc/aflib.h 2012-12-15 11:18:09 UTC (rev 562) @@ -163,7 +163,9 @@ extern int32_t (* __FASTCALL__ FIR_i16)(const int16_t *x,const int16_t *w); extern float (* __FASTCALL__ FIR_f32)(const float *x,const float *w); -#ifndef SATURATE -#define SATURATE(x,_min,_max) {if((x)<(_min)) (x)=(_min); else if((x)>(_max)) (x)=(_max);} +template <class T> const T& saturate ( T& x, const T& _min, const T& _max ) { + if(x<_min) x=_min; + else if(x>_max) x=_max; + return x; +} #endif -#endif Modified: mplayerxp/postproc/aflib_accel.h =================================================================== --- mplayerxp/postproc/aflib_accel.h 2012-12-14 15:13:41 UTC (rev 561) +++ mplayerxp/postproc/aflib_accel.h 2012-12-15 11:18:09 UTC (rev 562) @@ -346,7 +346,7 @@ if(!_ivec_aligned(out)) for(;i<insamples;i++) { ftmp=in[i]; - SATURATE(ftmp,-0.999998,+0.999998); + saturate(ftmp,-0.999998f,+0.999998f); out[i]=(int32_t)lrintf((std::numeric_limits<int32_t>::max()-1)*ftmp); if(_ivec_aligned(out)) break; } @@ -371,7 +371,7 @@ #endif for(;i<insamples;i++) { ftmp=in[i]; - SATURATE(ftmp,-0.999998,+0.999998); + saturate(ftmp,-0.999998f,+0.999998f); out[i]=(int32_t)lrintf((std::numeric_limits<int32_t>::max()-1)*ftmp); } } @@ -424,7 +424,7 @@ case 1: for(i=0;i<in->len;i++) { ftmp=((float*)in->audio)[i]; - SATURATE(ftmp,-1.0,+1.0); + saturate(ftmp,-1.0f,+1.0f); ((int8_t*)out->audio)[i]=(int8_t)lrintf(std::numeric_limits<int16_t>::max()*ftmp); } break; @@ -439,7 +439,7 @@ #else for(i=0;i<in->len;i++) { ftmp=((float*)in->audio)[i]; - SATURATE(ftmp,-1.0,+1.0); + saturate(ftmp,-1.0f,+1.0f); ((int16_t*)out->audio)[i]=(int16_t)lrintf(std::numeric_limits<int16_t>::max()*ftmp); } #endif @@ -447,7 +447,7 @@ case 3: for(i=0;i<in->len;i++) { ftmp=((float*)in->audio)[i]; - SATURATE(ftmp,-1.0,+1.0); + saturate(ftmp,-1.0f,+1.0f); store24bit(out->audio, i, (int32_t)lrintf((std::numeric_limits<int32_t>::max()-1)*ftmp)); } break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2012-12-15 17:27:18
|
Revision: 564 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=564&view=rev Author: nickols_k Date: 2012-12-15 17:27:08 +0000 (Sat, 15 Dec 2012) Log Message: ----------- small part of last patch. The farewell message! It seems that my copy of gcc compiler was skilfully hacked by malefactor(s). They block uploading of main patch: converting libao2 ->libao3. Therefore, libao2 is most important place of my project for them and for their dark deals. Weel, i need to find out other ways to continue my development, what is impossible right for now. Breakpoint 1, mpxp::query_interface (sd=...) at ao_alsa9.cpp:1013 1013 static AO_Interface* query_interface(const std::string& sd) { return new(zeromem) Alsa_AO_Interface(sd); } (gdb) print sd $1 = (const std::string &) @0x18dcff0: {static npos = <optimized out>, _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>}, _M_p = 0x0}} (gdb) s operator new (size=88) at mp_malloc.cpp:574 574 any_t *operator new(size_t size,const zeromemory_t&) { return SECURE_NAME1(_mp_mallocz)(size); } (gdb) n x1840952739 (size=88) at mp_malloc.cpp:549 549 any_t* SECURE_NAME1(_mp_mallocz)(size_t size) { (gdb) n 551 ptr = mp_mallocz(size); (gdb) n 552 if(!ptr) { (gdb) n 557 } (gdb) n mpxp::query_interface (sd=...) at ao_alsa9.cpp:1013 1013 static AO_Interface* query_interface(const std::string& sd) { return new(zeromem) Alsa_AO_Interface(sd); } (gdb) s Alsa_AO_Interface (_subdevice=..., this=<optimized out>) at ao_alsa9.cpp:1013 1013 static AO_Interface* query_interface(const std::string& sd) { return new(zeromem) Alsa_AO_Interface(sd); } (gdb) s AO_Interface (_subdevice=..., this=<optimized out>) at audio_out_internal.h:11 11 AO_Interface(const std::string& _subdevice):subdevice(_subdevice) {} (gdb) print _subdevice $2 = <optimized out> (gdb) s mpxp::query_interface (sd=...) at ao_alsa9.cpp:1013 1013 static AO_Interface* query_interface(const std::string& sd) { return new(zeromem) Alsa_AO_Interface(sd); } (gdb) s Alsa_AO_Interface (_subdevice=..., this=0x19b6fa8) at ao_alsa9.cpp:1013 1013 static AO_Interface* query_interface(const std::string& sd) { return new(zeromem) Alsa_AO_Interface(sd); } (gdb) print _subdevice $3 = (const std::string &) @0x18dcff0: {static npos = <optimized out>, _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>}, _M_p = 0x0}} (gdb) s AO_Interface (_subdevice=..., this=0x19b6fa8) at audio_out_internal.h:11 11 AO_Interface(const std::string& _subdevice):subdevice(_subdevice) {} (gdb) s std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string (this=0x19b6fb0, __str=...) at /Data/3rdparty.src/gcc/gcc-4.5.4/x86_64-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.h:441 441 basic_string(const basic_string& __str); (gdb) print this $4 = ( std::basic_string<char, std::char_traits<char>, std::allocator<char> > * const) 0x19b6fb0 (gdb) print *this $5 = {static npos = 18446744073709551615, _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>}, _M_p = 0x0}} Modified Paths: -------------- mplayerxp/libao2/Makefile mplayerxp/libao2/ao_arts.cpp mplayerxp/libao2/ao_esd.cpp mplayerxp/libao2/ao_jack.cpp mplayerxp/libao2/ao_nas.cpp mplayerxp/libao2/ao_null.cpp mplayerxp/libao2/ao_openal.cpp mplayerxp/libao2/ao_oss.cpp mplayerxp/libao2/ao_sdl.cpp mplayerxp/libao2/ao_wav.cpp mplayerxp/libao2/audio_out.cpp mplayerxp/libao2/audio_out.h mplayerxp/mplayerxp.cpp Added Paths: ----------- mplayerxp/libao2/ao_alsa.cpp Removed Paths: ------------- mplayerxp/libao2/ao_alsa9.cpp mplayerxp/libao2/mixer.cpp mplayerxp/libao2/mixer.h Modified: mplayerxp/libao2/Makefile =================================================================== --- mplayerxp/libao2/Makefile 2012-12-15 13:09:33 UTC (rev 563) +++ mplayerxp/libao2/Makefile 2012-12-15 17:27:08 UTC (rev 564) @@ -4,7 +4,7 @@ LIBNAME = libao2.a # TODO: moveout ao_sdl.c so it's only used when SDL is detected -CXXSRCS=audio_out.cpp mixer.cpp afmt.cpp +CXXSRCS=audio_out.cpp afmt.cpp CXXSRCS+=ao_null.cpp ao_wav.cpp ifeq ($(HAVE_SDL),yes) CXXSRCS+=ao_sdl.cpp @@ -13,7 +13,7 @@ CXXSRCS+=ao_oss.cpp endif ifeq ($(HAVE_ALSA),yes) -CXXSRCS+=ao_alsa9.cpp +CXXSRCS+=ao_alsa.cpp endif ifeq ($(HAVE_ARTS),yes) CXXSRCS+=ao_arts.cpp Copied: mplayerxp/libao2/ao_alsa.cpp (from rev 563, mplayerxp/libao2/ao_alsa9.cpp) =================================================================== --- mplayerxp/libao2/ao_alsa.cpp (rev 0) +++ mplayerxp/libao2/ao_alsa.cpp 2012-12-15 17:27:08 UTC (rev 564) @@ -0,0 +1,1024 @@ +#include "mp_config.h" +#include "osdep/mplib.h" +using namespace mpxp; +/* + ao_alsa9 - ALSA-0.9.x output plugin for MPlayer + + (C) Alex Beregszaszi <al...@na...> + + modified for real alsa-0.9.0-support by Joy Winter <jo...@pi...> + additional AC3 passthrough support by Andy Lo A Foe <an...@al...> + 08/22/2002 iec958-init rewritten and merged with common init, joy + + Any bugreports regarding to this driver are welcome. +*/ + +#include <errno.h> +#include <sys/time.h> +#include <stdlib.h> +#include <math.h> +#include <string.h> +#include <sys/poll.h> + +#include "mplayerxp.h" +#define ALSA_PCM_NEW_HW_PARAMS_API +#define ALSA_PCM_NEW_SW_PARAMS_API +#include <alsa/asoundlib.h> + +#include "audio_out.h" +#include "audio_out_internal.h" +#include "afmt.h" +#include "ao_msg.h" +#include "libmpstream2/mrl.h" + +namespace mpxp { +typedef struct priv_conf_s { + int mmap; + int noblock; +}priv_conf_t; +static priv_conf_t priv_conf; +static const mrl_config_t alsaconf[]={ + { "mmap", &priv_conf.mmap, MRL_TYPE_BOOL, 0, 1 }, + { "noblock", &priv_conf.noblock, MRL_TYPE_BOOL, 0, 1 }, + { NULL, NULL, 0, 0, 0 } +}; +class Alsa_AO_Interface : public AO_Interface { + public: + Alsa_AO_Interface(const std::string& subdevice); + virtual ~Alsa_AO_Interface(); + + virtual MPXP_Rc open(unsigned flags); + virtual MPXP_Rc configure(unsigned rate,unsigned channels,unsigned format); + virtual unsigned samplerate() const; + virtual unsigned channels() const; + virtual unsigned format() const; + virtual unsigned buffersize() const; + virtual unsigned outburst() const; + virtual MPXP_Rc test_rate(unsigned r) const; + virtual MPXP_Rc test_channels(unsigned c) const; + virtual MPXP_Rc test_format(unsigned f) const; + virtual void reset(); + virtual unsigned get_space(); + virtual float get_delay(); + virtual unsigned play(const any_t* data,unsigned len,unsigned flags); + virtual void pause(); + virtual void resume(); + virtual MPXP_Rc ctrl(int cmd,long arg) const; + private: + unsigned _channels,_samplerate,_format; + unsigned _buffersize,_outburst; + unsigned bps() const { return _channels*_samplerate*afmt2bps(_format); } + void show_caps(unsigned device) const; + int xrun(const char *str_mode) const; + unsigned play_normal(const any_t* data, unsigned len); + unsigned play_mmap(const any_t* data, unsigned len); + snd_pcm_format_t fmt2alsa(unsigned format) const; + + snd_pcm_t* handler; + snd_pcm_format_t snd_format; + snd_pcm_hw_params_t* hwparams; + snd_pcm_sw_params_t* swparams; + size_t bytes_per_sample; + int first; +}; + +Alsa_AO_Interface::Alsa_AO_Interface(const std::string& _subdevice) + :AO_Interface(_subdevice) {} +Alsa_AO_Interface::~Alsa_AO_Interface() { + int err; + if(!handler) { + MSG_ERR("alsa-uninit: no handler defined!\n"); + return; + } + if (!priv_conf.noblock) { + if ((err = snd_pcm_drain(handler)) < 0) { + MSG_ERR("alsa-uninit: pcm drain error: %s\n", snd_strerror(err)); + return; + } + } + if ((err = snd_pcm_close(handler)) < 0) { + MSG_ERR("alsa-uninit: pcm close error: %s\n", snd_strerror(err)); + return; + } else { + handler = NULL; + MSG_V("alsa-uninit: pcm closed\n"); + } + snd_pcm_hw_params_free(hwparams); + snd_pcm_sw_params_free(swparams); +} + +#define ALSA_DEVICE_SIZE 48 + +#define BUFFERTIME // else SET_CHUNK_SIZE +#undef USE_POLL + +snd_pcm_format_t Alsa_AO_Interface::fmt2alsa(unsigned f) const { + switch (f) + { + case AFMT_S8: + return SND_PCM_FORMAT_S8; + break; + case AFMT_U8: + return SND_PCM_FORMAT_U8; + break; + case AFMT_U16_LE: + return SND_PCM_FORMAT_U16_LE; + break; + case AFMT_U16_BE: + return SND_PCM_FORMAT_U16_BE; + break; +#ifndef WORDS_BIGENDIAN + case AFMT_AC3: +#endif + case AFMT_S16_LE: + return SND_PCM_FORMAT_S16_LE; + break; +#ifdef WORDS_BIGENDIAN + case AFMT_AC3: +#endif + case AFMT_S16_BE: + return SND_PCM_FORMAT_S16_BE; + break; + case AFMT_S32_LE: + return SND_PCM_FORMAT_S32_LE; + break; + case AFMT_S32_BE: + return SND_PCM_FORMAT_S32_BE; + break; + case AFMT_U32_LE: + return SND_PCM_FORMAT_U32_LE; + break; + case AFMT_U32_BE: + return SND_PCM_FORMAT_U32_BE; + break; + case AFMT_S24_LE: + return SND_PCM_FORMAT_S24_LE; + break; + case AFMT_S24_BE: + return SND_PCM_FORMAT_S24_BE; + break; + case AFMT_U24_LE: + return SND_PCM_FORMAT_U24_LE; + break; + case AFMT_U24_BE: + return SND_PCM_FORMAT_U24_BE; + break; + case AFMT_FLOAT32: +#ifdef WORDS_BIGENDIAN + return SND_PCM_FORMAT_FLOAT_BE; +#else + return SND_PCM_FORMAT_FLOAT_LE; +#endif + break; + default: + return SND_PCM_FORMAT_MPEG; + break; + } +} + +/* to set/get/query special features/parameters */ +MPXP_Rc Alsa_AO_Interface::ctrl(int cmd, long arg) const { + switch(cmd) { + case AOCONTROL_GET_VOLUME: + case AOCONTROL_SET_VOLUME: +#ifndef WORDS_BIGENDIAN + { //seems to be a problem on macs? + ao_control_vol_t *vol = (ao_control_vol_t *)arg; + + int err; + snd_mixer_t *handle; + snd_mixer_elem_t *elem; + snd_mixer_selem_id_t *sid; + + const char *mix_name = "PCM"; + const char *card = "default"; + + long pmin, pmax; + long get_vol, set_vol; + float calc_vol, diff, f_multi; + + if(_format == AFMT_AC3) return MPXP_True; + + //allocate simple id + snd_mixer_selem_id_alloca(&sid); + + //sets simple-mixer index and name + snd_mixer_selem_id_set_index(sid, 0); + snd_mixer_selem_id_set_name(sid, mix_name); + + if ((err = snd_mixer_open(&handle, 0)) < 0) { + MSG_ERR("alsa-control_ao: mixer open error: %s\n", snd_strerror(err)); + return MPXP_Error; + } + + if ((err = snd_mixer_attach(handle, card)) < 0) { + MSG_ERR("alsa-control_ao: mixer attach %s error: %s", card, snd_strerror(err)); + snd_mixer_close(handle); + return MPXP_Error; + } + + if ((err = snd_mixer_selem_register(handle, NULL, NULL)) < 0) { + MSG_ERR("alsa-control_ao: mixer register error: %s", snd_strerror(err)); + snd_mixer_close(handle); + return MPXP_Error; + } + if ((err = snd_mixer_load(handle)) < 0) { + MSG_ERR("alsa-control_ao: mixer load error: %s", snd_strerror(err)); + snd_mixer_close(handle); + return MPXP_Error; + } + + elem = snd_mixer_find_selem(handle, sid); + if (!elem) { + MSG_ERR("alsa-control_ao: unable to find simple control_ao '%s',%i\n", snd_mixer_selem_id_get_name(sid), snd_mixer_selem_id_get_index(sid)); + snd_mixer_close(handle); + return MPXP_Error; + } + + snd_mixer_selem_get_playback_volume_range(elem,&pmin,&pmax); + f_multi = (100 / (float)pmax); + + if (cmd == AOCONTROL_SET_VOLUME) { + + diff = (vol->left+vol->right) / 2; + set_vol = rint(diff / f_multi); + + if (set_vol < 0) set_vol = 0; + else if (set_vol > pmax) set_vol = pmax; + + //setting channels + if ((err = snd_mixer_selem_set_playback_volume(elem, snd_mixer_selem_channel_id_t(0), set_vol)) < 0) { + MSG_ERR("alsa-control_ao: error setting left channel, %s",snd_strerror(err)); + return MPXP_Error; + } + if ((err = snd_mixer_selem_set_playback_volume(elem, snd_mixer_selem_channel_id_t(1), set_vol)) < 0) { + MSG_ERR("alsa-control_ao: error setting right channel, %s",snd_strerror(err)); + return MPXP_Error; + } + } else { + snd_mixer_selem_get_playback_volume(elem, snd_mixer_selem_channel_id_t(0), &get_vol); + calc_vol = get_vol; + calc_vol = rintf(calc_vol * f_multi); + + vol->left = vol->right = (int)calc_vol; + + //printf("get_vol = %i, calc=%i\n",get_vol, calc_vol); + } + snd_mixer_close(handle); + return MPXP_Ok; + } +#else // end big-endian + return MPXP_Unknown; +#endif + } //end witch + return MPXP_Unknown; +} + +void Alsa_AO_Interface::show_caps(unsigned device) const { + snd_pcm_info_t *alsa_info; + snd_pcm_t *pcm; + snd_pcm_hw_params_t *hw_params; + snd_output_t *sout; + int err,cards=-1; + unsigned rmin,rmax; + unsigned j,sdmin,sdmax; + char adevice[ALSA_DEVICE_SIZE]; + if ((err = snd_card_next(&cards)) < 0 || cards < 0) + { + MSG_ERR("AO-INFO: alsa-init: no soundcards found: %s\n", snd_strerror(err)); + return; + } + snd_pcm_info_malloc(&alsa_info); + snd_pcm_info_set_device(alsa_info,device); + sdmin=snd_pcm_info_get_subdevice(alsa_info); + sdmax=sdmin+snd_pcm_info_get_subdevices_count(alsa_info); + MSG_INFO("AO-INFO: show caps for device %i:%i-%i\n",device,sdmin,sdmax); + for(j=sdmin;j<=sdmax;j++) { + int i; + snd_pcm_info_set_subdevice(alsa_info,j); + sprintf(adevice,"hw:%u,%u",snd_pcm_info_get_device(alsa_info),snd_pcm_info_get_subdevice(alsa_info)); + MSG_INFO("AO-INFO: %s %s.%s.%s\n\n",adevice,snd_pcm_info_get_id(alsa_info),snd_pcm_info_get_name(alsa_info),snd_pcm_info_get_subdevice_name(alsa_info)); + if(snd_pcm_open(&pcm,adevice,SND_PCM_STREAM_PLAYBACK,SND_PCM_NONBLOCK)<0) { + MSG_ERR("alsa-init: playback open error: %s\n", snd_strerror(err)); + return; + } + snd_pcm_hw_params_malloc(&hw_params); + if(snd_pcm_hw_params_any(pcm, hw_params)<0) { + MSG_ERR("alsa-init: can't get initial parameters: %s\n", snd_strerror(err)); + return; + } + MSG_INFO(" AO-INFO: List of access type: "); + for(i=0;i<SND_PCM_ACCESS_LAST;i++) + if(!snd_pcm_hw_params_test_access(pcm,hw_params,snd_pcm_access_t(i))) + MSG_INFO("%s ",snd_pcm_access_name(snd_pcm_access_t(i))); + MSG_INFO("\n"); + MSG_INFO(" AO-INFO: List of supported formats: "); + for(i=0;i<SND_PCM_FORMAT_LAST;i++) + if(!snd_pcm_hw_params_test_format(pcm,hw_params,snd_pcm_format_t(i))) + MSG_INFO("%s ",snd_pcm_format_name(snd_pcm_format_t(i))); + MSG_INFO("\n"); + MSG_INFO(" AO-INFO: List of supported channels: "); + for(i=0;i<64;i++) + if(!snd_pcm_hw_params_test_format(pcm,hw_params,snd_pcm_format_t(i))) + MSG_INFO("%u ",i); + MSG_INFO("\n"); + snd_pcm_hw_params_get_rate_min(hw_params,&rmin,&err); + snd_pcm_hw_params_get_rate_max(hw_params,&rmax,&err); + MSG_INFO(" AO-INFO: Rates range: %u %u\n",rmin,rmax); + snd_output_stdio_attach(&sout, stderr, 0); + snd_pcm_hw_params_dump(hw_params, sout); + if(hw_params) snd_pcm_hw_params_free(hw_params); + if(pcm) snd_pcm_close(pcm); + } + snd_pcm_info_free(alsa_info); +} + +/* + open & setup audio device + return: 1=success 0=fail +*/ +MPXP_Rc Alsa_AO_Interface::open(unsigned flags) { + int err; + int cards = -1; + snd_pcm_info_t *alsa_info; + const char *str_block_mode; + char *alsa_dev=NULL; + char *alsa_port=NULL; + char alsa_device[ALSA_DEVICE_SIZE]; + UNUSED(flags); + first=1; + + handler = NULL; + alsa_device[0]='\0'; + + MSG_V("alsa-init: compiled for ALSA-%s\n", SND_LIB_VERSION_STR); + + if (!subdevice.empty()) { + const char *param; + char *p; + // example: -ao alsa:hw:0#mmap=1 + param=mrl_parse_line(subdevice,NULL,NULL,&alsa_dev,&alsa_port); + mrl_parse_params(param,alsaconf); + if(alsa_port) { + p=strchr(alsa_port,','); + if(p) { + if(strcmp(p+1,"-1")==0) { + *p='\0'; + show_caps(atoi(alsa_port)); + return MPXP_False; + } + } + if(alsa_port) snprintf(alsa_device,sizeof(alsa_device),"%s:%s",alsa_dev,alsa_port); + else strncpy(alsa_device,alsa_dev,sizeof(alsa_device)); + MSG_V("alsa-init: soundcard set to %s\n", alsa_device); + } //end parsing ao->subdevice + } + + if ((err = snd_card_next(&cards)) < 0 || cards < 0) { + MSG_ERR("alsa-init: no soundcards found: %s\n", snd_strerror(err)); + return MPXP_False; + } + + if (alsa_device[0] == '\0') { + int tmp_device, tmp_subdevice; + + if ((err = snd_pcm_info_malloc(&alsa_info)) < 0) { + MSG_ERR("alsa-init: memory allocation error: %s\n", snd_strerror(err)); + return MPXP_False; + } + + if ((tmp_device = snd_pcm_info_get_device(alsa_info)) < 0) { + MSG_ERR("alsa-init: cant get device\n"); + return MPXP_False; + } + + if ((tmp_subdevice = snd_pcm_info_get_subdevice(alsa_info)) < 0) { + MSG_ERR("alsa-init: cant get subdevice\n"); + return MPXP_False; + } + MSG_V("alsa-init: got device=%i, subdevice=%i\n", tmp_device, tmp_subdevice); + + if ((err = snprintf(alsa_device, ALSA_DEVICE_SIZE, "hw:%1d,%1d", tmp_device, tmp_subdevice)) <= 0) { + MSG_ERR("alsa-init: cant wrote device-id\n"); + } + snd_pcm_info_free(alsa_info); + } + + MSG_WARN("alsa-init: Testing & bugs are welcome. Found %d cards, use: %s\n",cards+1,alsa_device); + //setting modes for block or nonblock-mode + int open_mode,block_mode; + if (priv_conf.noblock) { + open_mode = SND_PCM_NONBLOCK; + block_mode = 1; + str_block_mode = "nonblock-mode"; + } else { + open_mode = 0; + block_mode = 0; + str_block_mode = "block-mode"; + } + + if (!handler) { + //modes = 0, SND_PCM_NONBLOCK, SND_PCM_ASYNC + if ((err = snd_pcm_open(&handler, alsa_device, SND_PCM_STREAM_PLAYBACK, open_mode)) < 0) { + if (priv_conf.noblock) { + MSG_ERR("alsa-init: open in nonblock-mode failed, trying to open in block-mode\n"); + if ((err = snd_pcm_open(&handler, alsa_device, SND_PCM_STREAM_PLAYBACK, 0)) < 0) { + MSG_ERR("alsa-init: playback open error: %s\n", snd_strerror(err)); + alsa_device[0]='\0'; + return MPXP_False; + } else { + block_mode = 0; + str_block_mode = "block-mode"; + } + } else { + MSG_ERR("alsa-init: playback open error: %s\n", snd_strerror(err)); + alsa_device[0]='\0'; + return MPXP_False; + } + } + alsa_device[0]='\0'; + if ((err = snd_pcm_nonblock(handler, block_mode)) < 0) { + MSG_ERR("alsa-init: error set block-mode %s\n", snd_strerror(err)); + } else MSG_V("alsa-init: pcm opend in %s\n", str_block_mode); + + snd_pcm_hw_params_malloc(&hwparams); + snd_pcm_sw_params_malloc(&swparams); + + // setting hw-parameters + if ((err = snd_pcm_hw_params_any(handler, hwparams)) < 0) { + MSG_ERR("alsa-init: unable to get initial parameters: %s\n", + snd_strerror(err)); + return MPXP_False; + } + MSG_DBG2("snd_pcm_hw_params_any()\n"); + if (priv_conf.mmap) { + snd_pcm_access_mask_t *mask = (snd_pcm_access_mask_t*)alloca(snd_pcm_access_mask_sizeof()); + snd_pcm_access_mask_none(mask); + snd_pcm_access_mask_set(mask, SND_PCM_ACCESS_MMAP_INTERLEAVED); + snd_pcm_access_mask_set(mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED); + snd_pcm_access_mask_set(mask, SND_PCM_ACCESS_MMAP_COMPLEX); + err = snd_pcm_hw_params_set_access_mask(handler, hwparams, mask); + MSG_ERR("alsa-init: mmap set\n"); + } else { + err = snd_pcm_hw_params_set_access(handler, hwparams,SND_PCM_ACCESS_RW_INTERLEAVED); + MSG_DBG2("snd_pcm_hw_params_set_access(SND_PCM_ACCESS_RW_INTERLEAVED)\n"); + } + if (err < 0) { + MSG_ERR("alsa-init: unable to set access type: %s\n", snd_strerror(err)); + return MPXP_False; + } + } // end switch priv->handler (spdif) + return MPXP_Ok; +} // end init + +MPXP_Rc Alsa_AO_Interface::configure(unsigned r,unsigned c,unsigned f) { + int err,i; + size_t chunk_size=0,chunk_bytes,bits_per_sample,bits_per_frame; + snd_pcm_uframes_t dummy; + + MSG_V("alsa-conf: requested format: %d Hz, %d channels, %s\n", r, + c, ao_format_name(f)); + + _samplerate = r; + _format = f; + _channels = c; + _outburst = OUTBURST; + //ao->buffersize = MAX_OUTBURST; // was 16384 + + snd_format=fmt2alsa(_format); + + switch(snd_format) { + case SND_PCM_FORMAT_S16_LE: + case SND_PCM_FORMAT_U16_LE: + case SND_PCM_FORMAT_S16_BE: + case SND_PCM_FORMAT_U16_BE: + case SND_PCM_FORMAT_S32_LE: + case SND_PCM_FORMAT_S32_BE: + case SND_PCM_FORMAT_U32_LE: + case SND_PCM_FORMAT_U32_BE: + case SND_PCM_FORMAT_FLOAT_BE: + case SND_PCM_FORMAT_FLOAT_LE: + case SND_PCM_FORMAT_S24_LE: + case SND_PCM_FORMAT_S24_BE: + case SND_PCM_FORMAT_U24_LE: + case SND_PCM_FORMAT_U24_BE: + break; + case -1: + MSG_ERR("alsa-conf: invalid format (%s) requested - output disabled\n", + ao_format_name(_format)); + return MPXP_False; + default: + break; + } + bytes_per_sample = bps() / _samplerate; + + if ((err = snd_pcm_hw_params_set_format(handler, hwparams, + snd_format)) < 0) { + MSG_ERR("alsa-conf: unable to set format(%s): %s\n", + snd_pcm_format_name(snd_format), + snd_strerror(err)); + MSG_HINT("Please try one of: "); + for(i=0;i<SND_PCM_FORMAT_LAST;i++) + if (!(snd_pcm_hw_params_test_format(handler, hwparams, snd_pcm_format_t(i)))) + MSG_HINT("%s ",snd_pcm_format_name(snd_pcm_format_t(i))); + MSG_HINT("\n"); + return MPXP_False; + } + MSG_DBG2("snd_pcm_hw_params_set_format(%i)\n",snd_format); + + if ((err = snd_pcm_hw_params_set_rate_near(handler, hwparams, &_samplerate, 0)) < 0) { + MSG_ERR("alsa-conf: unable to set samplerate %u: %s\n", + _samplerate, + snd_strerror(err)); + return MPXP_False; + } + MSG_DBG2("snd_pcm_hw_params_set_rate_near(%i)\n",_samplerate); + + if ((err = snd_pcm_hw_params_set_channels(handler, hwparams, + _channels)) < 0) { + MSG_ERR("alsa-conf: unable to set %u channels: %s\n", + _channels, + snd_strerror(err)); + return MPXP_False; + } + MSG_DBG2("snd_pcm_hw_params_set_channels(%i)\n",_channels); +#ifdef BUFFERTIME + { + int dir; + unsigned period_time,alsa_buffer_time = 500000; /* buffer time in us */ + + if ((err = snd_pcm_hw_params_set_buffer_time_near(handler, hwparams, &alsa_buffer_time, &dir)) < 0) { + MSG_ERR("alsa-init: unable to set buffer time near: %s\n", + snd_strerror(err)); + return MPXP_False; + } + MSG_DBG2("snd_pcm_hw_set_buffer_time_near(%i)\n",alsa_buffer_time); + + period_time = alsa_buffer_time/4; + if ((err = snd_pcm_hw_params_set_period_time_near(handler, hwparams, &period_time, &dir)) < 0) { + /* original: alsa_buffer_time/ao->bps */ + MSG_ERR("alsa-init: unable to set period time: %s\n", + snd_strerror(err)); + return MPXP_False; + } + MSG_DBG2("snd_pcm_hw_set_period_time_near(%i)\n",period_time); + MSG_V("alsa-init: buffer_time: %d, period_time :%d\n",alsa_buffer_time, period_time); + } +#else + { + int dir=0; + unsigned period_time=100000; /* period time in us */ + snd_pcm_uframes_t size; + if ((err = snd_pcm_hw_params_set_period_time_near(handler, hwparams, &period_time, &dir)) < 0) { + MSG_ERR("alsa-init: unable to set period_time: %s\n", snd_strerror(err)); + return MPXP_False; + } + MSG_DBG2("snd_pcm_hw_set_period_time(%i)\n",period_time); + + //get chunksize + if ((err = snd_pcm_hw_params_get_period_size(hwparams, &size, &dir)) < 0) { + MSG_ERR("alsa-init: unable to get period_size: %s\n", snd_strerror(err)); + return MPXP_False; + } + MSG_DBG2("snd_pcm_hw_get_period_size(%i)\n",size); + chunk_size=size; + } +#endif + // gets buffersize for control_ao + if ((err = snd_pcm_hw_params_get_buffer_size(hwparams,&dummy)) < 0) { + MSG_ERR("alsa-conf: unable to get buffersize: %s\n", snd_strerror(err)); + return MPXP_False; + } else { + _buffersize = dummy * bytes_per_sample; + MSG_V("alsa-conf: got buffersize=%i\n", _buffersize); + } + MSG_DBG2("snd_pcm_hw_params_get_buffer_size(%i)\n",dummy); + bits_per_sample = snd_pcm_format_physical_width(snd_format); + MSG_DBG2("%i=snd_pcm_hw_format_pohysical_width()\n",bits_per_sample); + bits_per_frame = bits_per_sample * _channels; + chunk_bytes = chunk_size * bits_per_frame / 8; + + MSG_V("alsa-conf: bits per sample (bps)=%i, bits per frame (bpf)=%i, chunk_bytes=%i\n",bits_per_sample,bits_per_frame,chunk_bytes); + + /* finally install hardware parameters */ + if ((err = snd_pcm_hw_params(handler, hwparams)) < 0) { + MSG_ERR("alsa-conf: unable to set hw-parameters: %s\n", + snd_strerror(err)); + return MPXP_False; + } + MSG_DBG2("snd_pcm_hw_params()\n"); + // setting sw-params (only avail-min) if noblocking mode was choosed + if (priv_conf.noblock) { + if ((err = snd_pcm_sw_params_current(handler, swparams)) < 0) { + MSG_ERR("alsa-conf: unable to get parameters: %s\n",snd_strerror(err)); + return MPXP_False; + } + + //set min available frames to consider pcm ready (4) + //increased for nonblock-mode should be set dynamically later + if ((err = snd_pcm_sw_params_set_avail_min(handler, swparams, 4)) < 0) { + MSG_ERR("alsa-conf: unable to set avail_min %s\n",snd_strerror(err)); + return MPXP_False; + } + + if ((err = snd_pcm_sw_params(handler, swparams)) < 0) { + MSG_ERR("alsa-conf: unable to install sw-params\n"); + return MPXP_False; + } + + }//end swparams + + if ((err = snd_pcm_prepare(handler)) < 0) { + MSG_ERR("alsa-conf: pcm prepare error: %s\n", snd_strerror(err)); + return MPXP_False; + } + // end setting hw-params + MSG_V("alsa-conf: %d Hz/%d channels/%d bpf/%d bytes buffer/%s\n", + _samplerate, _channels, bytes_per_sample, _buffersize, + snd_pcm_format_description(snd_format)); + return MPXP_Ok; +} // end config_ao + +void Alsa_AO_Interface::pause() { + int err; + + if (!priv_conf.noblock) { + //drain causes error in nonblock-mode! + if ((err = snd_pcm_drain(handler)) < 0) { + MSG_ERR("alsa-pause: pcm drain error: %s\n", snd_strerror(err)); + return; + } + } else { + MSG_V("alsa-pause: paused nonblock\n"); + return; + } +} + +void Alsa_AO_Interface::resume() { + int err; + + if ((err = snd_pcm_prepare(handler)) < 0) { + MSG_ERR("alsa-resume: pcm prepare error: %s\n", snd_strerror(err)); + return; + } +} + +/* stop playing and empty buffers (for seeking/pause) */ +void Alsa_AO_Interface::reset() { + int err; + + if ((err = snd_pcm_drop(handler)) < 0) { + MSG_ERR("alsa-reset: pcm drop error: %s\n", snd_strerror(err)); + return; + } + if ((err = snd_pcm_prepare(handler)) < 0) { + MSG_ERR("alsa-reset: pcm prepare error: %s\n", snd_strerror(err)); + return; + } + return; +} + +#ifdef USE_POLL +static int __FASTCALL__ wait_for_poll(snd_pcm_t *handle, struct pollfd *ufds, unsigned int count) +{ + unsigned short revents; + + while (1) { + poll(ufds, count, -1); + snd_pcm_poll_descriptors_revents(handle, ufds, count, &revents); + if (revents & POLLERR) return -EIO; + if (revents & POLLOUT) return 0; + } +} +#endif + +static void _timersub(const struct timeval*a,const struct timeval* b,struct timeval* result) { + result->tv_sec = a->tv_sec - b->tv_sec; + result->tv_usec = a->tv_usec - b->tv_usec; + if (result->tv_usec < 0) { + --result->tv_sec; + result->tv_usec += 1000000; + } +} + +/* I/O error handler */ +int Alsa_AO_Interface::xrun(const char *str_mode) const { + int err; + snd_pcm_status_t *status; + + snd_pcm_status_alloca(&status); + + if ((err = snd_pcm_status(handler, status))<0) { + MSG_ERR("status error: %s", snd_strerror(err)); + return 0; + } + + if (snd_pcm_status_get_state(status) == SND_PCM_STATE_XRUN) { + struct timeval now, diff, tstamp; + gettimeofday(&now, 0); + snd_pcm_status_get_trigger_tstamp(status, &tstamp); + _timersub(&now, &tstamp, &diff); + MSG_V("alsa-%s: xrun of at least %.3f msecs. resetting stream\n", + str_mode, + diff.tv_sec * 1000 + diff.tv_usec / 1000.0); + } + + if ((err = snd_pcm_prepare(handler))<0) { + MSG_ERR("xrun: prepare error: %s", snd_strerror(err)); + return 0; + } + + return 1; /* ok, data should be accepted again */ +} + +unsigned Alsa_AO_Interface::play(const any_t* data, unsigned len, unsigned flags) { + unsigned result; + UNUSED(flags); + MSG_DBG2("[ao_alsa] %s playing %i bytes\n",priv_conf.mmap?"mmap":"normal",len); + if (priv_conf.mmap) result = play_mmap(data, len); + else result = play_normal(data, len); + return result; +} + +/* + plays 'len' bytes of 'data' + returns: number of bytes played + modified last at 29.06.02 by jp + thanxs for marius <ma...@ro...> for giving us the light ;) +*/ + +unsigned Alsa_AO_Interface::play_normal(const any_t* data, unsigned len) { + unsigned num_frames = len / bytes_per_sample; + const char *output_samples = (const char *)data; + snd_pcm_sframes_t res = 0; + + //fprintf(stderr,"alsa-play: frames=%i, len=%i\n",num_frames,len); + + if (!handler) { + MSG_ERR("alsa-play: device configuration error"); + return 0; + } + + while (num_frames > 0) { + res = snd_pcm_writei(handler, (any_t*)output_samples, num_frames); + if (res == -EAGAIN) { + snd_pcm_wait(handler, 1000); + } else if (res == -EPIPE) { /* underrun */ + if (xrun("play") <= 0) { + MSG_ERR("alsa-play: xrun reset error"); + return 0; + } + } else if (res == -ESTRPIPE) { /* suspend */ + MSG_WARN("alsa-play: pcm in suspend mode. trying to resume\n"); + while ((res = snd_pcm_resume(handler)) == -EAGAIN) ::sleep(1); + } else if (res < 0) { + MSG_ERR("alsa-play: unknown status, trying to reset soundcard\n"); + if ((res = snd_pcm_prepare(handler)) < 0) { + MSG_ERR("alsa-play: snd prepare error"); + return 0; + break; + } + } + + if (res > 0) { + /* output_samples += ao->channels * res; */ + output_samples += res * bytes_per_sample; + num_frames -= res; + } + } //end while + + if (res < 0) { + MSG_ERR("alsa-play: write error %s", snd_strerror(res)); + return 0; + } + return res < 0 ? 0 : len; +} + +/* mmap-mode mainly based on descriptions by Joshua Haberman <jo...@ha...> + * 'An overview of the ALSA API' http://people.debian.org/~joshua/x66.html + * and some help by Paul Davis <pb...@op...> */ + +unsigned Alsa_AO_Interface::play_mmap(const any_t* data, unsigned len) { + snd_pcm_sframes_t commitres, frames_available; + snd_pcm_uframes_t frames_transmit, size, offset; + const snd_pcm_channel_area_t *area; + any_t* outbuffer; + unsigned result; + +#ifdef USE_POLL //seems not really be needed + struct pollfd *ufds; + int count; + + count = snd_pcm_poll_descriptors_count (handler); + ufds = mp_malloc(sizeof(struct pollfd) * count); + snd_pcm_poll_descriptors(handler, ufds, count); + + //first wait_for_poll + if (err = (wait_for_poll(handler, ufds, count) < 0)) { + if (snd_pcm_state(handler) == SND_PCM_STATE_XRUN || + snd_pcm_state(handler) == SND_PCM_STATE_SUSPENDED) { + xrun("play"); + } + } +#endif + + outbuffer = alloca(_buffersize); + + //don't trust get_space() ;) + frames_available = snd_pcm_avail_update(handler) * bytes_per_sample; + if (frames_available < 0) xrun("play"); + + if (frames_available < 4) { + if (first) { + first = 0; + snd_pcm_start(handler); + } else { //FIXME should break and return 0? + snd_pcm_wait(handler, -1); + first = 1; + } + } + + /* len is simply the available bufferspace got by get_space() + * but real avail_buffer in frames is ab/priv->bytes_per_sample */ + size = len / bytes_per_sample; + + //if (verbose) + //printf("len: %i size %i, f_avail %i, bps %i ...\n", len, size, frames_available, priv->bytes_per_sample); + + frames_transmit = size; + + /* prepare areas and set sw-pointers + * frames_transmit returns the real available buffer-size + * sometimes != frames_available cause of ringbuffer 'emulation' */ + snd_pcm_mmap_begin(handler, &area, &offset, &frames_transmit); + + /* this is specific to interleaved streams (or non-interleaved + * streams with only one channel) */ + outbuffer = ((char *) area->addr + (area->first + area->step * offset) / 8); //8 + + //write data + memcpy(outbuffer, data, (frames_transmit * bytes_per_sample)); + commitres = snd_pcm_mmap_commit(handler, offset, frames_transmit); + + if (commitres < 0 || (snd_pcm_uframes_t)commitres != frames_transmit) { + if (snd_pcm_state(handler) == SND_PCM_STATE_XRUN || + snd_pcm_state(handler) == SND_PCM_STATE_SUSPENDED) { + xrun("play"); + } + } + + //calculate written frames! + result = commitres * bytes_per_sample; + + //mplayer doesn't like -result + if ((int)result < 0) result = 0; + +#ifdef USE_POLL + delete ufds; +#endif + + return result; +} + +typedef enum space_status_e { + GET_SPACE_OPEN, + GET_SPACE_PREPARED, + GET_SPACE_RUNNING, + GET_SPACE_PAUSED, + GET_SPACE_XRUN, + GET_SPACE_UNDEFINED +}space_status; +/* how many byes are mp_free in the buffer */ +unsigned Alsa_AO_Interface::get_space() { + snd_pcm_status_t *status; + int ret,st; + space_status e_status=GET_SPACE_UNDEFINED; + + //snd_pcm_sframes_t avail_frames = 0; + + if ((ret = snd_pcm_status_malloc(&status)) < 0) { + MSG_ERR("alsa-space: memory allocation error: %s\n", snd_strerror(ret)); + return 0; + } + + if ((ret = snd_pcm_status(handler, status)) < 0) { + MSG_ERR("alsa-space: cannot get pcm status: %s\n", snd_strerror(ret)); + return 0; + } + + switch((st=snd_pcm_status_get_state(status))) { + case SND_PCM_STATE_OPEN: + e_status = GET_SPACE_OPEN; + case SND_PCM_STATE_PREPARED: + if (e_status!=GET_SPACE_OPEN) { + e_status = GET_SPACE_PREPARED; + first = 1; + ret = snd_pcm_status_get_avail(status) * bytes_per_sample; + if (ret == 0) //ugly workaround for hang in mmap-mode + ret = 10; + break; + } + case SND_PCM_STATE_RUNNING: + ret = snd_pcm_status_get_avail(status) * bytes_per_sample; + //avail_frames = snd_pcm_avail_update(priv->handler) * priv->bytes_per_sample; + if (e_status!=GET_SPACE_OPEN && e_status!=GET_SPACE_PREPARED) + e_status = GET_SPACE_RUNNING; + break; + case SND_PCM_STATE_PAUSED: + MSG_V("alsa-space: paused"); + e_status = GET_SPACE_PAUSED; + ret = 0; + break; + case SND_PCM_STATE_XRUN: + xrun("space"); + e_status = GET_SPACE_XRUN; + first = 1; + ret = 0; + break; + default: + e_status = GET_SPACE_UNDEFINED; + ret = snd_pcm_status_get_avail(status) * bytes_per_sample; + if (ret <= 0) { + xrun("space"); + } + } + + if (e_status!=GET_SPACE_RUNNING) + MSG_V("alsa-space: mp_free space = %i, status=%i, %i --\n", ret, st, e_status); + snd_pcm_status_free(status); + + if (ret < 0) { + MSG_ERR("negative value!!\n"); + ret = 0; + } + + return ret; +} + +/* delay in seconds between first and last sample in buffer */ +float Alsa_AO_Interface::get_delay() +{ + if (handler) { + snd_pcm_status_t *status; + int r; + float ret; + + if ((ret = snd_pcm_status_malloc(&status)) < 0) { + MSG_ERR("alsa-delay: memory allocation error: %s\n", snd_strerror(ret)); + return 0; + } + + if ((ret = snd_pcm_status(handler, status)) < 0) { + MSG_ERR("alsa-delay: cannot get pcm status: %s\n", snd_strerror(ret)); + return 0; + } + + switch(snd_pcm_status_get_state(status)) { + case SND_PCM_STATE_OPEN: + case SND_PCM_STATE_PREPARED: + case SND_PCM_STATE_RUNNING: + r=snd_pcm_status_get_delay(status); + ret = (float)r/(float)_samplerate; + break; + default: + ret = 0; + } + snd_pcm_status_free(status); + + if (ret < 0) ret = 0; + return ret; + } else return 0; +} + +unsigned Alsa_AO_Interface::samplerate() const { return _samplerate; } +unsigned Alsa_AO_Interface::channels() const { return _channels; } +unsigned Alsa_AO_Interface::format() const { return _format; } +unsigned Alsa_AO_Interface::buffersize() const { return _buffersize; } +unsigned Alsa_AO_Interface::outburst() const { return _outburst; } +MPXP_Rc Alsa_AO_Interface::test_channels(unsigned c) const { + return snd_pcm_hw_params_test_channels(handler, hwparams,c)==0? + MPXP_True:MPXP_False; +} +MPXP_Rc Alsa_AO_Interface::test_rate(unsigned r) const { + return snd_pcm_hw_params_test_rate(handler, hwparams,r,0)==0? + MPXP_True:MPXP_False; +} +MPXP_Rc Alsa_AO_Interface::test_format(unsigned f) const { + snd_pcm_format_t rval; + rval=fmt2alsa(f); + return snd_pcm_hw_params_test_format(handler, hwparams,snd_pcm_format_t(rval))==0? + MPXP_True:MPXP_False; +} + +static AO_Interface* query_interface(const std::string& sd) { return new(zeromem) Alsa_AO_Interface(sd); } + +extern const ao_info_t audio_out_alsa = +{ + "ALSA-1.x audio output", + "alsa", + "Alex Beregszaszi <al...@na...>, Joy Winter <jo...@pi...>", + "under developement", + query_interface +}; +} //namespace mpxp + Deleted: mplayerxp/libao2/ao_alsa9.cpp =================================================================== --- mplayerxp/libao2/ao_alsa9.cpp 2012-12-15 13:09:33 UTC (rev 563) +++ mplayerxp/libao2/ao_alsa9.cpp 2012-12-15 17:27:08 UTC (rev 564) @@ -1,1024 +0,0 @@ -#include "mp_config.h" -#include "osdep/mplib.h" -using namespace mpxp; -/* - ao_alsa9 - ALSA-0.9.x output plugin for MPlayer - - (C) Alex Beregszaszi <al...@na...> - - modified for real alsa-0.9.0-support by Joy Winter <jo...@pi...> - additional AC3 passthrough support by Andy Lo A Foe <an...@al...> - 08/22/2002 iec958-init rewritten and merged with common init, joy - - Any bugreports regarding to this driver are welcome. -*/ - -#include <errno.h> -#include <sys/time.h> -#include <stdlib.h> -#include <math.h> -#include <string.h> -#include <sys/poll.h> - -#include "mplayerxp.h" -#define ALSA_PCM_NEW_HW_PARAMS_API -#define ALSA_PCM_NEW_SW_PARAMS_API -#include <alsa/asoundlib.h> - -#include "audio_out.h" -#include "audio_out_internal.h" -#include "afmt.h" -#include "ao_msg.h" -#include "libmpstream2/mrl.h" - -namespace mpxp { -typedef struct priv_conf_s { - int mmap; - int noblock; -}priv_conf_t; -static priv_conf_t priv_conf; -static const mrl_config_t alsaconf[]={ - { "mmap", &priv_conf.mmap, MRL_TYPE_BOOL, 0, 1 }, - { "noblock", &priv_conf.noblock, MRL_TYPE_BOOL, 0, 1 }, - { NULL, NULL, 0, 0, 0 } -}; -class Alsa_AO_Interface : public AO_Interface { - public: - Alsa_AO_Interface(const std::string& subdevice); - virtual ~Alsa_AO_Interface(); - - virtual MPXP_Rc open(unsigned flags); - virtual MPXP_Rc configure(unsigned rate,unsigned channels,unsigned format); - virtual unsigned samplerate() const; - virtual unsigned channels() const; - virtual unsigned format() const; - virtual unsigned buffersize() const; - virtual unsigned outburst() const; - virtual MPXP_Rc test_rate(unsigned r) const; - virtual MPXP_Rc test_channels(unsigned c) const; - virtual MPXP_Rc test_format(unsigned f) const; - virtual void reset(); - virtual unsigned get_space(); - virtual float get_delay(); - virtual unsigned play(const any_t* data,unsigned len,unsigned flags); - virtual void pause(); - virtual void resume(); - virtual MPXP_Rc ctrl(int cmd,long arg) const; - private: - unsigned _channels,_samplerate,_format; - unsigned _buffersize,_outburst; - unsigned bps() const { return _channels*_samplerate*afmt2bps(_format); } - void show_caps(unsigned device) const; - int xrun(const char *str_mode) const; - unsigned play_normal(const any_t* data, unsigned len); - unsigned play_mmap(const any_t* data, unsigned len); - snd_pcm_format_t fmt2alsa(unsigned format) const; - - snd_pcm_t* handler; - snd_pcm_format_t snd_format; - snd_pcm_hw_params_t* hwparams; - snd_pcm_sw_params_t* swparams; - size_t bytes_per_sample; - int first; -}; - -Alsa_AO_Interface::Alsa_AO_Interface(const std::string& _subdevice) - :AO_Interface(_subdevice) {} -Alsa_AO_Interface::~Alsa_AO_Interface() { - int err; - if(!handler) { - MSG_ERR("alsa-uninit: no handler defined!\n"); - return; - } - if (!priv_conf.noblock) { - if ((err = snd_pcm_drain(handler)) < 0) { - MSG_ERR("alsa-uninit: pcm drain error: %s\n", snd_strerror(err)); - return; - } - } - if ((err = snd_pcm_close(handler)) < 0) { - MSG_ERR("alsa-uninit: pcm close error: %s\n", snd_strerror(err)); - return; - } else { - handler = NULL; - MSG_V("alsa-uninit: pcm closed\n"); - } - snd_pcm_hw_params_free(hwparams); - snd_pcm_sw_params_free(swparams); -} - -#define ALSA_DEVICE_SIZE 48 - -#define BUFFERTIME // else SET_CHUNK_SIZE -#undef USE_POLL - -snd_pcm_format_t Alsa_AO_Interface::fmt2alsa(unsigned f) const { - switch (f) - { - case AFMT_S8: - return SND_PCM_FORMAT_S8; - break; - case AFMT_U8: - return SND_PCM_FORMAT_U8; - break; - case AFMT_U16_LE: - return SND_PCM_FORMAT_U16_LE; - break; - case AFMT_U16_BE: - return SND_PCM_FORMAT_U16_BE; - break; -#ifndef WORDS_BIGENDIAN - case AFMT_AC3: -#endif - case AFMT_S16_LE: - return SND_PCM_FORMAT_S16_LE; - break; -#ifdef WORDS_BIGENDIAN - case AFMT_AC3: -#endif - case AFMT_S16_BE: - return SND_PCM_FORMAT_S16_BE; - break; - case AFMT_S32_LE: - return SND_PCM_FORMAT_S32_LE; - break; - case AFMT_S32_BE: - return SND_PCM_FORMAT_S32_BE; - break; - case AFMT_U32_LE: - return SND_PCM_FORMAT_U32_LE; - break; - case AFMT_U32_BE: - return SND_PCM_FORMAT_U32_BE; - break; - case AFMT_S24_LE: - return SND_PCM_FORMAT_S24_LE; - break; - case AFMT_S24_BE: - return SND_PCM_FORMAT_S24_BE; - break; - case AFMT_U24_LE: - return SND_PCM_FORMAT_U24_LE; - break; - case AFMT_U24_BE: - return SND_PCM_FORMAT_U24_BE; - break; - case AFMT_FLOAT32: -#ifdef WORDS_BIGENDIAN - return SND_PCM_FORMAT_FLOAT_BE; -#else - return SND_PCM_FORMAT_FLOAT_LE; -#endif - break; - default: - return SND_PCM_FORMAT_MPEG; - break; - } -} - -/* to set/get/query special features/parameters */ -MPXP_Rc Alsa_AO_Interface::ctrl(int cmd, long arg) const { - switch(cmd) { - case AOCONTROL_GET_VOLUME: - case AOCONTROL_SET_VOLUME: -#ifndef WORDS_BIGENDIAN - { //seems to be a problem on macs? - ao_control_vol_t *vol = (ao_control_vol_t *)arg; - - int err; - snd_mixer_t *handle; - snd_mixer_elem_t *elem; - snd_mixer_selem_id_t *sid; - - const char *mix_name = "PCM"; - const char *card = "default"; - - long pmin, pmax; - long get_vol, set_vol; - float calc_vol, diff, f_multi; - - if(_format == AFMT_AC3) return MPXP_True; - - //allocate simple id - snd_mixer_selem_id_alloca(&sid); - - //sets simple-mixer index and name - snd_mixer_selem_id_set_index(sid, 0); - snd_mixer_selem_id_set_name(sid, mix_name); - - if ((err = snd_mixer_open(&handle, 0)) < 0) { - MSG_ERR("alsa-control_ao: mixer open error: %s\n", snd_strerror(err)); - return MPXP_Error; - } - - if ((err = snd_mixer_attach(handle, card)) < 0) { - MSG_ERR("alsa-control_ao: mixer attach %s error: %s", card, snd_strerror(err)); - snd_mixer_close(handle); - return MPXP_Error; - } - - if ((err = snd_mixer_selem_register(handle, NULL, NULL)) < 0) { - MSG_ERR("alsa-control_ao: mixer register error: %s", snd_strerror(err)); - snd_mixer_close(handle); - return MPXP_Error; - } - if ((err = snd_mixer_load(handle)) < 0) { - MSG_ERR("alsa-control_ao: mixer load error: %s", snd_strerror(err)); - snd_mixer_close(handle); - return MPXP_Error; - } - - elem = snd_mixer_find_selem(handle, sid); - if (!elem) { - MSG_ERR("alsa-control_ao: unable to find simple control_ao '%s',%i\n", snd_mixer_selem_id_get_name(sid), snd_mixer_selem_id_get_index(sid)); - snd_mixer_close(handle); - return MPXP_Error; - } - - snd_mixer_selem_get_playback_volume_range(elem,&pmin,&pmax); - f_multi = (100 / (float)pmax); - - if (cmd == AOCONTROL_SET_VOLUME) { - - diff = (vol->left+vol->right) / 2; - set_vol = rint(diff / f_multi); - - if (set_vol < 0) set_vol = 0; - else if (set_vol > pmax) set_vol = pmax; - - //setting channels - if ((err = snd_mixer_selem_set_playback_volume(elem, snd_mixer_selem_channel_id_t(0), set_vol)) < 0) { - MSG_ERR("alsa-control_ao: error setting left channel, %s",snd_strerror(err)); - return MPXP_Error; - } - if ((err = snd_mixer_selem_set_playback_volume(elem, snd_mixer_selem_channel_id_t(1), set_vol)) < 0) { - MSG_ERR("alsa-control_ao: error setting right channel, %s",snd_strerror(err)); - return MPXP_Error; - } - } else { - snd_mixer_selem_get_playback_volume(elem, snd_mixer_selem_channel_id_t(0), &get_vol); - calc_vol = get_vol; - calc_vol = rintf(calc_vol * f_multi); - - vol->left = vol->right = (int)calc_vol; - - //printf("get_vol = %i, calc=%i\n",get_vol, calc_vol); - } - snd_mixer_close(handle); - return MPXP_Ok; - } -#else // end big-endian - return MPXP_Unknown; -#endif - } //end witch - return MPXP_Unknown; -} - -void Alsa_AO_Interface::show_caps(unsigned device) const { - snd_pcm_info_t *alsa_info; - snd_pcm_t *pcm; - snd_pcm_hw_params_t *hw_params; - snd_output_t *sout; - int err,cards=-1; - unsigned rmin,rmax; - unsigned j,sdmin,sdmax; - char adevice[ALSA_DEVICE_SIZE]; - if ((err = snd_card_next(&cards)) < 0 || cards < 0) - { - MSG_ERR("AO-INFO: alsa-init: no soundcards found: %s\n", snd_strerror(err)); - return; - } - snd_pcm_info_malloc(&alsa_info); - snd_pcm_info_set_device(alsa_info,device); - sdmin=snd_pcm_info_get_subdevice(alsa_info); - sdmax=sdmin+snd_pcm_info_get_subdevices_count(alsa_info); - MSG_INFO("AO-INFO: show caps for device %i:%i-%i\n",device,sdmin,sdmax); - for(j=sdmin;j<=sdmax;j++) { - int i; - snd_pcm_info_set_subdevice(alsa_info,j); - sprintf(adevice,"hw:%u,%u",snd_pcm_info_get_device(alsa_info),snd_pcm_info_get_subdevice(alsa_info)); - MSG_INFO("AO-INFO: %s %s.%s.%s\n\n",adevice,snd_pcm_info_get_id(alsa_info),snd_pcm_info_get_name(alsa_info),snd_pcm_info_get_subdevice_name(alsa_info)); - if(snd_pcm_open(&pcm,adevice,SND_PCM_STREAM_PLAYBACK,SND_PCM_NONBLOCK)<0) { - MSG_ERR("alsa-init: playback open error: %s\n", snd_strerror(err)); - return; - } - snd_pcm_hw_params_malloc(&hw_params); - if(snd_pcm_hw_params_any(pcm, hw_params)<0) { - MSG_ERR("alsa-init: can't get initial parameters: %s\n", snd_strerror(err)); - return; - } - MSG_INFO(" AO-INFO: List of access type: "); - for(i=0;i<SND_PCM_ACCESS_LAST;i++) - if(!snd_pcm_hw_params_test_access(pcm,hw_params,snd_pcm_access_t(i))) - MSG_INFO("%s ",snd_pcm_access_name(snd_pcm_access_t(i))); - MSG_INFO("\n"); - MSG_INFO(" AO-INFO: List of supported formats: "); - for(i=0;i<SND_PCM_FORMAT_LAST;i++) - if(!snd_pcm_hw_params_test_format(pcm,hw_params,snd_pcm_format_t(i))) - MSG_INFO("%s ",snd_pcm_format_name(snd_pcm_format_t(i))); - MSG_INFO("\n"); - MSG_INFO(" AO-INFO: List of supported channels: "); - for(i=0;i<64;i++) - if(!snd_pcm_hw_params_test_format(pcm,hw_params,snd_pcm_format_t(i))) - MSG_INFO("%u ",i); - MSG_INFO("\n"); - snd_pcm_hw_params_get_rate_min(hw_params,&rmin,&err); - snd_pcm_hw_params_get_rate_max(hw_params,&rmax,&err); - MSG_INFO(" AO-INFO: Rates range: %u %u\n",rmin,rmax); - snd_output_stdio_attach(&sout, stderr, 0); - snd_pcm_hw_params_dump(hw_params, sout); - if(hw_params) snd_pcm_hw_params_free(hw_params); - if(pcm) snd_pcm_close(pcm); - } - snd_pcm_info_free(alsa_info); -} - -/* - open & setup audio device - return: 1=success 0=fail -*/ -MPXP_Rc Alsa_AO_Interface::open(unsigned flags) { - int err; - int cards = -1; - snd_pcm_info_t *alsa_info; - const char *str_block_mode; - char *alsa_dev=NULL; - char *alsa_port=NULL; - char alsa_device[ALSA_DEVICE_SIZE]; - UNUSED(flags); - first=1; - - handler = NULL; - alsa_device[0]='\0'; - - MSG_V("alsa-init: compiled for ALSA-%s\n", SND_LIB_VERSION_STR); - - if (!subdevice.empty()) { - const char *param; - char *p; - // example: -ao alsa:hw:0#mmap=1 - param=mrl_parse_line(subdevice,NULL,NULL,&alsa_dev,&alsa_port); - mrl_parse_params(param,alsaconf); - if(alsa_port) { - p=strchr(alsa_port,','); - if(p) { - if(strcmp(p+1,"-1")==0) { - *p='\0'; - show_caps(atoi(alsa_port)); - return MPXP_False; - } - } - if(alsa_port) snprintf(alsa_device,sizeof(alsa_device),"%s:%s",alsa_dev,alsa_port); - else strncpy(alsa_device,alsa_dev,sizeof(alsa_device)); - MSG_V("alsa-init: soundcard set to %s\n", alsa_device); - } //end parsing ao->subdevice - } - - if ((err = snd_card_next(&cards)) < 0 || cards < 0) { - MSG_ERR("alsa-init: no soundcards found: %s\n", snd_strerror(err)); - return MPXP_False; - } - - if (alsa_device[0] == '\0') { - int tmp_device, tmp_subdevice; - - if ((err = snd_pcm_info_malloc(&alsa_info)) < 0) { - MSG_ERR("alsa-init: memory allocation error: %s\n", snd_strerror(err)); - return MPXP_False; - } - - if ((tmp_device = snd_pcm_info_get_device(alsa_info)) < 0) { - MSG_ERR("alsa-init: cant get device\n"); - return MPXP_False; - } - - if ((tmp_subdevice = snd_pcm_info_get_subdevice(alsa_info)) < 0) { - MSG_ERR("alsa-init: cant get subdevice\n"); - return MPXP_False; - } - MSG_V("alsa-init: got device=%i, subdevice=%i\n", tmp_device, tmp_subdevice); - - if ((err = snprintf(alsa_device, ALSA_DEVICE_SIZE, "hw:%1d,%1d", tmp_device, tmp_subdevice)) <= 0) { - MSG_ERR("alsa-init: cant wrote device-id\n"); - } - snd_pcm_info_free(alsa_info); - } - - MSG_WARN("alsa-init: Testing & bugs are welcome. Found %d cards, use: %s\n",cards+1,alsa_device); - //setting modes for block or nonblock-mode - int open_mode,block_mode; - if (priv_conf.noblock) { - open_mode = SND_PCM_NONBLOCK; - block_mode = 1; - str_block_mode = "nonblock-mode"; - } else { - open_mode = 0; - block_mode = 0; - str_block_mode = "block-mode"; - } - - if (!handler) { - //modes = 0, SND_PCM_NONBLOCK, SND_PCM_ASYNC - if ((err = snd_pcm_open(&handler, alsa_device, SND_PCM_STREAM_PLAYBACK, open_mode)) < 0) { - if (priv_conf.noblock) { - MSG_ERR("alsa-init: open in nonblock-mode failed, trying to open in block-mode\n"); - if ((err = snd_pcm_open(&handler, alsa_device, SND_PCM_STREAM_PLAYBACK, 0)) < 0) { - MSG_ERR("alsa-init: playback open error: %s\n", snd_strerror(err)); - alsa_device[0]='\0'; - return MPXP_False; - } else { - block_mode = 0; - str_block_mode = "block-mode"; - } - } else { - MSG_ERR("alsa-init: playback open error: %s\n", snd_strerror(err)); - alsa_device[0]='\0'; - return MPXP_False; - } - } - alsa_device[0]='\0'; - if ((err = snd_pcm_nonblock(handler, block_mode)) < 0) { - MSG_ERR("alsa-init: error set block-mode %s\n", snd_strerror(err)); - } else MSG_V("alsa-init: pcm opend in %s\n", str_block_mode); - - snd_pcm_hw_params_malloc(&hwparams); - snd_pcm_sw_params_malloc(&swparams); - - // setting hw-parameters - if ((err = snd_pcm_hw_params_any(handler, hwparams)) < 0) { - MSG_ERR("alsa-init: unable to get initial parameters: %s\n", - snd_strerror(err)); - return MPXP_False; - } - MSG_DBG2("snd_pcm_hw_params_any()\n"); - if (priv_conf.mmap) { - snd_pcm_access_mask_t *mask = (snd_pcm_access_mask_t*)alloca(snd_pcm_access_mask_sizeof()); - snd_pcm_access_mask_none(mask); - snd_pcm_access_mask_set(mask, SND_PCM_ACCESS_MMAP_INTERLEAVED); - snd_pcm_access_mask_set(mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED); - snd_pcm_access_mask_set(mask, SND_PCM_ACCESS_MMAP_COMPLEX); - err = snd_pcm_hw_params_set_access_mask(handler, hwparams, mask); - MSG_ERR("alsa-init: mmap set\n"); - } else { - err = snd_pcm_hw_params_set_access(handler, hwparams,SND_PCM_ACCESS_RW_INTERLEAVED); - MSG_DBG2("snd_pcm_hw_params_set_access(SND_PCM_ACCESS_RW_INTERLEAVED)\n"); - } - if (err < 0) { - MSG_ERR("alsa-init: unable to set access type: %s\n", snd_strerror(err)); - return MPXP_False; - } - } // end switch priv->handler (spdif) - return MPXP_Ok; -} // end init - -MPXP_Rc Alsa_AO_Interface::configure(unsigned r,unsigned c,unsigned f) { - int err,i; - size_t chunk_size=0,chunk_bytes,bits_per_sample,bits_per_frame; - snd_pcm_uframes_t dummy; - - MSG_V("alsa-conf: requested format: %d Hz, %d channels, %s\n", r, - c, ao_format_name(f)); - - _samplerate = r; - _format = f; - _channels = c; - _outburst = OUTBURST; - //ao->buffersize = MAX_OUTBURST; // was 16384 - - snd_format=fmt2alsa(_format); - - switch(snd_format) { - case SND_PCM_FORMAT_S16_LE: - case SND_PCM_FORMAT_U16_LE: - case SND_PCM_FORMAT_S16_BE: - case SND_PCM_FORMAT_U16_BE: - case SND_PCM_FORMAT_S32_LE: - case SND_PCM_FORMAT_S32_BE: - case SND_PCM_FORMAT_U32_LE: - case SND_PCM_FORMAT_U32_BE: - case SND_PCM_FORMAT_FLOAT_BE: - case SND_PCM_FORMAT_FLOAT_LE: - case SND_PCM_FORMAT_S24_LE: - case SND_PCM_FORMAT_S24_BE: - case SND_PCM_FORMAT_U24_LE: - case SND_PCM_FORMAT_U24_BE: - break; - case -1: - MSG_ERR("alsa-conf: invalid format (%s) requested - output disabled\n", - ao_format_name(_format)); - return MPXP_False; - default: - break; - } - bytes_per_sample = bps() / _samplerate; - - if ((err = snd_pcm_hw_params_set_format(handler, hwparams, - snd_format)) < 0) { - MSG_ERR("alsa-conf: unable to set format(%s): %s\n", - snd_pcm_format_name(snd_format), - snd_strerror(err)); - MSG_HINT("Please try one of: "); - for(i=0;i<SND_PCM_FORMAT_LAST;i++) - if (!(snd_pcm_hw_params_test_format(handler, hwparams, snd_pcm_format_t(i)))) - MSG_HINT("%s ",snd_pcm_format_name(snd_pcm_format_t(i))); - MSG_HINT("\n"); - return MPXP_False; - } - MSG_DBG2("snd_pcm_hw_params_set_format(%i)\n",snd_format); - - if ((err = snd_pcm_hw_params_set_rate_near(handler, hwparams, &_samplerate, 0)) < 0) { - MSG_ERR("alsa-conf: unable to set samplerate %u: %s\n", - _samplerate, - snd_strerror(err)); - return MPXP_False; - } - MSG_DBG2("snd_pcm_hw_params_set_rate_near(%i)\n",_samplerate); - - if ((err = snd_pcm_hw_params_set_channels(handler, hwparams, - _channels)) < 0) { - MSG_ERR("alsa-conf: unable to set %u channels: %s\n", - _channels, - snd_strerror(err)); - return MPXP_False; - } - MSG_DBG2("snd_pcm_hw_params_set_channels(%i)\n",_channels); -#ifdef BUFFERTIME - { - int dir; - unsigned period_time,alsa_buffer_time = 500000; /* buffer time in us */ - - if ((err = snd_pcm_hw_params_set_buffer_time_near(handler, hwparams, &alsa_buffer_time, &dir)) < 0) { - MSG_ERR("alsa-init: unable to set buffer time near: %s\n", - snd_strerror(err)); - return MPXP_False; - } - MSG_DBG2("snd_pcm_hw_set_buffer_time_near(%i)\n",alsa_buffer_time); - - period_time = alsa_buffer_time/4; - if ((err = snd_pcm_hw_params_set_period_time_near(handler, hwparams, &period_time, &dir)) < 0) { - /* original: alsa_buffer_time/ao->bps */ - MSG_ERR("alsa-init: unable to set period time: %s\n", - snd_strerror(err)); - return MPXP_False; - } - MSG_DBG2("snd_pcm_hw_set_period_time_near(%i)\n",period_time); - MSG_V("alsa-init: buffer_time: %d, period_time :%d\n",alsa_buffer_time, period_time); - } -#else - { - int dir=0; - unsigned period_time=100000; /* period time in us */ - snd_pcm_uframes_t size; - if ((err = snd_pcm_hw_params_set_period_time_near(handler, hwparams, &period_time, &dir)) < 0) { - MSG_ERR("alsa-init: unable to set period_time: %s\n", snd_strerror(err)); - return MPXP_False; - } - MSG_DBG2("snd_pcm_hw_set_period_time(%i)\n",period_time); - - //get chunksize - if ((err = snd_pcm_hw_params_get_period_size(hwparams, &size, &dir)) < 0) { - MSG_ERR("alsa-init: unable to get period_size: %s\n", snd_strerror(err)); - return MPXP_False; - } - MSG_DBG2("snd_pcm_hw_get_period_size(%i)\n",size); - chunk_size=size; - } -#endif - // gets buffersize for control_ao - if ((err = snd_pcm_hw_params_get_buffer_size(hwparams,&dummy)) < 0) { - MSG_ERR("alsa-conf: unable to get buffersize: %s\n", snd_strerror(err)); - return MPXP_False; - } else { - _buffersize = dummy * bytes_per_sample; - MSG_V("alsa-conf: got buffersize=%i\n", _buffersize); - } - MSG_DBG2("snd_pcm_hw_params_get_buffer_size(%i)\n",dummy); - bits_per_sample = snd_pcm_format_physical_width(snd_format); - MSG_DBG2("%i=snd_pcm_hw_format_pohysical_width()\n",bits_per_sample); - bits_per_frame = bits_per_sample * _channels; - chunk_bytes = chunk_size * bits_per_frame / 8; - - MSG_V("alsa-conf: bits per sample (bps)=%i, bits per frame (bpf)=%i, chunk_bytes=%i\n",bits_per_sample,bits_per_frame,chunk_bytes); - - /* finally install hardware parameters */ - if ((err = snd_pcm_hw_params(handler, hwparams)) < 0) { - MSG_ERR("alsa-conf: unable to set hw-parameters: %s\n", - snd_strerror(err)); - return MPXP_False; - } - MSG_DBG2("snd_pcm_hw_params()\n"); - // setting sw-params (only avail-min) if noblocking mode was choosed - if (priv_conf.noblock) { - if ((err = snd_pcm_sw_params_current(handler, swparams)) < 0) { - MSG_ERR("alsa-conf: unable to get parameters: %s\n",snd_strerror(err)); - return MPXP_False; - } - - //set min available frames to consider pcm ready (4) - //increased for nonblock-mode should be set dynamically later - if ((err = snd_pcm_sw_params_set_avail_min(handler, swparams, 4)) < 0) { - MSG_ERR("alsa-conf: unable to set avail_min %s\n",snd_strerror(err)); - return MPXP_False; - } - - if ((err = snd_pcm_sw_params(handler, swparams)) < 0) { - MSG_ERR("alsa-conf: unable to install sw-params\n"); - return MPXP_False; - } - - }//end swparams - - if ((err = snd_pcm_prepare(handler)) < 0) { - MSG_ERR("alsa-conf: pcm prepare error: %s\n", snd_strerror(err)); - return MPXP_False; - } - // end setting hw-params - MSG_V("alsa-conf: %d Hz/%d channels/%d bpf/%d bytes buffer/%s\n", - _samplerate, _channels, bytes_per_sample, _buffersize, - snd_pcm_format_description(snd_format)); - return MPXP_Ok; -} // end config_ao - -void Alsa_AO_Interface::pause() { - int err; - - if (!priv_conf.noblock) { - //drain causes error in nonblock-mode! - if ((err = snd_pcm_drain(handler)) < 0) { - MSG_ERR("alsa-pause: pcm drain error: %s\n", snd_strerror(err)); - return; - } - } else { - MSG_V("alsa-pause: paused nonblock\n"); - return; - } -} - -void Alsa_AO_Interface::resume() { - int err; - - if ((err = snd_pcm_prepare(handler)) < 0) { - MSG_ERR("alsa-resume: pcm prepare error: %s\n", snd_strerror(err)); - return; - } -} - -/* stop playing and empty buffers (for seeking/pause) */ -void Alsa_AO_Interface::reset() { - int err; - - if ((err = snd_pcm_drop(handler)) < 0) { - MSG_ERR("alsa-reset: pcm drop error: %s\n", snd_strerror(err)); - return; - } - if ((err = snd_pcm_prepare(handler)) < 0) { - MSG_ERR("alsa-reset: pcm prepare error: %s\n", snd_strerror(err)); - return; - } - return; -} - -#ifdef USE_POLL -static int __FASTCALL__ wait_for_poll(snd_pcm_t *handle, struct pollfd *ufds, unsigned int count) -{ - unsigned short revents; - - while (1) { - poll(ufds, count, -1); - snd_pcm_poll_descriptors_revents(handle, ufds, count, &revents); - if (revents & POLLERR) return -EIO; - if (revents & POLLOUT) return 0; - } -} -#endif - -static void _timersub(const struct timeval*a,const struct timeval* b,struct timeval* result) { - result->tv_sec = a->tv_sec - b->tv_sec; - result->tv_usec = a->tv_usec - b->tv_usec; - if (result->tv_usec < 0) { - --result->tv_sec; - result->tv_usec += 1000000; - } -} - -/* I/O error handler */ -int Alsa_AO_Interface::xrun(const char *str_mode) const { - int err; - snd_pcm_status_t *status; - - snd_pcm_status_alloca(&status); - - if ((err = snd_pcm_status(handler, status))<0) { - MSG_ERR("status error: %s", snd_strerror(err)); - return 0; - } - - if (snd_pcm_status_get_state(status) == SND_PCM_STATE_XRUN) { - struct timeval now, diff, tstamp; - gettimeofday(&now, 0); - snd_pcm_status_get_trigger_tstamp(status, &tstamp); - _timersub(&now, &tstamp, &diff); - MSG_V("alsa-%s: xrun of at least %.3f msecs. resetting stream\n", - str_mode, - diff.tv_sec * 1000 + diff.tv_usec / 1000.0); - } - - if ((err = snd_pcm_prepare(handler))<0) { - MSG_ERR("xrun: prepare error: %s", snd_strerror(err)); - return 0; - } - - return 1; /* ok, data should be accepted again */ -} - -unsigned Alsa_AO_Interface::play(const any_t* data, unsigned len, unsigned flags) { - unsigned result; - UNUSED(flags); - MSG_DBG2("[ao_... [truncated message content] |
From: <nic...@us...> - 2012-12-17 10:31:50
|
Revision: 568 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=568&view=rev Author: nickols_k Date: 2012-12-17 10:31:40 +0000 (Mon, 17 Dec 2012) Log Message: ----------- use references instead of pointers Modified Paths: -------------- mplayerxp/libao3/audio_out.cpp mplayerxp/libao3/audio_out.h mplayerxp/libmpstream2/stream.cpp mplayerxp/libmpstream2/stream.h mplayerxp/libvo2/video_out.cpp mplayerxp/libvo2/video_out.h Modified: mplayerxp/libao3/audio_out.cpp =================================================================== --- mplayerxp/libao3/audio_out.cpp 2012-12-17 08:47:00 UTC (rev 567) +++ mplayerxp/libao3/audio_out.cpp 2012-12-17 10:31:40 UTC (rev 568) @@ -183,20 +183,15 @@ } Audio_Output::Audio_Output(const char* _subdevice) - :subdevice(mp_strdup(_subdevice)) -{ - priv_t* priv=new(zeromem) priv_t; - opaque=priv; - fill_false_pointers(antiviral_hole,reinterpret_cast<long>(&opaque)-reinterpret_cast<long>(&antiviral_hole)); - priv->driver=NULL; -} + :subdevice(mp_strdup(_subdevice)), + opaque(*new(zeromem) priv_t){} Audio_Output::~Audio_Output() { - priv_t* priv=static_cast<priv_t*>(opaque); - delete priv->driver; + priv_t& priv=static_cast<priv_t&>(opaque); + delete priv.driver; if(subdevice) delete subdevice; - delete priv; + delete &priv; } void Audio_Output::print_help() const { @@ -211,111 +206,111 @@ } MPXP_Rc Audio_Output::_register(const char *driver_name,unsigned flags) const { - priv_t* priv=static_cast<priv_t*>(opaque); + priv_t& priv=static_cast<priv_t&>(opaque); unsigned i; if(!driver_name) { - priv->info=audio_out_drivers[0]; - priv->driver=audio_out_drivers[0]->query_interface(subdevice?subdevice:""); + priv.info=audio_out_drivers[0]; + priv.driver=audio_out_drivers[0]->query_interface(subdevice?subdevice:""); } else for (i=0; audio_out_drivers[i] != &audio_out_null; i++) { const ao_info_t *info = audio_out_drivers[i]; if(strcmp(info->short_name,driver_name) == 0){ - priv->info = audio_out_drivers[i]; - priv->driver = audio_out_drivers[i]->query_interface(subdevice?subdevice:""); + priv.info = audio_out_drivers[i]; + priv.driver = audio_out_drivers[i]->query_interface(subdevice?subdevice:""); break; } } - if(priv->driver->open(flags)==MPXP_Ok) return MPXP_Ok; + if(priv.driver->open(flags)==MPXP_Ok) return MPXP_Ok; return MPXP_False; } const ao_info_t* Audio_Output::get_info() const { - priv_t* priv=static_cast<priv_t*>(opaque); - return priv->info; + priv_t& priv=static_cast<priv_t&>(opaque); + return priv.info; } MPXP_Rc Audio_Output::configure(unsigned r,unsigned c,unsigned f) const { - priv_t* priv=static_cast<priv_t*>(opaque); - return priv->driver->configure(r,c,f); + priv_t& priv=static_cast<priv_t&>(opaque); + return priv.driver->configure(r,c,f); } unsigned Audio_Output::channels() const { - priv_t* priv=static_cast<priv_t*>(opaque); - return priv->driver->channels(); + priv_t& priv=static_cast<priv_t&>(opaque); + return priv.driver->channels(); } unsigned Audio_Output::samplerate() const { - priv_t* priv=static_cast<priv_t*>(opaque); - return priv->driver->samplerate(); + priv_t& priv=static_cast<priv_t&>(opaque); + return priv.driver->samplerate(); } unsigned Audio_Output::format() const { - priv_t* priv=static_cast<priv_t*>(opaque); - return priv->driver->format(); + priv_t& priv=static_cast<priv_t&>(opaque); + return priv.driver->format(); } MPXP_Rc Audio_Output::test_channels(unsigned c) const { - priv_t* priv=static_cast<priv_t*>(opaque); - return priv->driver->test_channels(c); + priv_t& priv=static_cast<priv_t&>(opaque); + return priv.driver->test_channels(c); } MPXP_Rc Audio_Output::test_rate(unsigned s) const { - priv_t* priv=static_cast<priv_t*>(opaque); - return priv->driver->test_rate(s); + priv_t& priv=static_cast<priv_t&>(opaque); + return priv.driver->test_rate(s); } MPXP_Rc Audio_Output::test_format(unsigned f) const { - priv_t* priv=static_cast<priv_t*>(opaque); - return priv->driver->test_format(f); + priv_t& priv=static_cast<priv_t&>(opaque); + return priv.driver->test_format(f); } unsigned Audio_Output::bps() const { - priv_t* priv=static_cast<priv_t*>(opaque); - return priv->driver->channels()* - priv->driver->samplerate()* - afmt2bps(priv->driver->format()); + priv_t& priv=static_cast<priv_t&>(opaque); + return priv.driver->channels()* + priv.driver->samplerate()* + afmt2bps(priv.driver->format()); } unsigned Audio_Output::buffersize() const { - priv_t* priv=static_cast<priv_t*>(opaque); - return priv->driver->buffersize(); + priv_t& priv=static_cast<priv_t&>(opaque); + return priv.driver->buffersize(); } unsigned Audio_Output::outburst() const { - priv_t* priv=static_cast<priv_t*>(opaque); - return priv->driver->outburst(); + priv_t& priv=static_cast<priv_t&>(opaque); + return priv.driver->outburst(); } void Audio_Output::reset() const { - priv_t* priv=static_cast<priv_t*>(opaque); - priv->driver->reset(); + priv_t& priv=static_cast<priv_t&>(opaque); + priv.driver->reset(); } unsigned Audio_Output::get_space() const { - priv_t* priv=static_cast<priv_t*>(opaque); - return priv->driver->get_space(); + priv_t& priv=static_cast<priv_t&>(opaque); + return priv.driver->get_space(); } float Audio_Output::get_delay() const { - priv_t* priv=static_cast<priv_t*>(opaque); - return priv->driver->get_delay(); + priv_t& priv=static_cast<priv_t&>(opaque); + return priv.driver->get_delay(); } unsigned Audio_Output::play(const any_t* data,unsigned len,unsigned flags) const { - priv_t* priv=static_cast<priv_t*>(opaque); - return priv->driver->play(data,len,flags); + priv_t& priv=static_cast<priv_t&>(opaque); + return priv.driver->play(data,len,flags); } void Audio_Output::pause() const { - priv_t* priv=static_cast<priv_t*>(opaque); - priv->driver->pause(); + priv_t& priv=static_cast<priv_t&>(opaque); + priv.driver->pause(); } void Audio_Output::resume() const { - priv_t* priv=static_cast<priv_t*>(opaque); - priv->driver->resume(); + priv_t& priv=static_cast<priv_t&>(opaque); + priv.driver->resume(); } MPXP_Rc Audio_Output::ctrl(int cmd,long arg) const { - priv_t* priv=static_cast<priv_t*>(opaque); - return priv->driver->ctrl(cmd,arg); + priv_t& priv=static_cast<priv_t&>(opaque); + return priv.driver->ctrl(cmd,arg); } void Audio_Output::mixer_getvolume(float *l,float *r) const { @@ -361,12 +356,12 @@ } void Audio_Output::mixer_mute() const { - priv_t* priv=static_cast<priv_t*>(opaque); - if ( priv->muted ) { mixer_setvolume(priv->mute_l,priv->mute_r ); priv->muted=0; } + priv_t& priv=static_cast<priv_t&>(opaque); + if ( priv.muted ) { mixer_setvolume(priv.mute_l,priv.mute_r ); priv.muted=0; } else { - mixer_getvolume(&priv->mute_l,&priv->mute_r ); + mixer_getvolume(&priv.mute_l,&priv.mute_r ); mixer_setvolume(0,0); - priv->muted=1; + priv.muted=1; } } -} // namespace mpxp \ No newline at end of file +} // namespace mpxp Modified: mplayerxp/libao3/audio_out.h =================================================================== --- mplayerxp/libao3/audio_out.h 2012-12-17 08:47:00 UTC (rev 567) +++ mplayerxp/libao3/audio_out.h 2012-12-17 10:31:40 UTC (rev 568) @@ -67,8 +67,7 @@ char* subdevice; float pts; /**< PTS of audio buffer */ private: - char antiviral_hole[RND_CHAR2]; - any_t* opaque; /**< for internal use */ + Opaque& opaque; /**< for internal use */ }; /* prototypes */ extern const char * __FASTCALL__ ao_format_name(int format); Modified: mplayerxp/libmpstream2/stream.cpp =================================================================== --- mplayerxp/libmpstream2/stream.cpp 2012-12-17 08:47:00 UTC (rev 567) +++ mplayerxp/libmpstream2/stream.cpp 2012-12-17 10:31:40 UTC (rev 568) @@ -92,7 +92,7 @@ Stream::Stream(Stream::type_e t) :_type(t) { - fill_false_pointers(antiviral_hole,reinterpret_cast<long>(&pin)-reinterpret_cast<long>(&antiviral_hole)); + fill_false_pointers(antiviral_hole,reinterpret_cast<long>(&pin)-reinterpret_cast<long>(&antiviral_hole[0])); pin=STREAM_PIN; reset(); } Modified: mplayerxp/libmpstream2/stream.h =================================================================== --- mplayerxp/libmpstream2/stream.h 2012-12-17 08:47:00 UTC (rev 567) +++ mplayerxp/libmpstream2/stream.h 2012-12-17 10:31:40 UTC (rev 568) @@ -92,7 +92,6 @@ private: int read(stream_packet_t* sp); Stream_Interface* driver; /**< low-level stream driver */ - Opaque* priv; /**< private data used by stream driver */ type_e _type; int _eof; /**< indicates EOF */ }; Modified: mplayerxp/libvo2/video_out.cpp =================================================================== --- mplayerxp/libvo2/video_out.cpp 2012-12-17 08:47:00 UTC (rev 567) +++ mplayerxp/libvo2/video_out.cpp 2012-12-17 10:31:40 UTC (rev 568) @@ -134,22 +134,20 @@ delete vo_iface; } -Video_Output::Video_Output() { +Video_Output::Video_Output() + :vo_priv(*new(zeromem) vo_priv_t) { inited=0; osd_progbar_type=-1; osd_progbar_value=100; // 0..256 - vo_priv_t* priv; - priv=new(zeromem) vo_priv_t; - vo_priv=priv; - fill_false_pointers(antiviral_hole,reinterpret_cast<long>(&flags)-reinterpret_cast<long>(&antiviral_hole)); + fill_false_pointers(antiviral_hole,reinterpret_cast<long>(&flags)-reinterpret_cast<long>(&antiviral_hole[0])); } Video_Output::~Video_Output() { - vo_priv_t* priv=static_cast<vo_priv_t*>(vo_priv); + vo_priv_t& priv=static_cast<vo_priv_t&>(vo_priv); MSG_DBG3("dri_vo_dbg: vo_uninit\n"); inited--; - delete priv; + delete &priv; } void Video_Output::print_help() const @@ -166,7 +164,7 @@ const vo_info_t* Video_Output::get_info() const { - vo_priv_t& priv=*static_cast<vo_priv_t*>(vo_priv); + vo_priv_t& priv=static_cast<vo_priv_t&>(vo_priv); return priv.video_out; } @@ -180,7 +178,7 @@ offset=drv_name.find(':'); if(offset!=std::string::npos) subdev = drv_name.substr(offset+1); } - vo_priv_t& priv=*static_cast<vo_priv_t*>(vo_priv); + vo_priv_t& priv=static_cast<vo_priv_t&>(vo_priv); unsigned i; if(drv_name.empty()) priv.video_out=vo_infos[0]; else @@ -200,7 +198,7 @@ void Video_Output::dri_config(uint32_t fourcc) const { - vo_priv_t& priv=*static_cast<vo_priv_t*>(vo_priv); + vo_priv_t& priv=static_cast<vo_priv_t&>(vo_priv); priv.dri.is_planar = vo_describe_fourcc(fourcc,&priv.vod); priv.dri.bpp=priv.vod.bpp; if(!priv.dri.bpp) priv.dri.has_dri=0; /*unknown fourcc*/ @@ -212,7 +210,7 @@ void Video_Output::ps_tune(unsigned width,unsigned height) const { - vo_priv_t& priv=*static_cast<vo_priv_t*>(vo_priv); + vo_priv_t& priv=static_cast<vo_priv_t&>(vo_priv); int src_is_planar; unsigned src_stride,ps_x,ps_y; vo_format_desc vd; @@ -238,7 +236,7 @@ void Video_Output::dri_tune(unsigned width,unsigned height) const { - vo_priv_t& priv=*static_cast<vo_priv_t*>(vo_priv); + vo_priv_t& priv=static_cast<vo_priv_t&>(vo_priv); priv.dri.sstride=priv.dri.is_planar?width:width*((priv.dri.bpp+7)/8); priv.dri.off[0] = priv.dri.off[1] = priv.dri.off[2] = priv.dri.off[3] = 0; if(!priv.dri.is_planar) { @@ -292,7 +290,7 @@ void Video_Output::dri_reconfig(int is_resize ) const { - vo_priv_t& priv=*static_cast<vo_priv_t*>(vo_priv); + vo_priv_t& priv=static_cast<vo_priv_t&>(vo_priv); priv.dri.has_dri = 1; priv.vo_iface->get_surface_caps(&priv.dri.cap); dri_config(priv.dri.cap.fourcc); @@ -315,7 +313,7 @@ uint32_t d_height, vo_flags_e _fullscreen, const std::string& title, uint32_t format) { - vo_priv_t& priv=*static_cast<vo_priv_t*>(vo_priv); + vo_priv_t& priv=static_cast<vo_priv_t&>(vo_priv); priv.parent=s; MPXP_Rc retval; unsigned dest_fourcc,w,d_w,h,d_h; @@ -374,7 +372,7 @@ /* if vo_driver doesn't support dri then it won't work with this logic */ uint32_t Video_Output::query_format(uint32_t* fourcc, unsigned src_w, unsigned src_h) const { - vo_priv_t& priv=*static_cast<vo_priv_t*>(vo_priv); + vo_priv_t& priv=static_cast<vo_priv_t&>(vo_priv); uint32_t dri_forced_fourcc; vo_query_fourcc_t qfourcc; MSG_DBG3("dri_vo_dbg: vo_query_format(%08lX)\n",*fourcc); @@ -390,14 +388,14 @@ MPXP_Rc Video_Output::reset() const { - vo_priv_t& priv=*static_cast<vo_priv_t*>(vo_priv); + vo_priv_t& priv=static_cast<vo_priv_t&>(vo_priv); MSG_DBG3("dri_vo_dbg: vo_reset\n"); return priv.vo_iface->reset(); } MPXP_Rc Video_Output::screenshot(unsigned idx) const { - vo_priv_t& priv=*static_cast<vo_priv_t*>(vo_priv); + vo_priv_t& priv=static_cast<vo_priv_t&>(vo_priv); char buf[256]; MSG_DBG3("dri_vo_dbg: vo_screenshot\n"); sprintf(buf,"%llu",priv.frame_counter); @@ -409,27 +407,27 @@ MPXP_Rc Video_Output::pause() const { - vo_priv_t& priv=*static_cast<vo_priv_t*>(vo_priv); + vo_priv_t& priv=static_cast<vo_priv_t&>(vo_priv); MSG_DBG3("dri_vo_dbg: vo_pause\n"); return priv.vo_iface->pause(); } MPXP_Rc Video_Output::resume() const { - vo_priv_t& priv=*static_cast<vo_priv_t*>(vo_priv); + vo_priv_t& priv=static_cast<vo_priv_t&>(vo_priv); MSG_DBG3("dri_vo_dbg: vo_resume\n"); return priv.vo_iface->resume(); } MPXP_Rc Video_Output::get_surface_caps(dri_surface_cap_t*caps) const { - vo_priv_t& priv=*static_cast<vo_priv_t*>(vo_priv); + vo_priv_t& priv=static_cast<vo_priv_t&>(vo_priv); priv.vo_iface->get_surface_caps(caps); return MPXP_Ok; } MPXP_Rc Video_Output::get_surface(mp_image_t* mpi) const { - vo_priv_t& priv=*static_cast<vo_priv_t*>(vo_priv); + vo_priv_t& priv=static_cast<vo_priv_t&>(vo_priv); int width_less_stride; MSG_DBG2("dri_vo_dbg: vo_get_surface type=%X flg=%X\n",mpi->type,mpi->flags); width_less_stride = 0; @@ -483,7 +481,7 @@ int Video_Output::adjust_size(unsigned cw,unsigned ch,unsigned *nw,unsigned *nh) const { - vo_priv_t& priv=*static_cast<vo_priv_t*>(vo_priv); + vo_priv_t& priv=static_cast<vo_priv_t&>(vo_priv); MSG_DBG3("dri_vo_dbg: adjust_size was called %u %u %u %u\n",cw,ch,*nw,*nh); if((priv.dri.flags & VOFLAG_SWSCALE) && (cw != *nw || ch != *nh) && !(priv.dri.flags & VOFLAG_FULLSCREEN)) { @@ -514,7 +512,7 @@ int Video_Output::check_events() const { - vo_priv_t& priv=*static_cast<vo_priv_t*>(vo_priv); + vo_priv_t& priv=static_cast<vo_priv_t&>(vo_priv); uint32_t retval; int need_repaint; vo_resize_t vrest; @@ -536,7 +534,7 @@ MPXP_Rc Video_Output::fullscreen() const { - vo_priv_t& priv=*static_cast<vo_priv_t*>(vo_priv); + vo_priv_t& priv=static_cast<vo_priv_t&>(vo_priv); MPXP_Rc retval; MSG_DBG3("dri_vo_dbg: vo_fullscreen\n"); retval = priv.vo_iface->toggle_fullscreen(); @@ -547,13 +545,13 @@ } unsigned Video_Output::get_num_frames() const { - vo_priv_t& priv=*static_cast<vo_priv_t*>(vo_priv); + vo_priv_t& priv=static_cast<vo_priv_t&>(vo_priv); return priv.dri.num_xp_frames; } MPXP_Rc Video_Output::draw_slice(const mp_image_t *mpi) const { - vo_priv_t& priv=*static_cast<vo_priv_t*>(vo_priv); + vo_priv_t& priv=static_cast<vo_priv_t&>(vo_priv); unsigned i,_w[4],_h[4],x,y; MSG_DBG3("dri_vo_dbg: vo_draw_slice xywh=%i %i %i %i\n",mpi->x,mpi->y,mpi->w,mpi->h); if(priv.dri.has_dri) { @@ -591,14 +589,14 @@ void Video_Output::select_frame(unsigned play_idx) const { - vo_priv_t& priv=*static_cast<vo_priv_t*>(vo_priv); + vo_priv_t& priv=static_cast<vo_priv_t&>(vo_priv); MSG_DBG2("dri_vo_dbg: vo_select_frame(play_idx=%u)\n",play_idx); priv.vo_iface->select_frame(play_idx); } void Video_Output::flush_page(unsigned decoder_idx) const { - vo_priv_t& priv=*static_cast<vo_priv_t*>(vo_priv); + vo_priv_t& priv=static_cast<vo_priv_t&>(vo_priv); MSG_DBG3("dri_vo_dbg: vo_flush_pages [idx=%u]\n",decoder_idx); priv.frame_counter++; if((priv.dri.cap.caps & DRI_CAP_VIDEO_MMAPED)!=DRI_CAP_VIDEO_MMAPED) @@ -608,7 +606,7 @@ /* DRAW OSD */ void Video_Output::clear_rect(unsigned _y0,unsigned h,uint8_t *dest,unsigned stride,unsigned dstride,uint8_t filler) const { - vo_priv_t& priv=*static_cast<vo_priv_t*>(vo_priv); + vo_priv_t& priv=static_cast<vo_priv_t&>(vo_priv); unsigned i; for(i=0;i<h;i++) { @@ -619,7 +617,7 @@ void Video_Output::clear_rect2(unsigned _y0,unsigned h,uint8_t *dest,unsigned stride,unsigned dstride,uint8_t filler) const { - vo_priv_t& priv=*static_cast<vo_priv_t*>(vo_priv); + vo_priv_t& priv=static_cast<vo_priv_t&>(vo_priv); unsigned i; unsigned _y1 = priv.dri.cap.y/2; unsigned _y2 = (priv.dri.cap.y+priv.dri.cap.h)/2; @@ -632,7 +630,7 @@ void Video_Output::clear_rect4(unsigned _y0,unsigned h,uint8_t *dest,unsigned stride,unsigned dstride,uint8_t filler) const { - vo_priv_t& priv=*static_cast<vo_priv_t*>(vo_priv); + vo_priv_t& priv=static_cast<vo_priv_t&>(vo_priv); unsigned i; unsigned _y1 = priv.dri.cap.y/4; unsigned _y2 = (priv.dri.cap.y+priv.dri.cap.h)/4; @@ -645,7 +643,7 @@ void Video_Output::clear_rect_rgb(unsigned _y0,unsigned h,uint8_t *dest,unsigned stride,unsigned dstride) const { - vo_priv_t& priv=*static_cast<vo_priv_t*>(vo_priv); + vo_priv_t& priv=static_cast<vo_priv_t&>(vo_priv); unsigned i; for(i=0;i<h;i++) { @@ -656,7 +654,7 @@ void Video_Output::clear_rect_yuy2(unsigned _y0,unsigned h,uint8_t *dest,unsigned stride,unsigned dstride) const { - vo_priv_t& priv=*static_cast<vo_priv_t*>(vo_priv); + vo_priv_t& priv=static_cast<vo_priv_t&>(vo_priv); unsigned i; for(i=0;i<h;i++) { @@ -677,7 +675,7 @@ void Video_Output::dri_remove_osd(unsigned idx,int x0,int _y0, int w,int h) const { - vo_priv_t& priv=*static_cast<vo_priv_t*>(vo_priv); + vo_priv_t& priv=static_cast<vo_priv_t&>(vo_priv); dri_surface_t surf; surf.idx=idx; priv.vo_iface->get_surface(&surf); @@ -732,7 +730,7 @@ void Video_Output::dri_draw_osd(unsigned idx,int x0,int _y0, int w,int h,const unsigned char* src,const unsigned char *srca, int stride) const { - vo_priv_t& priv=*static_cast<vo_priv_t*>(vo_priv); + vo_priv_t& priv=static_cast<vo_priv_t&>(vo_priv); int finalize=is_final(); if(unsigned(x0+w)<=priv.dri.cap.width&&unsigned(_y0+h)<=priv.dri.cap.height) { @@ -757,7 +755,7 @@ void Video_Output::draw_osd(unsigned idx) const { - vo_priv_t& priv=*static_cast<vo_priv_t*>(vo_priv); + vo_priv_t& priv=static_cast<vo_priv_t&>(vo_priv); MSG_DBG3("dri_vo_dbg: vo_draw_osd\n"); if(priv.dri.has_dri && !(priv.dri.cap.caps & DRI_CAP_HWOSD)) { @@ -770,7 +768,7 @@ void Video_Output::draw_spudec_direct(unsigned idx) const { - vo_priv_t& priv=*static_cast<vo_priv_t*>(vo_priv); + vo_priv_t& priv=static_cast<vo_priv_t&>(vo_priv); MSG_DBG3("dri_vo_dbg: vo_draw_osd\n"); if(priv.dri.has_dri && !(priv.dri.cap.caps & DRI_CAP_HWOSD)) { @@ -785,14 +783,14 @@ MPXP_Rc Video_Output::ctrl(uint32_t request, any_t*data) const { MPXP_Rc rval; - vo_priv_t& priv=*static_cast<vo_priv_t*>(vo_priv); + vo_priv_t& priv=static_cast<vo_priv_t&>(vo_priv); rval=priv.vo_iface->ctrl(request,data); MSG_DBG3("dri_vo_dbg: %u=vo_control( %u, %p )\n",rval,request,data); return rval; } int Video_Output::is_final() const { - vo_priv_t& priv=*static_cast<vo_priv_t*>(vo_priv); + vo_priv_t& priv=static_cast<vo_priv_t&>(vo_priv); int mmaped=priv.dri.cap.caps&DRI_CAP_VIDEO_MMAPED; int busmaster=priv.dri.cap.caps&DRI_CAP_BUSMASTERING; return mmaped||busmaster||(priv.dri.num_xp_frames>1); Modified: mplayerxp/libvo2/video_out.h =================================================================== --- mplayerxp/libvo2/video_out.h 2012-12-17 08:47:00 UTC (rev 567) +++ mplayerxp/libvo2/video_out.h 2012-12-17 10:31:40 UTC (rev 568) @@ -148,7 +148,7 @@ }; struct vf_stream_t; - class Video_Output { + class Video_Output : public Opaque { public: Video_Output(); virtual ~Video_Output(); @@ -222,8 +222,8 @@ void clear_rect_rgb(unsigned _y0,unsigned h,uint8_t *dest,unsigned stride,unsigned dstride) const; void clear_rect_yuy2(unsigned _y0,unsigned h,uint8_t *dest,unsigned stride,unsigned dstride) const; + video_private& vo_priv;/* private data of vo structure */ int inited; - video_private* vo_priv;/* private data of vo structure */ }; /** Notification event when windowed output has been resized (as data of VOCTRL_CHECK_EVENT) */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2012-12-19 17:44:21
|
Revision: 579 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=579&view=rev Author: nickols_k Date: 2012-12-19 17:44:09 +0000 (Wed, 19 Dec 2012) Log Message: ----------- NEW: use std::iostream library based output methods Modified Paths: -------------- mplayerxp/dump.cpp mplayerxp/input2/in_msg.h mplayerxp/libao3/ao_msg.h mplayerxp/libmpcodecs/ad_msg.h mplayerxp/libmpcodecs/codecs_ld.cpp mplayerxp/libmpcodecs/vd_msg.h mplayerxp/libmpconf/cfgparser.cpp mplayerxp/libmpconf/codec-cfg.cpp mplayerxp/libmpconf/m_option.cpp mplayerxp/libmpconf/m_property.cpp mplayerxp/libmpconf/m_struct.cpp mplayerxp/libmpconf/subopt-helper.cpp mplayerxp/libmpdemux/demux_msg.h mplayerxp/libmpstream2/stream_msg.h mplayerxp/libmpsub/find_sub.cpp mplayerxp/libmpsub/spudec.cpp mplayerxp/libmpsub/subreader.cpp mplayerxp/libmpsub/vobsub.cpp mplayerxp/libplaytree/asxparser.cpp mplayerxp/libplaytree/playtree.cpp mplayerxp/libplaytree/playtreeparser.cpp mplayerxp/libvo2/vo_msg.h mplayerxp/mplayerxp.cpp mplayerxp/mpxp_msg.cpp mplayerxp/mpxp_msg.h mplayerxp/nls/mpxp_help-cz.h mplayerxp/nls/mpxp_help-de.h mplayerxp/nls/mpxp_help-dk.h mplayerxp/nls/mpxp_help-en.h mplayerxp/nls/mpxp_help-es.h mplayerxp/nls/mpxp_help-fr.h mplayerxp/nls/mpxp_help-hu.h mplayerxp/nls/mpxp_help-it.h mplayerxp/nls/mpxp_help-ko.h mplayerxp/nls/mpxp_help-nl.h mplayerxp/nls/mpxp_help-no.h mplayerxp/nls/mpxp_help-pl.h mplayerxp/nls/mpxp_help-ro.h mplayerxp/nls/mpxp_help-ru.h mplayerxp/nls/mpxp_help-sk.h mplayerxp/nls/nls_msg.h mplayerxp/osdep/osdep_msg.h mplayerxp/postproc/postprocess.cpp mplayerxp/postproc/pp_msg.h mplayerxp/postproc/swscale.cpp mplayerxp/xmpcore/sig_hand.cpp mplayerxp/xmpcore/xmp_adecoder.cpp mplayerxp/xmpcore/xmp_aframe.cpp mplayerxp/xmpcore/xmp_aplayer.cpp mplayerxp/xmpcore/xmp_core.cpp mplayerxp/xmpcore/xmp_image.cpp mplayerxp/xmpcore/xmp_vdecoder.cpp mplayerxp/xmpcore/xmp_vplayer.cpp Added Paths: ----------- mplayerxp/global_msg.h mplayerxp/libmpconf/parser_msg.h mplayerxp/libmpsub/mpsub_msg.h mplayerxp/libplaytree/playtree_msg.h mplayerxp/player_msg.h Modified: mplayerxp/dump.cpp =================================================================== --- mplayerxp/dump.cpp 2012-12-19 12:02:27 UTC (rev 578) +++ mplayerxp/dump.cpp 2012-12-19 17:44:09 UTC (rev 579) @@ -17,8 +17,7 @@ #include "libmpdemux/muxer.h" #include "libmpstream2/stream.h" #include "libmpstream2/mrl.h" -#define MSGT_CLASS MSGT_GLOBAL -#include "mpxp_msg.h" +#include "global_msg.h" #include "dump.h" namespace mpxp { Added: mplayerxp/global_msg.h =================================================================== --- mplayerxp/global_msg.h (rev 0) +++ mplayerxp/global_msg.h 2012-12-19 17:44:09 UTC (rev 579) @@ -0,0 +1,21 @@ +#ifndef GLOBAL_MSG_H +#define GLOBAL_MSG_H 1 + +#define MSGT_CLASS MSGT_GLOBAL +#include "mpxp_msg.h" + +namespace mpxp { + static mpxp_ostream_info mpxp_info(MSGT_GLOBAL); + static mpxp_ostream_fatal mpxp_fatal(MSGT_GLOBAL); + static mpxp_ostream_err mpxp_err(MSGT_GLOBAL); + static mpxp_ostream_warn mpxp_warn(MSGT_GLOBAL); + static mpxp_ostream_ok mpxp_ok(MSGT_GLOBAL); + static mpxp_ostream_hint mpxp_hint(MSGT_GLOBAL); + static mpxp_ostream_status mpxp_status(MSGT_GLOBAL); + static mpxp_ostream_v mpxp_v(MSGT_GLOBAL); + 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 Property changes on: mplayerxp/global_msg.h ___________________________________________________________________ Added: svn:eol-style + native Modified: mplayerxp/input2/in_msg.h =================================================================== --- mplayerxp/input2/in_msg.h 2012-12-19 12:02:27 UTC (rev 578) +++ mplayerxp/input2/in_msg.h 2012-12-19 17:44:09 UTC (rev 579) @@ -4,4 +4,18 @@ #define MSGT_CLASS MSGT_INPUT #include "mpxp_msg.h" +namespace mpxp { + static mpxp_ostream_info mpxp_info(MSGT_INPUT); + static mpxp_ostream_fatal mpxp_fatal(MSGT_INPUT); + static mpxp_ostream_err mpxp_err(MSGT_INPUT); + static mpxp_ostream_warn mpxp_warn(MSGT_INPUT); + static mpxp_ostream_ok mpxp_ok(MSGT_INPUT); + static mpxp_ostream_hint mpxp_hint(MSGT_INPUT); + static mpxp_ostream_status mpxp_status(MSGT_INPUT); + static mpxp_ostream_v mpxp_v(MSGT_INPUT); + static mpxp_ostream_dbg2 mpxp_dbg2(MSGT_INPUT); + static mpxp_ostream_dbg3 mpxp_dbg3(MSGT_INPUT); + static mpxp_ostream_dbg4 mpxp_dbg4(MSGT_INPUT); +} // namespace mpxp + #endif Modified: mplayerxp/libao3/ao_msg.h =================================================================== --- mplayerxp/libao3/ao_msg.h 2012-12-19 12:02:27 UTC (rev 578) +++ mplayerxp/libao3/ao_msg.h 2012-12-19 17:44:09 UTC (rev 579) @@ -4,4 +4,18 @@ #define MSGT_CLASS MSGT_AO #include "mpxp_msg.h" +namespace mpxp { + static mpxp_ostream_info mpxp_info(MSGT_AO); + static mpxp_ostream_fatal mpxp_fatal(MSGT_AO); + static mpxp_ostream_err mpxp_err(MSGT_AO); + static mpxp_ostream_warn mpxp_warn(MSGT_AO); + static mpxp_ostream_ok mpxp_ok(MSGT_AO); + static mpxp_ostream_hint mpxp_hint(MSGT_AO); + static mpxp_ostream_status mpxp_status(MSGT_AO); + static mpxp_ostream_v mpxp_v(MSGT_AO); + static mpxp_ostream_dbg2 mpxp_dbg2(MSGT_AO); + static mpxp_ostream_dbg3 mpxp_dbg3(MSGT_AO); + static mpxp_ostream_dbg4 mpxp_dbg4(MSGT_AO); +} // namespace mpxp + #endif Modified: mplayerxp/libmpcodecs/ad_msg.h =================================================================== --- mplayerxp/libmpcodecs/ad_msg.h 2012-12-19 12:02:27 UTC (rev 578) +++ mplayerxp/libmpcodecs/ad_msg.h 2012-12-19 17:44:09 UTC (rev 579) @@ -4,4 +4,18 @@ #define MSGT_CLASS MSGT_DECAUDIO #include "mpxp_msg.h" +namespace mpxp { + static mpxp_ostream_info mpxp_info(MSGT_DECAUDIO); + static mpxp_ostream_fatal mpxp_fatal(MSGT_DECAUDIO); + static mpxp_ostream_err mpxp_err(MSGT_DECAUDIO); + static mpxp_ostream_warn mpxp_warn(MSGT_DECAUDIO); + static mpxp_ostream_ok mpxp_ok(MSGT_DECAUDIO); + static mpxp_ostream_hint mpxp_hint(MSGT_DECAUDIO); + static mpxp_ostream_status mpxp_status(MSGT_DECAUDIO); + static mpxp_ostream_v mpxp_v(MSGT_DECAUDIO); + static mpxp_ostream_dbg2 mpxp_dbg2(MSGT_DECAUDIO); + static mpxp_ostream_dbg3 mpxp_dbg3(MSGT_DECAUDIO); + static mpxp_ostream_dbg4 mpxp_dbg4(MSGT_DECAUDIO); +} // namespace mpxp + #endif Modified: mplayerxp/libmpcodecs/codecs_ld.cpp =================================================================== --- mplayerxp/libmpcodecs/codecs_ld.cpp 2012-12-19 12:02:27 UTC (rev 578) +++ mplayerxp/libmpcodecs/codecs_ld.cpp 2012-12-19 17:44:09 UTC (rev 579) @@ -11,8 +11,7 @@ #include <stdarg.h> #include "codecs_ld.h" #include "mpxp_help.h" -#define MSGT_CLASS MSGT_GLOBAL -#include "mpxp_msg.h" +#include "global_msg.h" any_t* ld_codec(const char *name,const char *url_hint) { Modified: mplayerxp/libmpcodecs/vd_msg.h =================================================================== --- mplayerxp/libmpcodecs/vd_msg.h 2012-12-19 12:02:27 UTC (rev 578) +++ mplayerxp/libmpcodecs/vd_msg.h 2012-12-19 17:44:09 UTC (rev 579) @@ -4,4 +4,18 @@ #define MSGT_CLASS MSGT_DECVIDEO #include "mpxp_msg.h" +namespace mpxp { + static mpxp_ostream_info mpxp_info(MSGT_DECVIDEO); + static mpxp_ostream_fatal mpxp_fatal(MSGT_DECVIDEO); + static mpxp_ostream_err mpxp_err(MSGT_DECVIDEO); + static mpxp_ostream_warn mpxp_warn(MSGT_DECVIDEO); + static mpxp_ostream_ok mpxp_ok(MSGT_DECVIDEO); + static mpxp_ostream_hint mpxp_hint(MSGT_DECVIDEO); + static mpxp_ostream_status mpxp_status(MSGT_DECVIDEO); + static mpxp_ostream_v mpxp_v(MSGT_DECVIDEO); + static mpxp_ostream_dbg2 mpxp_dbg2(MSGT_DECVIDEO); + static mpxp_ostream_dbg3 mpxp_dbg3(MSGT_DECVIDEO); + static mpxp_ostream_dbg4 mpxp_dbg4(MSGT_DECVIDEO); +} // namespace mpxp + #endif Modified: mplayerxp/libmpconf/cfgparser.cpp =================================================================== --- mplayerxp/libmpconf/cfgparser.cpp 2012-12-19 12:02:27 UTC (rev 578) +++ mplayerxp/libmpconf/cfgparser.cpp 2012-12-19 17:44:09 UTC (rev 579) @@ -34,8 +34,7 @@ #include "mplayerxp.h" #include "cfgparser.h" #include "libplaytree/playtree.h" -#define MSGT_CLASS MSGT_CFGPARSER -#include "mpxp_msg.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); } Modified: mplayerxp/libmpconf/codec-cfg.cpp =================================================================== --- mplayerxp/libmpconf/codec-cfg.cpp 2012-12-19 12:02:27 UTC (rev 578) +++ mplayerxp/libmpconf/codec-cfg.cpp 2012-12-19 17:44:09 UTC (rev 579) @@ -25,8 +25,7 @@ #include "loader/wine/avifmt.h" #include "libvo2/img_format.h" #include "codec-cfg.h" -#define MSGT_CLASS MSGT_CODECCFG -#include "mpxp_msg.h" +#include "parser_msg.h" #define MAX_NR_TOKEN 16 Modified: mplayerxp/libmpconf/m_option.cpp =================================================================== --- mplayerxp/libmpconf/m_option.cpp 2012-12-19 12:02:27 UTC (rev 578) +++ mplayerxp/libmpconf/m_option.cpp 2012-12-19 17:44:09 UTC (rev 579) @@ -16,8 +16,7 @@ #include "cfgparser.h" #include "m_option.h" #include "libmpstream2/url.h" -#define MSGT_CLASS MSGT_CPLAYER -#include "mpxp_msg.h" +#include "parser_msg.h" // Don't mp_free for 'production' atm #ifndef MP_DEBUG Modified: mplayerxp/libmpconf/m_property.cpp =================================================================== --- mplayerxp/libmpconf/m_property.cpp 2012-12-19 12:02:27 UTC (rev 578) +++ mplayerxp/libmpconf/m_property.cpp 2012-12-19 17:44:09 UTC (rev 579) @@ -14,8 +14,7 @@ #include "m_option.h" #include "m_property.h" #include "mpxp_help.h" -#define MSGT_CLASS MSGT_CPLAYER -#include "mpxp_msg.h" +#include "parser_msg.h" #define ROUND(x) ((int)((x)<0 ? (x)-0.5 : (x)+0.5)) Modified: mplayerxp/libmpconf/m_struct.cpp =================================================================== --- mplayerxp/libmpconf/m_struct.cpp 2012-12-19 12:02:27 UTC (rev 578) +++ mplayerxp/libmpconf/m_struct.cpp 2012-12-19 17:44:09 UTC (rev 579) @@ -9,8 +9,7 @@ #include "m_option.h" #include "m_struct.h" -#define MSGT_CLASS MSGT_CPLAYER -#include "mpxp_msg.h" +#include "parser_msg.h" const m_option_t* m_struct_get_field(const m_struct_t* st,const char* f) { Added: mplayerxp/libmpconf/parser_msg.h =================================================================== --- mplayerxp/libmpconf/parser_msg.h (rev 0) +++ mplayerxp/libmpconf/parser_msg.h 2012-12-19 17:44:09 UTC (rev 579) @@ -0,0 +1,21 @@ +#ifndef PARSER_MSG_H +#define PARSER_MSG_H 1 + +#define MSGT_CLASS MSGT_PARSER +#include "mpxp_msg.h" + +namespace mpxp { + static mpxp_ostream_info mpxp_info(MSGT_PARSER); + static mpxp_ostream_fatal mpxp_fatal(MSGT_PARSER); + static mpxp_ostream_err mpxp_err(MSGT_PARSER); + static mpxp_ostream_warn mpxp_warn(MSGT_PARSER); + static mpxp_ostream_ok mpxp_ok(MSGT_PARSER); + static mpxp_ostream_hint mpxp_hint(MSGT_PARSER); + static mpxp_ostream_status mpxp_status(MSGT_PARSER); + static mpxp_ostream_v mpxp_v(MSGT_PARSER); + static mpxp_ostream_dbg2 mpxp_dbg2(MSGT_PARSER); + static mpxp_ostream_dbg3 mpxp_dbg3(MSGT_PARSER); + static mpxp_ostream_dbg4 mpxp_dbg4(MSGT_PARSER); +} // namespace mpxp + +#endif Property changes on: mplayerxp/libmpconf/parser_msg.h ___________________________________________________________________ Added: svn:eol-style + native Modified: mplayerxp/libmpconf/subopt-helper.cpp =================================================================== --- mplayerxp/libmpconf/subopt-helper.cpp 2012-12-19 12:02:27 UTC (rev 578) +++ mplayerxp/libmpconf/subopt-helper.cpp 2012-12-19 17:44:09 UTC (rev 579) @@ -25,8 +25,7 @@ #include <assert.h> #include "subopt-helper.h" -#define MSGT_CLASS MSGT_GLOBAL -#include "mpxp_msg.h" +#include "global_msg.h" #ifndef MP_DEBUG #define NDEBUG Modified: mplayerxp/libmpdemux/demux_msg.h =================================================================== --- mplayerxp/libmpdemux/demux_msg.h 2012-12-19 12:02:27 UTC (rev 578) +++ mplayerxp/libmpdemux/demux_msg.h 2012-12-19 17:44:09 UTC (rev 579) @@ -4,4 +4,18 @@ #define MSGT_CLASS MSGT_DEMUXER #include "mpxp_msg.h" +namespace mpxp { + static mpxp_ostream_info mpxp_info(MSGT_DEMUXER); + static mpxp_ostream_fatal mpxp_fatal(MSGT_DEMUXER); + static mpxp_ostream_err mpxp_err(MSGT_DEMUXER); + static mpxp_ostream_warn mpxp_warn(MSGT_DEMUXER); + static mpxp_ostream_ok mpxp_ok(MSGT_DEMUXER); + static mpxp_ostream_hint mpxp_hint(MSGT_DEMUXER); + static mpxp_ostream_status mpxp_status(MSGT_DEMUXER); + static mpxp_ostream_v mpxp_v(MSGT_DEMUXER); + static mpxp_ostream_dbg2 mpxp_dbg2(MSGT_DEMUXER); + static mpxp_ostream_dbg3 mpxp_dbg3(MSGT_DEMUXER); + static mpxp_ostream_dbg4 mpxp_dbg4(MSGT_DEMUXER); +} // namespace mpxp + #endif Modified: mplayerxp/libmpstream2/stream_msg.h =================================================================== --- mplayerxp/libmpstream2/stream_msg.h 2012-12-19 12:02:27 UTC (rev 578) +++ mplayerxp/libmpstream2/stream_msg.h 2012-12-19 17:44:09 UTC (rev 579) @@ -4,4 +4,18 @@ #define MSGT_CLASS MSGT_STREAM #include "mpxp_msg.h" +namespace mpxp { + static mpxp_ostream_info mpxp_info(MSGT_STREAM); + static mpxp_ostream_fatal mpxp_fatal(MSGT_STREAM); + static mpxp_ostream_err mpxp_err(MSGT_STREAM); + static mpxp_ostream_warn mpxp_warn(MSGT_STREAM); + static mpxp_ostream_ok mpxp_ok(MSGT_STREAM); + static mpxp_ostream_hint mpxp_hint(MSGT_STREAM); + static mpxp_ostream_status mpxp_status(MSGT_STREAM); + static mpxp_ostream_v mpxp_v(MSGT_STREAM); + static mpxp_ostream_dbg2 mpxp_dbg2(MSGT_STREAM); + static mpxp_ostream_dbg3 mpxp_dbg3(MSGT_STREAM); + static mpxp_ostream_dbg4 mpxp_dbg4(MSGT_STREAM); +} // namespace mpxp + #endif Modified: mplayerxp/libmpsub/find_sub.cpp =================================================================== --- mplayerxp/libmpsub/find_sub.cpp 2012-12-19 12:02:27 UTC (rev 578) +++ mplayerxp/libmpsub/find_sub.cpp 2012-12-19 17:44:09 UTC (rev 579) @@ -11,8 +11,7 @@ #include "libvo2/video_out.h" #include "libvo2/sub.h" #include "subreader.h" -#define MSGT_CLASS MSGT_FINDSUB -#include "mpxp_msg.h" +#include "mpsub_msg.h" static int current_sub=0; Added: mplayerxp/libmpsub/mpsub_msg.h =================================================================== --- mplayerxp/libmpsub/mpsub_msg.h (rev 0) +++ mplayerxp/libmpsub/mpsub_msg.h 2012-12-19 17:44:09 UTC (rev 579) @@ -0,0 +1,21 @@ +#ifndef MPSUB_MSG_H +#define MPSUB_MSG_H 1 + +#define MSGT_CLASS MSGT_MPSUB +#include "mpxp_msg.h" + +namespace mpxp { + static mpxp_ostream_info mpxp_info(MSGT_MPSUB); + static mpxp_ostream_fatal mpxp_fatal(MSGT_MPSUB); + static mpxp_ostream_err mpxp_err(MSGT_MPSUB); + static mpxp_ostream_warn mpxp_warn(MSGT_MPSUB); + static mpxp_ostream_ok mpxp_ok(MSGT_MPSUB); + static mpxp_ostream_hint mpxp_hint(MSGT_MPSUB); + static mpxp_ostream_status mpxp_status(MSGT_MPSUB); + static mpxp_ostream_v mpxp_v(MSGT_MPSUB); + static mpxp_ostream_dbg2 mpxp_dbg2(MSGT_MPSUB); + static mpxp_ostream_dbg3 mpxp_dbg3(MSGT_MPSUB); + static mpxp_ostream_dbg4 mpxp_dbg4(MSGT_MPSUB); +} // namespace mpxp + +#endif Property changes on: mplayerxp/libmpsub/mpsub_msg.h ___________________________________________________________________ Added: svn:eol-style + native Modified: mplayerxp/libmpsub/spudec.cpp =================================================================== --- mplayerxp/libmpsub/spudec.cpp 2012-12-19 12:02:27 UTC (rev 578) +++ mplayerxp/libmpsub/spudec.cpp 2012-12-19 17:44:09 UTC (rev 579) @@ -27,8 +27,7 @@ #include "xmpcore/xmp_core.h" #include "spudec.h" #include "mpxp_conf_lavc.h" -#define MSGT_CLASS MSGT_SPUDEC -#include "mpxp_msg.h" +#include "mpsub_msg.h" /* Valid values for spu_aamode: 0: none (fastest, most ugly) Modified: mplayerxp/libmpsub/subreader.cpp =================================================================== --- mplayerxp/libmpsub/subreader.cpp 2012-12-19 12:02:27 UTC (rev 578) +++ mplayerxp/libmpsub/subreader.cpp 2012-12-19 17:44:09 UTC (rev 579) @@ -24,8 +24,7 @@ #include <iconv.h> #endif #endif -#define MSGT_CLASS MSGT_SUBREADER -#include "mpxp_msg.h" +#include "mpsub_msg.h" /* Maximal length of line of a subtitle */ #define LINE_LEN 1000 Modified: mplayerxp/libmpsub/vobsub.cpp =================================================================== --- mplayerxp/libmpsub/vobsub.cpp 2012-12-19 12:02:27 UTC (rev 578) +++ mplayerxp/libmpsub/vobsub.cpp 2012-12-19 17:44:09 UTC (rev 579) @@ -21,8 +21,7 @@ #include "libmpstream2/stream.h" #include "vobsub.h" #include "spudec.h" -#define MSGT_CLASS MSGT_VOBSUB -#include "mpxp_msg.h" +#include "mpsub_msg.h" #ifdef HAVE_GETLINE extern ssize_t getline(char **, size_t *, FILE *); Modified: mplayerxp/libplaytree/asxparser.cpp =================================================================== --- mplayerxp/libplaytree/asxparser.cpp 2012-12-19 12:02:27 UTC (rev 578) +++ mplayerxp/libplaytree/asxparser.cpp 2012-12-19 17:44:09 UTC (rev 579) @@ -13,8 +13,7 @@ #include "asxparser.h" #include "libmpconf/cfgparser.h" #include "mplayerxp.h" -#define MSGT_CLASS MSGT_PLAYTREE -#include "mpxp_msg.h" +#include "playtree_msg.h" namespace mpxp { Modified: mplayerxp/libplaytree/playtree.cpp =================================================================== --- mplayerxp/libplaytree/playtree.cpp 2012-12-19 12:02:27 UTC (rev 578) +++ mplayerxp/libplaytree/playtree.cpp 2012-12-19 17:44:09 UTC (rev 579) @@ -13,8 +13,7 @@ #endif #include "libmpstream2/stream.h" #include "playtree.h" -#define MSGT_CLASS MSGT_PLAYTREE -#include "mpxp_msg.h" +#include "playtree_msg.h" static int play_tree_is_valid(play_tree_t* pt); Added: mplayerxp/libplaytree/playtree_msg.h =================================================================== --- mplayerxp/libplaytree/playtree_msg.h (rev 0) +++ mplayerxp/libplaytree/playtree_msg.h 2012-12-19 17:44:09 UTC (rev 579) @@ -0,0 +1,21 @@ +#ifndef PLAYTREE_MSG_H +#define PLAYTREE_MSG_H 1 + +#define MSGT_CLASS MSGT_PLAYTREE +#include "mpxp_msg.h" + +namespace mpxp { + static mpxp_ostream_info mpxp_info(MSGT_PLAYTREE); + static mpxp_ostream_fatal mpxp_fatal(MSGT_PLAYTREE); + static mpxp_ostream_err mpxp_err(MSGT_PLAYTREE); + static mpxp_ostream_warn mpxp_warn(MSGT_PLAYTREE); + static mpxp_ostream_ok mpxp_ok(MSGT_PLAYTREE); + static mpxp_ostream_hint mpxp_hint(MSGT_PLAYTREE); + static mpxp_ostream_status mpxp_status(MSGT_PLAYTREE); + static mpxp_ostream_v mpxp_v(MSGT_PLAYTREE); + static mpxp_ostream_dbg2 mpxp_dbg2(MSGT_PLAYTREE); + static mpxp_ostream_dbg3 mpxp_dbg3(MSGT_PLAYTREE); + static mpxp_ostream_dbg4 mpxp_dbg4(MSGT_PLAYTREE); +} // namespace mpxp + +#endif Property changes on: mplayerxp/libplaytree/playtree_msg.h ___________________________________________________________________ Added: svn:eol-style + native Modified: mplayerxp/libplaytree/playtreeparser.cpp =================================================================== --- mplayerxp/libplaytree/playtreeparser.cpp 2012-12-19 12:02:27 UTC (rev 578) +++ mplayerxp/libplaytree/playtreeparser.cpp 2012-12-19 17:44:09 UTC (rev 579) @@ -17,8 +17,7 @@ #include "asxparser.h" #include "playtree.h" #include "playtreeparser.h" -#define MSGT_CLASS MSGT_PLAYTREE -#include "mpxp_msg.h" +#include "playtree_msg.h" #define BUF_STEP 1024 Modified: mplayerxp/libvo2/vo_msg.h =================================================================== --- mplayerxp/libvo2/vo_msg.h 2012-12-19 12:02:27 UTC (rev 578) +++ mplayerxp/libvo2/vo_msg.h 2012-12-19 17:44:09 UTC (rev 579) @@ -6,4 +6,18 @@ #endif #include "mpxp_msg.h" +namespace mpxp { + static mpxp_ostream_info mpxp_info(MSGT_VO); + static mpxp_ostream_fatal mpxp_fatal(MSGT_VO); + static mpxp_ostream_err mpxp_err(MSGT_VO); + static mpxp_ostream_warn mpxp_warn(MSGT_VO); + static mpxp_ostream_ok mpxp_ok(MSGT_VO); + static mpxp_ostream_hint mpxp_hint(MSGT_VO); + static mpxp_ostream_status mpxp_status(MSGT_VO); + static mpxp_ostream_v mpxp_v(MSGT_VO); + static mpxp_ostream_dbg2 mpxp_dbg2(MSGT_VO); + static mpxp_ostream_dbg3 mpxp_dbg3(MSGT_VO); + static mpxp_ostream_dbg4 mpxp_dbg4(MSGT_VO); +} // namespace mpxp + #endif Modified: mplayerxp/mplayerxp.cpp =================================================================== --- mplayerxp/mplayerxp.cpp 2012-12-19 12:02:27 UTC (rev 578) +++ mplayerxp/mplayerxp.cpp 2012-12-19 17:44:09 UTC (rev 579) @@ -4,6 +4,8 @@ /* MplayerXP (C) 2000-2002. by A'rpi/ESP-team (C) 2002. by Nickols_K */ #include <algorithm> #include <iostream> +#include <iomanip> + #include <ctype.h> #include <stdio.h> #include <stdlib.h> @@ -55,8 +57,7 @@ #include "postproc/libmenu/menu.h" #include "input2/input.h" -#define MSGT_CLASS MSGT_CPLAYER -#include "mpxp_msg.h" +#include "player_msg.h" #include "xmpcore/xmp_core.h" #include "xmpcore/xmp_vplayer.h" #include "xmpcore/xmp_adecoder.h" @@ -233,18 +234,18 @@ rc|=mp_mprotect((any_t*)antiviral_hole4,sizeof(antiviral_hole4),MP_DENY_ALL); if(verbose) { if(rc) - MSG_ERR("*** Error! Cannot initialize antiviral protection: '%s' ***!\n",strerror(errno)); + mpxp_err<<"*** Error! Cannot initialize antiviral protection: '"<<strerror(errno)<<"' ***!"<<std::endl; else - MSG_OK("*** Antiviral protection was inited ***!!!\n"); + mpxp_ok<<"*** Antiviral protection was inited ***!!!"<<std::endl; } return rc; } static MPXP_Rc mpxp_test_antiviral_protection(int* verbose) { - if(*verbose) MSG_INFO("Your've specified test-av option!\nRight now MPlayerXP should make coredump!\n"); + 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]; - MSG_ERR("Antiviral protection of MPlayerXP doesn't work!"); + mpxp_err<<"Antiviral protection of MPlayerXP doesn't work!"<<std::endl; return MPXP_Virus; } @@ -388,7 +389,7 @@ MP_UNIT("exit_player"); - if(!why.empty()) MSG_HINT(MSGTR_Exiting,why.c_str()); + if(!why.empty()) mpxp_hint<<std::endl<<MSGTR_Exiting<<"...("<<why<<")"<<std::endl; if(mpxp_context().mconfig) m_config_free(mpxp_context().mconfig); mpxp_print_uninit(); mpxp_uninit_structs(); @@ -428,20 +429,20 @@ char *conffile; int conffile_fd; if ((conffile = get_path("")) == NULL) { - MSG_WARN(MSGTR_NoHomeDir); + mpxp_warn<<MSGTR_NoHomeDir<<std::endl; } else { mkdir(conffile, 0777); delete conffile; if ((conffile = get_path("config")) == NULL) { - MSG_ERR(MSGTR_GetpathProblem); + mpxp_err<<MSGTR_GetpathProblem<<std::endl; conffile=(char*)mp_malloc(strlen("config")+1); if(conffile) strcpy(conffile,"config"); } if ((conffile_fd = open(conffile, O_CREAT | O_EXCL | O_WRONLY, 0666)) != -1) { - MSG_INFO(MSGTR_CreatingCfgFile, conffile); - write(conffile_fd, default_config, strlen(default_config)); - close(conffile_fd); + 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) != MPXP_Ok) exit(1); delete conffile; @@ -508,26 +509,26 @@ gCpuCaps.hasAVX= gCpuCaps.hasFMA=0; } - MSG_V("User corrected CPU flags: MMX=%d MMX2=%d 3DNow=%d 3DNow2=%d SSE=%d SSE2=%d SSE3=%d SSSE3=%d SSE41=%d SSE42=%d AES=%d AVX=%d FMA=%d\n", - 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); + 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; - MSG_V("mpxp_context().mplayer_accel=%i\n",mpxp_context().mplayer_accel); + mpxp_v<<"mpxp_context().mplayer_accel="<<mpxp_context().mplayer_accel<<std::endl; } #endif @@ -569,7 +570,7 @@ /* check codec.conf*/ if(!parse_codec_cfg(get_path("win32codecs.conf"))) { if(!parse_codec_cfg(CONFDIR"/win32codecs.conf")) { - MSG_HINT(MSGTR_CopyCodecsConf); + mpxp_hint<<MSGTR_CopyCodecsConf<<std::endl; mpxp_uninit_structs(); exit(0); } @@ -593,10 +594,11 @@ void show_help(void) { // no file/vcd/dvd -> show HELP: - MSG_INFO("%s",help_text); + mpxp_info<<help_text<<std::endl; Stream::print_drivers(); - MSG_INFO("\nExample: mplayerxp -ao alsa:hw:0 -vo x11 your.avi\n" - "Use --long-help option for full help\n"); + 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(void) { @@ -614,7 +616,7 @@ /* check codec.conf*/ if(!parse_codec_cfg(get_path("win32codecs.conf"))){ if(!parse_codec_cfg(CONFDIR"/win32codecs.conf")){ - MSG_HINT(MSGTR_CopyCodecsConf); + mpxp_hint<<MSGTR_CopyCodecsConf<<std::endl; mpxp_uninit_structs(); exit(0); } @@ -776,37 +778,41 @@ mpxp_context().bench->total_start=GetTimer()-mpxp_context().bench->total_start; total_time_usage = (float)mpxp_context().bench->total_start*0.000001; - MSG_INFO("\nAVE BENCHMARKs: VC:%8.3fs VO:%8.3fs A:%8.3fs D:%8.3fs = %8.4fs C:%8.3fs\n", - 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,tot); + 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) - MSG_INFO("AVE BENCHMARK%%: VC:%8.4f%% VO:%8.4f%% A:%8.4f%% D:%8.4f%% C:%8.4f%% = %8.4f%%\n", - 100.0*mpxp_context().bench->video/total_time_usage, - 100.0*mpxp_context().bench->vout/total_time_usage, - 100.0*(mpxp_context().bench->audio+mpxp_context().bench->audio_decode)/total_time_usage, - 100.0*mpxp_context().bench->demux/total_time_usage, - 100.0*mpxp_context().bench->c2/total_time_usage, - 100.0*tot/total_time_usage); + 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; - MSG_INFO("\nREAL RESULTS: from %u was dropped=%u\n" - ,nframes,mpxp_context().engine().xp_core->video->num_dropped_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)) - MSG_STATUS("A:%6.1f %4.1f%%\r" - ,sh_audio->timer-mpxp_context().audio().output->get_delay() - ,(sh_audio->timer>0.5)?100.0*(mpxp_context().bench->audio+mpxp_context().bench->audio_decode)/(double)sh_audio->timer:0 - ); + mpxp_status<<std::setprecision(1) + <<"A:"<<sh_audio->timer-mpxp_context().audio().output->get_delay() + <<" "<<rev_time + <<"\r"; else - MSG_STATUS("A:%6.1f %4.1f%% B:%4.1f\r" - ,sh_audio->timer-mpxp_context().audio().output->get_delay() - ,(sh_audio->timer>0.5)?100.0*(mpxp_context().bench->audio+mpxp_context().bench->audio_decode)/(double)sh_audio->timer:0 - ,get_delay_audio_buffer() - ); + 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(); } // for multifile support: @@ -832,7 +838,8 @@ #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) MSG_ERR(MSGTR_CantLoadFont,mp_conf.font_name); + 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("font/font.desc"),mp_conf.font_factor,mp_conf.verbose>1); @@ -845,13 +852,13 @@ const char *menu_cfg; menu_cfg = get_path("menu.conf"); if(menu_init(NULL, menu_cfg)) - MSG_INFO("Menu initialized: %s\n", menu_cfg); + mpxp_info<<"Menu initialized: "<<menu_cfg<<std::endl; else { menu_cfg="/etc/menu.conf"; if(menu_init(NULL, menu_cfg)) - MSG_INFO("Menu initialized: %s\n", menu_cfg); + mpxp_info<<"Menu initialized: "<<menu_cfg<<std::endl; else - MSG_WARN("Menu init failed\n"); + mpxp_warn<<"Menu init failed"<<std::endl; } } MP_UNIT("init_osd"); @@ -866,7 +873,7 @@ vo_inited = (mpxp_context().video().output->init(mp_conf.video_driver?mp_conf.video_driver:"")==MPXP_Ok)?1:0; if(!vo_inited){ - MSG_FATAL(MSGTR_InvalidVOdriver,mp_conf.video_driver?mp_conf.video_driver:"?"); + mpxp_fatal<<MSGTR_InvalidVOdriver<<": "<<(mp_conf.video_driver?mp_conf.video_driver:"?")<<std::endl; exit_player(MSGTR_Exit_error); } @@ -893,7 +900,7 @@ 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) - MSG_ERR(MSGTR_CantLoadSub,mp_conf.vobsub_name); + 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); @@ -921,7 +928,7 @@ play_tree_t* entry; // Handle playlist MP_UNIT("handle_playlist"); - MSG_V("Parsing playlist %s...\n",filename); + mpxp_v<<"Parsing playlist "<<filename<<"..."<<std::endl; entry = parse_playtree(_libinput,stream); if(!entry) { entry = playtree_iter->tree; @@ -979,27 +986,27 @@ sh_video_t* sh_video=reinterpret_cast<sh_video_t*>(_demuxer->video->sh); int fmt; char *c; - MSG_INFO("[Stream]:"); + mpxp_info<<"[Stream]:"; if(sh_video) { - MSG_INFO("Video="); + mpxp_info<<"Video="; if(sh_video->bih)fmt=sh_video->bih->biCompression; else fmt=sh_video->fourcc; c=(char *)&fmt; if(isprint(c[0]) && isprint(c[1]) && isprint(c[2]) && isprint(c[3])) - MSG_INFO("%.4s",c); + mpxp_info<<std::setw(4)<<c; else - MSG_INFO("%08X",fmt); + mpxp_info<<std::hex<<std::setw(8)<<fmt; } if(sh_audio) { - MSG_INFO(" Audio="); + mpxp_info<<" Audio="; fmt=sh_audio->wtag; c=(char *)&fmt; if(isprint(c[0]) && isprint(c[1]) && isprint(c[2]) && isprint(c[3])) - MSG_INFO("%.4s",c); + mpxp_info<<std::setw(4)<<c; else - MSG_INFO("%08X",fmt); + mpxp_info<<std::hex<<std::setw(8)<<fmt; } - MSG_INFO("\n"); + mpxp_info<<std::endl; } void MPXPSystem::read_video_properties() const { @@ -1007,21 +1014,22 @@ Demuxer_Stream *d_video=_demuxer->video; MP_UNIT("video_read_properties"); if(!sh_video->read_properties()) { - MSG_ERR("Video: can't read properties\n"); + mpxp_err<<"Video: can't read properties"<<std::endl; d_video->sh=NULL; sh_video=reinterpret_cast<sh_video_t*>(d_video->sh); } else { - MSG_V("[V] filefmt:%d fourcc:0x%X size:%dx%d fps:%5.2f ftime:=%6.4f\n", - _demuxer->file_format,sh_video->fourcc, sh_video->src_w,sh_video->src_h, - sh_video->fps,1/sh_video->fps - ); + 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){ - MSG_ERR(MSGTR_FPSnotspecified); + mpxp_err<<MSGTR_FPSnotspecified<<std::endl; d_video->sh=NULL; sh_video=reinterpret_cast<sh_video_t*>(d_video->sh); } @@ -1064,7 +1072,7 @@ 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) MSG_ERR(MSGTR_CantLoadSub,mp_conf.sub_name); + 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 ? sub_filename( get_path("sub/"), filename ) : "default.sub", sh_video->fps ); @@ -1087,13 +1095,13 @@ #ifdef ENABLE_WIN32LOADER if(!found) { // Go through the codec.conf and find the best codec... - if(mp_conf.audio_family) MSG_INFO(MSGTR_TryForceAudioFmt,mp_conf.audio_family); + 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 */ - MSG_ERR(MSGTR_CantFindAfmtFallback); + mpxp_err<<MSGTR_CantFindAfmtFallback<<std::endl; mp_conf.audio_family=NULL; continue; } @@ -1102,7 +1110,10 @@ 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)) { - MSG_V("%s audio codec: [%s] drv:%s (%s)\n",mp_conf.audio_codec?"Forcing":"Detected",sh_audio->codec->codec_name,sh_audio->codec->driver_name,sh_audio->codec->s_info); + mpxp_v<<mp_conf.audio_codec?"Forcing":"Detected" + <<" audio codec: ["<<sh_audio->codec->codec_name + <<"] drv:"<<sh_audio->codec->driver_name + <<" ("<<sh_audio->codec->s_info<<")"<<std::endl; found=1; break; } @@ -1115,25 +1126,25 @@ #endif if(!found) { const char *fmt; - MSG_ERR(MSGTR_CantFindAudioCodec); + mpxp_err<<MSGTR_CantFindAudioCodec<<std::endl; fmt = (const char *)&sh_audio->wtag; if(isprint(fmt[0]) && isprint(fmt[1]) && isprint(fmt[2]) && isprint(fmt[3])) - MSG_ERR(" '%c%c%c%c'!\n",fmt[0],fmt[1],fmt[2],fmt[3]); + mpxp_err<<std::setw(4)<<" '"<<fmt<<"'!"<<std::endl; else - MSG_ERR(" 0x%08X!\n",sh_audio->wtag); + mpxp_err<<" 0x"<<std::hex<<std::setprecision(8)<<sh_audio->wtag<<"!"<<std::endl; MSG_HINT( MSGTR_TryUpgradeCodecsConfOrRTFM,get_path("win32codecs.conf")); 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:""))) { - MSG_ERR(MSGTR_CannotInitAO); + 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){ - MSG_FATAL(MSGTR_InvalidAOdriver,mp_conf.audio_driver); + mpxp_fatal<<MSGTR_InvalidAOdriver<<": "<<mp_conf.audio_driver<<std::endl; exit_player(MSGTR_Exit_error); } } @@ -1158,12 +1169,12 @@ codecs_reset_selection(0); if(mp_conf.video_codec) { /* forced codec by name: */ - MSG_INFO("Forced video codec: %s\n",mp_conf.video_codec); + mpxp_info<<"Forced video codec: "<<mp_conf.video_codec<<std::endl; sh_video->decoder=mpcv_init(sh_video,mp_conf.video_codec,NULL,-1,_libinput); } else { int status; /* try in stability order: UNTESTED, WORKING, BUGGY, BROKEN */ - if(mp_conf.video_family) MSG_INFO(MSGTR_TryForceVideoFmt,mp_conf.video_family); + 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((sh_video->decoder=mpcv_init(sh_video,NULL,mp_conf.video_family,status,_libinput))) break; @@ -1177,12 +1188,12 @@ if(!sh_video->inited) { const char *fmt; - MSG_ERR(MSGTR_CantFindVideoCodec); + mpxp_err<<MSGTR_CantFindVideoCodec<<std::endl; fmt = (const char *)&sh_video->fourcc; if(isprint(fmt[0]) && isprint(fmt[1]) && isprint(fmt[2]) && isprint(fmt[3])) - MSG_ERR(" '%c%c%c%c'!\n",fmt[0],fmt[1],fmt[2],fmt[3]); + mpxp_err<<std::setw(4)<<" '"<<fmt<<"'!"<<std::endl; else - MSG_ERR(" 0x%08X!\n",sh_video->fourcc); + mpxp_err<<" 0x"<<std::hex<<std::setw(8)<<sh_video->fourcc<<std::endl; MSG_HINT( MSGTR_TryUpgradeCodecsConfOrRTFM,get_path("win32codecs.conf")); d_video->sh = NULL; sh_video = reinterpret_cast<sh_video_t*>(d_video->sh); @@ -1190,8 +1201,10 @@ } else inited_flags|=INITED_VCODEC; if(sh_video) - MSG_V("%s video codec: [%s] vfm:%s (%s)\n", - mp_conf.video_codec?"Forcing":"Detected",sh_video->codec->codec_name,sh_video->codec->driver_name,sh_video->codec->s_info); + 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; } @@ -1202,22 +1215,19 @@ int rc=0; const ao_info_t *info=mpxp_context().audio().output->get_info(); MP_UNIT("setup_audio"); - MSG_V("AO: [%s] %iHz %s %s\n", - info->short_name, - mp_conf.force_srate?mp_conf.force_srate:sh_audio->rate, - sh_audio->nch>7?"surround71": + 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) - ); - MSG_V("AO: Description: %s\nAO: Author: %s\n", - info->name, info->author); - if(strlen(info->comment) > 0) - MSG_V("AO: Comment: %s\n", info->comment); + 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; @@ -1231,19 +1241,19 @@ sh_audio->nch, sh_audio->afmt, // output: &samplerate, &channels, &format)!=MPXP_Ok){ - MSG_ERR("Audio filter chain preinit failed\n"); + mpxp_err<<"Audio filter chain preinit failed"<<std::endl; } else { - MSG_V("AF_pre: %dHz %dch (%s) afmt=%08X sh_audio_min=%i\n", - samplerate, channels, - ao_format_name(format),format - ,sh_audio->audio_out_minsize); + mpxp_v<<"AF_pre: "<<samplerate<<"Hz "<<channels<<"ch (" + <<ao_format_name(format)<< + ") afmt="<<std::hex<<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)) { - MSG_ERR("Can't configure audio device\n"); + 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; @@ -1258,7 +1268,7 @@ mpaf_format_e(mpxp_context().audio().output->format()), mpxp_context().audio().output->outburst()*4, mpxp_context().audio().output->buffersize())!=MPXP_Ok) { - MSG_ERR("No matching audio filter found!\n"); + mpxp_err<<"No matching audio filter found!"<<std::endl; } } return rc; @@ -1269,15 +1279,19 @@ 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 */ - MSG_FATAL("Not enough buffers for DECODING AHEAD!\nNeed %u buffers but exist only %u\n",3,mpxp_context().engine().xp_core->num_v_buffs); + 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) MSG_OK("Using DECODING AHEAD mplayer's core with %u video buffers\n",mpxp_context().engine().xp_core->num_v_buffs); - else MSG_OK("Using DECODING AHEAD mplayer's core with %u audio buffers\n",mpxp_context().engine().xp_core->num_a_buffs); + 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; @@ -1300,7 +1314,9 @@ rs = rpts%60; } else rh=rm=rs=0; if(h != ph || m != pm || s != ps) { - MSG_STATUS(">%02u:%02u:%02u (%02u:%02u:%02u)\r",h,m,s,rh,rm,rs); + mpxp_status<<std::setw(2)<<">"<<h<<":"<<m<<":"<<s + <<"("<<rh<<":"<<rm<<":"<<rs<<")\r"; + mpxp_status.flush(); ph = h; pm = m; ps = s; @@ -1325,7 +1341,7 @@ 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); - MSG_V("Set nav box: %i %i %i %i\n",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); } } @@ -1339,8 +1355,8 @@ mpxp_context().video().output->pause(); } if(mp_conf.verbose) { - MSG_STATUS("\n------ PAUSED -------\r"); - fflush(stdout); + mpxp_status<<std::endl<<"------ PAUSED -------\r"; + mpxp_status.flush(); } if (ao_inited==MPXP_Ok && sh_audio) { @@ -1412,16 +1428,16 @@ case MP_CMD_SPEED_INCR : case MP_CMD_SPEED_MULT : case MP_CMD_SPEED_SET : - MSG_WARN("Speed adjusting is not implemented yet!\n"); + mpxp_warn<<"Speed adjusting is not implemented yet!"<<std::endl; break; case MP_CMD_SWITCH_AUDIO : - MSG_INFO("ID_AUDIO_TRACK=%i\n",demuxer_switch_audio_r(_demuxer, _demuxer->audio->id+1)); + mpxp_info<<"ID_AUDIO_TRACK="<<demuxer_switch_audio_r(_demuxer, _demuxer->audio->id+1)<<std::endl; break; case MP_CMD_SWITCH_VIDEO : - MSG_INFO("ID_VIDEO_TRACK=%i\n",demuxer_switch_video_r(_demuxer, _demuxer->video->id+1)); + mpxp_info<<"ID_VIDEO_TRACK="<<demuxer_switch_video_r(_demuxer, _demuxer->video->id+1)<<std::endl; break; case MP_CMD_SWITCH_SUB : - MSG_INFO("ID_SUB_TRACK=%i\n",demuxer_switch_subtitle_r(_demuxer, _demuxer->sub->id+1)); + 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 : @@ -1595,7 +1611,7 @@ vo_osd_changed(OSDTYPE_SUBTITLE); } break; default : - MSG_ERR("Received unknow cmd %s\n",cmd->name); + mpxp_err<<"Received unknow cmd "<<cmd->name<<std::endl; } mp_cmd_free(cmd); } @@ -1660,7 +1676,7 @@ xmp_register_main(exit_sighandler); mpxp_print_init(mp_conf.verbose+MSGL_STATUS); - MSG_INFO("%s",banner_text); + mpxp_info<<banner_text<<std::endl; /* currently it's lowest point of MPXPSystem initialization */ mpxp_context().engine().MPXPSys = new(zeromem) MPXPSystem; @@ -1680,8 +1696,8 @@ exit_player("Error parse command line"); // error parsing cmdline if(!mp_conf.xp) { - MSG_ERR("Error: detected option: -core.xp=0\n" - "Note! Single-thread mode is not longer supported by MPlayerXP\n"); + 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) { @@ -1720,9 +1736,9 @@ // Many users forget to include command line in bugreports... if(mp_conf.verbose){ - MSG_INFO("CommandLine:"); - for(i=1;i<argc;i++) MSG_INFO(" '%s'",argv[i]); - MSG_INFO("\n"); + mpxp_info<<"CommandLine:"; + for(i=1;i<argc;i++) mpxp_info<<" '"<<argv[i]<<"'"; + mpxp_info<<std::endl; } //------ load global data first ------ @@ -1736,7 +1752,7 @@ play_next_file: ao_subdevice=MPXPSys.init_output_subsystems(); - if(filename) MSG_OK(MSGTR_Playing, filename); + if(filename) mpxp_ok<<MSGTR_Playing<<" "<<filename<<std::endl; forced_subs_only=MPXPSys.init_vobsub(filename); @@ -1758,7 +1774,7 @@ stream_dump_type=0; if(mp_conf.stream_dump) if((stream_dump_type=dump_parse(mp_conf.stream_dump))==0) { - MSG_ERR("Wrong dump parameters! Unable to continue\n"); + mpxp_err<<"Wrong dump parameters! Unable to continue"<<std::endl; exit_player(MSGTR_Exit_error); } @@ -1770,7 +1786,7 @@ 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... - MSG_ERR("Can't open: %s\n",filename); + mpxp_err<<"Can't open: "<<filename<<std::endl; eof = MPXPSys.libmpdemux_was_interrupted(PT_NEXT_ENTRY); goto goto_next_file; } @@ -1824,7 +1840,7 @@ fflush(stdout); if(!sh_video && !sh_audio) { - MSG_FATAL("No stream found\n"); + mpxp_fatal<<"No stream found"<<std::endl; goto goto_next_file; // exit_player(MSGTR_Exit_error); } @@ -1844,18 +1860,20 @@ /* is it non duplicate block fro find_acodec() ??? */ if(sh_audio){ - MSG_V("Initializing audio codec...\n"); + mpxp_v<<"Initializing audio codec..."<<std::endl; if(!mpxp_context().audio().decoder) { if((mpxp_context().audio().decoder=mpca_init(sh_audio))==NULL){ - MSG_ERR(MSGTR_CouldntInitAudioCodec); + mpxp_err<<MSGTR_CouldntInitAudioCodec<<std::endl; d_audio->sh=NULL; sh_audio=reinterpret_cast<sh_audio_t*>(d_audio->sh); } } if(sh_audio) { - MSG_V("AUDIO: srate=%d chans=%d bps=%d sfmt=0x%X ratio: %d->%d\n" - ,sh_audio->rate,sh_audio->nch,afmt2bps(sh_audio->afmt) - ,sh_audio->afmt,sh_audio->i_bps,sh_audio->af_bps); + mpxp_v<<"AUDIO: srate="<<sh_audio->rate + <<" chans="<<sh_audio->nch + <<" bps="<<afmt2bps(sh_audio->afmt) + <<" sfmt=0x"<<std::hex<<sh_audio->afmt + <<" ratio: "<<sh_audio->i_bps<<"->"<<sh_audio->af_bps<<std::endl; } } @@ -1885,14 +1903,14 @@ if(rc==MPXP_Ok) mpxp_context().output_quality=quality; if(mp_conf.autoq>mpxp_context().output_quality) mp_conf.autoq=mpxp_context().output_quality; else mpxp_context().output_quality=mp_conf.autoq; - MSG_V("AutoQ: setting quality to %d\n",mpxp_context().output_quality); + mpxp_v<<"AutoQ: setting quality to "<<mpxp_context().output_quality<<std::endl; mpcv_set_quality(mpxp_context().video().decoder,mpxp_context().output_quality); } // ========== Init display (sh_video->src_w*sh_video->src_h/out_fmt) ============ MPXPSys.inited_flags|=INITED_VO; - MSG_V("INFO: Video OUT driver init OK!\n"); + mpxp_v<<"INFO: Video OUT driver init OK!"<<std::endl; MP_UNIT("init_libvo"); fflush(stdout); @@ -1924,14 +1942,14 @@ sh_audio->chapter_change=0; sh_audio->a_pts=HUGE; } else { - MSG_INFO(MSGTR_NoSound); + mpxp_info<<MSGTR_NoSound<<std::endl; d_audio->free_packs(); // mp_free buffered chunks d_audio->id=-2; // do not read audio chunks if(MPXPSys.ao_inited==MPXP_Ok) MPXPSys.uninit_player(INITED_AO); // close device } if(!sh_video){ - MSG_INFO("Video: no video!!!\n"); + mpxp_info<<"Video: no video!!!"<<std::endl; d_video->free_packs(); d_video->id=-2; if(MPXPSys.vo_inited) MPXPSys.uninit_player(INITED_VO); @@ -1947,7 +1965,7 @@ /* Init timers and benchmarking */ mpxp_context().rtc_fd=InitTimer(); if(!mp_conf.nortc && mpxp_context().rtc_fd>0) { close(mpxp_context().rtc_fd); mpxp_context().rtc_fd=-1; } - MSG_V("Using %s timing\n",mpxp_context().rtc_fd>0?"rtc":mp_conf.softsleep?"software":"usleep()"); + mpxp_v<<"Using "<<(mpxp_context().rtc_fd>0?"rtc":mp_conf.softsleep?"software":"usleep()")<<" timing"<<std::endl; mpxp_context().bench->total_start=GetTimer(); mpxp_context().bench->audio=0; mpxp_context().bench->audio_decode=0; mpxp_context().bench->video=0; @@ -1975,18 +1993,17 @@ // TODO: rewrite test backtrace in .asm // mpxp_test_backtrace(); if(xmp_run_players()!=0) exit_player("Can't run xp players!\n"); - MSG_OK("Using the next %i threads:\n",mpxp_context().engine().xp_core->num_threads); + 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++) - MSG_OK("[%i] %s (id=%u, pth_id=%lu)\n" - ,idx - ,mpxp_context().engine().xp_core->mpxp_threads[idx]->name - ,mpxp_context().engine().xp_core->mpxp_threads[idx]->pid - ,mpxp_context().engine().xp_core->mpxp_threads[idx]->pth_id); - + mpxp_ok<<"["<<idx<<"] " + <<mpxp_context().engine().xp_core->mpxp_threads[idx]->name + <<" (id="<<mpxp_context().engine().xp_core->mpxp_threads[idx]->pid + <<" pth_id="<<mpxp_context().engine().xp_core->mpxp_threads[idx]->pth_id + <<")"<<std::endl; //==================== START PLAYING ======================= - MSG_OK(MSGTR_StartPlaying);fflush(stdout); + mpxp_ok<<MSGTR_StartPlaying<<std::endl; mpxp_print_flush(); while(!eof){ @@ -2026,7 +2043,7 @@ } /* Looping. */ if(eof && mp_conf.loop_times>=0) { - MSG_V("loop_times = %d, eof = %d\n", mp_conf.loop_times,eof); + mpxp_v<<"loop_times = "<<mp_conf.loop_times<<", eof = "<<eof<<std::endl; if(mp_conf.loop_times>1) mp_conf.loop_times--; else if(mp_conf.loop_times==1) mp_conf.loop_times=-1; @@ -2063,7 +2080,7 @@ #endif } // while(!eof) - MSG_V("EOF code: %d\n",eof); + mpxp_v<<"EOF code: "<<eof<<std::endl; goto_next_file: // don't jump here after ao/vo/getch initialization! Modified: mplayerxp/mpxp_msg.cpp =================================================================== --- mplayerxp/mpxp_msg.cpp 2012-12-19 12:02:27 UTC (rev 578) +++ mplayerxp/mpxp_msg.cpp 2012-12-19 17:44:09 UTC (rev 579) @@ -1,6 +1,8 @@ #include "mpxp_config.h" #include "osdep/mplib.h" using namespace mpxp; +#include <algorithm> + #include <stdio.h> #include <stdlib.h> #include <stdarg.h> @@ -13,6 +15,130 @@ #include "mpxp_msg.h" namespace mpxp { +mpxp_streambuf::mpxp_streambuf(mpxp_ostream& _parent,const std::string& _data) + :data(_data) + ,parent(_parent) +{ + setp(buf, buf + BUF_SIZE); +} + +mpxp_streambuf::~mpxp_streambuf() {} + +int mpxp_streambuf::overflow(int c) { + // Handle output + put_chars(pbase(), pptr()); + if (c != Traits::eof()) { + char c2 = c; + // Handle the one character that didn't fit to buffer + put_chars(&c2, &c2 + 1); + } + // This tells that buffer is empty again + setp(buf, buf + BUF_SIZE); + // I'm not sure about this return value! + return 0; +} + +int mpxp_streambuf::sync() { + // Handle output + put_chars(pbase(), pptr()); + // This tells that buffer is empty again + setp(buf, buf + BUF_SIZE); + return 0; +} + +void mpxp_streambuf::put_chars(char const* begin, char const* end) const { + if(!(parent._type&mp_conf.msg_filter)) { parent.setstate(std::ios_base::badbit); return; } + if(::isatty(::fileno(::stderr))) std::cerr<<data; + ::fwrite(begin,end-begin,1,::stderr); +} + +static const char* msg_prefix[] = { + "GLOBAL", + "PLAYER", + "LIBVO", + "LIBAO", + "DEMUX", + "PARSER", + "DECAUD", + "DECVID", + "MPSUB", + "OSDEP", + "PLAYTR", + "INPUT", + "OSD", + "CPUDTC", + "CODCFG", + "SWS", + "POSTPR", + "NLS", + "STREAM", + "UNKNOWN" +}; + +mpxp_ostream::mpxp_ostream(const std::string& data,mpxp_msgt_e type) + :std::basic_ostream< char, std::char_traits< char > >(&buf) + ,_type(type) + ,idx(compute_idx(type)) + ,buf(*this,mp_conf.verbose>1?data+msg_prefix[idx]+": ":data) {} +mpxp_ostream::~mpxp_ostream() {} + +unsigned mpxp_ostream::compute_idx(mpxp_msgt_e type) const { + unsigned mod_idx=0,_idx=type; + while((_idx&0x1)==0) { mod_idx++; _idx>>=1; } + return std::min(_idx,unsigned(sizeof(msg_prefix)/sizeof(msg_prefix[0]))); +} + +/* TODO: replace this block with std::string */ +static const char blue[]="\033[0;34;40m"; +static const char green[]="\033[0;32;40m"; +static const char cyan[]="\033[0;36;40m"; +static const char red[]="\033[0;31;40m"; +static const char magenta[]="\033[0;35;40m"; +static const char brown[]="\033[0;33;40m"; +static const char gray[]="\033[0;37;40m"; +static const char light_blue[]="\033[1;34;40m"; +static const char light_green[]="\033[1;32;40m"; +static const char light_cyan[]="\033[1;36;40m"; +static const char light_red[]="\033[1;31;40m"; +static const char light_magenta[]="\033[1;35;40m"; +static const char yellow[]="\033[1;33;40m"; +static const char white[]="\033[1;37;40m"; + +mpxp_ostream_info::mpxp_ostream_info(mpxp_msgt_e type):mpxp_ostream(gray,type){} +mpxp_ostream_info::~mpxp_ostream_info() {} + +mpxp_ostream_fatal::mpxp_ostream_fatal(mpxp_msgt_e type):mpxp_ostream(light_red,type){} +mpxp_ostream_fatal::~mpxp_ostream_fatal() {} + +mpxp_ostream_err::mpxp_ostream_err(mpxp_msgt_e type):mpxp_ostream(red,type){} +mpxp_ostream_err::~mpxp_ostream_err() {} + +mpxp_ostream_warn::mpxp_ostream_warn(mpxp_msgt_e type):mpxp_ostream(yellow,type){} +mpxp_ostream_warn::~mpxp_ostream_warn() {} + +mpxp_ostream_ok::mpxp_ostream_ok(mpxp_msgt_e type):mpxp_ostream(light_green,type){} +mpxp_ostream_ok::~mpxp_ostream_ok() {} + +mpxp_ostream_hint::mpxp_ostream_hint(mpxp_msgt_e type):mpxp_ostream(light_cyan,type){} +mpxp_ostream_hint::~mpxp_ostream_hint() {} + +mpxp_ostream_status::mpxp_ostream_status(mpxp_msgt_e type):mpxp_ostream(light_blue,type){} +mpxp_ostream_status::~mpxp_ostream_status() {} + +mpxp_ostream_v::mpxp_ostream_v(mpxp_msgt_e type):mpxp_ostream(cyan,type){ if(mp_conf.verbose<1) setstate(ios_base::badbit); /* do not display */ } +mpxp_ostream_v::~mpxp_ostream_v() {} + +mpxp_ostream_dbg2::mpxp_ostream_dbg2(mpxp_msgt_e type):mpxp_ostream(gray,type){ if(mp_conf.verbose<2) setstate(ios_base::badbit); /* do not display */ } +mpxp_ostream_dbg2::~mpxp_ostream_dbg2() {} + +mpxp_ostream_dbg3::mpxp_ostream_dbg3(mpxp_msgt_e type):mpxp_ostream(gray,type){ if(mp_conf.verbose<3) setstate(ios_base::badbit); /* do not display */ } +mpxp_ostream_dbg3::~mpxp_ostream_dbg3() {} + +mpxp_ostream_dbg4::mpxp_ostream_dbg4(mpxp_msgt_e type):mpxp_ostream(gray,type){ if(mp_conf.verbose<4) setstate(ios_base::badbit); /* do not display */ } +mpxp_ostream_dbg4::~mpxp_ostream_dbg4() {} + +/* old stuff: */ + inline int _bg(int x) { return x >> 4; } inline int _fg(int x) { return x & 0x0f; } struct priv_t { @@ -59,30 +185,6 @@ delete priv; } -static const char * msg_prefix[] = -{ - "GLOBAL", - "PLAYER", - "LIBVO", - "LIBAO", - "DEMUX", - "CFGPRS", - "DECAUD", - "DECVID", - "VOBSUB", - "OSDEP", - "SPUDEC", - "PLAYTR", - "INPUT", - "OSD", - "CPUDTC", - "CODCFG", - "SWS", - "FINDSB", - "SUBRDR", - "POSTPR" -}; - int mpxp_printf( unsigned x, const std::string& format, ... ){ /* TODO: more useful usage of module_id */ int rc=0; Modified: mplayerxp/mpxp_msg.h =================================================================== --- mplayerxp/mpxp_msg.h 2012-12-19 12:02:27 UTC (rev 578) +++ mplayerxp/mpxp_msg.h 2012-12-19 17:44:09 UTC (rev 579) @@ -1,7 +1,9 @@ #ifndef __MPXP_MSG_H_INCLUDED #define __MPXP_MSG_H_INCLUDED 1 #include "mplayerxp.h" +#include "osdep/mplib.h" +#include <iostream> #include <string> /* TODO: more highlighted levels */ @@ -11,49 +13,153 @@ namespace mpxp { -enum { - MSGL_FATAL =0U, /* will exit/abort LightRed */ - MSGL_ERR =1U, /* continues Red */ - MSGL_WARN =2U, /* only warning Yellow */ - MSGL_OK =3U, /* checkpoint was passed OK. LightGreen */ - MSGL_HINT =4U, /* short help message LightCyan */ - MSGL_INFO =5U, /* -quiet LightGray */ - MSGL_STATUS =6U, /* v=0 (old status line) LightBlue */ - MSGL_V =7U, /* v=1 Cyan */ - MSGL_DBG2 =8U, /* v=2 LightGray */ - MSGL_DBG3 =9U, /* v=3 LightGray */ - MSGL_DBG4 =10U,/* v=4 LightGray */ + enum mpxp_msgl_e { + MSGL_FATAL =0U, /* will exit/abort LightRed */ + MSGL_ERR =1U, /* continues Red */ + MSGL_WARN =2U, /* only warning Yellow */ + MSGL_OK =3U, /* checkpoint was passed OK. LightGreen */ + MSGL_HINT =4U, /* short help message LightCyan */ + MSGL_INFO =5U, /* -quiet LightGray */ + MSGL_STATUS =6U, /* v=0 (old status line) LightBlue */ + MSGL_V =7U, /* v=1 Cyan */ + MSGL_DBG2 =8U, /* v=2 LightGray */ + MSGL_DBG3 =9U, /* v=3 LightGray */ + MSGL_DBG4 =10U,/* v=4 LightGray */ + MSGL_MASK =0xF0000000 + }; - MSGL_MASK =0xF0000000 -}; -// code/module: -enum { - MSGT_GLOBAL =0x00000001, - MSGT_CPLAYER =0x00000002, - MSGT_VO =0x00000004, - MSGT_AO =0x00000008, - MSGT_DEMUXER =0x00000010, - MSGT_CFGPARSER =0x00000020, - MSGT_DECAUDIO =0x00000040, - MSGT_DECVIDEO =0x00000080, - MSGT_VOBSUB =0x00000100, - MSGT_OSDEP =0x00000200, - MSGT_SPUDEC =0x00000400, - MSGT_PLAYTREE =0x00000800, - MSGT_INPUT =0x00001000, - MSGT_OSD =0x00002000, - MSGT_CPUDETECT =0x00004000, - MSGT_CODECCFG =0x00008000, - MSGT_SWS =0x00010000, - MSGT_FINDSUB =0x00020000, - MSGT_SUBREADER =0x00040000, - MSGT_PP =0x00080000, - MSGT_NLS =0x00100000, - MSGT_STREAM =0x00200000, + // code/module: + enum mpxp_msgt_e { + MSGT_GLOBAL =0x00000001, + MSGT_CPLAYER =0x00000002, + MSGT_VO =0x00000004, + MSGT_AO =0x00000008, + MSGT_DEMUXER =0x00000010, + MSGT_PARSER =0x00000020, + MSGT_DECAUDIO =0x00000040, + MSGT_DECVIDEO =0x00000080, + MSGT_MPSUB =0x00000100, + MSGT_OSDEP =0x00000200, + MSGT_PLAYTREE =0x00000400, + MSGT_INPUT =0x00000800, + MSGT_OSD =0x00001000, + MSGT_CPUDETECT =0x00002000, + ... [truncated message content] |
From: <nic...@us...> - 2012-12-20 08:10:38
|
Revision: 580 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=580&view=rev Author: nickols_k Date: 2012-12-20 08:10:31 +0000 (Thu, 20 Dec 2012) Log Message: ----------- small fixes! About illegal patch: i still cannot fix segfault in int32_to_int16 function. Below printed gdb's listing of this place. It seems that i have substituted content of stdint.h file with extremely substituted #defines which time from time restore original value of types. More that obviously that such behaviour is impossible without hacked compiler. Breakpoint 1, int32_to_int16_SSE3 (in_data=0x7fffee0a4a20, out_data= 0x7fffe80009b0, inlen=9216, final=0) at ./aflib_accel.h:131 131 unsigned i,insamples = inlen/sizeof(int32_t); (gdb) n 140 i=0; (gdb) print insamples $1 = 9216 (gdb) n 134 len_mm=inlen&(~(_ivec_size()-1)); (gdb) print insamples $2 = 9216 (gdb) print inlen $3 = 9216 (gdb) n 131 unsigned i,insamples = inlen/sizeof(int32_t); (gdb) print insamples $4 = 9216 (gdb) n 142 if(!_ivec_aligned(out_data)) (gdb) print insamples $5 = 2304 (gdb) n 147 if((len_mm-i)>=_ivec_size()) (gdb) n 135 mm_insamples=len_mm/sizeof(int32_t); (gdb) n 148 for(;i<mm_insamples;i+=vec_insamples) (gdb) print mm_insamples $6 = <optimized out> (gdb) print insamples $7 = 2304 Modified Paths: -------------- mplayerxp/mpxp_msg.cpp mplayerxp/mpxp_msg.h Modified: mplayerxp/mpxp_msg.cpp =================================================================== --- mplayerxp/mpxp_msg.cpp 2012-12-19 17:44:09 UTC (rev 579) +++ mplayerxp/mpxp_msg.cpp 2012-12-20 08:10:31 UTC (rev 580) @@ -48,7 +48,7 @@ void mpxp_streambuf::put_chars(char const* begin, char const* end) const { if(!(parent._type&mp_conf.msg_filter)) { parent.setstate(std::ios_base::badbit); return; } - if(::isatty(::fileno(::stderr))) std::cerr<<data; + if(::isatty(::fileno(::stderr))) ::fwrite(data.c_str(),data.length(),1,::stderr); ::fwrite(begin,end-begin,1,::stderr); } Modified: mplayerxp/mpxp_msg.h =================================================================== --- mplayerxp/mpxp_msg.h 2012-12-19 17:44:09 UTC (rev 579) +++ mplayerxp/mpxp_msg.h 2012-12-20 08:10:31 UTC (rev 580) @@ -70,7 +70,7 @@ // For EOF detection typedef std::char_traits< char > Traits; // Work in buffer mode. It is also possible to work without buffer. - static size_t const BUF_SIZE = 256; + static size_t const BUF_SIZE = 2048; Opaque unusable; char buf[BUF_SIZE]; // This is example about userdata This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nic...@us...> - 2012-12-21 17:47:54
|
Revision: 594 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=594&view=rev Author: nickols_k Date: 2012-12-21 17:47:42 +0000 (Fri, 21 Dec 2012) Log Message: ----------- convert MSG_* into mpxp_ostream compatible output Modified Paths: -------------- mplayerxp/input2/in_msg.h mplayerxp/libmpdemux/demuxer_info.cpp mplayerxp/libmpdemux/demuxer_r.cpp mplayerxp/libmpdemux/demuxer_stream.cpp mplayerxp/libmpstream2/cache2.cpp mplayerxp/libmpstream2/s_cdd.cpp mplayerxp/libmpstream2/s_dvdnav.cpp mplayerxp/libmpstream2/s_dvdread.cpp mplayerxp/libmpstream2/s_file.cpp mplayerxp/libmpstream2/s_ftp.cpp mplayerxp/libmpstream2/s_lavc.cpp mplayerxp/libmpstream2/s_network.cpp mplayerxp/libmpstream2/s_oss.cpp mplayerxp/libmpstream2/s_rtsp.cpp mplayerxp/libmpstream2/s_tv.cpp mplayerxp/libmpstream2/s_udp.cpp mplayerxp/libmpstream2/s_vcdnav.cpp mplayerxp/libplaytree/asxparser.cpp mplayerxp/nls/mpxp_help-en.h mplayerxp/nls/mpxp_help-ru.h Modified: mplayerxp/input2/in_msg.h =================================================================== --- mplayerxp/input2/in_msg.h 2012-12-21 15:12:47 UTC (rev 593) +++ mplayerxp/input2/in_msg.h 2012-12-21 17:47:42 UTC (rev 594) @@ -1,7 +1,6 @@ #ifndef IN_MSG_H #define IN_MSG_H -#define MSGT_CLASS MSGT_INPUT #include "mpxp_msg.h" namespace mpxp { Modified: mplayerxp/libmpdemux/demuxer_info.cpp =================================================================== --- mplayerxp/libmpdemux/demuxer_info.cpp 2012-12-21 15:12:47 UTC (rev 593) +++ mplayerxp/libmpdemux/demuxer_info.cpp 2012-12-21 17:47:42 UTC (rev 594) @@ -36,12 +36,12 @@ MPXP_Rc Demuxer_Info::add(unsigned opt, const char *param) { if(!opt || opt > INFOT_MAX) { - MSG_WARN("Unknown info type %u\n",opt); + mpxp_warn<<"Unknown info type "<<opt<<std::endl; return MPXP_False; } opt--; if(id[opt]) { - MSG_V( "Demuxer info '%s' already present as '%s'!\n",info_names[opt],id[opt]); + mpxp_v<<"Demuxer info '"<<info_names[opt]<<"' already present as '"<<id[opt]<<"'!"<<std::endl; delete id[opt]; } id[opt]=nls_recode2screen_cp(sub_data.cp,param,strlen(param)); @@ -51,10 +51,10 @@ int Demuxer_Info::print(const std::string& filename) const { unsigned i; - MSG_HINT(" CLIP INFO (%s):\n",filename.c_str()); + mpxp_hint<<" CLIP INFO ("<<filename<<"):"<<std::endl; for(i=0;i<INFOT_MAX;i++) if(id[i]) - MSG_HINT(" %s: %s\n",info_names[i],id[i]); + mpxp_hint<<" "<<info_names[i]<<": "<<id[i]<<std::endl; return 0; } Modified: mplayerxp/libmpdemux/demuxer_r.cpp =================================================================== --- mplayerxp/libmpdemux/demuxer_r.cpp 2012-12-21 15:12:47 UTC (rev 593) +++ mplayerxp/libmpdemux/demuxer_r.cpp 2012-12-21 17:47:42 UTC (rev 594) @@ -39,8 +39,7 @@ float retval; Demuxer* demuxer=ds->demuxer; mpxp_context().engine().xp_core->initial_apts_corr.need_correction=0; - MSG_DBG2("initial_apts from: stream_pts=%f pts_bytes=%u got_bytes=%u i_bps=%u\n" - ,ds->pts,ds->tell_pts(),nbytes,((sh_audio_t*)ds->demuxer->audio->sh)->i_bps); + mpxp_dbg2<<"initial_apts from: stream_pts="<<ds->pts<<" pts_bytes="<<ds->tell_pts()<<" got_bytes="<<nbytes<<" i_bps="<<(((sh_audio_t*)ds->demuxer->audio->sh)->i_bps)<<std::endl; /* FIXUP AUDIO PTS*/ if((demuxer->file_format == Demuxer::Type_MPEG_ES || demuxer->file_format == Demuxer::Type_MPEG4_ES || @@ -55,7 +54,7 @@ spts=ds->demuxer->stream->stream_pts(); ds->pts_corr=spts>0?spts:ds->prev_pts; ds->pts_flags=0; - MSG_V("***PTS discontinuity happens*** correct audio %f pts as %f\n",ds->pts,ds->pts_corr); + mpxp_v<<"***PTS discontinuity happens*** correct audio "<<ds->pts<<" pts as "<<ds->pts_corr<<std::endl; } if(ds->pts>1.0) ds->pts_flags=1; if(!ds->eof) ds->prev_pts=ds->pts+ds->pts_corr; @@ -69,7 +68,7 @@ mpxp_context().engine().xp_core->initial_apts_corr.nbytes=nbytes; retval = ds->pts; } - MSG_DBG2("initial_apts is: %f\n",retval); + mpxp_dbg2<<"initial_apts is: "<<retval<<std::endl; return retval; } Modified: mplayerxp/libmpdemux/demuxer_stream.cpp =================================================================== --- mplayerxp/libmpdemux/demuxer_stream.cpp 2012-12-21 15:12:47 UTC (rev 593) +++ mplayerxp/libmpdemux/demuxer_stream.cpp 2012-12-21 17:47:42 UTC (rev 594) @@ -69,12 +69,10 @@ // _first packet in stream _first=_last=dp; } - MSG_DBG2("DEMUX: Append packet: len=%d pts=%5.3f pos=%u [_packs: A=%d V=%d]\n", - dp->length(),dp->pts,(unsigned int)dp->pos,demuxer->audio->_packs,demuxer->video->_packs); + mpxp_dbg2<<"DEMUX: Append packet: len="<<dp->length()<<" pts="<<dp->pts<<" pos="<<(unsigned int)dp->pos<<" [_packs: A="<<demuxer->audio->_packs<<" V="<<demuxer->video->_packs<<"]"<<std::endl; } else - MSG_DBG2("DEMUX: Skip packet: len=%d pts=%5.3f pos=%u [_packs: A=%d V=%d]\n", - dp->length(),dp->pts,(unsigned int)dp->pos,demuxer->audio->_packs,demuxer->video->_packs); + mpxp_dbg2<<"DEMUX: Skip packet: len="<<dp->length()<<" pts="<<dp->pts<<" pos="<<(unsigned int)dp->pos<<" [_packs: A="<<demuxer->audio->_packs<<" V="<<demuxer->video->_packs<<"]"<<std::endl; } void Demuxer_Stream::read_packet(Stream *stream,int len,float _pts,off_t _pos,dp_flags_e _flags){ @@ -86,7 +84,7 @@ dp->flags=_flags; // append packet to DS stream: add_packet(dp); - MSG_DBG2("ds_read_packet(%u,%f,%llu,%i)\n",len,pts,pos,flags); + mpxp_dbg2<<"ds_read_packet("<<len<<","<<pts<<","<<pos<<","<<flags<<")"<<std::endl; } // return value: @@ -96,10 +94,10 @@ if (_buffer) delete _buffer; /* free_packs(ds); */ if(mp_conf.verbose>2) { - if(this==demuxer->audio) MSG_DBG3("ds_fill_buffer(d_audio) called\n"); - else if(this==demuxer->video) MSG_DBG3("ds_fill_buffer(d_video) called\n"); - else if(this==demuxer->sub) MSG_DBG3("ds_fill_buffer(d_sub) called\n"); - else MSG_DBG3("ds_fill_buffer(unknown %p) called\n",this); + if(this==demuxer->audio) mpxp_dbg3<<"ds_fill_buffer(d_audio) called"<<std::endl; + else if(this==demuxer->video) mpxp_dbg3<<"ds_fill_buffer(d_video) called"<<std::endl; + else if(this==demuxer->sub) mpxp_dbg3<<"ds_fill_buffer(d_sub) called"<<std::endl; + else mpxp_dbg3<<"ds_fill_buffer(unknown) called"<<std::endl; } while(1){ if(_packs){ @@ -127,24 +125,24 @@ return 1; //ds->_buffer_size; } if(demuxer->audio->_bytes>=MAX_PACK_BYTES){ - MSG_ERR(MSGTR_TooManyAudioInBuffer,demuxer->audio->_packs,demuxer->audio->_bytes); - MSG_HINT(MSGTR_MaybeNI); + mpxp_err<<"[Demuxer]:"<<MSGTR_TooManyAudioInBuffer<<":"<<demuxer->audio->_packs<<" "<<demuxer->audio->_bytes<<"bytes"<<std::endl; + mpxp_hint<<MSGTR_MaybeNI<<std::endl; break; } if(demuxer->video->_bytes>=MAX_PACK_BYTES){ - MSG_ERR(MSGTR_TooManyVideoInBuffer,demuxer->video->_packs,demuxer->video->_bytes); - MSG_HINT(MSGTR_MaybeNI); + mpxp_err<<"[Demuxer]:"<<MSGTR_TooManyVideoInBuffer<<":"<<demuxer->video->_packs<<" "<<demuxer->video->_bytes<<"bytes"<<std::endl; + mpxp_hint<<MSGTR_MaybeNI<<std::endl; break; } if(!demuxer->demux(this)){ - MSG_DBG2("ds_fill_buffer: demuxer->demux() failed\n"); + mpxp_dbg2<<"ds_fill_buffer: demuxer->demux() failed"<<std::endl; break; // EOF } } _buffer_pos=_buffer_size=0; _buffer=NULL; _current=NULL; - MSG_V("ds_fill_buffer: EOF reached (stream: %s) \n",this==demuxer->audio?"audio":"video"); + mpxp_v<<"ds_fill_buffer: EOF reached (stream: "<<(this==demuxer->audio?"audio":"video")<<")"<<std::endl; eof=1; check_pin("demuxer",pin,DS_PIN); return 0; @@ -260,13 +258,13 @@ float Demuxer_Stream::get_next_pts() { while(!_first) { if(demuxer->audio->_bytes>=MAX_PACK_BYTES){ - MSG_ERR(MSGTR_TooManyAudioInBuffer,demuxer->audio->_packs,demuxer->audio->_bytes); - MSG_HINT(MSGTR_MaybeNI); + mpxp_err<<"[Demuxer]:"<<MSGTR_TooManyAudioInBuffer<<":"<<demuxer->audio->_packs<<" "<<demuxer->audio->_bytes<<"bytes"<<std::endl; + mpxp_hint<<MSGTR_MaybeNI<<std::endl; return -1; } if(demuxer->video->_bytes>=MAX_PACK_BYTES){ - MSG_ERR(MSGTR_TooManyVideoInBuffer,demuxer->video->_packs,demuxer->video->_bytes); - MSG_HINT(MSGTR_MaybeNI); + mpxp_err<<"[Demuxer]:"<<MSGTR_TooManyVideoInBuffer<<":"<<demuxer->video->_packs<<" "<<demuxer->video->_bytes<<"bytes"<<std::endl; + mpxp_hint<<MSGTR_MaybeNI<<std::endl; return -1; } if(!demuxer->fill_buffer(this)) return -1; Modified: mplayerxp/libmpstream2/cache2.cpp =================================================================== --- mplayerxp/libmpstream2/cache2.cpp 2012-12-21 15:12:47 UTC (rev 593) +++ mplayerxp/libmpstream2/cache2.cpp 2012-12-21 17:47:42 UTC (rev 594) @@ -3,10 +3,6 @@ using namespace mpxp; #include <algorithm> -#define READ_USLEEP_TIME 10000 -#define FILL_USLEEP_TIME 50000 -#define PREFILL_SLEEP_TIME 200 - #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -30,9 +26,12 @@ #include "stream_msg.h" namespace mpxp { -#define CPF_EMPTY 0x00000001UL -#define CPF_EOF 0x80000000UL -#define CPF_DONE 0x40000000UL /* special case for dvd packets to exclude them from sending again */ +static const int READ_USLEEP_TIME=10000; +static const int FILL_USLEEP_TIME=50000; +static const int PREFILL_SLEEP_TIME=200; +static const int CPF_EMPTY=0x00000001UL; +static const int CPF_EOF=0x80000000UL; +static const int CPF_DONE=0x40000000UL; /* special case for dvd packets to exclude them from sending again */ struct cache_packet_t { off_t filepos; /* some nav-packets have length so we need to know real pos of data packet */ @@ -63,55 +62,45 @@ char* mem; }; -#if 0 -#define MSG_CH MSG_V -#else -#define MSG_CH(...) -#endif +inline void CACHE2_LOCK(cache_vars_t& cv) { pthread_mutex_lock(&cv.mutex); } +inline void CACHE2_UNLOCK(cache_vars_t& cv) { pthread_mutex_unlock(&cv.mutex); } -#define CACHE2_LOCK(cv) { MSG_CH("CACHE2_LOCK\n"); pthread_mutex_lock(&cv->mutex); } -#define CACHE2_UNLOCK(cv) { MSG_CH("CACHE2_UNLOCK\n");pthread_mutex_unlock(&cv->mutex); } +inline void CACHE2_TLOCK(cache_vars_t& cv) { pthread_mutex_lock(&cv.mutex); } +inline void CACHE2_TUNLOCK(cache_vars_t& cv) { pthread_mutex_unlock(&cv.mutex); } -#define CACHE2_TLOCK(cv) { MSG_CH("CACHE2_TLOCK\n"); pthread_mutex_lock(&cv->mutex); } -#define CACHE2_TUNLOCK(cv) { MSG_CH("CACHE2_TUNLOCK\n");pthread_mutex_unlock(&cv->mutex); } +inline void CACHE2_PACKET_LOCK(cache_packet_t& c) { pthread_mutex_lock(&c.cp_mutex); } +inline void CACHE2_PACKET_UNLOCK(cache_packet_t& c) { pthread_mutex_unlock(&c.cp_mutex); } -#define CACHE2_PACKET_LOCK(cidx) { MSG_CH("CACHE2_PACKET_LOCK\n"); pthread_mutex_lock(&c->packets[cidx].cp_mutex); } -#define CACHE2_PACKET_UNLOCK(cidx) { MSG_CH("CACHE2_PACKET_UNLOCK\n");pthread_mutex_unlock(&c->packets[cidx].cp_mutex); } +inline void CACHE2_PACKET_TLOCK(cache_packet_t& c) { pthread_mutex_lock(&c.cp_mutex); } +inline void CACHE2_PACKET_TUNLOCK(cache_packet_t& c) { pthread_mutex_unlock(&c.cp_mutex); } -#define CACHE2_PACKET_TLOCK(cidx) { MSG_CH("CACHE2_PACKET_TLOCK\n"); pthread_mutex_lock(&c->packets[cidx].cp_mutex); } -#define CACHE2_PACKET_TUNLOCK(cidx) { MSG_CH("CACHE2_PACKET_TUNLOCK\n");pthread_mutex_unlock(&c->packets[cidx].cp_mutex); } +inline off_t START_FILEPOS(cache_vars_t& c) { return c.packets[c.first].filepos; } +inline off_t END_FILEPOS(cache_vars_t& c) { return c.packets[c.last].filepos+c.packets[c.last].sp.len; } +inline unsigned CP_NEXT(cache_vars_t& c,unsigned idx) { return (idx+1)%c.npackets; } -#define START_FILEPOS(c) ((c)->packets[(c)->first].filepos) -#define END_FILEPOS(c) ((c)->packets[(c)->last].filepos+(c)->packets[(c)->last].sp.len) -#define CP_NEXT(c,idx) (((idx)+1)%(c)->npackets) - #ifdef __i386__ -#define COREDUMP() { __asm __volatile(".short 0xffff":::"memory"); } +inline void COREDUMP() { __asm __volatile(".short 0xffff":::"memory"); } #else -#define COREDUMP() +inline void COREDUMP() {} #endif -#if 0 -#define C2_ASSERT(cond) if(cond) { MSG_FATAL("internal error at cache2.c:%u: (%s)\n",__LINE__,#cond); COREDUMP(); } -#else -#define C2_ASSERT(cond) if(cond) MSG_FATAL("internal error at cache2.c:%u: (%s)\n",__LINE__,#cond); -#endif +inline void C2_ASSERT(int cond) { if(cond) MSG_FATAL("internal error at cache2.c: (%i)\n",cond); } static int __FASTCALL__ c2_cache_fill(cache_vars_t* c){ int len,in_cache,legacy_eof,seek_eof; off_t readpos,new_start; unsigned cidx,cp; - CACHE2_TLOCK(c); + CACHE2_TLOCK(*c); readpos=c->read_filepos; - in_cache=(readpos>=START_FILEPOS(c)&&readpos<END_FILEPOS(c)); + in_cache=(readpos>=START_FILEPOS(*c)&&readpos<END_FILEPOS(*c)); new_start = readpos - c->back_size; if(new_start<c->stream->start_pos()) new_start=c->stream->start_pos(); seek_eof=0; if(!in_cache && c->stream->type()&Stream::Type_Seekable) { /* seeking... */ MSG_DBG2("Out of boundaries... seeking to %lli {in_cache(%i) %lli<%lli>%lli} \n" - ,new_start,in_cache,START_FILEPOS(c),readpos,END_FILEPOS(c)); + ,new_start,in_cache,START_FILEPOS(*c),readpos,END_FILEPOS(*c)); if(c->stream->eof() || c->eof) c->stream->reset(); c->stream->seek(new_start); if(errno) { MSG_WARN("c2_seek(drv:%s) error: %s\n",c->stream->driver_info->mrl,strerror(errno)); errno=0; } @@ -119,31 +108,31 @@ c->last=c->first; if(c->packets[c->first].filepos < new_start-(off_t)c->stream->sector_size()) MSG_WARN("CACHE2: found wrong offset after seeking %lli (wanted: %lli)\n",c->packets[c->first].filepos,new_start); - MSG_DBG2("Seek done. new pos: %lli\n",START_FILEPOS(c)); + MSG_DBG2("Seek done. new pos: %lli\n",START_FILEPOS(*c)); } else { /* find new start of buffer according on readpos */ cidx=c->first; do { if((new_start>=c->packets[cidx].filepos&&new_start<c->packets[cidx].filepos+c->packets[cidx].sp.len) && !c->packets[cidx].sp.type) break; - cidx=CP_NEXT(c,cidx); + cidx=CP_NEXT(*c,cidx); }while(cidx!=c->first); - MSG_DBG2("CACHE2: Assigning first as %p for %lli\n",c->first,START_FILEPOS(c)); + MSG_DBG2("CACHE2: Assigning first as %p for %lli\n",c->first,START_FILEPOS(*c)); c->first=cidx; } - CACHE2_TUNLOCK(c); - if(CP_NEXT(c,c->last) == c->first || c->eof) { + CACHE2_TUNLOCK(*c); + if(CP_NEXT(*c,c->last) == c->first || c->eof) { MSG_DBG2("CACHE2: cache full\n"); return 0; /* cache full */ } len=0; - cp=cidx=c->last==c->first?c->first:CP_NEXT(c,c->last); - do { CACHE2_PACKET_TLOCK(cidx); c->packets[cidx].state|=CPF_EMPTY; CACHE2_PACKET_TUNLOCK(cidx); cidx=CP_NEXT(c,cidx); } while(cidx!=c->first); + cp=cidx=c->last==c->first?c->first:CP_NEXT(*c,c->last); + do { CACHE2_PACKET_TLOCK(c->packets[cidx]); c->packets[cidx].state|=CPF_EMPTY; CACHE2_PACKET_TUNLOCK(c->packets[cidx]); cidx=CP_NEXT(*c,cidx); } while(cidx!=c->first); cidx=cp; c->in_fill=1; while(1) { - CACHE2_PACKET_TLOCK(cidx); + CACHE2_PACKET_TLOCK(c->packets[cidx]); c->packets[cidx].sp.len=c->sector_size; c->packets[cidx].filepos = c->stream->tell(); c->stream->read(c->packets[cidx].sp.buf,c->packets[cidx].sp.len); @@ -159,27 +148,27 @@ else legacy_eof=0; if(c->packets[cidx].sp.len < 0 || (c->packets[cidx].sp.len == 0 && c->packets[cidx].sp.type == 0) || legacy_eof || seek_eof) { /* EOF */ - MSG_DBG2("CACHE2: guess EOF: %lli %lli\n",START_FILEPOS(c),END_FILEPOS(c)); + MSG_DBG2("CACHE2: guess EOF: %lli %lli\n",START_FILEPOS(*c),END_FILEPOS(*c)); c->packets[cidx].state|=CPF_EOF; c->eof=1; c->packets[cidx].state&=~CPF_EMPTY; c->packets[cidx].state&=~CPF_DONE; if(errno) { MSG_WARN("c2_fill_buffer(drv:%s) error: %s\n",c->stream->driver_info->mrl,strerror(errno)); errno=0; } - CACHE2_PACKET_TUNLOCK(cidx); + CACHE2_PACKET_TUNLOCK(c->packets[cidx]); break; } if(c->packets[cidx].sp.type == 0) len += c->packets[cidx].sp.len; c->last=cidx; c->packets[cidx].state&=~CPF_EMPTY; c->packets[cidx].state&=~CPF_DONE; - CACHE2_PACKET_TUNLOCK(cidx); - cidx=CP_NEXT(c,cidx); - MSG_DBG2("CACHE2: start=%lli end_filepos = %lli\n",START_FILEPOS(c),END_FILEPOS(c)); + CACHE2_PACKET_TUNLOCK(c->packets[cidx]); + cidx=CP_NEXT(*c,cidx); + MSG_DBG2("CACHE2: start=%lli end_filepos = %lli\n",START_FILEPOS(*c),END_FILEPOS(*c)); if(cidx==c->first) { MSG_DBG2("CACHE2: end of queue is reached: %p\n",c->first); break; } - CACHE2_TUNLOCK(c); + CACHE2_TUNLOCK(*c); } c->in_fill=0; MSG_DBG2("CACHE2: totally got %u bytes\n",len); @@ -272,11 +261,11 @@ { MSG_DBG2( "c2_stream_fill_buffer\n"); if(c->eof) return 0; - while(c->read_filepos>=END_FILEPOS(c) || c->read_filepos<START_FILEPOS(c)) + while(c->read_filepos>=END_FILEPOS(*c) || c->read_filepos<START_FILEPOS(*c)) { if(c->eof) break; usleep(READ_USLEEP_TIME); // 10ms - MSG_DBG2("Waiting for %lli in %lli %lli\n",c->read_filepos,START_FILEPOS(c),END_FILEPOS(c)); + MSG_DBG2("Waiting for %lli in %lli %lli\n",c->read_filepos,START_FILEPOS(*c),END_FILEPOS(*c)); continue; // try again... } return c->eof?0:1; @@ -290,12 +279,12 @@ c->stream->reset(); cidx=c->first; was_eof=0; - do{ was_eof |= (c->packets[cidx].state&CPF_EOF); c->packets[cidx].state&=~CPF_EOF; cidx=CP_NEXT(c,cidx); }while(cidx!=c->first); + do{ was_eof |= (c->packets[cidx].state&CPF_EOF); c->packets[cidx].state&=~CPF_EOF; cidx=CP_NEXT(*c,cidx); }while(cidx!=c->first); c->eof=0; if(was_eof) { cidx=c->first; - do{ c->packets[cidx].state|=CPF_EMPTY; cidx=CP_NEXT(c,cidx); }while(cidx!=c->first); + do{ c->packets[cidx].state|=CPF_EMPTY; cidx=CP_NEXT(*c,cidx); }while(cidx!=c->first); c->last=c->first; c->read_filepos=c->stream->start_pos(); c->stream->seek(c->read_filepos); @@ -304,43 +293,43 @@ static int __FASTCALL__ c2_stream_seek_long(cache_vars_t* c,off_t pos){ - MSG_DBG2("CACHE2_SEEK: %lli,%lli,%lli <> %lli\n",START_FILEPOS(c),c->read_filepos,END_FILEPOS(c),pos); - if(pos<0/* || pos>END_FILEPOS(c)*/) { c->eof=1; return 0; } + MSG_DBG2("CACHE2_SEEK: %lli,%lli,%lli <> %lli\n",START_FILEPOS(*c),c->read_filepos,END_FILEPOS(*c),pos); + if(pos<0/* || pos>END_FILEPOS(*c)*/) { c->eof=1; return 0; } while(c->in_fill) yield_timeslice(); - CACHE2_LOCK(c); + CACHE2_LOCK(*c); if(c->eof) c2_stream_reset(c); C2_ASSERT(pos < c->stream->start_pos()); c->read_filepos=pos; - CACHE2_UNLOCK(c); + CACHE2_UNLOCK(*c); c2_stream_fill_buffer(c); - return c->eof?pos<END_FILEPOS(c)?1:0:1; + return c->eof?pos<END_FILEPOS(*c)?1:0:1; } static unsigned __FASTCALL__ c2_find_packet(cache_vars_t* c,off_t pos) { unsigned retval; - CACHE2_LOCK(c); + CACHE2_LOCK(*c); retval = c->first; - CACHE2_UNLOCK(c); + CACHE2_UNLOCK(*c); while(1) { - CACHE2_PACKET_LOCK(retval); - while(c->packets[retval].state&CPF_EMPTY) { CACHE2_PACKET_UNLOCK(retval); usleep(0); CACHE2_PACKET_LOCK(retval); } + CACHE2_PACKET_LOCK(c->packets[retval]); + while(c->packets[retval].state&CPF_EMPTY) { CACHE2_PACKET_UNLOCK(c->packets[retval]); usleep(0); CACHE2_PACKET_LOCK(c->packets[retval]); } if((pos >= c->packets[retval].filepos && pos < c->packets[retval].filepos+c->packets[retval].sp.len && !c->packets[retval].sp.type) || (c->packets[retval].state&CPF_EOF)) break; /* packet is locked */ - CACHE2_PACKET_UNLOCK(retval); - CACHE2_LOCK(c); - retval=CP_NEXT(c,retval); + CACHE2_PACKET_UNLOCK(c->packets[retval]); + CACHE2_LOCK(*c); + retval=CP_NEXT(*c,retval); if(retval==c->first) { MSG_DBG2("Can't find packet for offset %lli\n",pos); - CACHE2_UNLOCK(c); + CACHE2_UNLOCK(*c); return UINT_MAX; } - CACHE2_UNLOCK(c); + CACHE2_UNLOCK(*c); } return retval; } @@ -362,7 +351,7 @@ c->packets[i].sp.len<0 || c->packets[i].state&CPF_EMPTY || (c->packets[i].sp.len==0 && c->packets[i].sp.type)) break; - CACHE2_PACKET_LOCK(i); + CACHE2_PACKET_LOCK(c->packets[i]); *len += c->packets[i].sp.len; (*npackets)++; } @@ -376,7 +365,7 @@ { cidx = c2_find_packet(c,pos); if(cidx!=UINT_MAX || c->eof) break; - if(cidx!=UINT_MAX) CACHE2_PACKET_UNLOCK(cidx); + if(cidx!=UINT_MAX) CACHE2_PACKET_UNLOCK(c->packets[cidx]); c2_stream_fill_buffer(c); } c2_get_continious_mem(c,cidx,len,npackets); @@ -388,20 +377,20 @@ MSG_DBG2("next_packet: start=%p cur=%i\n",c->first,cidx); while(1) { - CACHE2_LOCK(c); - cidx=CP_NEXT(c,cidx); - CACHE2_UNLOCK(c); - CACHE2_PACKET_LOCK(cidx); - while(c->packets[cidx].state&CPF_EMPTY) { CACHE2_PACKET_UNLOCK(cidx); usleep(0); CACHE2_PACKET_LOCK(cidx); } + CACHE2_LOCK(*c); + cidx=CP_NEXT(*c,cidx); + CACHE2_UNLOCK(*c); + CACHE2_PACKET_LOCK(c->packets[cidx]); + while(c->packets[cidx].state&CPF_EMPTY) { CACHE2_PACKET_UNLOCK(c->packets[cidx]); usleep(0); CACHE2_PACKET_LOCK(c->packets[cidx]); } if(cidx==c->first) { - CACHE2_PACKET_UNLOCK(cidx); + CACHE2_PACKET_UNLOCK(c->packets[cidx]); c2_stream_fill_buffer(c); cidx = c2_find_packet(c,c->read_filepos); break; } if(!c->packets[cidx].sp.type) break; /* packet is locked */ - CACHE2_PACKET_UNLOCK(cidx); + CACHE2_PACKET_UNLOCK(c->packets[cidx]); } c2_get_continious_mem(c,cidx,len,npackets); MSG_DBG2("next_packet: rp: %lli fp: %lli len %lu type %i\n",c->read_filepos,c->packets[cidx].filepos,c->packets[cidx].sp.len,c->packets[cidx].sp.type); @@ -415,18 +404,18 @@ unsigned cur,i,npackets; cur=c2_wait_packet(c,c->read_filepos,&mlen,&npackets); eof = cur!=UINT_MAX?((int)(c->packets[cur].state&CPF_EOF)):c->eof; - if(cur==UINT_MAX||eof) { if(cur!=UINT_MAX) CACHE2_PACKET_UNLOCK(cur); return 0; } + if(cur==UINT_MAX||eof) { if(cur!=UINT_MAX) CACHE2_PACKET_UNLOCK(c->packets[cur]); return 0; } MSG_DBG2( "c2_stream_read %i bytes from %lli\n",total,c->read_filepos); while(len){ int x; if(c->read_filepos>=c->packets[cur].filepos+mlen){ - for(i=0;i<npackets;i++) CACHE2_PACKET_UNLOCK(cur+i); + for(i=0;i<npackets;i++) CACHE2_PACKET_UNLOCK(c->packets[cur+i]); mlen=len; cur=c2_next_packet(c,cur,&mlen,&npackets); eof = cur!=UINT_MAX?(c->packets[cur].state&CPF_EOF):1; if(eof) { - CACHE2_PACKET_UNLOCK(cur); + CACHE2_PACKET_UNLOCK(c->packets[cur]); return total-len; // EOF } } @@ -440,7 +429,7 @@ mem+=x; len-=x; c->read_filepos+=x; } - CACHE2_PACKET_UNLOCK(cur); + CACHE2_PACKET_UNLOCK(c->packets[cur]); if(mp_conf.verbose>2) { MSG_DBG2( "c2_stream_read got %u bytes ",total); @@ -457,8 +446,8 @@ static int __FASTCALL__ c2_stream_seek(cache_vars_t* c,off_t pos) { - MSG_DBG2( "c2_seek to %lli (%lli %lli) %i\n",(long long)pos,(long long)START_FILEPOS(c),(long long)END_FILEPOS(c),c->first); - if(pos>=START_FILEPOS(c) && pos < END_FILEPOS(c)) + MSG_DBG2( "c2_seek to %lli (%lli %lli) %i\n",(long long)pos,(long long)START_FILEPOS(*c),(long long)END_FILEPOS(*c),c->first); + if(pos>=START_FILEPOS(*c) && pos < END_FILEPOS(*c)) { c->read_filepos=pos; return pos; @@ -476,7 +465,7 @@ unsigned cur; int retval; cur = c2_find_packet(c,c->read_filepos); - if(cur!=UINT_MAX) CACHE2_PACKET_UNLOCK(cur); + if(cur!=UINT_MAX) CACHE2_PACKET_UNLOCK(c->packets[cur]); retval = cur!=UINT_MAX?((int)(c->packets[cur].state&CPF_EOF)):c->eof; MSG_DBG2("stream_eof: %i\n",retval); return retval; @@ -490,7 +479,7 @@ { if(eof) c->packets[cur].state|=CPF_EOF; else c->packets[cur].state&=~CPF_EOF; - CACHE2_PACKET_UNLOCK(cur); + CACHE2_PACKET_UNLOCK(c->packets[cur]); } c->eof=eof; MSG_DBG2("stream_set_eof: %i\n",eof); @@ -524,17 +513,17 @@ c->pth=mpxp_context().engine().xp_core->mpxp_threads[rc]; // wait until cache is filled at least prefill_init % MSG_V("CACHE_PRE_INIT: %lld [%lld] %lld pre:%d eof:%d SS=%u \n", - START_FILEPOS(c),c->read_filepos,END_FILEPOS(c),_min,c->eof,ss); - while((c->read_filepos<START_FILEPOS(c) || END_FILEPOS(c)-c->read_filepos<_min) - && !c->eof && CP_NEXT(c,c->last)!=c->first){ + START_FILEPOS(*c),c->read_filepos,END_FILEPOS(*c),_min,c->eof,ss); + while((c->read_filepos<START_FILEPOS(*c) || END_FILEPOS(*c)-c->read_filepos<_min) + && !c->eof && CP_NEXT(*c,c->last)!=c->first){ if(!(type()&Stream::Type_Seekable)) MSG_STATUS("\rCache fill: %5.2f%% (%d bytes) ", - 100.0*(float)(END_FILEPOS(c)-c->read_filepos)/(float)(c->buffer_size), - END_FILEPOS(c)-c->read_filepos); + 100.0*(float)(END_FILEPOS(*c)-c->read_filepos)/(float)(c->buffer_size), + END_FILEPOS(*c)-c->read_filepos); else MSG_V("\rCache fill: %5.2f%% (%d bytes) ", - 100.0*(float)(END_FILEPOS(c)-c->read_filepos)/(float)(c->buffer_size), - END_FILEPOS(c)-c->read_filepos); + 100.0*(float)(END_FILEPOS(*c)-c->read_filepos)/(float)(c->buffer_size), + END_FILEPOS(*c)-c->read_filepos); if(c->eof) break; // file is smaller than prefill size if(mpdemux_check_interrupt(libinput,PREFILL_SLEEP_TIME)) return; Modified: mplayerxp/libmpstream2/s_cdd.cpp =================================================================== --- mplayerxp/libmpstream2/s_cdd.cpp 2012-12-21 15:12:47 UTC (rev 593) +++ mplayerxp/libmpstream2/s_cdd.cpp 2012-12-21 17:47:42 UTC (rev 594) @@ -53,7 +53,7 @@ char *device; UNUSED(flags); if(filename=="help") { - MSG_HINT("Usage: cdda://<@device><#trackno>\n"); + mpxp_hint<<"Usage: cdda://<@device><#trackno>"<<std::endl; return MPXP_False; } param=mrl_parse_line(filename,NULL,NULL,&device,NULL); @@ -103,7 +103,7 @@ case SCTRL_AUD_GET_CHANNELS: *(int *)args=priv->channels(track_idx); if(*(int *)args<=0) *(int *)args=2; - MSG_V("cdda channels: %u\n",*(int *)args); + mpxp_v<<"cdda channels: "<<*(int *)args<<std::endl; return MPXP_Ok; case SCTRL_AUD_GET_SAMPLERATE: *(int *)args = 44100; @@ -150,7 +150,7 @@ MPXP_Rc retval; UNUSED(flags); if(filename=="help") { - MSG_HINT("Usage: cddb://<@device><#trackno>\n"); + mpxp_hint<<"Usage: cddb://<@device><#trackno>"<<std::endl; return MPXP_False; } param=mrl_parse_line(filename,NULL,NULL,&device,NULL); Modified: mplayerxp/libmpstream2/s_dvdnav.cpp =================================================================== --- mplayerxp/libmpstream2/s_dvdnav.cpp 2012-12-21 15:12:47 UTC (rev 593) +++ mplayerxp/libmpstream2/s_dvdnav.cpp 2012-12-21 17:47:42 UTC (rev 594) @@ -130,7 +130,7 @@ /* report the title?! */ if (dvdnav_get_title_string(dvdnav,&title_str)==DVDNAV_STATUS_OK) { - MSG_INFO("Title: '%s'\n",title_str); + mpxp_info<<"Title: "<<title_str<<std::endl; } return MPXP_Ok; } @@ -144,11 +144,11 @@ case 0: return; case 0xff: - MSG_V( "Sleeping indefinately\n" ); + mpxp_v<<"Sleeping indefinately"<<std::endl; sleeping=2; break; default: - MSG_V( "Sleeping %d sec(s)\n", seconds ); + mpxp_v<<"Sleeping "<<seconds<<"sec(s)"<<std::endl; sleep_until = GetTimer();// + seconds*1000000; sleeping=1; break; @@ -167,10 +167,10 @@ } dvdnav_still_skip(dvdnav); // continue past... sleeping=0; - MSG_V("%s: woke up!\n",__FUNCTION__); + mpxp_v<<"woke up!"<<std::endl; } dvd_nav_still=0; - MSG_V("%s: active\n",__FUNCTION__); + mpxp_v<<"active"<<std::endl; return 0; } @@ -187,15 +187,15 @@ filename=_filename; param=mrl_parse_line(_filename,NULL,NULL,&dvd_device,NULL); if(strcmp(param,"help") == 0) { - MSG_HINT("Usage: dvdnav://<title>,<chapter>\n"); + mpxp_hint<<"Usage: dvdnav://<title>,<chapter>"<<std::endl; return MPXP_False; } param=mrl_parse_params(param,dvdnavopts_conf); if (new_stream(dvd_device?dvd_device:DEFAULT_DVD_DEVICE)!=MPXP_Ok) { - MSG_ERR(MSGTR_CantOpenDVD,dvd_device?dvd_device:DEFAULT_DVD_DEVICE); + mpxp_err<<MSGTR_CantOpenDVD<<":"<<(dvd_device?dvd_device:DEFAULT_DVD_DEVICE)<<std::endl; if(!dvd_device) { if (new_stream(DEFAULT_CDROM_DEVICE)!=MPXP_Ok) - MSG_ERR(MSGTR_CantOpenDVD,DEFAULT_CDROM_DEVICE); + mpxp_err<<MSGTR_CantOpenDVD<<":"<<DEFAULT_CDROM_DEVICE<<std::endl; else goto dvd_ok; } @@ -214,16 +214,16 @@ dvdnav_set_PGC_positioning_flag(dvdnav,1); ntitles=0; dvdnav_get_number_of_titles(dvdnav,&ntitles); - MSG_INFO(MSGTR_DVDnumTitles,ntitles); + mpxp_info<<MSGTR_DVDnumTitles<<":"<<ntitles<<std::endl; if(dvdnav_conf.title != -1) { int nparts; dvdnav_get_number_of_parts(dvdnav,dvdnav_conf.title,&nparts); - MSG_INFO(MSGTR_DVDnumChapters,dvdnav_conf.title,nparts); + mpxp_info<<MSGTR_DVDnumChapters<<":"<<dvdnav_conf.title<<":"<<nparts<<std::endl; if(dvdnav_conf.chapter != -1) dvdnav_part_play(dvdnav,dvdnav_conf.title,dvdnav_conf.chapter); else dvdnav_title_play(dvdnav,dvdnav_conf.title); cpos=2048; /* disallow dvdnav_reset */ dvdnav_current_title_info(dvdnav,&dvdnav_conf.title,&dvdnav_conf.chapter); - MSG_INFO("Playing %i part of %i title\n",dvdnav_conf.chapter,dvdnav_conf.title); + mpxp_info<<"Playing "<<dvdnav_conf.chapter<<" part of "<<dvdnav_conf.title<<" title"<<std::endl; } return MPXP_Ok; } @@ -248,7 +248,7 @@ if (!de->details) return; if (dvd_nav_still) { - MSG_V("%s: got a stream_read while I should be asleep!\n",__FUNCTION__); + mpxp_v<<"got a stream_read while I should be asleep!"<<std::endl; de->event=DVDNAV_STILL_FRAME; de->len=0; return; @@ -256,7 +256,7 @@ done=0; while(!done) { if (dvdnav_get_next_block(dvdnav,reinterpret_cast<uint8_t*>(de->details),&event,&de->len)!=DVDNAV_STATUS_OK) { - MSG_ERR( "Error getting next block from DVD (%s)\n",dvdnav_err_to_string(dvdnav) ); + mpxp_err<<"Error getting next block from DVD: "<<dvdnav_err_to_string(dvdnav)<<std::endl; de->len=-1; } if(event == DVDNAV_STILL_FRAME) { @@ -275,13 +275,11 @@ _this=dvdnav_get_current_nav_pci(dvdnav); vobu_s_pts=_this->pci_gi.vobu_s_ptm/90000.; vobu_e_pts=_this->pci_gi.vobu_e_ptm/90000.; - MSG_V("Handling NAV_PACKET: vobu_s_ptm=%f vobu_e_ptm=%f e_eltm=%f\n" - ,vobu_s_pts - ,vobu_e_pts - ,(float)_this->pci_gi.e_eltm.second+_this->pci_gi.e_eltm.minute*60.+_this->pci_gi.e_eltm.hour*3600.); + mpxp_v<<"Handling NAV_PACKET: vobu_s_ptm="<<vobu_s_pts + <<" vobu_e_ptm="<<vobu_e_pts<<" e_eltm="<<((float)_this->pci_gi.e_eltm.second+_this->pci_gi.e_eltm.minute*60.+_this->pci_gi.e_eltm.hour*3600.)<<std::endl; if(vobu_s_pts < vobu_e_pts) { _stream_pts += vobu_e_pts-vobu_s_pts; - MSG_V("DVD's discontinuities found! Applying delta: %f\n",_stream_pts); + mpxp_v<<"DVD's discontinuities found! Applying delta: "<<_stream_pts<<std::endl; } else _stream_pts = vobu_s_pts; vobu_s_pts = vobu_s_pts; @@ -291,13 +289,11 @@ dvdnav_current_title_info(dvdnav, &ct, &cc); if(ct<=0) { menu_mode=1; - MSG_V("entering menu mode: %i %i\n",ct,cc); - MSG_V("vmgm: %i vtsm: %i\n", - dvdnav_is_domain_vmgm(dvdnav), - dvdnav_is_domain_vtsm(dvdnav)); + mpxp_v<<"entering menu mode: "<<ct<<" "<<cc<<std::endl; + mpxp_v<<"vmgm: "<<dvdnav_is_domain_vmgm(dvdnav)<<" vtsm: "<<dvdnav_is_domain_vtsm(dvdnav)<<std::endl; } else { menu_mode=0; - MSG_V("leaving menu mode: %i %i\n",ct,cc); + mpxp_v<<"leaving menu mode: "<<ct<<" "<<cc<<std::endl; } } else done=1; } @@ -402,7 +398,7 @@ dvdnav_highlight_event_t *_hlev = (dvdnav_highlight_event_t*)(sp->buf); int btnum; int display_mode=1; - MSG_V("DVDNAV_HIGHLIGHT: %i %i %i %i\n",_hlev->sx,_hlev->sy,_hlev->ex,_hlev->ey); + mpxp_v<<"DVDNAV_HIGHLIGHT: "<<_hlev->sx<<" "<<_hlev->sy<<" "<<_hlev->ex<<" "<<_hlev->ey<<std::endl; if (!dvdnav) return; memcpy(&hlev,_hlev,sizeof(dvdnav_highlight_event_t)); pnavpci = dvdnav_get_current_nav_pci (dvdnav); @@ -435,7 +431,7 @@ } case DVDNAV_STILL_FRAME: { const dvdnav_still_event_t *still_event = (const dvdnav_still_event_t*)(sp->buf); - MSG_DBG2( "######## DVDNAV Event: Still Frame: %d sec(s)\n", still_event->length ); + mpxp_dbg2<<"######## DVDNAV Event: Still Frame: "<<still_event->length<<" sec(s)"<<std::endl; while (stream_sleeping()) { yield_timeslice(); } @@ -443,22 +439,15 @@ break; } case DVDNAV_STOP: - MSG_DBG2( "DVDNAV Event: Nav Stop\n" ); + mpxp_dbg2<<"DVDNAV Event: Nav Stop"<<std::endl; break; case DVDNAV_NOP: - MSG_V("DVDNAV Event: Nav NOP\n"); + mpxp_v<<"DVDNAV Event: Nav NOP"<<std::endl; break; #if 0 case DVDNAV_SPU_STREAM_CHANGE: { const dvdnav_spu_stream_change_event_t * stream_change=(const dvdnav_spu_stream_change_event_t*)(sp->buf); - MSG_DBG2("DVDNAV Event: Nav SPU Stream Change: phys_wide: %d phys_letterbox: %d phys_panscan: %d logical: %d\n", - stream_change->physical_wide, - stream_change->physical_letterbox, - stream_change->physical_pan_scan, - stream_change->logical); if (mpxp_context().video().output->spudec && mp_conf.dvdsub_id!=stream_change->physical_wide) { - MSG_DBG2("d_dvdsub->id change: was %d is now %d\n", - d_dvdsub->id,stream_change->physical_wide); // FIXME: need a better way to change SPU id d_dvdsub->id=mp_conf.dvdsub_id=stream_change->physical_wide; if (mpxp_context().video().output->spudec) spudec_reset(mpxp_context().video().output->spudec); @@ -468,14 +457,9 @@ case DVDNAV_AUDIO_STREAM_CHANGE: { int aid_temp; const dvdnav_audio_stream_change_event_t *stream_change = (const dvdnav_audio_stream_change_event_t*)(sp->buf); - MSG_DBG2("DVDNAV Event: Nav Audio Stream Change: phys: %d logical: %d\n", - stream_change->physical, - stream_change->logical); aid_temp=stream_change->physical; if (aid_temp>=0) aid_temp+=128; // FIXME: is this sane? if (d_audio && mp_conf.audio_id!=aid_temp) { - MSG_DBG2("d_audio->id change: was %d is now %d\n", - d_audio->id,aid_temp); // FIXME: need a bettery way to change audio stream id d_audio->id=mp_conf.dvdsub_id=aid_temp; mpxp_resync_audio_stream(); @@ -485,27 +469,25 @@ #endif case DVDNAV_VTS_CHANGE:{ const dvdnav_vts_change_event_t *evts = (const dvdnav_vts_change_event_t *)(sp->buf); - MSG_V("DVDNAV Event: Nav VTS Change %u\n",evts->new_domain); + mpxp_v<<"DVDNAV Event: Nav VTS Change "<<evts->new_domain<<std::endl; } break; case DVDNAV_CELL_CHANGE: { const dvdnav_cell_change_event_t *ecell=(const dvdnav_cell_change_event_t*)(sp->buf); - MSG_V("DVDNAV_CELL_CHANGE: N=%i pgN=%i cell_start=%f pg_start=%f cell_length=%f pg_length=%f pgc_length=%f\n" - ,ecell->cellN - ,ecell->pgN - ,ecell->cell_start/90000. - ,ecell->pg_start/90000. - ,ecell->cell_length/90000. - ,ecell->pg_length/90000. - ,ecell->pgc_length/90000.); + mpxp_v<<"DVDNAV_CELL_CHANGE: N="<<ecell->cellN + <<" pgN="<<ecell->pgN<<" cell_start="<<(ecell->cell_start/90000.) + <<" pg_start="<<(ecell->pg_start/90000.) + <<" cell_length="<<(ecell->cell_length/90000.) + <<" pg_length="<<(ecell->pg_length/90000.) + <<" pgc_length="<<(ecell->pgc_length/90000.)<<std::endl; } break; case DVDNAV_NAV_PACKET: - MSG_V("DVDNAV Event: Nav Packet\n"); + mpxp_v<<"DVDNAV Event: Nav Packet"<<std::endl; break; case DVDNAV_SPU_CLUT_CHANGE: - MSG_DBG2("DVDNAV Event: Nav SPU CLUT Change\n"); - if(sp->len!=64) MSG_WARN("DVDNAV Event: Nav SPU CLUT Change: %i bytes <> 64\n",sp->len); + mpxp_dbg2<<"DVDNAV Event: Nav SPU CLUT Change"<<std::endl; + if(sp->len!=64) mpxp_warn<<"DVDNAV Event: Nav SPU CLUT Change: "<<sp->len<<" bytes <> 64"<<std::endl; // send new palette to SPU decoder if (mpxp_context().video().output->spudec) spudec_update_palette(mpxp_context().video().output->spudec,(const unsigned int *)(sp->buf)); break; @@ -531,7 +513,7 @@ break; case MP_CMD_DVDNAV_MENU: { int title,part; - MSG_V("Menu call\n"); + mpxp_v<<"Menu call"<<std::endl; dvdnav_current_title_info(dvdnav, &title, &part); if(title>0) { if(dvdnav_menu_call(dvdnav, DVD_MENU_Part) == DVDNAV_STATUS_OK @@ -546,7 +528,7 @@ dvdnav_button_activate(dvdnav,pci); break; default: - MSG_V("Weird DVD Nav cmd %d\n",cmd); + mpxp_v<<"Weird DVD Nav cmd "<<cmd<<std::endl; break; } dvdnav_get_current_highlight(dvdnav, &button); Modified: mplayerxp/libmpstream2/s_dvdread.cpp =================================================================== --- mplayerxp/libmpstream2/s_dvdread.cpp 2012-12-21 15:12:47 UTC (rev 593) +++ mplayerxp/libmpstream2/s_dvdread.cpp 2012-12-21 17:47:42 UTC (rev 594) @@ -5,6 +5,7 @@ s_dvdread - DVDREAD stream interface */ #include <limits> +#include <iomanip> #include "mplayerxp.h" /* fake stdint */ @@ -161,14 +162,13 @@ code=lang[1]|(lang[0]<<8); for(i=0;i<unsigned(nr_of_channels);i++){ if(audio_streams[i].language==code){ - MSG_V("Selected DVD audio channel: %d language: %c%c\n", - audio_streams[i].id, lang[0],lang[1]); + mpxp_v<<"Selected DVD audio channel: "<<audio_streams[i].id<<" language: "<<lang[0]<<lang[1]<<std::endl; return audio_streams[i].id; } } lang+=2; while (lang[0]==',' || lang[0]==' ') ++lang; } - MSG_WARN("No matching DVD audio language found!\n"); + mpxp_warn<<"No matching DVD audio language found!"<<std::endl; return -1; } @@ -180,14 +180,13 @@ code=lang[1]|(lang[0]<<8); for(i=0;i<unsigned(nr_of_subtitles);i++){ if(subtitles[i].language==code){ - MSG_V("Selected DVD subtitle channel: %d language: %c%c\n", - subtitles[i].id, lang[0],lang[1]); + mpxp_v<<"Selected DVD subtitle channel: "<<subtitles[i].id<<" language: "<<lang[0]<<lang[1]<<std::endl; return subtitles[i].id; } } lang+=2; while (lang[0]==',' || lang[0]==' ') ++lang; } - MSG_WARN("No matching DVD subtitle language found!\n"); + mpxp_warn<<"No matching DVD subtitle language found!"<<std::endl; return -1; } @@ -201,7 +200,7 @@ { int ttn,pgc_id,pgn; - MSG_V("dvd_next_title %d\n",dvd_title); + mpxp_v<<"dvd_next_title "<<dvd_title<<std::endl; if(vts_file) ifoClose(vts_file); if(title) DVDCloseFile(title); @@ -210,8 +209,7 @@ */ vts_file = ifoOpen(dvd, tt_srpt->title[dvd_title].title_set_nr ); if( !vts_file ) { - MSG_ERR( MSGTR_DVDnoIFO, - tt_srpt->title[dvd_title].title_set_nr ); + mpxp_err<<MSGTR_DVDnoIFO<<":"<<tt_srpt->title[dvd_title].title_set_nr<<std::endl; ifoClose( vmg_file ); DVDClose( dvd ); return 0; @@ -222,8 +220,7 @@ title = DVDOpenFile( dvd, tt_srpt->title[dvd_title].title_set_nr, DVD_READ_TITLE_VOBS ); if( !title ) { - MSG_ERR( MSGTR_DVDnoVOBs, - tt_srpt->title[dvd_title].title_set_nr ); + mpxp_err<<MSGTR_DVDnoVOBs<<tt_srpt->title[dvd_title].title_set_nr<<std::endl; ifoClose( vts_file ); ifoClose( vmg_file ); DVDClose( dvd ); @@ -282,17 +279,14 @@ // 1 - stereo // 5 - 5.1 audio_streams[nr_of_channels].channels=audio->channels; - MSG_V("[open] audio stream: %d audio format: %s (%s) language: %s aid: %d\n", - nr_of_channels, - dvd_audio_stream_types[ audio->audio_format ], - dvd_audio_stream_channels[ audio->channels ], - tmp, - audio_streams[nr_of_channels].id - ); + mpxp_v<<"[open] audio stream: "<<nr_of_channels + <<" audio format: "<<dvd_audio_stream_types[ audio->audio_format ] + <<" ("<<dvd_audio_stream_channels[ audio->channels ] + <<") language: "<<tmp<<" aid: "<<audio_streams[nr_of_channels].id<<std::endl; nr_of_channels++; } } - MSG_V("[open] number of audio channels on disk: %d.\n",nr_of_channels ); + mpxp_v<<"[open] number of audio channels on disk: "<<nr_of_channels<<std::endl; } /** @@ -322,13 +316,11 @@ else if(video->display_aspect_ratio == 3) /* 16:9 */ subtitles[nr_of_subtitles].id = vts_file->vts_pgcit->pgci_srp[ttn].pgc->subp_control[i] >> 8 & 31; - MSG_V("[open] subtitle ( sid ): %d language: %s\n", - nr_of_subtitles, - tmp ); + mpxp_v<<"[open] subtitle ( sid ): "<<nr_of_subtitles<<" language: "<<tmp<<std::endl; nr_of_subtitles++; } } - MSG_V("[open] number of subtitles on disk: %d\n",nr_of_subtitles ); + mpxp_v<<"[open] number of subtitles on disk: "<<nr_of_subtitles<<std::endl; /** * Determine which program chain we want to watch. This is based on the * chapter number. @@ -350,14 +342,14 @@ if( cur_pgc->cell_playback[cur_cell].block_type == BLOCK_TYPE_ANGLE_BLOCK ) cur_cell+=dvd_angle; cur_pack = cur_pgc->cell_playback[ cur_cell ].first_sector; cell_last_pack=cur_pgc->cell_playback[ cur_cell ].last_sector; - MSG_V( "DVD start cell: %d pack: 0x%X-0x%X \n",cur_cell,cur_pack,cell_last_pack); + mpxp_v<<"DVD start cell: "<<cur_cell<<" pack: 0x"<<std::hex<<cur_pack<<"-0x"<<std::hex<<cell_last_pack<<std::endl; return 1; } int DvdRead_Stream_Interface::next_cell(){ int _next_cell=cur_cell; - MSG_V( "dvd_next_cell: next1=0x%X \n",_next_cell); + mpxp_v<<"dvd_next_cell: next1=0x"<<std::hex<<_next_cell<<std::endl; if( cur_pgc->cell_playback[ _next_cell ].block_type == BLOCK_TYPE_ANGLE_BLOCK ) { while(_next_cell<last_cell) { @@ -365,7 +357,7 @@ ++_next_cell; } } - MSG_V( "dvd_next_cell: next2=0x%X \n",_next_cell); + mpxp_v<<"dvd_next_cell: next2=0x"<<std::hex<<_next_cell<<std::endl; ++_next_cell; if(_next_cell>=last_cell) return -1; // EOF @@ -373,7 +365,7 @@ _next_cell+=dvd_angle; if(_next_cell>=last_cell) return -1; // EOF } - MSG_V( "dvd_next_cell: next3=0x%X \n",_next_cell); + mpxp_v<<"dvd_next_cell: next3=0x"<<std::hex<<_next_cell<<std::endl; return _next_cell; } @@ -394,10 +386,10 @@ if( dsi_pack.vobu_sri.next_vobu != SRI_END_OF_CELL ) { cur_pack= dsi_pack.dsi_gi.nv_pck_lbn + ( dsi_pack.vobu_sri.next_vobu & 0x3fffffff ); - MSG_V( "Navi new pos=0x%X \n",cur_pack); + mpxp_v<<"Navi new pos=0x"<<std::hex<<cur_pack<<std::endl; } else { // end of cell! find next cell! - MSG_V( "--- END OF CELL !!! ---\n"); + mpxp_v<<"--- END OF CELL !!! ---"<<std::endl; cur_pack=cell_last_pack+1; } } @@ -411,7 +403,7 @@ // == BLOCK_TYPE_ANGLE_BLOCK ) cur_cell+=dvd_angle; cur_pack = cur_pgc->cell_playback[ cur_cell ].first_sector; cell_last_pack=cur_pgc->cell_playback[ cur_cell ].last_sector; - MSG_V( "DVD next cell: %d pack: 0x%X-0x%X \n",cur_cell,cur_pack,cell_last_pack); + mpxp_v<<"DVD next cell: "<<cur_cell<<" pack: 0x"<<std::hex<<cur_pack<<"-0x"<<std::hex<<cell_last_pack<<std::endl; } else if(cur_title<last_title) { cur_title++; next_title(cur_title); @@ -454,22 +446,19 @@ > Invalid NAVIpacket! lba=30 gsi_navi=8002F pci_navi=8002F angle=0 */ if(cur_pack != dsi_pack.dsi_gi.nv_pck_lbn){ - MSG_V( "Invalid NAVIpacket! lba=%X gsi_navi=%X pci_navi=%X angle=%X\n" - ,cur_pack - ,dsi_pack.dsi_gi.nv_pck_lbn - ,pci_pack.pci_gi.nv_pck_lbn - ,dsi_pack.sml_agli.data[dvd_angle].address - ); + mpxp_v<<"Invalid NAVIpacket! lba="<<std::hex<<cur_pack + <<" gsi_navi="<<std::hex<<dsi_pack.dsi_gi.nv_pck_lbn + <<" pci_navi="<<std::hex<<pci_pack.pci_gi.nv_pck_lbn + <<" angle=%"<<std::hex<<dsi_pack.sml_agli.data[dvd_angle].address<<std::endl; } else { // process! vobu_s_pts=pci_pack.pci_gi.vobu_s_ptm/90000.; vobu_e_pts=pci_pack.pci_gi.vobu_e_ptm/90000.; packs_left = dsi_pack.dsi_gi.vobu_ea; - MSG_V( "Found NAVI packet! lba=%X angle=%X len=%d vobu_s_pts=%f vobu_e_pts=%f\n" - ,cur_pack,packs_left - ,dsi_pack.sml_agli.data[dvd_angle].address - ,vobu_s_pts,vobu_e_pts); - + mpxp_v<<"Found NAVI packet! lba="<<std::hex<<cur_pack + <<" angle="<<std::hex<<packs_left + <<" len="<<dsi_pack.sml_agli.data[dvd_angle].address + <<" vobu_s_pts="<<vobu_s_pts<<" vobu_e_pts="<<vobu_e_pts<<std::endl; if(angle_seek){ int skip=0; unsigned i; @@ -495,13 +484,13 @@ cur_pack=dsi_pack.dsi_gi.nv_pck_lbn+ dsi_pack.sml_agli.data[dvd_angle].address; angle_seek=0; - MSG_V("Angle-seek synced using sml_agli map! new_lba=0x%X\n",cur_pack); + mpxp_v<<"Angle-seek synced using sml_agli map! new_lba=0x"<<std::hex<<cur_pack<<std::endl; } else { // check if we're in the right cell, jump otherwise: if( (dsi_pack.dsi_gi.vobu_c_idn==cur_pgc->cell_position[cur_cell].cell_nr) && (dsi_pack.dsi_gi.vobu_vob_idn==cur_pgc->cell_position[cur_cell].vob_id_nr) ){ angle_seek=0; - MSG_V("Angle-seek synced by cell/vob IDN search!\n"); + mpxp_v<<"Angle-seek synced by cell/vob IDN search!"<<std::endl; } else { // wrong angle, skip this vobu: cur_pack=dsi_pack.dsi_gi.nv_pck_lbn+ @@ -512,7 +501,7 @@ } if(vobu_s_pts < vobu_e_pts) { _stream_pts += vobu_e_pts-vobu_s_pts; - MSG_V("DVD's discontinuities found! Applying delta: %f\n",_stream_pts); + mpxp_v<<"DVD's discontinuities found! Applying delta: "<<_stream_pts<<std::endl; } else _stream_pts = vobu_s_pts; } @@ -572,8 +561,9 @@ _stream_pts=vobu_s_pts=vobu_e_pts=0.; } - MSG_V( "DVD Seek! lba=0x%X cell=%d packs: 0x%X-0x%X \n", - cur_pack,cur_cell,cur_pgc->cell_playback[ cur_cell ].first_sector,cell_last_pack); + mpxp_v<<"DVD Seek! lba=0x"<<std::hex<<cur_pack + <<" cell="<<cur_cell<<" packs: 0x"<<std::hex<<cur_pgc->cell_playback[ cur_cell ].first_sector + <<"-0x"<<cell_last_pack<<std::endl; // if we're in interleaved multi-angle cell, find the right angle chain! // (read Navi block, and use the seamless angle jump table) @@ -601,7 +591,7 @@ last_title=-1; if(filename=="help" || filename.length()==10) { - MSG_HINT("Usage: dvdread://<@device>#<titleno>-<lasttitle>,<chapter>-<lastchapter>,<angle>\n"); + mpxp_hint<<"Usage: dvdread://<@device>#<titleno>-<lasttitle>,<chapter>-<lastchapter>,<angle>"<<std::endl; return MPXP_False; } args=mrl_parse_line(filename,NULL,NULL,&dvd_device,NULL); @@ -630,12 +620,12 @@ */ dvd = DVDOpen(dvd_device?dvd_device:DEFAULT_DVD_DEVICE); if( !dvd ) { - MSG_ERR(MSGTR_CantOpenDVD,dvd_device?dvd_device:DEFAULT_DVD_DEVICE); + mpxp_err<<MSGTR_CantOpenDVD<<":"<<(dvd_device?dvd_device:DEFAULT_DVD_DEVICE)<<std::endl; if(dvd_device) delete dvd_device; return MPXP_False; } if(dvd_device) delete dvd_device; - MSG_V(MSGTR_DVDwait); + mpxp_v<<MSGTR_DVDwait<<std::endl; /** * Load the video manager to find out the information about the titles on @@ -643,7 +633,7 @@ */ vmg_file = ifoOpen( dvd, 0 ); if( !vmg_file ) { - MSG_ERR( "Can't open VMG info!\n"); + mpxp_err<<"Can't open VMG info!"<<std::endl; DVDClose( dvd ); return MPXP_False; } @@ -651,10 +641,9 @@ /** * Make sure our title number is valid. */ - MSG_INFO( MSGTR_DVDnumTitles, - tt_srpt->nr_of_srpts ); + mpxp_info<<MSGTR_DVDnumTitles<<":"<<tt_srpt->nr_of_srpts<<std::endl; if( dvd_title < 1 || dvd_title > tt_srpt->nr_of_srpts ) { - MSG_ERR( MSGTR_DVDinvalidTitle, dvd_title); + mpxp_err<<MSGTR_DVDinvalidTitle<<":"<<dvd_title<<std::endl; ifoClose( vmg_file ); DVDClose( dvd ); return MPXP_False; @@ -665,17 +654,16 @@ /** * Make sure the chapter number is valid for this title. */ - MSG_INFO( MSGTR_DVDnumChapters, - tt_srpt->title[dvd_title].nr_of_ptts ); + mpxp_info<<MSGTR_DVDnumChapters<<":"<<tt_srpt->title[dvd_title].nr_of_ptts<<std::endl; if( dvd_chapter<1 || dvd_chapter>tt_srpt->title[dvd_title].nr_of_ptts ) { - MSG_ERR( MSGTR_DVDinvalidChapter, dvd_chapter); + mpxp_err<<MSGTR_DVDinvalidChapter<<":"<<dvd_chapter<<std::endl; ifoClose( vmg_file ); DVDClose( dvd ); return MPXP_False; } if( dvd_last_chapter>0 ) { if ( dvd_last_chapter<dvd_chapter || dvd_last_chapter>tt_srpt->title[dvd_title].nr_of_ptts ) { - MSG_ERR( "Invalid DVD last chapter number: %d\n", dvd_last_chapter); + mpxp_err<<"Invalid DVD last chapter number: "<<dvd_last_chapter<<std::endl; ifoClose( vmg_file ); DVDClose( dvd ); return MPXP_False; @@ -686,10 +674,9 @@ /** * Make sure the angle number is valid for this title. */ - MSG_V( MSGTR_DVDnumAngles, - tt_srpt->title[dvd_title].nr_of_angles ); + mpxp_v<<MSGTR_DVDnumAngles<<":"<<tt_srpt->title[dvd_title].nr_of_angles<<std::endl; if( dvd_angle<1 || dvd_angle>tt_srpt->title[dvd_title].nr_of_angles ) { - MSG_ERR( MSGTR_DVDinvalidAngle, dvd_angle); + mpxp_err<<MSGTR_DVDinvalidAngle<<":"<<dvd_angle<<std::endl; ifoClose( vmg_file ); DVDClose( dvd ); return MPXP_False; @@ -708,7 +695,7 @@ _end_pos=(off_t)(cur_pgc->cell_playback[last_cell-1].last_sector)*2048; next_title(dvd_title); - MSG_V( MSGTR_DVDopenOk); + mpxp_ok<<MSGTR_DVDopenOk<<std::endl; spos=0; return MPXP_Ok; Modified: mplayerxp/libmpstream2/s_file.cpp =================================================================== --- mplayerxp/libmpstream2/s_file.cpp 2012-12-21 15:12:47 UTC (rev 593) +++ mplayerxp/libmpstream2/s_file.cpp 2012-12-21 17:47:42 UTC (rev 594) @@ -53,7 +53,7 @@ if(filename=="-") fd=0; else fd=::open(filename.c_str(),O_RDONLY); if(fd<0) { - MSG_ERR("[s_file] Cannot open file: '%s'\n",filename.c_str()); + mpxp_err<<"[s_file] Cannot open file: "<<filename<<std::endl; return MPXP_False; } was_open = (fd==0)?0:1; Modified: mplayerxp/libmpstream2/s_ftp.cpp =================================================================== --- mplayerxp/libmpstream2/s_ftp.cpp 2012-12-21 15:12:47 UTC (rev 593) +++ mplayerxp/libmpstream2/s_ftp.cpp 2012-12-21 17:47:42 UTC (rev 594) @@ -117,12 +117,12 @@ break; } if(!tcp.has_data(15)) { - MSG_ERR("[ftp] read timed out\n"); + mpxp_err<<"[ftp] read timed out"<<std::endl; retval = -1; break; } if ((x = tcp.read((uint8_t*)cput,cleft)) == -1) { - MSG_ERR("[ftp] read error: %s\n",strerror(errno)); + mpxp_err<<"[ftp] read error: "<<strerror(errno)<<std::endl; retval = -1; break; } @@ -151,7 +151,7 @@ r = atoi(response)/100; if(rsp) strcpy(rsp,response); - MSG_V("[ftp] < %s",response); + mpxp_v<<"[ftp] < "<<response; if (response[3] == '-') { strncpy(match,response,3); @@ -159,10 +159,10 @@ match[4] = '\0'; do { if (readline(response,256) == -1) { - MSG_ERR("[ftp] Control socket read failed\n"); + mpxp_err<<"[ftp] Control socket read failed"<<std::endl; return 0; } - MSG_V("[ftp] < %s",response); + mpxp_v<<"[ftp] < "<<response; } while (strncmp(response,match,4)); } return r; @@ -174,12 +174,12 @@ int l = _cmd.length(); int hascrlf = cmd[l - 2] == '\r' && cmd[l - 1] == '\n'; - if(hascrlf && l == 2) MSG_V("\n"); - else MSG_V("[ftp] > %s",cmd); + if(hascrlf && l == 2) mpxp_v<<std::endl; + else mpxp_v<<"[ftp] > "<<cmd; while(l > 0) { int s = tcp.write((const uint8_t*)cmd,l); if(s <= 0) { - MSG_ERR("[ftp] write error: %s\n",strerror(errno)); + mpxp_err<<"[ftp] write error: "<<strerror(errno)<<std::endl; return 0; } cmd += s; @@ -197,12 +197,12 @@ resp = SendCmd("PASV",rsp_txt); if(resp != 2) { - MSG_WARN("[ftp] command 'PASV' failed: %s\n",rsp_txt); + mpxp_warn<<"[ftp] command 'PASV' failed: "<<rsp_txt<<std::endl; return 0; } par = strchr(rsp_txt,'('); if(!par || !par[0] || !par[1]) { - MSG_ERR("[ftp] invalid server response: %s ??\n",rsp_txt); + mpxp_err<<"[ftp] invalid server response: "<<rsp_txt<<std::endl; return 0; } sscanf(par+1,"%u,%u,%u,%u,%u,%u",&num[0],&num[1],&num[2],&num[3],&num[4],&num[5]); @@ -210,7 +210,7 @@ url.redirect(str); tcp.open(url); - if(!tcp.established()) MSG_ERR("[ftp] failed to create data connection\n"); + if(!tcp.established()) mpxp_err<<"[ftp] failed to create data connection"<<std::endl; return 1; } @@ -227,7 +227,7 @@ snprintf(str,255,"REST %"PRId64, (int64_t)newpos); resp = SendCmd(str,rsp_txt); if(resp != 3) { - MSG_WARN("[ftp] command '%s' failed: %s\n",str,rsp_txt); + mpxp_warn<<"[ftp] command '"<<str<<"' failed: "<<rsp_txt<<std::endl; newpos = 0; } } @@ -236,7 +236,7 @@ resp = SendCmd(str,rsp_txt); if(resp != 1) { - MSG_ERR("[ftp] command '%s' failed: %s\n",str,rsp_txt); + mpxp_err<<"[ftp] command '"<<str<<"' failed: "<<rsp_txt<<std::endl; return 0; } spos = newpos; @@ -249,10 +249,10 @@ if(!OpenData(spos)) return -1; if(!tcp.has_data(15)) { - MSG_ERR("[ftp] read timed out\n"); + mpxp_err<<"[ftp] read timed out"<<std::endl; return -1; } - MSG_V("ftp read: %u bytes\n",sp->len); + mpxp_v<<"ftp read: "<<sp->len<<" bytes"<<std::endl; r = tcp.read((uint8_t*)sp->buf,sp->len); spos+=r; return (r <= 0) ? -1 : r; @@ -263,13 +263,13 @@ char rsp_txt[256]; if(spos==newpos) return spos; - MSG_V("ftp seek: %llu bytes\n",newpos); + mpxp_v<<"ftp seek: "<<newpos<<" bytes"<<std::endl; if(spos > file_len) return 0; // Check to see if the server did not already terminate the transfer if(tcp.has_data(0)) { if(readresp(rsp_txt) != 2) - MSG_WARN("[ftp] Warning the server didn't finished the transfer correctly: %s\n",rsp_txt); + mpxp_warn<<"[ftp] Warning the server didn't finished the transfer correctly: "<<rsp_txt<<std::endl; tcp.close(); } @@ -287,7 +287,7 @@ // Or the 226 Transfer complete resp = readresp(rsp_txt); if(resp != 4 && resp != 2) { - MSG_ERR("[ftp] Server didn't abort correctly: %s\n",rsp_txt); + mpxp_err<<"[ftp] Server didn't abort correctly: "<<rsp_txt<<std::endl; return 0; } // Send the ABOR command @@ -322,15 +322,12 @@ // url = check4proxies (rurl); if(url.host().empty() && !url.file().empty()) { bad_url: - MSG_ERR("[ftp] Bad url\n"); + mpxp_err<<"[ftp] Bad url"<<std::endl; return MPXP_False; } if(url.user().empty()) url.set_login("anonymous","no@spam"); url.assign_port(21); - MSG_V("FTP: Opening ~%s :%s @%s :%i %s\n" - ,url.user().c_str(),url.password().c_str(),url.host().c_str(), - url.port(),url.file().c_str()); - + mpxp_v<<"FTP: Opening ~"<<url.user()<<" :"<<url.password()<<" @"<<url.host()<<" :"<<url.port()<<" "<<url.file()<<std::endl; // Open the control connection tcp.open(url); @@ -351,12 +348,12 @@ snprintf(str,255,"PASS %s",url.password().c_str()); resp = SendCmd(str,rsp_txt); if(resp != 2) { - MSG_ERR("[ftp] command '%s' failed: %s\n",str,rsp_txt); + mpxp_err<<"[ftp] command '"<<str<<"' failed: "<<rsp_txt<<std::endl; close(); return MPXP_False; } } else if(resp != 2) { - MSG_ERR("[ftp] command '%s' failed: %s\n",str,rsp_txt); + mpxp_err<<"[ftp] command '"<<str<<"' failed: "<<rsp_txt<<std::endl; close(); return MPXP_False; } @@ -364,7 +361,7 @@ // Set the transfer type resp = SendCmd("TYPE I",rsp_txt); if(resp != 2) { - MSG_ERR("[ftp] command 'TYPE I' failed: %s\n",rsp_txt); + mpxp_err<<"[ftp] command 'TYPE I' failed: "<<rsp_txt<<std::endl; close(); return MPXP_False; } @@ -372,14 +369,14 @@ // Get System of FTP resp = SendCmd("SYST",rsp_txt); if(resp != 2) { - MSG_ERR("[ftp] command 'SYST' failed: %s\n",rsp_txt); + mpxp_err<<"[ftp] command 'SYST' failed: "<<rsp_txt<<std::endl; close(); return MPXP_False; } - MSG_INFO("[ftp] System: %s\n",rsp_txt); + mpxp_info<<"[ftp] System: "<<rsp_txt<<std::endl; resp = SendCmd("STAT",rsp_txt); if(resp != 2) { - MSG_ERR("[ftp] command 'STAT' failed: %s\n",rsp_txt); + mpxp_err<<"[ftp] command 'STAT' failed: "<<rsp_txt<<std::endl; close(); return MPXP_False; } @@ -389,7 +386,7 @@ snprintf(str,255,"SIZE %s",url.file().c_str()); resp = SendCmd(str,rsp_txt); if(resp != 2) { - MSG_WARN("[ftp] command '%s' failed: %s\n",str,rsp_txt); + mpxp_warn<<"[ftp] command '"<<str<<"' failed: "<<rsp_txt<<std::endl; } else { int dummy; sscanf(rsp_txt,"%d %"PRId64,&dummy,&file_len); Modified: mplayerxp/libmpstream2/s_lavc.cpp =================================================================== --- mplayerxp/libmpstream2/s_lavc.cpp 2012-12-21 15:12:47 UTC (rev 593) +++ mplayerxp/libmpstream2/s_lavc.cpp 2012-12-21 17:47:42 UTC (rev 594) @@ -73,7 +73,7 @@ UNUSED(flags); av_register_all(); - MSG_V("[lavc] Opening %s\n", filename.c_str()); + mpxp_v<<"[lavc] Opening "<<filename<<std::endl; if (ffurl_open(&ctx, filename.c_str(), 0, &int_cb, NULL) < 0) return MPXP_False; spos = 0; Modified: mplayerxp/libmpstream2/s_network.cpp =================================================================== --- mplayerxp/libmpstream2/s_network.cpp 2012-12-21 15:12:47 UTC (rev 593) +++ mplayerxp/libmpstream2/s_network.cpp 2012-12-21 17:47:42 UTC (rev 594) @@ -53,10 +53,10 @@ UNUSED(flags); if(url.redirect(filename)==MPXP_Ok) { if((networking=Networking::start(tcp,url))==NULL){ - MSG_ERR(MSGTR_UnableOpenURL, filename.c_str()); + mpxp_err<<MSGTR_UnableOpenURL<<":"<<filename<<std::endl; return MPXP_False; } - MSG_INFO(MSGTR_ConnToServer, url.host().c_str()); + mpxp_info<<MSGTR_ConnToServer<<":"<<url.host()<<std::endl; spos = 0; return MPXP_Ok; } @@ -82,7 +82,7 @@ if(networking!=NULL) { newpos=networking->seek(tcp, pos); if( newpos<0 ) { - MSG_WARN("Stream not seekable!\n"); + mpxp_warn<<"Stream not seekable!"<<std::endl; return 1; } } Modified: mplayerxp/libmpstream2/s_oss.cpp =================================================================== --- mplayerxp/libmpstream2/s_oss.cpp 2012-12-21 15:12:47 UTC (rev 593) +++ mplayerxp/libmpstream2/s_oss.cpp 2012-12-21 17:47:42 UTC (rev 594) @@ -64,7 +64,7 @@ int err; UNUSED(flags); if(filename=="help") { - MSG_HINT("Usage: oss://<@device>#<channels>,<samplerate>,<sampleformat>\n"); + mpxp_hint<<"Usage: oss://<@device>#<channels>,<samplerate>,<sampleformat>"<<std::endl; return MPXP_False; } args=mp_strdup(mrl_parse_line(filename,NULL,NULL,&oss_device,NULL)); @@ -93,9 +93,9 @@ tmp = samplerate; err=0; if (::ioctl(fd, SNDCTL_DSP_SPEED, &samplerate)<0) - MSG_ERR("[s_oss] Can't set samplerate to %u (will use %u)\n",tmp,samplerate); + mpxp_err<<"[s_oss] Can't set samplerate to "<<tmp<<" (will use "<<samplerate<<")"<<std::endl; else - MSG_DBG2("[o_oss] Did set samplerate to %u\n",samplerate); + mpxp_dbg2<<"[o_oss] Did set samplerate to "<<samplerate<<std::endl; tmp = nchannels; if(tmp>2) err=::ioctl(fd, SNDCTL_DSP_CHANNELS, &nchannels); @@ -104,8 +104,8 @@ err=::ioctl(fd, SNDCTL_DSP_STEREO, ¶m); nchannels=param?2:1; } - if(err<0) MSG_ERR("[s_oss] Can't set channels to %u (will use %u)\n",tmp,nchannels); - else MSG_DBG2("[o_oss] Did set channels to %u\n",nchannels); + if(err<0) mpxp_err<<"[s_oss] Can't set channels to "<<tmp<<" (will use "<<nchannels<<")"<<std::endl; + else mpxp_dbg2<<"[o_oss] Did set channels to "<<nchannels<<std::endl; mp_aframe_t afd; int oss_fmt; afd.rate=samplerate; @@ -114,27 +114,27 @@ oss_fmt=mpaf2afmt(sampleformat); tmp=oss_fmt; if(::ioctl(fd, SNDCTL_DSP_SETFMT, &oss_fmt)<0) - MSG_ERR("[s_oss] Can't set format %s (will use %s)\n",ao_format_name(tmp),ao_format_name(oss_fmt)); + mpxp_err<<"[s_oss] Can't set format "<<ao_format_name(tmp)<<" (will use "<<ao_format_name(oss_fmt)<<")"<<std::endl; else - MSG_DBG2("[o_oss] Did set format to %s\n",ao_format_name(oss_fmt)); + mpxp_dbg2<<"[o_oss] Did set format to "<<ao_format_name(oss_fmt)<<std::endl; tmp = PCM_ENABLE_INPUT; if(::ioctl(fd, SNDCTL_DSP_SETTRIGGER, &tmp)<0) - MSG_ERR("[s_oss] Can't enable input\n"); + mpxp_err<<"[s_oss] Can't enable input"<<std::endl; else - MSG_DBG2("[o_oss] Did set trigger to %u\n",tmp); + mpxp_dbg2<<"[o_oss] Did set trigger to "<<tmp<<std::endl; _sector_size = 0; err = ::ioctl(fd, SNDCTL_DSP_GETBLKSIZE, &_sector_size); if (err < 0) - MSG_ERR("[s_oss] Can't get blocksize\n"); + mpxp_err<<"[s_oss] Can't get blocksize"<<std::endl; else - MSG_DBG2("[o_oss] Did get blocksize as %u\n",_sector_size); + mpxp_dbg2<<"[o_oss] Did get blocksize as "<<_sector_size<<std::endl; // correct the blocksize to a reasonable value if (_sector_size <= 0) { _sector_size = 4096*nchannels*(sampleformat&MPAF_BPS_MASK); } else if (_sector_size < 4096*nchannels*(sampleformat&MPAF_BPS_MASK)) { _sector_size *= 4096*nchannels*(sampleformat&MPAF_BPS_MASK)/_sector_size; } - MSG_DBG2("[o_oss] Correct blocksize as %u\n",_sector_size); + ... [truncated message content] |
From: <nic...@us...> - 2012-12-22 12:15:57
|
Revision: 595 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=595&view=rev Author: nickols_k Date: 2012-12-22 12:15:42 +0000 (Sat, 22 Dec 2012) Log Message: ----------- convert MSG_* into mpxp_ostream compatible output Modified Paths: -------------- mplayerxp/libmpstream2/cache2.cpp mplayerxp/libmpstream2/cdda.cpp mplayerxp/libmpstream2/cddb.cpp mplayerxp/libmpstream2/cookies.cpp mplayerxp/libmpstream2/http.cpp mplayerxp/libmpstream2/librtsp/rtsp.cpp mplayerxp/libmpstream2/librtsp/rtsp_rtp.cpp mplayerxp/libmpstream2/librtsp/rtsp_session.cpp mplayerxp/libmpstream2/mrl.cpp mplayerxp/libmpstream2/network.cpp mplayerxp/libmpstream2/network_asf.cpp mplayerxp/libmpstream2/network_asf_mmst.cpp mplayerxp/libmpstream2/network_nop.cpp mplayerxp/libmpstream2/pnm.cpp mplayerxp/libmpstream2/realrtsp/asmrp.cpp mplayerxp/libmpstream2/realrtsp/real.cpp mplayerxp/libmpstream2/realrtsp/rmff.cpp mplayerxp/libmpstream2/realrtsp/sdpplin.cpp mplayerxp/libmpstream2/rtp_cache.cpp mplayerxp/libmpstream2/stream_msg.h mplayerxp/libmpstream2/tcp.cpp mplayerxp/libmpstream2/tvi/tvi_bsdbt848.cpp mplayerxp/libmpstream2/tvi/tvi_v4l.cpp mplayerxp/libmpstream2/udp.cpp mplayerxp/libmpstream2/url.cpp mplayerxp/nls/mpxp_help-en.h mplayerxp/nls/mpxp_help-ru.h Modified: mplayerxp/libmpstream2/cache2.cpp =================================================================== --- mplayerxp/libmpstream2/cache2.cpp 2012-12-21 17:47:42 UTC (rev 594) +++ mplayerxp/libmpstream2/cache2.cpp 2012-12-22 12:15:42 UTC (rev 595) @@ -84,7 +84,7 @@ inline void COREDUMP() {} #endif -inline void C2_ASSERT(int cond) { if(cond) MSG_FATAL("internal error at cache2.c: (%i)\n",cond); } +inline void C2_ASSERT(int cond) { if(cond) mpxp_fatal<<"internal error at cache2.c: "<<cond<<std::endl; } static int __FASTCALL__ c2_cache_fill(cache_vars_t* c){ int len,in_cache,legacy_eof,seek_eof; @@ -99,16 +99,17 @@ seek_eof=0; if(!in_cache && c->stream->type()&Stream::Type_Seekable) { /* seeking... */ - MSG_DBG2("Out of boundaries... seeking to %lli {in_cache(%i) %lli<%lli>%lli} \n" - ,new_start,in_cache,START_FILEPOS(*c),readpos,END_FILEPOS(*c)); + mpxp_dbg2<<"Out of boundaries... seeking to "<<new_start + <<" {in_cache("<<in_cache<<") " + <<START_FILEPOS(*c)<<"<"<<readpos<<">"<<END_FILEPOS(*c)<<"}"<<std::endl; if(c->stream->eof() || c->eof) c->stream->reset(); c->stream->seek(new_start); - if(errno) { MSG_WARN("c2_seek(drv:%s) error: %s\n",c->stream->driver_info->mrl,strerror(errno)); errno=0; } + if(errno) { mpxp_warn<<"c2_seek(drv:"<<c->stream->driver_info->mrl<<") error: "<<strerror(errno)<<std::endl; errno=0; } if((c->packets[c->first].filepos=c->stream->tell())<0) seek_eof=1; c->last=c->first; if(c->packets[c->first].filepos < new_start-(off_t)c->stream->sector_size()) - MSG_WARN("CACHE2: found wrong offset after seeking %lli (wanted: %lli)\n",c->packets[c->first].filepos,new_start); - MSG_DBG2("Seek done. new pos: %lli\n",START_FILEPOS(*c)); + mpxp_warn<<"CACHE2: found wrong offset after seeking "<<c->packets[c->first].filepos<<" (wanted: "<<new_start<<")"<<std::endl; + mpxp_dbg2<<"Seek done. new pos: "<<START_FILEPOS(*c)<<std::endl; } else { /* find new start of buffer according on readpos */ cidx=c->first; @@ -117,12 +118,12 @@ && !c->packets[cidx].sp.type) break; cidx=CP_NEXT(*c,cidx); }while(cidx!=c->first); - MSG_DBG2("CACHE2: Assigning first as %p for %lli\n",c->first,START_FILEPOS(*c)); + mpxp_dbg2<<"CACHE2: Assigning first as "<<reinterpret_cast<any_t*>(c->first)<<" for "<<START_FILEPOS(*c)<<std::endl; c->first=cidx; } CACHE2_TUNLOCK(*c); if(CP_NEXT(*c,c->last) == c->first || c->eof) { - MSG_DBG2("CACHE2: cache full\n"); + mpxp_dbg2<<"CACHE2: cache full"<<std::endl; return 0; /* cache full */ } len=0; @@ -136,24 +137,24 @@ c->packets[cidx].sp.len=c->sector_size; c->packets[cidx].filepos = c->stream->tell(); c->stream->read(c->packets[cidx].sp.buf,c->packets[cidx].sp.len); - MSG_DBG2("CACHE2: read_packet at %lli (wanted %u got %u type %i)",c->packets[cidx].filepos,c->sector_size,c->packets[cidx].sp.len,c->packets[cidx].sp.type); + mpxp_dbg2<<"CACHE2: read_packet at "<<c->packets[cidx].filepos<<" (wanted "<<c->sector_size<<" got "<<c->packets[cidx].sp.len<<" type "<<c->packets[cidx].sp.type<<")"; if(mp_conf.verbose>1) if(c->packets[cidx].sp.len>8) { int i; for(i=0;i<8;i++) - MSG_DBG2("%02X ",(int)(unsigned char)c->packets[cidx].sp.buf[i]); + mpxp_dbg2<<std::hex<<(unsigned)(unsigned char)c->packets[cidx].sp.buf[i]<<" "; } - MSG_DBG2("\n"); + mpxp_dbg2<<std::endl; if(c->stream->ctrl(SCTRL_EOF,NULL)==MPXP_Ok) legacy_eof=1; else legacy_eof=0; if(c->packets[cidx].sp.len < 0 || (c->packets[cidx].sp.len == 0 && c->packets[cidx].sp.type == 0) || legacy_eof || seek_eof) { /* EOF */ - MSG_DBG2("CACHE2: guess EOF: %lli %lli\n",START_FILEPOS(*c),END_FILEPOS(*c)); + mpxp_dbg2<<"CACHE2: guess EOF: "<<START_FILEPOS(*c)<<" "<<END_FILEPOS(*c)<<std::endl; c->packets[cidx].state|=CPF_EOF; c->eof=1; c->packets[cidx].state&=~CPF_EMPTY; c->packets[cidx].state&=~CPF_DONE; - if(errno) { MSG_WARN("c2_fill_buffer(drv:%s) error: %s\n",c->stream->driver_info->mrl,strerror(errno)); errno=0; } + if(errno) { mpxp_warn<<"c2_fill_buffer(drv:"<<c->stream->driver_info->mrl<<") error: "<<strerror(errno)<<std::endl; errno=0; } CACHE2_PACKET_TUNLOCK(c->packets[cidx]); break; } @@ -163,15 +164,15 @@ c->packets[cidx].state&=~CPF_DONE; CACHE2_PACKET_TUNLOCK(c->packets[cidx]); cidx=CP_NEXT(*c,cidx); - MSG_DBG2("CACHE2: start=%lli end_filepos = %lli\n",START_FILEPOS(*c),END_FILEPOS(*c)); + mpxp_dbg2<<"CACHE2: start="<<START_FILEPOS(*c)<<" end_filepos = "<<END_FILEPOS(*c)<<std::endl; if(cidx==c->first) { - MSG_DBG2("CACHE2: end of queue is reached: %p\n",c->first); + mpxp_dbg2<<"CACHE2: end of queue is reached: "<<reinterpret_cast<any_t*>(c->first)<<std::endl; break; } CACHE2_TUNLOCK(*c); } c->in_fill=0; - MSG_DBG2("CACHE2: totally got %u bytes\n",len); + mpxp_dbg2<<"CACHE2: totally got "<<len<<" bytes"<<std::endl; return len; } @@ -187,12 +188,12 @@ c->mem=new char [num*sector]; if(!c->packets || !c->mem) { - MSG_ERR(MSGTR_OutOfMemory); + mpxp_err<<MSGTR_OutOfMemory<<std::endl; delete c; return 0; } pmem = c->mem; - MSG_DBG2("For cache navigation was allocated %u bytes as %u packets (%u/%u)\n",i,num,size,sector); + mpxp_dbg2<<"For cache navigation was allocated "<<i<<" bytes as "<<num<<" packets ("<<size<<"/"<<sector<<")"<<std::endl; c->first=c->last=0; for(i=0;i<num;i++) { @@ -203,7 +204,7 @@ } if(mp_conf.verbose>1) for(i=0;i<num;i++) { - MSG_DBG2("sizeof(c)=%u c=%i c->sp.buf=%p\n",sizeof(cache_packet_t),i,c->packets[i].sp.buf); + mpxp_dbg2<<"sizeof(c)="<<sizeof(cache_packet_t)<<" c="<<i<<" c->sp.buf="<<reinterpret_cast<any_t*>(c->packets[i].sp.buf)<<std::endl; } c->buffer_size=num*sector; c->sector_size=sector; @@ -215,7 +216,7 @@ static void sig_cache2( void ) { - MSG_V("cache2 segfault\n"); + mpxp_v<<"cache2 segfault"<<std::endl; mpxp_print_flush(); xmp_killall_threads(pthread_self()); __exit_sighandler(); @@ -259,13 +260,13 @@ static int __FASTCALL__ c2_stream_fill_buffer(cache_vars_t* c) { - MSG_DBG2( "c2_stream_fill_buffer\n"); + mpxp_dbg2<<"c2_stream_fill_buffer"<<std::endl; if(c->eof) return 0; while(c->read_filepos>=END_FILEPOS(*c) || c->read_filepos<START_FILEPOS(*c)) { if(c->eof) break; usleep(READ_USLEEP_TIME); // 10ms - MSG_DBG2("Waiting for %lli in %lli %lli\n",c->read_filepos,START_FILEPOS(*c),END_FILEPOS(*c)); + mpxp_dbg2<<"Waiting for "<<c->read_filepos<<" in "<<START_FILEPOS(*c)<<" "<<END_FILEPOS(*c)<<std::endl; continue; // try again... } return c->eof?0:1; @@ -275,7 +276,7 @@ { unsigned cidx; int was_eof; - MSG_DBG2("c2_stream_reset\n"); + mpxp_dbg2<<"c2_stream_reset"<<std::endl; c->stream->reset(); cidx=c->first; was_eof=0; @@ -293,7 +294,7 @@ static int __FASTCALL__ c2_stream_seek_long(cache_vars_t* c,off_t pos){ - MSG_DBG2("CACHE2_SEEK: %lli,%lli,%lli <> %lli\n",START_FILEPOS(*c),c->read_filepos,END_FILEPOS(*c),pos); + mpxp_dbg2<<"CACHE2_SEEK: "<<START_FILEPOS(*c)<<","<<c->read_filepos<<","<<END_FILEPOS(*c)<<" <> "<<pos<<std::endl; if(pos<0/* || pos>END_FILEPOS(*c)*/) { c->eof=1; return 0; } while(c->in_fill) yield_timeslice(); CACHE2_LOCK(*c); @@ -325,7 +326,7 @@ retval=CP_NEXT(*c,retval); if(retval==c->first) { - MSG_DBG2("Can't find packet for offset %lli\n",pos); + mpxp_dbg2<<"Can't find packet for offset "<<pos<<std::endl; CACHE2_UNLOCK(*c); return UINT_MAX; } @@ -374,7 +375,7 @@ static unsigned c2_next_packet(cache_vars_t* c,unsigned cidx,int *len,unsigned *npackets) { - MSG_DBG2("next_packet: start=%p cur=%i\n",c->first,cidx); + mpxp_dbg2<<"next_packet: start="<<reinterpret_cast<any_t*>(c->first)<<" cur="<<cidx<<std::endl; while(1) { CACHE2_LOCK(*c); @@ -393,7 +394,7 @@ CACHE2_PACKET_UNLOCK(c->packets[cidx]); } c2_get_continious_mem(c,cidx,len,npackets); - MSG_DBG2("next_packet: rp: %lli fp: %lli len %lu type %i\n",c->read_filepos,c->packets[cidx].filepos,c->packets[cidx].sp.len,c->packets[cidx].sp.type); + mpxp_dbg2<<"next_packet: rp: "<<c->read_filepos<<" fp: "<<c->packets[cidx].filepos<<" len "<<c->packets[cidx].sp.len<<" type "<<c->packets[cidx].sp.type<<std::endl; return cidx; } @@ -405,7 +406,7 @@ cur=c2_wait_packet(c,c->read_filepos,&mlen,&npackets); eof = cur!=UINT_MAX?((int)(c->packets[cur].state&CPF_EOF)):c->eof; if(cur==UINT_MAX||eof) { if(cur!=UINT_MAX) CACHE2_PACKET_UNLOCK(c->packets[cur]); return 0; } - MSG_DBG2( "c2_stream_read %i bytes from %lli\n",total,c->read_filepos); + mpxp_dbg2<<"c2_stream_read "<<total<<" bytes from "<<c->read_filepos<<std::endl; while(len){ int x; if(c->read_filepos>=c->packets[cur].filepos+mlen){ @@ -423,7 +424,7 @@ x=mlen-buf_pos; C2_ASSERT(buf_pos>=(unsigned)mlen); if(x>len) x=len; - if(!x) MSG_WARN( "c2_read: dead-lock\n"); + if(!x) mpxp_warn<<"c2_read: dead-lock"<<std::endl; memcpy(mem,&c->packets[cur].sp.buf[buf_pos],x); buf_pos+=x; mem+=x; len-=x; @@ -432,9 +433,9 @@ CACHE2_PACKET_UNLOCK(c->packets[cur]); if(mp_conf.verbose>2) { - MSG_DBG2( "c2_stream_read got %u bytes ",total); - for(i=0;i<std::min(8,total);i++) MSG_DBG2("%02X ",(int)((unsigned char)_mem[i])); - MSG_DBG2("\n"); + mpxp_dbg2<<"c2_stream_read got "<<total<<" bytes "; + for(i=0;i<std::min(8,total);i++) mpxp_dbg2<<std::hex<<(unsigned)((unsigned char)_mem[i]); + mpxp_dbg2<<std::endl; } return total; } @@ -446,7 +447,7 @@ static int __FASTCALL__ c2_stream_seek(cache_vars_t* c,off_t pos) { - MSG_DBG2( "c2_seek to %lli (%lli %lli) %i\n",(long long)pos,(long long)START_FILEPOS(*c),(long long)END_FILEPOS(*c),c->first); + mpxp_dbg2<<"c2_seek to "<<pos<<" ("<<START_FILEPOS(*c)<<" "<<END_FILEPOS(*c)<<") "<<c->first<<std::endl; if(pos>=START_FILEPOS(*c) && pos < END_FILEPOS(*c)) { c->read_filepos=pos; @@ -467,7 +468,7 @@ cur = c2_find_packet(c,c->read_filepos); if(cur!=UINT_MAX) CACHE2_PACKET_UNLOCK(c->packets[cur]); retval = cur!=UINT_MAX?((int)(c->packets[cur].state&CPF_EOF)):c->eof; - MSG_DBG2("stream_eof: %i\n",retval); + mpxp_dbg2<<"stream_eof: "<<retval<<std::endl; return retval; } @@ -482,7 +483,7 @@ CACHE2_PACKET_UNLOCK(c->packets[cur]); } c->eof=eof; - MSG_DBG2("stream_set_eof: %i\n",eof); + mpxp_dbg2<<"stream_set_eof: "<<eof<<std::endl; } /* @@ -496,7 +497,7 @@ if (!(type()&Stream::Type_Seekable)) { // The stream has no 'fd' behind it, so is non-cacheable - MSG_WARN("\rThis stream is non-cacheable\n"); + mpxp_warn<<"\rThis stream is non-cacheable"<<std::endl; return; } @@ -512,23 +513,18 @@ if((rc=xmp_register_thread(NULL,sig_cache2,cache2_routine,"cache2"))==UINT_MAX) return; c->pth=mpxp_context().engine().xp_core->mpxp_threads[rc]; // wait until cache is filled at least prefill_init % - MSG_V("CACHE_PRE_INIT: %lld [%lld] %lld pre:%d eof:%d SS=%u \n", - START_FILEPOS(*c),c->read_filepos,END_FILEPOS(*c),_min,c->eof,ss); + mpxp_v<<"CACHE_PRE_INIT: "<<START_FILEPOS(*c)<<" ["<<c->read_filepos<<"] "<<END_FILEPOS(*c)<<" pre:"<<_min<<" eof:"<<c->eof<<" SS="<<ss<<std::endl; while((c->read_filepos<START_FILEPOS(*c) || END_FILEPOS(*c)-c->read_filepos<_min) && !c->eof && CP_NEXT(*c,c->last)!=c->first){ if(!(type()&Stream::Type_Seekable)) - MSG_STATUS("\rCache fill: %5.2f%% (%d bytes) ", - 100.0*(float)(END_FILEPOS(*c)-c->read_filepos)/(float)(c->buffer_size), - END_FILEPOS(*c)-c->read_filepos); + mpxp_status<<"\rCache fill: "<<(100.0*(float)(END_FILEPOS(*c)-c->read_filepos)/(float)(c->buffer_size))<<"% ("<<(END_FILEPOS(*c)-c->read_filepos)<<" bytes) "; else - MSG_V("\rCache fill: %5.2f%% (%d bytes) ", - 100.0*(float)(END_FILEPOS(*c)-c->read_filepos)/(float)(c->buffer_size), - END_FILEPOS(*c)-c->read_filepos); + mpxp_v<<"\rCache fill: "<<(100.0*(float)(END_FILEPOS(*c)-c->read_filepos)/(float)(c->buffer_size))<<"% ("<<(END_FILEPOS(*c)-c->read_filepos)<<" bytes) "; if(c->eof) break; // file is smaller than prefill size if(mpdemux_check_interrupt(libinput,PREFILL_SLEEP_TIME)) return; } - MSG_STATUS("cache info: size=%u min=%u prefill=%u\n",size,_min,prefill); + mpxp_status<<"cache info: size="<<size<<" min="<<_min<<" prefill="<<prefill<<std::endl; return; // parent exits } Modified: mplayerxp/libmpstream2/cdda.cpp =================================================================== --- mplayerxp/libmpstream2/cdda.cpp 2012-12-21 17:47:42 UTC (rev 594) +++ mplayerxp/libmpstream2/cdda.cpp 2012-12-22 12:15:42 UTC (rev 595) @@ -85,39 +85,39 @@ cd = cdio_cddap_identify(dev.c_str(),mp_conf.verbose?1:0,NULL); if(!cd) { - MSG_ERR("Can't open cdda device: %s\n",dev.c_str()); + mpxp_err<<"Can't open cdda device: "<<dev<<std::endl; return MPXP_False; } cdio_cddap_verbose_set(cd, mp_conf.verbose?CDDA_MESSAGE_PRINTIT:CDDA_MESSAGE_FORGETIT, mp_conf.verbose?CDDA_MESSAGE_PRINTIT:CDDA_MESSAGE_FORGETIT); if(cdio_cddap_open(cd) != 0) { - MSG_ERR("Can't open disc\n"); + mpxp_err<<"Can't open disc"<<std::endl; cdda_close(cd); return MPXP_False; } cd_tracks=cdio_cddap_tracks(cd); - MSG_V("Found %d tracks on disc\n",cd_tracks); + mpxp_v<<"Found "<<cd_tracks<<" tracks on disc"<<std::endl; if(!arg[0]) for(i=1;i<=cd_tracks;i++) tracks[i-1].play=1; cdda_parse_tracks(arr,sizeof(arr)/sizeof(unsigned),arg); for(i=1;i<=256;i++) if (arr[i]) tracks[i-1].play=1; st_inited=0; - MSG_V("[CDDA] Queued tracks:"); + mpxp_v<<"[CDDA] Queued tracks:"; for(i=0;i<cd_tracks;i++) { if(tracks[i].play) { tracks[i].start_sector=cdio_cddap_track_firstsector(cd,i+1); tracks[i].end_sector=cdio_cddap_track_lastsector(cd,i+1); - MSG_V(" %d[%d-%d]",i+1,tracks[i].start_sector,tracks[i].end_sector); + mpxp_v<<" "<<i+1<<"["<<tracks[i].start_sector<<"-"<<tracks[i].end_sector<<"]"; if(!st_inited) { start_sector=tracks[i].start_sector; st_inited=1; } end_sector=tracks[i].end_sector; audiolen +=tracks[i].end_sector-tracks[i].start_sector+1; } } for(;i<256;i++) tracks[i].play=0; - MSG_V("\n"); + mpxp_v<<std::endl; min = (unsigned int)(audiolen/(60*75)); sec = (unsigned int)((audiolen/75)%60); msec = (unsigned int)(audiolen%75); @@ -138,12 +138,12 @@ for(i=0;i<256;i++){ if(tracks[i].play && tracks[i].end_sector==_sector) { cd_track=0; - MSG_V("Found track changing. old track=%u Sector=%u",i,_sector); + mpxp_v<<"Found track changing. old track="<<i<<" Sector="<<_sector<<std::endl; for(j=i+1;j<256;j++) { if(tracks[j].play && tracks[j].start_sector==_sector+1) { cd_track=tracks[j].start_sector; if(tr) *tr=j; - MSG_V("new track=%u Sector=%u",j,cd_track); + mpxp_v<<"new track="<<j<<" Sector="<<cd_track<<std::endl; } } } @@ -170,12 +170,12 @@ track_t i=255; if(cdio_cddap_read(cd, buf, sector, 1)==0) { - MSG_ERR("[CD-DA]: read error occured\n"); + mpxp_err<<"[CD-DA]: read error occured"<<std::endl; return -1; /* EOF */ } sector++; if(sector == end_sector) { - MSG_DBG2("EOF was reached\n"); + mpxp_dbg2<<"EOF was reached"<<std::endl; return -1; /* EOF */ } @@ -183,8 +183,8 @@ if(!sector) return -1; if(i!=255) { *tr=i+1; - MSG_V("Track %d, sector=%d\n", *tr, sector); - } else MSG_DBG2("Track %d, sector=%d\n", *tr, sector); + mpxp_v<<"Track "<<*tr<<", sector="<<sector<<std::endl; + } else mpxp_dbg2<<"Track "<<*tr<<", sector="<<sector<<std::endl; return CDIO_CD_FRAMESIZE_RAW; } @@ -194,7 +194,7 @@ track_t j=255; _sec = pos/CDIO_CD_FRAMESIZE_RAW; - MSG_DBG2("[CDDA] prepare seek to %ld\n",_sec); + mpxp_dbg2<<"[CDDA] prepare seek to "<<_sec<<std::endl; seeked_track=_sec; *tr=255; if( sector!=seeked_track ) { Modified: mplayerxp/libmpstream2/cddb.cpp =================================================================== --- mplayerxp/libmpstream2/cddb.cpp 2012-12-21 17:47:42 UTC (rev 594) +++ mplayerxp/libmpstream2/cddb.cpp 2012-12-22 12:15:42 UTC (rev 595) @@ -150,21 +150,21 @@ if( reply_parser==NULL || command==NULL || cddb_data==NULL ) return -1; sprintf( request, "http://%s/~cddb/cddb.cgi?cmd=%s%s&proto=%d", cddb_data->freedb_server, command, cddb_data->cddb_hello.c_str(), cddb_data->freedb_proto_level ); - MSG_V("Request[%s]\n", request ); + mpxp_v<<"Request["<<request<<"]"<<std::endl; if(url.redirect(request)!=MPXP_Ok) { - MSG_ERR("Not valid URL: '%s'\n",request); + mpxp_err<<"Not valid URL: "<<request<<std::endl; return -1; } if(http_send_request(tcp,url,0)!=MPXP_Ok) { - MSG_ERR("failed to send the http request\n"); + mpxp_err<<"failed to send the http request"<<std::endl; return -1; } HTTP_Header* http_hdr = http_read_response( tcp ); if( http_hdr==NULL ) { - MSG_ERR("Failed to read the http response\n"); + mpxp_err<<"Failed to read the http response"<<std::endl; return -1; } @@ -175,10 +175,10 @@ ret = reply_parser(*http_hdr, cddb_data); break; case 400: - MSG_V("Not Found\n"); + mpxp_v<<"Not Found"<<std::endl; break; default: - MSG_V("Unknown Error code\n"); + mpxp_v<<"Unknown Error code"<<std::endl; } delete http_hdr; @@ -188,78 +188,74 @@ } static int __FASTCALL__ cddb_read_cache(cddb_data_t *cddb_data) { - char file_name[100]; - struct stat stats; - int file_fd, ret; - size_t file_size; + char file_name[100]; + struct stat stats; + 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==NULL ) return -1; - sprintf( file_name, "%s%08lx", cddb_data->cache_dir, cddb_data->disc_id); + sprintf( file_name, "%s%08lx", cddb_data->cache_dir, cddb_data->disc_id); - file_fd = open(file_name, O_RDONLY); - if( file_fd<0 ) { - MSG_ERR("No cache found\n"); - return -1; - } + file_fd = ::open(file_name, O_RDONLY); + if( file_fd<0 ) { + mpxp_err<<"No cache found"<<std::endl; + return -1; + } - ret = fstat( file_fd, &stats ); - if( ret<0 ) { - perror("fstat"); - file_size = 4096; - } else { - file_size = stats.st_size; - } + ret = fstat( file_fd, &stats ); + if( ret<0 ) { + ::perror("fstat"); + file_size = 4096; + } else { + file_size = stats.st_size; + } - cddb_data->xmcd_file = new char [file_size]; - if( cddb_data->xmcd_file==NULL ) { - MSG_FATAL("Memory allocation failed\n"); - close(file_fd); - return -1; - } - cddb_data->xmcd_file_size = read(file_fd, cddb_data->xmcd_file, file_size); - if( cddb_data->xmcd_file_size!=file_size ) { - MSG_FATAL("Not all the xmcd file has been read\n"); - close(file_fd); - return -1; - } - - close(file_fd); - - return 0; + cddb_data->xmcd_file = new char [file_size]; + if( cddb_data->xmcd_file==NULL ) { + mpxp_fatal<<"Memory allocation failed"<<std::endl; + ::close(file_fd); + return -1; + } + cddb_data->xmcd_file_size = ::read(file_fd, cddb_data->xmcd_file, file_size); + if( cddb_data->xmcd_file_size!=file_size ) { + mpxp_fatal<<"Not all the xmcd file has been read"<<std::endl; + ::close(file_fd); + return -1; + } + ::close(file_fd); + return 0; } static int __FASTCALL__ cddb_write_cache(cddb_data_t *cddb_data) { - // We have the file, save it for cache. - char file_name[100]; - int file_fd; - int wrote=0; + // We have the file, save it for cache. + char file_name[100]; + 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==NULL ) return -1; - sprintf( file_name, "%s%08lx", cddb_data->cache_dir, cddb_data->disc_id); + sprintf( file_name, "%s%08lx", cddb_data->cache_dir, cddb_data->disc_id); - file_fd = creat(file_name, S_IREAD|S_IWRITE); - if( file_fd<0 ) { - perror("open"); - return -1; - } + file_fd = ::creat(file_name, S_IREAD|S_IWRITE); + if( file_fd<0 ) { + ::perror("open"); + return -1; + } - wrote = write(file_fd, cddb_data->xmcd_file, cddb_data->xmcd_file_size); - if( wrote<0 ) { - MSG_ERR("write: %s",strerror(errno)); - close(file_fd); - return -1; - } - if( (unsigned)wrote!=cddb_data->xmcd_file_size ) { - MSG_FATAL("Not all the xmcd file has been written\n"); - close(file_fd); - return -1; - } - - close(file_fd); - - return 0; + wrote = ::write(file_fd, cddb_data->xmcd_file, cddb_data->xmcd_file_size); + if( wrote<0 ) { + mpxp_err<<"write: "<<strerror(errno)<<std::endl; + ::close(file_fd); + return -1; + } + if( (unsigned)wrote!=cddb_data->xmcd_file_size ) { + mpxp_fatal<<"Not all the xmcd file has been written"<<std::endl; + ::close(file_fd); + return -1; + } + ::close(file_fd); + return 0; } static int cddb_read_parse(HTTP_Header& http_hdr, cddb_data_t *cddb_data) { @@ -272,7 +268,7 @@ ret = sscanf(http_hdr.get_body(), "%d ", &status); if( ret!=1 ) { - MSG_ERR("Parse error\n"); + mpxp_err<<"Parse error"<<std::endl; return -1; } @@ -280,13 +276,13 @@ case 210: ret = sscanf(http_hdr.get_body(), "%d %s %08lx", &status, category, &disc_id); if( ret!=3 ) { - MSG_ERR("Parse error\n"); + mpxp_err<<"Parse error"<<std::endl; return -1; } // Check if it's a xmcd database file ptr = strstr(const_cast<char*>(http_hdr.get_body()), "# xmcd"); if( ptr==NULL ) { - MSG_ERR("Invalid xmcd database file returned\n"); + mpxp_err<<"Invalid xmcd database file returned"<<std::endl; return -1; } // Ok found the beginning of the file @@ -295,14 +291,14 @@ if( ptr2==NULL ) { ptr2 = strstr(ptr, "\n.\n"); if( ptr2==NULL ) { - MSG_ERR("Unable to find '.'\n"); + mpxp_err<<"Unable to find '.'"<<std::endl; return -1; } } // Ok found the end // do a sanity check if( http_hdr.get_body_size()<(unsigned long)(ptr2-ptr) ) { - MSG_ERR("Unexpected fix me\n"); + mpxp_err<<"Unexpected fix me"<<std::endl; return -1; } cddb_data->xmcd_file = ptr; @@ -312,7 +308,7 @@ http_hdr.erase_body(); return cddb_write_cache(cddb_data); default: - MSG_ERR("Unhandled code\n"); + mpxp_err<<"Unhandled code"<<std::endl; } return 0; } @@ -330,7 +326,7 @@ ret = sscanf(http_hdr.get_body(), "%d ", &status); if( ret!=1 ) { - MSG_ERR("Parse error\n"); + mpxp_err<<"Parse error"<<std::endl; return -1; } @@ -339,7 +335,7 @@ // Found exact match ret = sscanf(http_hdr.get_body(), "%d %s %08lx %s", &status, cddb_data->category.c_str(), &(cddb_data->disc_id), album_title); if( ret!=4 ) { - MSG_ERR("Parse error\n"); + mpxp_err<<"Parse error"<<std::endl; return -1; } ptr = strstr(const_cast<char*>(http_hdr.get_body()), album_title); @@ -355,17 +351,17 @@ strncpy(album_title, ptr, len); album_title[len-2]='\0'; } - MSG_V("Parse OK, found: %s\n", album_title); + mpxp_v<<"Parse OK, found: "<<album_title<<std::endl; return cddb_request_titles(cddb_data); case 202: // No match found - MSG_ERR("Album not found\n"); + mpxp_err<<"Album not found"<<std::endl; break; case 210: // Found exact matches, list follows ptr = strstr(const_cast<char*>(http_hdr.get_body()), "\n"); if( ptr==NULL ) { - MSG_ERR("Unable to find end of line\n"); + mpxp_err<<"Unable to find end of line"<<std::endl; return -1; } ptr++; @@ -373,7 +369,7 @@ // we use? So let's take the first one. ret = sscanf(ptr, "%s %08lx %s", cddb_data->category.c_str(), &(cddb_data->disc_id), album_title); if( ret!=3 ) { - MSG_ERR("Parse error\n"); + mpxp_err<<"Parse error"<<std::endl; return -1; } ptr = strstr(const_cast<char*>(http_hdr.get_body()), album_title); @@ -389,7 +385,7 @@ strncpy(album_title, ptr, len); album_title[len-2]='\0'; } - MSG_V("Parse OK, found: %s\n", album_title); + mpxp_v<<"Parse OK, found: "<<album_title<<std::endl; return cddb_request_titles(cddb_data); /* body=[210 Found exact matches, list follows (until terminating `.') @@ -400,10 +396,10 @@ */ case 211: // Found inexact matches, list follows - MSG_WARN("No exact matches found, list follows\n"); + mpxp_warn<<"No exact matches found, list follows"<<std::endl; break; default: - MSG_ERR("Unhandled code\n"); + mpxp_err<<"Unhandled code"<<std::endl; } return -1; } @@ -415,7 +411,7 @@ ret = sscanf(http_hdr.get_body(), "%d ", &status); if( ret!=1 ) { - MSG_ERR("Parse error\n"); + mpxp_err<<"Parse error"<<std::endl; return -1; } @@ -423,18 +419,18 @@ case 210: ptr = strstr(const_cast<char*>(http_hdr.get_body()), "max proto:"); if( ptr==NULL ) { - MSG_ERR("Parse error\n"); + mpxp_err<<"Parse error"<<std::endl; return -1; } ret = sscanf(ptr, "max proto: %d", &max); if( ret!=1 ) { - MSG_ERR("Parse error\n"); + mpxp_err<<"Parse error"<<std::endl; return -1; } cddb_data->freedb_proto_level = max; return 0; default: - MSG_ERR("Unhandled code\n"); + mpxp_err<<"Unhandled code"<<std::endl; } return -1; } @@ -448,7 +444,7 @@ UNUSED(cddb_data); ret = sscanf((const char*)http_hdr.get_body(), "%d ", &status); if( ret!=1 ) { - MSG_ERR("Parse error\n"); + mpxp_err<<"Parse error"<<std::endl; return -1; } @@ -457,10 +453,10 @@ // Parse the sites return 0; case 401: - MSG_ERR("No sites information available\n"); + mpxp_err<<"No sites information available"<<std::endl; break; default: - MSG_ERR("Unhandled code\n"); + mpxp_err<<"Unhandled code"<<std::endl; } return -1; } @@ -508,7 +504,7 @@ cddb_create_hello(cddb_data); if( cddb_get_proto_level(cddb_data)<0 ) { - MSG_ERR("Failed to get the protocol level\n"); + mpxp_err<<"Failed to get the protocol level"<<std::endl; return -1; } @@ -539,7 +535,7 @@ } else { cddb_data.cache_dir = (char*)mp_malloc(strlen(home_dir)+strlen(cddb_cache_dir)+1); if( cddb_data.cache_dir==NULL ) { - MSG_FATAL("Memory allocation failed\n"); + mpxp_fatal<<"Memory allocation failed"<<std::endl; return MPXP_False; } sprintf(cddb_data.cache_dir, "%s%s", home_dir, cddb_cache_dir ); @@ -553,7 +549,6 @@ } if( cddb_data.xmcd_file!=NULL ) { -// printf("%s\n", cddb_data.xmcd_file ); *xmcd_file = cddb_data.xmcd_file; return MPXP_Ok; } @@ -590,8 +585,8 @@ cd_track = new(zeromem) cd_track_t; if( cd_track==NULL ) { - MSG_FATAL("Memory allocation failed\n"); - return NULL; + mpxp_fatal<<"Memory allocation failed"<<std::endl; + return NULL; } cd_track->name=track_name; cd_track->track_nb = track_nb; @@ -627,23 +622,23 @@ void CD_Info::print() const { cd_track_t *current_track; - MSG_INFO("================ CD INFO === start =========\n"); - MSG_INFO(" artist=[%s]\n" - " album=[%s]\n" - " genre=[%s]\n" - " nb_tracks=%d\n" - " length= %2d:%02d.%02d\n" - , artist.c_str() - , album.c_str() - , genre.c_str() - , nb_tracks - , min, sec, msec); + mpxp_info<<"================ CD INFO === start ========="<<std::endl; + mpxp_info<<" artist=["<<artist<<"]"<<std::endl; + mpxp_info<<" album=["<<album<<"]"<<std::endl; + mpxp_info<<" genre=["<<genre<<"]"<<std::endl; + mpxp_info<<" nb_tracks="<<nb_tracks<<std::endl; + mpxp_info<<" length= "<<min<<":"<<sec<<"."<<msec<<std::endl; current_track = first; while( current_track!=NULL ) { - MSG_V(" #%2d %2d:%02d.%02d @ %7ld\t[%s] \n", current_track->track_nb, current_track->min, current_track->sec, current_track->msec, current_track->frame_begin, current_track->name.c_str()); + mpxp_v<<" #"<<current_track->track_nb + <<" "<<current_track->min + <<":"<<current_track->sec + <<"."<<current_track->msec + <<" @ "<<current_track->frame_begin<<"\t[" + <<current_track->name<<"]"<<std::endl; current_track = current_track->next; } - MSG_INFO("================ CD INFO === end =========\n"); + mpxp_info<<"================ CD INFO === end ========="<<std::endl; } static char* __FASTCALL__ xmcd_parse_dtitle(CD_Info& cd_info,char *line) { Modified: mplayerxp/libmpstream2/cookies.cpp =================================================================== --- mplayerxp/libmpstream2/cookies.cpp 2012-12-21 17:47:42 UTC (rev 594) +++ mplayerxp/libmpstream2/cookies.cpp 2012-12-22 12:15:42 UTC (rev 595) @@ -101,24 +101,24 @@ int fd; char *buffer; - MSG_V("Loading cookie file: %s\n", filename); + mpxp_v<<"Loading cookie file: "<<filename<<std::endl; fd = open(filename, O_RDONLY); if (fd < 0) { - MSG_V("Could not open"); + mpxp_v<<"Could not open"<<std::endl; return NULL; } *length = lseek(fd, 0, SEEK_END); if (*length < 0) { - MSG_V("Could not find EOF"); + mpxp_v<<"Could not find EOF"<<std::endl; close(fd); return NULL; } if (unsigned(*length) > std::numeric_limits<size_t>::max() - 1) { - MSG_V("File too big, could not mp_malloc."); + mpxp_v<<"File too big, could not mp_malloc"<<std::endl; close(fd); return NULL; } @@ -126,14 +126,14 @@ lseek(fd, SEEK_SET, 0); if (!(buffer = new char [*length + 1])) { - MSG_V("Could not mp_malloc."); + mpxp_v<<"Could not mp_malloc"<<std::endl; close(fd); return NULL; } if (read(fd, buffer, *length) != *length) { delete buffer; - MSG_V("Read is behaving funny."); + mpxp_v<<"Read is behaving funny"<<std::endl; close(fd); return NULL; } @@ -151,7 +151,7 @@ char *ptr; off_t length; - MSG_V("Loading cookie file: %s\n", filename); + mpxp_v<<"Loading cookie file: "<<filename<<std::endl; ptr = load_file(filename, &length); if (!ptr) Modified: mplayerxp/libmpstream2/http.cpp =================================================================== --- mplayerxp/libmpstream2/http.cpp 2012-12-21 17:47:42 UTC (rev 594) +++ mplayerxp/libmpstream2/http.cpp 2012-12-22 12:15:42 UTC (rev 595) @@ -30,12 +30,12 @@ if( response==NULL) return -1; if( (unsigned)length > std::numeric_limits<size_t>::max() - buffer_size - 1) { - MSG_FATAL("Bad size in memory (re)allocation\n"); + mpxp_fatal<<"Bad size in memory (re)allocation"<<std::endl; return -1; } buffer = (uint8_t*)mp_realloc( buffer, buffer_size+length+1 ); if(buffer ==NULL ) { - MSG_FATAL("Memory allocation failed\n"); + mpxp_fatal<<"Memory allocation failed"<<std::endl; return -1; } memcpy( buffer+buffer_size, response, length ); @@ -62,7 +62,7 @@ // Get the protocol hdr_ptr = strstr( (char*)buffer, " " ); if( hdr_ptr==NULL ) { - MSG_FATAL("Malformed answer. No space separator found.\n"); + mpxp_fatal<<"Malformed answer. No space separator found"<<std::endl; return -1; } len = hdr_ptr-(char*)buffer; @@ -71,14 +71,14 @@ std::transform(sstr.begin(), sstr.end(),sstr.begin(), ::toupper); if(sstr=="HTTP") { if( sscanf( &protocol.c_str()[5],"1.%d", &(http_minor_version) )!=1 ) { - MSG_FATAL("Malformed answer. Unable to get HTTP minor version.\n"); + mpxp_fatal<<"Malformed answer. Unable to get HTTP minor version"<<std::endl; return -1; } } // Get the status code if( sscanf( ++hdr_ptr, "%d", &status_code )!=1 ) { - MSG_FATAL("Malformed answer. Unable to get status code.\n"); + mpxp_fatal<<"Malformed answer. Unable to get status code"<<std::endl; return -1; } hdr_ptr += 4; @@ -86,7 +86,7 @@ // Get the reason phrase ptr = strstr( hdr_ptr, "\n" ); if( hdr_ptr==NULL ) { - MSG_FATAL("Malformed answer. Unable to get the reason phrase.\n"); + mpxp_fatal<<"Malformed answer. Unable to get the reason phrase"<<std::endl; return -1; } len = ptr-hdr_ptr; @@ -103,7 +103,7 @@ if( ptr==NULL ) { ptr = strstr( (char*)buffer, "\n\n" ); if( ptr==NULL ) { - MSG_ERR("Header may be incomplete. No CRLF CRLF found.\n"); + mpxp_err<<"Header may be incomplete. No CRLF CRLF found"<<std::endl; return -1; } hdr_sep_len = 2; @@ -119,7 +119,7 @@ if( len==0 ) break; field = (char*)mp_realloc(field, len+1); if( field==NULL ) { - MSG_FATAL("Memory allocation failed\n"); + mpxp_fatal<<"Memory allocation failed"<<std::endl; return -1; } strncpy( field, hdr_ptr, len ); @@ -165,7 +165,7 @@ } buffer = new uint8_t [len+1]; if( buffer==NULL ) { - MSG_FATAL("Memory allocation failed\n"); + mpxp_fatal<<"Memory allocation failed"<<std::endl; return NULL; } buffer_size = len; @@ -234,7 +234,7 @@ usr_pass = new char [username.length()+pass_len+2]; if( usr_pass==NULL ) { - MSG_FATAL("Memory allocation failed\n"); + mpxp_fatal<<"Memory allocation failed"<<std::endl; goto out; } @@ -244,13 +244,13 @@ encoded_len = strlen(usr_pass)*2; b64_usr_pass = new char [encoded_len]; if( b64_usr_pass==NULL ) { - MSG_FATAL("Memory allocation failed\n"); + mpxp_fatal<<"Memory allocation failed"<<std::endl; goto out; } out_len = base64_encode( usr_pass, strlen(usr_pass), b64_usr_pass, encoded_len); if( out_len<0 ) { - MSG_FATAL("Base64 out overflow\n"); + mpxp_fatal<<"Base64 out overflow"<<std::endl; goto out; } @@ -258,7 +258,7 @@ auth = new char [encoded_len+22]; if( auth==NULL ) { - MSG_FATAL("Memory allocation failed\n"); + mpxp_fatal<<"Memory allocation failed"<<std::endl; goto out; } @@ -280,26 +280,19 @@ void HTTP_Header::debug_hdr( ) { unsigned i = 0; - MSG_V( "--- HTTP DEBUG HEADER --- START ---\n" - "protocol: [%s]\n" - "http minor version: [%d]\n" - "uri: [%s]\n" - "method: [%s]\n" - "status code: [%d]\n" - "reason phrase: [%s]\n" - "body size: [%d]\n" - ,protocol.c_str() - ,http_minor_version - ,uri.c_str() - ,method.c_str() - ,status_code - ,reason_phrase.c_str() - ,body.length() ); + mpxp_v<<"--- HTTP DEBUG HEADER --- START ---"<<std::endl; + mpxp_v<<"protocol: ["<<protocol<<"]"<<std::endl; + mpxp_v<<"http minor version: ["<<http_minor_version<<"]"<<std::endl; + mpxp_v<<"uri: ["<<uri<<"]"<<std::endl; + mpxp_v<<"method: ["<<method<<"]"<<std::endl; + mpxp_v<<"status code: ["<<status_code<<"]"<<std::endl; + mpxp_v<<"reason phrase: ["<<reason_phrase<<"]"<<std::endl; + mpxp_v<<"body size: ["<<body.length()<<"]"<<std::endl; - MSG_V("Fields:\n"); + mpxp_v<<"Fields:"<<std::endl; std::vector<std::string>::size_type sz = fields.size(); - for(i=0;i<sz;i++) MSG_V(" %d - %s\n", i, fields[i].c_str()); - MSG_V("--- HTTP DEBUG HEADER --- END ---\n"); + for(i=0;i<sz;i++) mpxp_v<<" "<<i<<" - "<<fields[i]<<std::endl; + mpxp_v<<"--- HTTP DEBUG HEADER --- END ---"<<std::endl; } int HTTP_Header::authenticate(URL& url, int *auth_retry) { @@ -316,15 +309,15 @@ const char *aut_space; aut_space = strstr(aut, "realm="); if( aut_space!=NULL ) aut_space += 6; - MSG_INFO("Authentication required for %s\n", aut_space); + mpxp_info<<"Authentication required for "<<aut_space<<std::endl; } else { - MSG_INFO("Authentication required\n"); + mpxp_info<<"Authentication required"<<std::endl; } if( !net_conf.username ) { mpxp_err<<MSGTR_ConnAuthFailed<<std::endl; return -1; } - if( !net_conf.password ) MSG_INFO("No password provided, trying blank password\n"); + if( !net_conf.password ) mpxp_info<<"No password provided, trying blank password"<<std::endl; url.set_login(net_conf.username,net_conf.password?net_conf.password:""); (*auth_retry)++; return 0; Modified: mplayerxp/libmpstream2/librtsp/rtsp.cpp =================================================================== --- mplayerxp/libmpstream2/librtsp/rtsp.cpp 2012-12-21 17:47:42 UTC (rev 594) +++ mplayerxp/libmpstream2/librtsp/rtsp.cpp 2012-12-22 12:15:42 UTC (rev 595) @@ -179,7 +179,7 @@ } if (n>=BUF_SIZE) { - MSG_FATAL("librtsp: buffer overflow in rtsp_get\n"); + mpxp_fatal<<"librtsp: buffer overflow in rtsp_get"<<std::endl; exit(1); } string=new char [n]; @@ -187,7 +187,7 @@ string[n-1]=0; #ifdef LOG - MSG_INFO("librtsp: << '%s'\n", string); + mpxp_info<<"librtsp: << "<<string<<std::endl; #endif delete buffer; @@ -203,7 +203,7 @@ char *buf=new char [len+2]; #ifdef LOG - MSG_INFO("librtsp: >> '%s'", string); + mpxp_info<<"librtsp: >> "<<string<<std::endl; #endif memcpy(buf,string,len); @@ -213,7 +213,7 @@ write_stream(buf, len+2); #ifdef LOG - MSG_INFO(" done.\n"); + mpxp_info>>" done"<<std::endl; #endif delete buf; } @@ -233,7 +233,7 @@ } else if (!strncmp(string, RTSP_METHOD_SET_PARAMETER,8)) { return RTSP_STATUS_SET_PARAMETER; } - if(code != RTSP_STATUS_OK) MSG_INFO("librtsp: server responds: '%s'\n",string); + if(code != RTSP_STATUS_OK) mpxp_info<<"librtsp: server responds: "<<string<<std::endl; return code; } @@ -303,7 +303,7 @@ sscanf(answer,"%*s %u",&answer_seq); if (cseq != answer_seq) { #ifdef LOG - MSG_WARN("librtsp: warning: CSeq mismatch. got %u, assumed %u", answer_seq, s->cseq); + mpxp_warn<<"librtsp: warning: CSeq mismatch. got "<<answer_seq<<", assumed "<<s->cseq<<std::endl; #endif cseq=answer_seq; } @@ -320,13 +320,13 @@ sscanf(answer,"%*s %s",buf); if (session) { if (strcmp(buf, session)) { - MSG_WARN("rtsp: warning: setting NEW session: %s\n", buf); + mpxp_warn<<"rtsp: warning: setting NEW session: "<<buf<<std::endl; delete session; session=mp_strdup(buf); } } else { #ifdef LOG - MSG_INFO("rtsp: setting session id to: %s\n", buf); + mpxp_info<<"rtsp: setting session id to: "<<buf<<std::endl; #endif session=mp_strdup(buf); } @@ -473,7 +473,7 @@ delete rest; if (seq<0) { #ifdef LOG - MSG_WARN("rtsp: warning: CSeq not recognized!\n"); + mpxp_warn<<"rtsp: warning: CSeq not recognized!"<<std::endl; #endif seq=1; } @@ -491,7 +491,7 @@ } } else i=read_stream(buffer, size); #ifdef LOG - MSG_INFO("librtsp: << %d of %d bytes\n", i, size); + mpxp_info<<"librtsp: << "<<i<<" of "<<size<<" bytes"<<std::endl; #endif return i; } @@ -533,7 +533,7 @@ s.param++; if (!tcp.established()) { - MSG_ERR("rtsp: failed to connect to '%s'\n", s.host); + mpxp_err<<"rtsp: failed to connect to "<<s.host<<std::endl; s.close(); delete &s; return NULL; Modified: mplayerxp/libmpstream2/librtsp/rtsp_rtp.cpp =================================================================== --- mplayerxp/libmpstream2/librtsp/rtsp_rtp.cpp 2012-12-21 17:47:42 UTC (rev 594) +++ mplayerxp/libmpstream2/librtsp/rtsp_rtp.cpp 2012-12-22 12:15:42 UTC (rev 595) @@ -241,7 +241,7 @@ /* Increase the socket rx buffer size to maximum -- this is UDP */ rxsockbufsz = 240 * 1024; if (::setsockopt (s, SOL_SOCKET, SO_RCVBUF, &rxsockbufsz, sizeof (rxsockbufsz))) - MSG_ERR("Couldn't set receive socket buffer size\n"); + mpxp_err<<"Couldn't set receive socket buffer size"<<std::endl; /* if multicast address, add membership */ if ((::ntohl (sin.sin_addr.s_addr) >> 28) == 0xe) { @@ -250,7 +250,7 @@ mcast.imr_interface.s_addr = 0; if (::setsockopt (s, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mcast, sizeof (mcast))) { - MSG_ERR("IP_ADD_MEMBERSHIP failed\n"); + mpxp_err<<"IP_ADD_MEMBERSHIP failed"<<std::endl; ::close (s); return -1; } @@ -264,7 +264,7 @@ if (WSAGetLastError() != WSAEINPROGRESS) #endif { - MSG_ERR("bind: %s\n", strerror (errno)); + mpxp_err<<"bind: "<<strerror(errno)<<std::endl; ::close (s); return -1; } @@ -278,11 +278,11 @@ err = ::select (s + 1, &set, NULL, NULL, &tv); if (err < 0) { - MSG_ERR("Select failed: %s\n", strerror (errno)); + mpxp_err<<"Select failed: "<<strerror (errno)<<std::endl; ::close (s); return -1; } else if (err == 0) { - MSG_ERR("Timeout! No data from host %s\n", hostname); + mpxp_err<<"Timeout! No data from host "<<hostname<<std::endl; ::close (s); return -1; } @@ -290,7 +290,7 @@ err_len = sizeof (err); ::getsockopt (s, SOL_SOCKET, SO_ERROR, &err, (socklen_t *) &err_len); if (err) { - MSG_ERR("Socket error: %d\n", err); + mpxp_err<<"Socket error: "<<err<<std::endl; ::close (s); return -1; } @@ -369,12 +369,12 @@ fsdp_description_delete (dsc); return NULL; } - MSG_V("SDP:\n%s\n", sdp); + mpxp_v<<"SDP: "<<sdp<<std::endl; delete sdp; /* 4. check for number of media streams: only one is supported */ if (fsdp_get_media_count (dsc) != 1) { - MSG_ERR("A single media stream only is supported atm.\n"); + mpxp_err<<"A single media stream only is supported atm"<<std::endl; fsdp_description_delete (dsc); return NULL; } @@ -429,8 +429,8 @@ /* RTCP port generally is RTP port + 1 */ client_rtcp_port = client_rtp_port + 1; - MSG_V("RTP Port from SDP appears to be: %d\n", client_rtp_port); - MSG_V("RTCP Port from SDP appears to be: %d\n", client_rtcp_port); + mpxp_v<<"RTP Port from SDP appears to be: "<<client_rtp_port<<std::endl; + mpxp_v<<"RTCP Port from SDP appears to be: "<<client_rtcp_port<<std::endl; /* 7. parse the `c=<network type> <addr type> <connection address>' line */ /* check for a valid media network type (inet) */ @@ -491,7 +491,7 @@ is_multicast ? RTSP_TRANSPORT_MULTICAST : RTSP_TRANSPORT_UNICAST, is_multicast ? RTSP_MULTICAST_PORT : RTSP_UNICAST_CLIENT_PORT, client_rtp_port, client_rtcp_port); - MSG_V("RTSP Transport: %s\n", temp_buf); + mpxp_v<<"RTSP Transport: "<<temp_buf<<std::endl; rtsp.unschedule_field (RTSP_SESSION); rtsp.schedule_field (temp_buf); @@ -537,16 +537,11 @@ if (!destination) destination = mp_strdup (server_addr); delete server_addr; - MSG_V("RTSP Destination: %s\n" - "Client RTP port : %d\n" - "Client RTCP port : %d\n" - "Server RTP port : %d\n" - "Server RTCP port : %d\n" - , destination - , client_rtp_port - , client_rtcp_port - , server_rtp_port - , server_rtcp_port); + mpxp_v<<"RTSP Destination: "<<destination<<std::endl; + mpxp_v<<"Client RTP port : "<<client_rtp_port<<std::endl; + mpxp_v<<"Client RTCP port : "<<client_rtcp_port<<std::endl; + mpxp_v<<"Server RTP port : "<<server_rtp_port<<std::endl; + mpxp_v<<"Server RTCP port : "<<server_rtcp_port<<std::endl; /* 12. performs RTSP PLAY request */ rtsp.schedule_field (npt); @@ -563,7 +558,7 @@ rtp_session->set_fd (rtp_sock, rtcp_sock); delete destination; - MSG_V("RTP Sock : %d\nRTCP Sock : %d\n",rtp_session->rtp_socket, rtp_session->rtcp_socket); + mpxp_v<<"RTP Sock : "<<rtp_session->rtp_socket<<" RTCP Sock : "<<rtp_session->rtcp_socket<<std::endl; if (rtp_session->rtp_socket == -1) { delete rtp_session; Modified: mplayerxp/libmpstream2/librtsp/rtsp_session.cpp =================================================================== --- mplayerxp/libmpstream2/librtsp/rtsp_session.cpp 2012-12-21 17:47:42 UTC (rev 594) +++ mplayerxp/libmpstream2/librtsp/rtsp_session.cpp 2012-12-22 12:15:42 UTC (rev 595) @@ -91,7 +91,7 @@ rtsp_session->s=Rtsp::connect(tcp,*mrl,path.c_str(),host.c_str(),port,NULL); if (!rtsp_session->s) { - MSG_ERR("rtsp_session: failed to connect to server %s\n", path.c_str()); + mpxp_err<<"rtsp_session: failed to connect to server "<<path<<std::endl; delete rtsp_session; return NULL; } @@ -116,7 +116,7 @@ { delete mrl_line; mrl_line=mp_strdup(rtsp_session->s->search_answers(RTSP_OPTIONS_LOCATION)); - MSG_INFO("rtsp_session: redirected to %s\n", mrl_line); + mpxp_info<<"rtsp_session: redirected to "<<mrl_line<<std::endl; rtsp_session->s->close(); delete server; delete *mrl; @@ -128,7 +128,7 @@ // goto connect; /* *shudder* i made a design mistake somewhere */ } else { - MSG_ERR("rtsp_session: session can not be established.\n"); + mpxp_err<<"rtsp_session: session can not be established"<<std::endl; rtsp_session->s->close(); delete server; delete rtsp_session; @@ -142,13 +142,13 @@ rtsp_session->real_session->header_len = 0; rtsp_session->real_session->recv_size = 0; rtsp_session->real_session->rdt_rawdata = 1; - MSG_V("smil-over-realrtsp playlist, switching to raw rdt mode\n"); + mpxp_v<<"smil-over-realrtsp playlist, switching to raw rdt mode"<<std::endl; } else { rtsp_session->real_session->header_len = rmff_dump_header (h, (char *) rtsp_session->real_session->header, HEADER_SIZE); if (rtsp_session->real_session->header_len < 0) { - MSG_ERR("rtsp_session: error while dumping RMFF headers, session can not be established.\n"); + mpxp_err<<"rtsp_session: error while dumping RMFF headers, session can not be established"<<std::endl; free_real_rtsp_session(rtsp_session->real_session); rtsp_session->s->close(); delete server; @@ -186,7 +186,7 @@ || !strstr (publics, RTSP_METHOD_PLAY) || !strstr (publics, RTSP_METHOD_TEARDOWN)) { - MSG_ERR("Remote server does not meet minimal RTSP 1.0 compliance.\n"); + mpxp_err<<"Remote server does not meet minimal RTSP 1.0 compliance"<<std::endl; rtsp_session->s->close (); delete server; delete mrl_line; @@ -201,7 +201,7 @@ /* neither a Real or an RTP server */ if (!rtsp_session->rtp_session) { - MSG_ERR("rtsp_session: unsupported RTSP server. Server type is '%s'.\n", server); + mpxp_err<<"rtsp_session: unsupported RTSP server. Server type is "<<server<<std::endl; rtsp_session->s->close (); delete server; delete mrl_line; @@ -241,7 +241,7 @@ fill = real_session->recv_size; if (real_session->recv_size == 0) { #ifdef LOG - MSG_INFO("librtsp: %d of %d bytes provided\n", len-to_copy, len); + mpxp_info<<"librtsp: "<<(len-to_copy)<<" of "<<len<<" bytes provided"<<std::endl; #endif return len-to_copy; } @@ -249,7 +249,7 @@ memcpy(dest, source, to_copy); real_session->recv_read += to_copy; #ifdef LOG - MSG_INFO("librtsp: %d bytes provided\n", len); + mpxp_info<<"librtsp: "<<len<<" bytes provided"<<std::endl; #endif return len; } else if (rtp_session) { Modified: mplayerxp/libmpstream2/mrl.cpp =================================================================== --- mplayerxp/libmpstream2/mrl.cpp 2012-12-21 17:47:42 UTC (rev 594) +++ mplayerxp/libmpstream2/mrl.cpp 2012-12-22 12:15:42 UTC (rev 595) @@ -86,7 +86,7 @@ static void mrl_store_args(const std::string& arg,char *value, const mrl_config_t * args) { #ifdef TEST_MRL - printf("arg='%s' value='%s'\n",arg,value); + mpxp_info<<"arg='"<<arg<<"' value='"<<value<<std::endl; return; #endif unsigned i; @@ -97,7 +97,7 @@ done=1; switch(args[i].type) { case MRL_TYPE_PRINT: - MSG_INFO("%s", (char *)args[i].value); + mpxp_info<<(char *)args[i].value<<std::endl; default: delete value; break; @@ -136,7 +136,7 @@ } i++; } - if(!done) MSG_WARN(" Can't handle argument: '%s'",arg.c_str()); + if(!done) mpxp_warn<<" Can't handle argument: "<<arg<<std::endl; } #define MRL_ARG_SEP ',' Modified: mplayerxp/libmpstream2/network.cpp =================================================================== --- mplayerxp/libmpstream2/network.cpp 2012-12-21 17:47:42 UTC (rev 594) +++ mplayerxp/libmpstream2/network.cpp 2012-12-22 12:15:42 UTC (rev 595) @@ -114,12 +114,12 @@ server_url.assign_port(80); tcp.open(server_url, Tcp::IP4); } - if(!tcp.established()) { MSG_ERR("Cannot establish connection\n"); goto err_out; } - MSG_DBG2("Request: [%s]\n", http_hdr.get_buffer() ); + if(!tcp.established()) { mpxp_err<<"Cannot establish connection"<<std::endl; goto err_out; } + mpxp_dbg2<<"Request: ["<<http_hdr.get_buffer()<<"]"<<std::endl; ret = tcp.write((uint8_t*)(http_hdr.get_buffer()), http_hdr.get_buffer_size()); if( ret!=(int)http_hdr.get_buffer_size() ) { - MSG_ERR("Error while sending HTTP request: didn't sent all the request\n"); + mpxp_err<<"Error while sending HTTP request: didn't sent all the request"<<std::endl; goto err_out; } @@ -131,28 +131,28 @@ } HTTP_Header* http_read_response( Tcp& tcp ) { - HTTP_Header* http_hdr = new(zeromem) HTTP_Header; - uint8_t response[BUFFER_SIZE]; - int i; + HTTP_Header* http_hdr = new(zeromem) HTTP_Header; + uint8_t response[BUFFER_SIZE]; + int i; - if( http_hdr==NULL ) return NULL; + if( http_hdr==NULL ) return NULL; - do { - i = tcp.read(response, BUFFER_SIZE); - if( i<0 ) { - MSG_ERR("Read failed\n"); - delete http_hdr; - return NULL; - } - if( i==0 ) { - MSG_ERR("http_read_response read 0 -ie- EOF\n"); - delete http_hdr; - return NULL; - } - http_hdr->response_append(response,i); - } while( !http_hdr->is_header_entire() ); - http_hdr->response_parse(); - return http_hdr; + do { + i = tcp.read(response, BUFFER_SIZE); + if( i<0 ) { + mpxp_err<<"Read failed"<<std::endl; + delete http_hdr; + return NULL; + } + if( i==0 ) { + mpxp_err<<"http_read_response read 0 -ie- EOF"<<std::endl; + delete http_hdr; + return NULL; + } + http_hdr->response_append(response,i); + } while( !http_hdr->is_header_entire() ); + http_hdr->response_parse(); + return http_hdr; } off_t http_seek(Tcp& tcp, Networking& networking, off_t pos ) { @@ -168,8 +168,8 @@ switch( http_hdr->get_status() ) { case 200: case 206: // OK - MSG_V("Content-Type: [%s]\n", http_hdr->get_field("Content-Type") ); - MSG_V("Content-Length: [%s]\n", http_hdr->get_field("Content-Length") ); + mpxp_v<<"Content-Type: ["<<http_hdr->get_field("Content-Type")<<"]"<<std::endl; + mpxp_v<<"Content-Length: ["<<http_hdr->get_field("Content-Length")<<"]"<<std::endl; if( http_hdr->get_body_size()>0 ) { if( networking.bufferize((unsigned char *)http_hdr->get_body(), http_hdr->get_body_size() )<0 ) { delete http_hdr; @@ -178,7 +178,7 @@ } break; default: - MSG_ERR("Server return %d: %s\n", http_hdr->get_status(), http_hdr->get_reason_phrase()); + mpxp_err<<"Server return "<<http_hdr->get_status()<<": "<<http_hdr->get_reason_phrase()<<std::endl; tcp.close(); } @@ -221,7 +221,7 @@ // Checking for RTP if( url.protocol2lower()=="rtp") { if( url.port()==0 ) { - MSG_ERR("You must enter a port number for RTP streams!\n"); + mpxp_err<<"You must enter a port number for RTP streams!"<<std::endl; goto err_out; } return MPXP_Ok; @@ -251,34 +251,34 @@ // note: I skip icy-notice1 and 2, as they contain html <BR> // and are IMHO useless info ::atmos if( (field_data = http_hdr->get_field("icy-name")) != NULL ) - MSG_INFO("Name : %s\n", field_data); field_data = NULL; + mpxp_info<<"Name : "<<field_data<<std::endl; field_data = NULL; if( (field_data = http_hdr->get_field("icy-genre")) != NULL ) - MSG_INFO("Genre : %s\n", field_data); field_data = NULL; + mpxp_info<<"Genre : "<<field_data<<std::endl; field_data = NULL; if( (field_data = http_hdr->get_field("icy-url")) != NULL ) - MSG_INFO("Website: %s\n", field_data); field_data = NULL; + mpxp_info<<"Website: "<<field_data<<std::endl; field_data = NULL; // XXX: does this really mean public server? ::atmos if( (field_data = http_hdr->get_field("icy-pub")) != NULL ) - MSG_INFO("Public : %s\n", atoi(field_data)?"yes":"no"); field_data = NULL; + mpxp_info<<"Public : "<<(atoi(field_data)?"yes":"no")<<std::endl; field_data = NULL; if( (field_data = http_hdr->get_field("icy-br")) != NULL ) - MSG_INFO("Bitrate: %skbit/s\n", field_data); field_data = NULL; + mpxp_info<<"Bitrate: "<<field_data<<"kbit/s"<<std::endl; field_data = NULL; if ( (field_data = http_hdr->get_field("content-type")) != NULL ) networking.mime = field_data; return MPXP_Ok; } case 400: // Server Full - MSG_ERR("Error: ICY-Server is full, skipping!\n"); + mpxp_err<<"Error: ICY-Server is full, skipping!"<<std::endl; goto err_out; case 401: // Service Unavailable - MSG_ERR("Error: ICY-Server return service unavailable, skipping!\n"); + mpxp_err<<"Error: ICY-Server return service unavailable, skipping!"<<std::endl; goto err_out; case 403: // Service Forbidden - MSG_ERR("Error: ICY-Server return 'Service Forbidden'\n"); + mpxp_err<<"Error: ICY-Server return 'Service Forbidden'"<<std::endl; goto err_out; case 404: // Resource Not Found - MSG_ERR("Error: ICY-Server couldn't find requested stream, skipping!\n"); + mpxp_err<<"Error: ICY-Server couldn't find requested stream, skipping!"<<std::endl; goto err_out; default: - MSG_ERR("Error: unhandled ICY-Errorcode, contact MPlayer developers!\n"); + mpxp_err<<"Error: unhandled ICY-Errorcode, contact MPlayer developers!"<<std::endl; goto err_out; } } @@ -290,9 +290,9 @@ content_type = http_hdr->get_field("Content-Type" ); if( content_type!=NULL ) { const char *content_length = NULL; - MSG_V("Content-Type: [%s]\n", content_type ); + mpxp_v<<"Content-Type: ["<<content_type<<"]"<<std::endl; if( (content_length = http_hdr->get_field("Content-Length")) != NULL) - MSG_V("Content-Length: [%s]\n", http_hdr->get_field("Content-Length")); + mpxp_v<<"Content-Length: ["<<http_hdr->get_field("Content-Length")<<"]"<<std::endl; } // Not found in the mime type table, don't fail, // we should try raw HTTP @@ -306,7 +306,7 @@ url.redirect(next_url); if (url.protocol2lower()=="mms") goto err_out; if (url.protocol2lower()=="http") { - MSG_WARN("Unsupported http %d redirect to %s protocol\n", http_hdr->get_status(), url.protocol().c_str()); + mpxp_warn<<"Unsupported http "<<http_hdr->get_status()<<" redirect to "<<url.protocol()<<" protocol"<<std::endl; goto err_out; } redirect = 1; @@ -317,11 +317,11 @@ redirect = 1; break; default: - MSG_ERR("Server returned %d: %s\n", http_hdr->get_status(), http_hdr->get_reason_phrase()); + mpxp_err<<"Server returned "<<http_hdr->get_status()<<": "<<http_hdr->get_reason_phrase()<<std::endl; goto err_out; } } else { - MSG_ERR("Unknown protocol '%s'\n", url.protocol().c_str()); + mpxp_err<<"Unknown protocol: "<<url.protocol()<<std::endl; goto err_out; } } while( redirect ); @@ -332,10 +332,9 @@ } int Networking::bufferize(unsigned char *_buffer, int size) { -//printf("networking_bufferize\n"); buffer = new char [size]; if( buffer==NULL ) { - MSG_FATAL(MSGTR_OutOfMemory); + mpxp_fatal<<MSGTR_OutOfMemory<<std::endl; return -1; } memcpy( buffer, _buffer, size ); @@ -351,7 +350,7 @@ mp_conf.s_cache_size = (prebuffer_size/1024)*5; if( mp_conf.s_cache_size<64 ) mp_conf.s_cache_size = 64; // 16KBytes min buffer } - MSG_INFO("[network] cache size set to: %i\n", mp_conf.s_cache_size); + mpxp_info<<"[network] cache size set to: "<<mp_conf.s_cache_size<<std::endl; } } @@ -373,18 +372,18 @@ tcp.close(); rc = Pnm_Networking::start(tcp, net_protocol); if (!rc) { - MSG_INFO("Can't connect with pnm, retrying with http.\n"); + mpxp_info<<"Can't connect with pnm, retrying with http"<<std::endl; return NULL; } } else if( url.protocol2lower()=="rtsp") { if ((rc = RealRtsp_Networking::start( tcp, net_protocol )) == NULL) { - MSG_INFO("Not a Realmedia rtsp url. Trying standard rtsp protocol.\n"); + mpxp_info<<"Not a Realmedia rtsp url. Trying standard rtsp protocol"<<std::endl; #ifdef STREAMING_LIVE_DOT_COM rc = Rtsp_Networking::start( tcp, net_protocol ); - if(!rc) MSG_ERR("rtsp_networking_start failed\n"); + if(!rc) mpxp_err<<"rtsp_networking_start failed"<<std::endl; return rc; #else - MSG_ERR("RTSP support requires the \"LIVE.COM Streaming Media\" libraries!\n"); + mpxp_err<<"RTSP support requires the \"LIVE.COM Streaming Media\" libraries!"<<std::endl; return NULL; #endif } @@ -392,7 +391,7 @@ tcp.close(); rc = Rtp_Networking::start(tcp, net_protocol, 1); if(!rc) { - MSG_ERR("rtp_networking_start(udp) failed\n"); + mpxp_err<<"rtp_networking_start(udp) failed"<<std::endl; return NULL; } } else if(url.protocol2lower()=="mms" || @@ -400,7 +399,7 @@ url.protocol2lower()=="mmsu") { rc=Asf_Mmst_Networking::start(tcp,net_protocol); if(!rc) { - MSG_ERR("asf_mmst_networking_start() failed\n"); + mpxp_err<<"asf_mmst_networking_start() failed"<<std::endl; return NULL; } } else { @@ -414,14 +413,14 @@ //sometimes a file is just on a webserver and it is not streamed. //try loading them default method as last resort for http protocol if (url.protocol2lower()=="http") { - MSG_STATUS("Trying default networking for http protocol\n "); + mpxp_status<<"Trying default networking for http protocol"<<std::endl; //reset stream tcp.close(); rc=Nop_Networking::start(tcp,net_protocol); } if (!rc) { - MSG_ERR("asf_networking_start failed\n"); - MSG_STATUS("Check if this is a playlist which requires -playlist option\nExample: mplayer -playlist <url>\n"); + mpxp_err<<"asf_networking_start failed"<<std::endl; + mpxp_status<<"Check if this is a playlist which requires -playlist option"<<std::endl<<"Example: mplayer -playlist <url>"<<std::endl; } } } Modified: mplayerxp/libmpstream2/network_asf.cpp =================================================================== --- mplayerxp/libmpstream2/network_asf.cpp 2012-12-21 17:47:42 UTC (rev 594) +++ mplayerxp/libmpstream2/network_asf.cpp 2012-12-22 12:15:42 UTC (rev 595) @@ -56,36 +56,36 @@ static int asf_networking(ASF_stream_chunck_t *stream_chunck, int *drop_packet ) { - if( drop_packet!=NULL ) *drop_packet = 0; + if( drop_packet!=NULL ) *drop_packet = 0; - if( stream_chunck->size<8 ) { - MSG_ERR("Ahhhh, stream_chunck size is too small: %d\n", stream_chunck->size); - return -1; - } - if( stream_chunck->size!=stream_chunck->size_confirm ) { - MSG_ERR("size_confirm mismatch!: %d %d\n", stream_chunck->size, stream_chunck->size_confirm); - return -1; - } - switch(stream_chunck->type) { - case ASF_STREAMING_CLEAR: // $C Clear ASF configuration - MSG_V("=====> Clearing ASF stream configuration!\n"); - if( drop_packet!=NULL ) *drop_packet = 1; - return stream_chunck->size; - break; - case ASF_STREAMING_DATA: // $D Data follows - break; - case ASF_STREAMING_END_TRANS: // $E Transfer complete - MSG_V("=====> Transfer complete\n"); - if( drop_packet!=NULL ) *drop_packet = 1; - return stream_chunck->size; - break; - case ASF_STREAMING_HEADER: // $H ASF header chunk follows - MSG_V("=====> ASF header chunk follows\n"); - break; - default... [truncated message content] |
From: <nic...@us...> - 2012-12-22 12:47:35
|
Revision: 597 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=597&view=rev Author: nickols_k Date: 2012-12-22 12:47:25 +0000 (Sat, 22 Dec 2012) Log Message: ----------- memory leaks-- Modified Paths: -------------- mplayerxp/input2/input.cpp mplayerxp/libvo2/font_load.cpp mplayerxp/loader/registry.c mplayerxp/mplayerxp.cpp mplayerxp/nls/mpxp_help-en.h mplayerxp/nls/mpxp_help-ru.h mplayerxp/osdep/get_path.cpp mplayerxp/osdep/get_path.h mplayerxp/postproc/af_export.cpp mplayerxp/postproc/af_raw.cpp Modified: mplayerxp/input2/input.cpp =================================================================== --- mplayerxp/input2/input.cpp 2012-12-22 12:17:38 UTC (rev 596) +++ mplayerxp/input2/input.cpp 2012-12-22 12:47:25 UTC (rev 597) @@ -1127,7 +1127,7 @@ #define BS_MAX 256 #define SPACE_CHAR " \n\r\t" -static int mp_input_parse_config(libinput_t& priv,const char *file) { +static int mp_input_parse_config(libinput_t& priv,const std::string& file) { int fd; int bs = 0,r,eof = 0,comments = 0; char *iter,*end; @@ -1135,7 +1135,7 @@ int n_binds = 0, keys[MP_MAX_KEY_DOWN+1] = { 0 }; mp_cmd_bind_t* binds = NULL; - fd = open(file,O_RDONLY); + fd = ::open(file.c_str(),O_RDONLY); if(fd < 0) { mpxp_err<<"Can't open input config file "<<file<<" : "<<strerror(errno)<<std::endl; @@ -1266,14 +1266,14 @@ } static void mp_input_init(libinput_t& priv) { - const char* file; + std::string file; file = config_file[0] != '/' ? get_path(config_file) : config_file; - if(!file) return; + if(file.empty()) return; if(! mp_input_parse_config(priv,file)) { // Try global conf dir - file = CONFDIR "/input.conf"; + file = std::string(CONFDIR)+"/input.conf"; if(! mp_input_parse_config(priv,file)) mpxp_warn<<"Falling back on default (hardcoded) input config"<<std::endl; } #ifdef HAVE_JOYSTICK Modified: mplayerxp/libvo2/font_load.cpp =================================================================== --- mplayerxp/libvo2/font_load.cpp 2012-12-22 12:17:38 UTC (rev 596) +++ mplayerxp/libvo2/font_load.cpp 2012-12-22 12:47:25 UTC (rev 597) @@ -10,7 +10,6 @@ #include <unistd.h> #include "font_load.h" #include "sub.h" -#include "osdep/get_path.h" #include "vo_msg.h" raw_file* load_raw(const char *name,int verbose){ @@ -72,9 +71,6 @@ desc->fpath = dn; // search in the same dir as fonts.desc - // desc->fpath=get_path("font/"); - // if (stat(desc->fpath, &fstate)!=0) desc->fpath=DATADIR"/font"; - // set up some defaults, and erase table desc->charspace=2; desc->spacewidth=12; desc->height=0; Modified: mplayerxp/loader/registry.c =================================================================== --- mplayerxp/loader/registry.c 2012-12-22 12:17:38 UTC (rev 596) +++ mplayerxp/loader/registry.c 2012-12-22 12:47:25 UTC (rev 597) @@ -23,8 +23,27 @@ //#undef TRACE //#define TRACE printf -extern char *get_path ( char * ); +static char *get_path(const char *filename){ + char *homedir; + char *buff; + static const char *config_dir = "/."PROGNAME; + int len; + if ((homedir = getenv("HOME")) == NULL) + return NULL; + len = strlen(homedir) + strlen(config_dir) + 1; + if (filename == NULL) { + if ((buff = (char *) mp_malloc(len)) == NULL) + return NULL; + sprintf(buff, "%s%s", homedir, config_dir); + } else { + len += strlen(filename) + 1; + if ((buff = (char *) mp_malloc(len)) == NULL) + return NULL; + sprintf(buff, "%s%s/%s", homedir, config_dir, filename); + } + return buff; +} // ...can be set before init_registry() call char* regpathname = NULL; Modified: mplayerxp/mplayerxp.cpp =================================================================== --- mplayerxp/mplayerxp.cpp 2012-12-22 12:17:38 UTC (rev 596) +++ mplayerxp/mplayerxp.cpp 2012-12-22 12:47:25 UTC (rev 597) @@ -426,26 +426,23 @@ void parse_cfgfiles( m_config_t& conf ) { - char *conffile; + std::string conffile; int conffile_fd; - if ((conffile = get_path("")) == NULL) { - mpxp_warn<<MSGTR_NoHomeDir<<std::endl; - } else { - mkdir(conffile, 0777); - delete conffile; - if ((conffile = get_path("config")) == NULL) { + conffile = get_path(); + if (conffile.empty()) mpxp_warn<<MSGTR_NoHomeDir<<std::endl; + else { + ::mkdir(conffile.c_str(), 0777); + conffile = get_path("config"); + if (conffile.empty()) { mpxp_err<<MSGTR_GetpathProblem<<std::endl; - conffile=(char*)mp_malloc(strlen("config")+1); - if(conffile) - strcpy(conffile,"config"); + conffile="config"; } - if ((conffile_fd = open(conffile, O_CREAT | O_EXCL | O_WRONLY, 0666)) != -1) { + 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) != MPXP_Ok) exit(1); - delete conffile; + if (m_config_parse_config_file(conf, conffile.c_str()) != MPXP_Ok) exit(1); } } @@ -568,7 +565,7 @@ #ifdef ENABLE_WIN32LOADER /* check codec.conf*/ - if(!parse_codec_cfg(get_path("win32codecs.conf"))) { + if(!parse_codec_cfg(get_path("win32codecs.conf").c_str())) { if(!parse_codec_cfg(CONFDIR"/win32codecs.conf")) { mpxp_hint<<MSGTR_CopyCodecsConf<<std::endl; mpxp_uninit_structs(); @@ -614,7 +611,7 @@ afm_help(); #ifdef ENABLE_WIN32LOADER /* check codec.conf*/ - if(!parse_codec_cfg(get_path("win32codecs.conf"))){ + if(!parse_codec_cfg(get_path("win32codecs.conf").c_str())){ if(!parse_codec_cfg(CONFDIR"/win32codecs.conf")){ mpxp_hint<<MSGTR_CopyCodecsConf<<std::endl; mpxp_uninit_structs(); @@ -842,20 +839,20 @@ mpxp_err<<MSGTR_CantLoadFont<<": "<<mp_conf.font_name<<std::endl; } else { // try default: - mpxp_context().video().output->font=read_font_desc(get_path("font/font.desc"),mp_conf.font_factor,mp_conf.verbose>1); + mpxp_context().video().output->font=read_font_desc(get_path("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 */ { - const char *menu_cfg; + std::string menu_cfg; menu_cfg = get_path("menu.conf"); - if(menu_init(NULL, menu_cfg)) + 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)) + if(menu_init(NULL, menu_cfg.c_str())) mpxp_info<<"Menu initialized: "<<menu_cfg<<std::endl; else mpxp_warn<<"Menu init failed"<<std::endl; @@ -1074,7 +1071,7 @@ 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 ? sub_filename( get_path("sub/"), filename ) + mpxp_context().subtitles=sub_read_file( filename ? sub_filename(get_path("sub/").c_str(), filename ) : "default.sub", sh_video->fps ); } if(mpxp_context().subtitles) { Modified: mplayerxp/nls/mpxp_help-en.h =================================================================== --- mplayerxp/nls/mpxp_help-en.h 2012-12-22 12:17:38 UTC (rev 596) +++ mplayerxp/nls/mpxp_help-en.h 2012-12-22 12:47:25 UTC (rev 597) @@ -100,7 +100,7 @@ #define MSGTR_IntBySignal "\nMPlayerXP interrupted by signal %d in module: %s \n" #endif #ifndef MSGTR_GetpathProblem -#define MSGTR_GetpathProblem "get_path(\"config\") problem\n" +#define MSGTR_GetpathProblem "get_path(\"config\") problem" #endif #ifndef MSGTR_CreatingCfgFile #define MSGTR_CreatingCfgFile "Creating config file" Modified: mplayerxp/nls/mpxp_help-ru.h =================================================================== --- mplayerxp/nls/mpxp_help-ru.h 2012-12-22 12:17:38 UTC (rev 596) +++ mplayerxp/nls/mpxp_help-ru.h 2012-12-22 12:47:25 UTC (rev 597) @@ -76,7 +76,7 @@ #define MSGTR_Playing "Воспроизведение" #define MSGTR_IntBySignal "\nMPlayerXP прерван сигналом %d в модуле: %s \n" -#define MSGTR_GetpathProblem "проблемы в get_path(\"config\")\n" +#define MSGTR_GetpathProblem "проблемы в get_path(\"config\")" #define MSGTR_CreatingCfgFile "Создание файла конфигурации" #define MSGTR_InvalidVOdriver "Недопустимое имя драйвера видео вывода" #define MSGTR_InvalidAOdriver "Недопустимое имя драйвера аудио вывода" Modified: mplayerxp/osdep/get_path.cpp =================================================================== --- mplayerxp/osdep/get_path.cpp 2012-12-22 12:17:38 UTC (rev 596) +++ mplayerxp/osdep/get_path.cpp 2012-12-22 12:47:25 UTC (rev 597) @@ -8,26 +8,15 @@ #include <string.h> #include "osdep_msg.h" namespace mpxp { -char *get_path(const char *filename){ - char *homedir; - char *buff; - static const char *config_dir = "/."PROGNAME; - int len; +std::string get_path(const std::string& filename){ + char *homedir; + std::string rs; + std::string config_dir = std::string("/.")+PROGNAME; - if ((homedir = getenv("HOME")) == NULL) - return NULL; - len = strlen(homedir) + strlen(config_dir) + 1; - if (filename == NULL) { - if ((buff = (char *) mp_malloc(len)) == NULL) - return NULL; - sprintf(buff, "%s%s", homedir, config_dir); - } else { - len += strlen(filename) + 1; - if ((buff = (char *) mp_malloc(len)) == NULL) - return NULL; - sprintf(buff, "%s%s/%s", homedir, config_dir, filename); - } - MSG_V("get_path('%s') -> '%s'\n",filename,buff); - return buff; + if ((homedir = ::getenv("HOME")) == NULL) return ""; + rs=std::string(homedir)+config_dir; + if (!filename.empty()) rs+="/"+filename; + mpxp_v<<"get_path('"<<filename<<"') -> "<<rs<<std::endl; + return rs; } }// namespace mpxp Modified: mplayerxp/osdep/get_path.h =================================================================== --- mplayerxp/osdep/get_path.h 2012-12-22 12:17:38 UTC (rev 596) +++ mplayerxp/osdep/get_path.h 2012-12-22 12:47:25 UTC (rev 597) @@ -1,7 +1,8 @@ #ifndef __MPXP_GET_PATH #define __MPXP_GET_PATH 1 +#include <string> namespace mpxp { - char *get_path(const char *filename); + std::string get_path(const std::string& filename=""); } #endif Modified: mplayerxp/postproc/af_export.cpp =================================================================== --- mplayerxp/postproc/af_export.cpp 2012-12-22 12:17:38 UTC (rev 596) +++ mplayerxp/postproc/af_export.cpp 2012-12-22 12:47:25 UTC (rev 597) @@ -26,8 +26,8 @@ #include "af.h" #include "af_internal.h" #include "mpxp_help.h" -#include "osdep/get_path.h" #include "osdep/fastmemcpy.h" +#include "osdep/get_path.h" #include "pp_msg.h" #define DEF_SZ 512 // default buffer size (in samples) @@ -41,11 +41,11 @@ { unsigned long long count; // Used for sync uint8_t* buf[AF_NCH]; // Buffers for storing the data before it is exported - int sz; // Size of buffer in samples - int wi; // Write index - int fd; // File descriptor to shared memory area - char* filename; // File to export data - any_t* mmap_area; // MMap shared area + int sz; // Size of buffer in samples + int wi; // Write index + int fd; // File descriptor to shared memory area + std::string filename; // File to export data + any_t* mmap_area; // MMap shared area }; /* Initialization and runtime control_af @@ -81,17 +81,15 @@ // Allocate new buffers (as one continuous block) s->buf[0] = new(zeromem) uint8_t[s->sz*af->conf.nch*af->conf.format&MPAF_BPS_MASK]; - if(NULL == s->buf[0]) - MSG_FATAL(MSGTR_OutOfMemory); + if(NULL == s->buf[0]) mpxp_fatal<<MSGTR_OutOfMemory<<std::endl; for(i = 1; i < af->conf.nch; i++) s->buf[i] = s->buf[0] + i*s->sz*(af->conf.format&MPAF_BPS_MASK); // Init memory mapping - s->fd = open(s->filename, O_RDWR | O_CREAT | O_TRUNC, 0640); - MSG_INFO( "[export] Exporting to file: %s\n", s->filename); + s->fd = open(s->filename.c_str(), O_RDWR | O_CREAT | O_TRUNC, 0640); + mpxp_info<<"[export] Exporting to file: "<<s->filename<<std::endl; if(s->fd < 0) - MSG_FATAL( "[export] Could not open/create file: %s\n", - s->filename); + mpxp_fatal<<"[export] Could not open/create file: "<<s->filename<<std::endl; // header + buffer mapsize = (SIZE_HEADER + ((af->conf.format&MPAF_BPS_MASK) * s->sz * af->conf.nch)); @@ -105,9 +103,8 @@ // mmap size s->mmap_area = mmap(0, mapsize, PROT_READ|PROT_WRITE,MAP_SHARED, s->fd, 0); if(s->mmap_area == NULL) - MSG_FATAL( "[export] Could not mmap file %s\n", s->filename); - MSG_INFO( "[export] Memory mapped to file: %s (%p)\n", - s->filename, s->mmap_area); + mpxp_fatal<<"[export] Could not mmap file "<<s->filename<<std::endl; + mpxp_info<<"[export] Memory mapped to file: "<<s->filename<<std::endl; // Initialize header *((int*)s->mmap_area) = af->conf.nch; @@ -127,9 +124,6 @@ char *str = reinterpret_cast<char*>(arg); if (!str){ - if(s->filename) - delete s->filename; - s->filename = get_path(SHARED_FILE); return MPXP_Ok; } @@ -137,13 +131,7 @@ while((str[i]) && (str[i] != ':')) i++; - if(s->filename) - delete s->filename; - - s->filename = new(zeromem) char[i + 1]; - memcpy(s->filename, str, i); - s->filename[i] = 0; - + s->filename.assign(str, i); sscanf(str + i + 1, "%d", &(s->sz)); return af->control_af(af, AF_CONTROL_EXPORT_SZ | AF_CONTROL_SET, &s->sz); @@ -151,8 +139,7 @@ case AF_CONTROL_EXPORT_SZ | AF_CONTROL_SET: s->sz = * (int *) arg; if((s->sz <= 0) || (s->sz > 2048)) - MSG_ERR( "[export] Buffer size must be between" - " 1 and 2048\n" ); + mpxp_err<<"[export] Buffer size must be between 1 and 2048"<<std::endl; return MPXP_Ok; case AF_CONTROL_EXPORT_SZ | AF_CONTROL_GET: @@ -180,9 +167,6 @@ if(s->fd > -1) close(s->fd); - if(s->filename) - delete s->filename; - delete s; af->setup = NULL; } Modified: mplayerxp/postproc/af_raw.cpp =================================================================== --- mplayerxp/postproc/af_raw.cpp 2012-12-22 12:17:38 UTC (rev 596) +++ mplayerxp/postproc/af_raw.cpp 2012-12-22 12:47:25 UTC (rev 597) @@ -20,7 +20,6 @@ #include "af.h" #include "af_internal.h" #include "mpxp_help.h" -#include "osdep/get_path.h" #include "pp_msg.h" #define WAV_ID_RIFF 0x46464952 /* "RIFF" */ 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 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 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 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] |