diff stream/cache2.c @ 30360:c74a5f8ffab3

Change code to allow playing a stream even if enabling the cache failed while still handling it when the user aborts the cache fill.
author reimar
date Sat, 23 Jan 2010 12:13:28 +0000
parents 44b8f698fd15
children 48c51ebbe421
line wrap: on
line diff
--- a/stream/cache2.c	Sat Jan 23 11:51:13 2010 +0000
+++ b/stream/cache2.c	Sat Jan 23 12:13:28 2010 +0000
@@ -313,6 +313,9 @@
   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 @@
   }
 
   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 @@
     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",