[Mplayerxp-cvslog] SF.net SVN: mplayerxp:[527] mplayerxp
Brought to you by:
olov
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. |