comparison stream/stream_file.c @ 35018:5f3501f7f4d9

Explicitly signal EOF when reaching the end of a file/pipe. Fixes a 4 second delay due to stream_reconnect for e.g. echo | mplayer -
author reimar
date Wed, 22 Aug 2012 18:24:56 +0000
parents 3e37890b6261
children ceb148e1fe31
comparison
equal deleted inserted replaced
35017:2136289a9c39 35018:5f3501f7f4d9
54 stream_opts_fields 54 stream_opts_fields
55 }; 55 };
56 56
57 static int fill_buffer(stream_t *s, char* buffer, int max_len){ 57 static int fill_buffer(stream_t *s, char* buffer, int max_len){
58 int r = read(s->fd,buffer,max_len); 58 int r = read(s->fd,buffer,max_len);
59 // We are certain this is EOF, do not retry
60 if (max_len && r == 0) s->eof = 1;
59 return (r <= 0) ? -1 : r; 61 return (r <= 0) ? -1 : r;
60 } 62 }
61 63
62 static int write_buffer(stream_t *s, char* buffer, int len) { 64 static int write_buffer(stream_t *s, char* buffer, int len) {
63 int r; 65 int r;