[MPlayer-cvslog] r30402 - in trunk: mplayer.c stream/cache2.c

reimar subversion at mplayerhq.hu
Sat Jan 23 13:13:28 CET 2010


Author: reimar
Date: Sat Jan 23 13:13:28 2010
New Revision: 30402

Log:
Change code to allow playing a stream even if enabling the cache failed
while still handling it when the user aborts the cache fill.

Modified:
   trunk/mplayer.c
   trunk/stream/cache2.c

Modified: trunk/mplayer.c
==============================================================================
--- trunk/mplayer.c	Sat Jan 23 12:51:13 2010	(r30401)
+++ trunk/mplayer.c	Sat Jan 23 13:13:28 2010	(r30402)
@@ -3281,10 +3281,12 @@ if(mpctx->stream->type==STREAMTYPE_DVDNA
 // CACHE2: initial prefill: 20%  later: 5%  (should be set by -cacheopts)
 goto_enable_cache:
 if(stream_cache_size>0){
+  int res;
   current_module="enable_cache";
-  if(!stream_enable_cache(mpctx->stream,stream_cache_size*1024,
+  res = stream_enable_cache(mpctx->stream,stream_cache_size*1024,
                           stream_cache_size*1024*(stream_cache_min_percent / 100.0),
-                          stream_cache_size*1024*(stream_cache_seek_min_percent / 100.0)))
+                          stream_cache_size*1024*(stream_cache_seek_min_percent / 100.0));
+  if(res == 0)
     if((mpctx->eof = libmpdemux_was_interrupted(PT_NEXT_ENTRY))) goto goto_next_file;
 }
 

Modified: trunk/stream/cache2.c
==============================================================================
--- trunk/stream/cache2.c	Sat Jan 23 12:51:13 2010	(r30401)
+++ trunk/stream/cache2.c	Sat Jan 23 13:13:28 2010	(r30402)
@@ -313,6 +313,9 @@ static void exit_sighandler(int x){
   exit(0);
 }
 
+/**
+ * \return 1 on success, 0 if the function was interrupted and -1 on error
+ */
 int stream_enable_cache(stream_t *stream,int size,int min,int seek_limit){
   int ss = stream->sector_size ? stream->sector_size : STREAM_BUFFER_SIZE;
   cache_vars_t* s;
@@ -323,7 +326,7 @@ int stream_enable_cache(stream_t *stream
   }
 
   s=cache_init(size,ss);
-  if(s == NULL) return 0;
+  if(s == NULL) return -1;
   stream->cache_data=s;
   s->stream=stream; // callback
   s->seek_limit=seek_limit;
@@ -362,7 +365,7 @@ int stream_enable_cache(stream_t *stream
     if (!stream->cache_pid) {
         mp_msg(MSGT_CACHE, MSGL_ERR,
                "Starting cache process/thread failed: %s.\n", strerror(errno));
-        return 0;
+        return -1;
     }
     // wait until cache is filled at least prefill_init %
     mp_msg(MSGT_CACHE,MSGL_V,"CACHE_PRE_INIT: %"PRId64" [%"PRId64"] %"PRId64"  pre:%d  eof:%d  \n",


More information about the MPlayer-cvslog mailing list