summaryrefslogtreecommitdiffstats
path: root/stream
diff options
context:
space:
mode:
authorUoti Urpala <uau@glyph.nonexistent.invalid>2010-05-30 16:25:04 +0300
committerUoti Urpala <uau@glyph.nonexistent.invalid>2010-05-30 16:25:04 +0300
commit8ce2c41ca57b405dc5bbe9b3d552e7755abbdeb9 (patch)
treea7be3f915e6d2d8a3d06544fbbdd692dcf19956d /stream
parent78f51a921f0141362fc95f215ffade5e87d87578 (diff)
parentc36de0867fc576ad5fd58fc28bd5fe3322579f36 (diff)
downloadmpv-8ce2c41ca57b405dc5bbe9b3d552e7755abbdeb9.tar.bz2
mpv-8ce2c41ca57b405dc5bbe9b3d552e7755abbdeb9.tar.xz
Merge svn changes up to r31226
Diffstat (limited to 'stream')
-rw-r--r--stream/cache2.c14
-rw-r--r--stream/stream.c5
2 files changed, 15 insertions, 4 deletions
diff --git a/stream/cache2.c b/stream/cache2.c
index 2558adbb91..67c2b174c0 100644
--- a/stream/cache2.c
+++ b/stream/cache2.c
@@ -223,7 +223,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){
@@ -351,11 +351,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);
@@ -441,7 +450,6 @@ err_out:
#if FORKED_CACHE
signal(SIGTERM,exit_sighandler); // kill
- signal(SIGUSR1, dummy_sighandler); // wakeup
cache_mainloop(s);
// make sure forked code never leaves this function
exit(0);
@@ -464,7 +472,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);
@@ -475,6 +482,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 80e37369f7..165166245d 100644
--- a/stream/stream.c
+++ b/stream/stream.c
@@ -260,7 +260,7 @@ stream_t *open_output_stream(const char *filename, struct MPOpts *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
@@ -282,6 +282,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;