summaryrefslogtreecommitdiffstats
path: root/stream
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2010-05-28 17:26:31 +0000
committerreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2010-05-28 17:26:31 +0000
commit6f7c1ea40922a7093e07958dc12d5519505c5a63 (patch)
tree32d87a820f114567cd94e5982c6e567650172eac /stream
parent4448190ef0c0c8029a3b3a41aab5b913ca0caa2b (diff)
downloadmpv-6f7c1ea40922a7093e07958dc12d5519505c5a63.tar.bz2
mpv-6f7c1ea40922a7093e07958dc12d5519505c5a63.tar.xz
Improve handling of cache process/thread hanging/being killed.
In particular allow a single STRG+C to quit MPlayer. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@31251 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'stream')
-rw-r--r--stream/cache2.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/stream/cache2.c b/stream/cache2.c
index e13f3e75f3..dd9f4414a7 100644
--- a/stream/cache2.c
+++ b/stream/cache2.c
@@ -116,6 +116,8 @@ static void cache_stats(cache_vars_t *s)
static int cache_read(cache_vars_t *s, unsigned char *buf, int size)
{
int total=0;
+ int sleep_count = 0;
+ int last_max = s->max_filepos;
while(size>0){
int pos,newb,len;
@@ -124,10 +126,21 @@ static int cache_read(cache_vars_t *s, unsigned char *buf, int size)
if(s->read_filepos>=s->max_filepos || s->read_filepos<s->min_filepos){
// eof?
if(s->eof) break;
+ if (s->max_filepos == last_max) {
+ if (sleep_count++ == 5)
+ mp_msg(MSGT_CACHE, MSGL_WARN, "Cache not filling!\n");
+ } else {
+ last_max = s->max_filepos;
+ sleep_count = 0;
+ }
// waiting for buffer fill...
- usec_sleep(READ_USLEEP_TIME); // 10ms
+ if (stream_check_interrupt(READ_USLEEP_TIME)) {
+ s->eof = 1;
+ break;
+ }
continue; // try again...
}
+ sleep_count = 0;
newb=s->max_filepos-s->read_filepos; // new bytes in the buffer
if(newb<min_fill) min_fill=newb; // statistics...
@@ -534,6 +547,7 @@ int cache_stream_seek_long(stream_t *stream,off_t pos){
}
int cache_do_control(stream_t *stream, int cmd, void *arg) {
+ int sleep_count = 0;
cache_vars_t* s = stream->cache_data;
switch (cmd) {
case STREAM_CTRL_SEEK_TO_TIME:
@@ -562,8 +576,14 @@ int cache_do_control(stream_t *stream, int cmd, void *arg) {
return STREAM_UNSUPPORTED;
}
cache_wakeup(stream);
- while (s->control != -1)
- usec_sleep(CONTROL_SLEEP_TIME);
+ while (s->control != -1) {
+ if (sleep_count++ == 1000)
+ mp_msg(MSGT_CACHE, MSGL_WARN, "Cache no responding!\n");
+ if (stream_check_interrupt(CONTROL_SLEEP_TIME)) {
+ s->eof = 1;
+ return STREAM_UNSUPPORTED;
+ }
+ }
switch (cmd) {
case STREAM_CTRL_GET_TIME_LENGTH:
case STREAM_CTRL_GET_CURRENT_TIME: