stream: don't set EOF flag in stream implementations

EOF should be set when reading more data fails. The stream
implementations have nothing to say here and should behave correctly
when trying to read when EOF was actually read.

Even when seeking, a correct EOF flag should be guaranteed. stream_seek()
(or actually stream_seek_long()) calls stream_fill_buffer() at least
once, which also updates the EOF flag.
This commit is contained in:
wm4 2013-06-06 20:40:02 +02:00
parent 1c35794efd
commit 0d5e6084ae
7 changed files with 1 additions and 13 deletions

View File

@ -397,7 +397,6 @@ eof_out:
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->pos += len;
stream_capture_write(s, buf, len);
@ -421,7 +420,6 @@ void stream_unread_buffer(stream_t *s, void *buffer, size_t buffer_size)
memcpy(s->buffer, buffer, buffer_size);
s->buf_pos = 0;
s->buf_len = buffer_size + remainder;
s->eof = 0;
}
int stream_fill_buffer(stream_t *s)

View File

@ -200,7 +200,6 @@ static int fill_buffer(stream_t *s, char *buffer, int max_len)
return -1;
if ((p->sector < p->start_sector) || (p->sector > p->end_sector)) {
s->eof = 1;
return 0;
}
@ -237,7 +236,6 @@ static int seek(stream_t *s, int64_t newpos)
s->pos = newpos;
sec = s->pos / CDIO_CD_FRAMESIZE_RAW;
if (s->pos < 0 || sec > p->end_sector) {
s->eof = 1;
p->sector = p->end_sector + 1;
return 0;
}

View File

@ -541,7 +541,6 @@ int dvb_set_channel(stream_t *stream, int card, int n)
stream->buf_pos = stream->buf_len = 0;
stream->pos = 0;
stream->eof = 0;
if(channel->freq != priv->last_freq)
if (! dvb_tune(priv, channel->freq, channel->pol, channel->srate, channel->diseqc, channel->tone,

View File

@ -55,8 +55,6 @@ static const struct m_struct_st stream_opts = {
static int fill_buffer(stream_t *s, char* buffer, int max_len){
int r = read(s->fd,buffer,max_len);
// We are certain this is EOF, do not retry
if (max_len && r == 0) s->eof = 1;
return (r <= 0) ? -1 : r;
}
@ -76,7 +74,6 @@ static int write_buffer(stream_t *s, char* buffer, int len) {
static int seek(stream_t *s,int64_t newpos) {
s->pos = newpos;
if(lseek(s->fd,s->pos,SEEK_SET)<0) {
s->eof=1;
return 0;
}
return 1;
@ -89,7 +86,7 @@ static int seek_forward(stream_t *s,int64_t newpos) {
}
while(s->pos<newpos){
int len=s->fill_buffer(s,s->buffer,STREAM_BUFFER_SIZE);
if(len<=0){ s->eof=1; s->buf_pos=s->buf_len=0; break; } // EOF
if(len<=0){ s->buf_pos=s->buf_len=0; break; } // EOF
s->buf_pos=0;
s->buf_len=len;
s->pos+=len;

View File

@ -337,7 +337,6 @@ static int seek(stream_t *s,int64_t newpos) {
char rsp_txt[256];
if(s->pos > s->end_pos) {
s->eof=1;
return 0;
}
@ -376,7 +375,6 @@ static int seek(stream_t *s,int64_t newpos) {
resp = readresp(p,rsp_txt);
if(resp != 4 && resp != 2) {
mp_msg(MSGT_OPEN,MSGL_ERR, "[ftp] Server didn't abort correctly: %s\n",rsp_txt);
s->eof = 1;
return 0;
}
// Send the ABOR command

View File

@ -60,7 +60,6 @@ static int seek(stream_t *s, int64_t newpos)
return -1;
s->pos = newpos;
if (avio_seek(avio, s->pos, SEEK_SET) < 0) {
s->eof = 1;
return 0;
}
return 1;

View File

@ -88,7 +88,6 @@ static int control(stream_t *s, int cmd, void *arg) {
static int seek(stream_t *s,int64_t newpos) {
s->pos = newpos;
if(smbc_lseek(s->fd,s->pos,SEEK_SET)<0) {
s->eof=1;
return 0;
}
return 1;