[MPlayer-dev-eng] libmpdemux/cache2.c: correct format strings given _FILE_OFFSET_BITS
a.guru at sympatico.ca
a.guru at sympatico.ca
Sun Aug 14 00:55:57 CEST 2005
Hi.
I noticed that "pre:0" was systematically being
printed in the CACHE_PRE_INIT message, even
though this value is usually non-zero. This was
because three 64-bit zero off_t values being
pushed on the stack before two 32-bit values
were consumed by mp_msg() as mere 32-bit values.
This patch defines two format-string macros
according to _FILE_OFFSET_BITS and adds an useful
new CACHE message.
--- libmpdemux/cache2.c.orig-1.0pre7 2004-07-26 18:06:30 -0400
+++ libmpdemux/cache2.c 2005-08-13 18:24:59 -0400
@@ -27,6 +27,13 @@ static DWORD WINAPI ThreadProc(void* s);
#endif
#include "mp_msg.h"
+#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64
+# define OFD "lld"
+# define OFX "llX"
+#else
+# define OFD "d"
+# define OFX "X"
+#endif
#include "stream.h"
@@ -119,7 +126,7 @@ int cache_fill(cache_vars_t* s){
if(read<s->min_filepos || read>s->max_filepos){
// seek...
- mp_msg(MSGT_CACHE,MSGL_DBG2,"Out of boundaries... seeking to 0x%X \n",read);
+ mp_msg(MSGT_CACHE,MSGL_DBG2,"Out of boundaries... seeking to 0x%"OFX" \n",read);
// streaming: drop cache contents only if seeking backward or too much fwd:
if(s->stream->type!=STREAMTYPE_STREAM ||
read<s->min_filepos || read>=s->max_filepos+s->buffer_size)
@@ -287,10 +294,15 @@ int stream_enable_cache(stream_t *stream
stream->cache_pid = CreateThread(NULL,0,ThreadProc,s,0,&threadId);
#endif
// wait until cache is filled at least prefill_init %
- mp_msg(MSGT_CACHE,MSGL_V,"CACHE_PRE_INIT: %d [%d] %d pre:%d eof:%d \n",
+ mp_msg(
+ MSGT_CACHE, MSGL_V,
+ "CACHE: size=%d min=%d prefill=%d buffer_size=%d fill_limit=%d prefill=%d\n",
+ size, min, prefill,
+ s->buffer_size, s->fill_limit, s->prefill);
+ mp_msg(MSGT_CACHE,MSGL_V,"CACHE_PRE_INIT: %"OFD" [%"OFD"] %"OFD" pre:%d eof:%d \n",
s->min_filepos,s->read_filepos,s->max_filepos,min,s->eof);
while(s->read_filepos<s->min_filepos || s->max_filepos-s->read_filepos<min){
- mp_msg(MSGT_CACHE,MSGL_STATUS,"\rCache fill: %5.2f%% (%d bytes) ",
+ mp_msg(MSGT_CACHE,MSGL_STATUS,"\rCache fill: %5.2f%% (%"OFD" bytes) ",
100.0*(float)(s->max_filepos-s->read_filepos)/(float)(s->buffer_size),
s->max_filepos-s->read_filepos
);
@@ -345,7 +357,7 @@ int cache_stream_seek_long(stream_t *str
s=stream->cache_data;
// s->seek_lock=1;
- mp_msg(MSGT_CACHE,MSGL_DBG2,"CACHE2_SEEK: 0x%X <= 0x%X (0x%X) <= 0x%X \n",s->min_filepos,(int)pos,s->read_filepos,s->max_filepos);
+ mp_msg(MSGT_CACHE,MSGL_DBG2,"CACHE2_SEEK: 0x%"OFX" <= 0x%"OFX" (0x%"OFX") <= 0x%"OFX" \n",s->min_filepos,pos,s->read_filepos,s->max_filepos);
newpos=pos/s->sector_size; newpos*=s->sector_size; // align
stream->pos=s->read_filepos=newpos;
@@ -362,11 +374,7 @@ int cache_stream_seek_long(stream_t *str
// stream->buf_pos=stream->buf_len=0;
// return 1;
-#ifdef _LARGEFILE_SOURCE
- mp_msg(MSGT_CACHE,MSGL_V,"cache_stream_seek: WARNING! Can't seek to 0x%llX !\n",(long long)(pos+newpos));
-#else
- mp_msg(MSGT_CACHE,MSGL_V,"cache_stream_seek: WARNING! Can't seek to 0x%X !\n",(pos+newpos));
-#endif
+ mp_msg(MSGT_CACHE,MSGL_V,"cache_stream_seek: WARNING! Can't seek to 0x%"OFX" !\n",(pos+newpos));
return 0;
}
More information about the MPlayer-dev-eng
mailing list