From d304c1d56c5ffc242a0ffefcc2a1c9fedb12f56c Mon Sep 17 00:00:00 2001 From: reimar Date: Wed, 26 May 2010 17:27:38 +0000 Subject: Disable waking the cache process up via a signal, it currently causes read errors due to not handling EINTR. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@31223 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/cache2.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'stream') diff --git a/stream/cache2.c b/stream/cache2.c index 51989ebd2a..fef316f627 100644 --- a/stream/cache2.c +++ b/stream/cache2.c @@ -102,7 +102,10 @@ static void cache_wakeup(stream_t *s) { #if FORKED_CACHE // signal process to wake up immediately - kill(s->cache_pid, SIGUSR1); + // Disabled for now since it causes incorrect EOFs + // due to interrupting read syscalls - this should be + // fixed instead though +// kill(s->cache_pid, SIGUSR1); #endif } -- cgit v1.2.3 From 328306708f6687e9cf43a32930b252bc18ba851f Mon Sep 17 00:00:00 2001 From: reimar Date: Wed, 26 May 2010 17:56:11 +0000 Subject: Re-enable wakeup-on-signal for cache process. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@31224 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/cache2.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'stream') diff --git a/stream/cache2.c b/stream/cache2.c index fef316f627..e936e47dca 100644 --- a/stream/cache2.c +++ b/stream/cache2.c @@ -102,10 +102,7 @@ static void cache_wakeup(stream_t *s) { #if FORKED_CACHE // signal process to wake up immediately - // Disabled for now since it causes incorrect EOFs - // due to interrupting read syscalls - this should be - // fixed instead though -// kill(s->cache_pid, SIGUSR1); + kill(s->cache_pid, SIGUSR1); #endif } @@ -356,11 +353,20 @@ static void cache_mainloop(cache_vars_t *s) { int sleep_count = 0; do { if (!cache_fill(s)) { +#if FORKED_CACHE + // Let signal wake us up, we cannot leave this + // enabled since we do not handle EINTR in most places. + // This might need extra code to work on BSD. + signal(SIGUSR1, dummy_sighandler); +#endif if (sleep_count < INITIAL_FILL_USLEEP_COUNT) { sleep_count++; usec_sleep(INITIAL_FILL_USLEEP_TIME); } else usec_sleep(FILL_USLEEP_TIME); // idle +#if FORKED_CACHE + signal(SIGUSR1, SIG_IGN); +#endif } else sleep_count = 0; // cache_stats(s->cache_data); @@ -449,7 +455,6 @@ err_out: use_gui = 0; // mp_msg may not use gui stuff in forked code #endif signal(SIGTERM,exit_sighandler); // kill - signal(SIGUSR1, dummy_sighandler); // wakeup cache_mainloop(s); // make sure forked code never leaves this function exit(0); -- cgit v1.2.3 From c36de0867fc576ad5fd58fc28bd5fe3322579f36 Mon Sep 17 00:00:00 2001 From: reimar Date: Wed, 26 May 2010 18:23:43 +0000 Subject: Retry reading even if we hit eof before. This allows playing growing files even with a large cache. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@31226 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/cache2.c | 4 ++-- stream/stream.c | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'stream') diff --git a/stream/cache2.c b/stream/cache2.c index e936e47dca..533781104b 100644 --- a/stream/cache2.c +++ b/stream/cache2.c @@ -225,7 +225,7 @@ static int cache_fill(cache_vars_t *s) //memcpy(&s->buffer[pos],s->stream->buffer,len); // avoid this extra copy! // .... len=stream_read(s->stream,&s->buffer[pos],space); - if(!len) s->eof=1; + s->eof= !len; s->max_filepos+=len; if(pos+len>=s->buffer_size){ @@ -477,7 +477,6 @@ static void *ThreadProc( void *s ){ int cache_stream_fill_buffer(stream_t *s){ int len; - if(s->eof){ s->buf_pos=s->buf_len=0; return 0; } if(!s->cache_pid) return stream_fill_buffer(s); // cache_stats(s->cache_data); @@ -488,6 +487,7 @@ int cache_stream_fill_buffer(stream_t *s){ //printf("cache_stream_fill_buffer->read -> %d\n",len); if(len<=0){ s->eof=1; s->buf_pos=s->buf_len=0; return 0; } + s->eof=0; s->buf_pos=0; s->buf_len=len; s->pos+=len; diff --git a/stream/stream.c b/stream/stream.c index d4abc69343..cdd9713a20 100644 --- a/stream/stream.c +++ b/stream/stream.c @@ -263,7 +263,7 @@ stream_t* open_output_stream(const char* filename, char** options) { int stream_fill_buffer(stream_t *s){ int len; - if (/*s->fd == NULL ||*/ s->eof) { return 0; } + // we will retry even if we already reached EOF previously. switch(s->type){ case STREAMTYPE_STREAM: #ifdef CONFIG_NETWORK @@ -285,6 +285,9 @@ int stream_fill_buffer(stream_t *s){ len= s->fill_buffer ? s->fill_buffer(s,s->buffer,STREAM_BUFFER_SIZE) : 0; } if(len<=0){ s->eof=1; return 0; } + // When reading succeeded we are obviously not at eof. + // This e.g. avoids issues with eof getting stuck when lavf seeks in MPEG-TS + s->eof=0; s->buf_pos=0; s->buf_len=len; s->pos+=len; -- cgit v1.2.3