Skip to content

Commit

Permalink
avio: deprecate url_feof
Browse files Browse the repository at this point in the history
AVIOContext.eof_reached should be used directly instead.

Signed-off-by: Ronald S. Bultje <[email protected]>
  • Loading branch information
elenril authored and rbultje committed Mar 7, 2011
1 parent 6a7e074 commit 66e5b1d
Show file tree
Hide file tree
Showing 64 changed files with 116 additions and 115 deletions.
2 changes: 1 addition & 1 deletion ffplay.c
Original file line number Diff line number Diff line change
Expand Up @@ -2568,7 +2568,7 @@ static int decode_thread(void *arg)
}
ret = av_read_frame(ic, pkt);
if (ret < 0) {
if (ret == AVERROR_EOF || url_feof(ic->pb))
if (ret == AVERROR_EOF || ic->pb->eof_reached)
eof=1;
if (url_ferror(ic->pb))
break;
Expand Down
2 changes: 1 addition & 1 deletion libavformat/4xm.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ static int fourxm_read_packet(AVFormatContext *s,
return ret;
fourcc_tag = AV_RL32(&header[0]);
size = AV_RL32(&header[4]);
if (url_feof(pb))
if (pb->eof_reached)
return AVERROR(EIO);
switch (fourcc_tag) {

Expand Down
2 changes: 1 addition & 1 deletion libavformat/aiffdec.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static int get_tag(AVIOContext *pb, uint32_t * tag)
{
int size;

if (url_feof(pb))
if (pb->eof_reached)
return AVERROR(EIO);

*tag = avio_rl32(pb);
Expand Down
2 changes: 1 addition & 1 deletion libavformat/amr.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ static int amr_read_packet(AVFormatContext *s,
AVCodecContext *enc = s->streams[0]->codec;
int read, size = 0, toc, mode;

if (url_feof(s->pb))
if (s->pb->eof_reached)
{
return AVERROR(EIO);
}
Expand Down
2 changes: 1 addition & 1 deletion libavformat/anm.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ static int read_packet(AVFormatContext *s,
Page *p;
int tmp, record_size;

if (url_feof(s->pb))
if (s->pb->eof_reached)
return AVERROR(EIO);

if (anm->page < 0)
Expand Down
2 changes: 1 addition & 1 deletion libavformat/ape.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ static int ape_read_packet(AVFormatContext * s, AVPacket * pkt)
APEContext *ape = s->priv_data;
uint32_t extra_size = 8;

if (url_feof(s->pb))
if (s->pb->eof_reached)
return AVERROR(EIO);
if (ape->currentframe > ape->totalframes)
return AVERROR(EIO);
Expand Down
4 changes: 2 additions & 2 deletions libavformat/applehttp.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ static int parse_playlist(AppleHTTPContext *c, const char *url,
if (var)
free_segment_list(var);
c->finished = 0;
while (!url_feof(in)) {
while (!in->eof_reached) {
read_chomp_line(in, line, sizeof(line));
if (av_strstart(line, "#EXT-X-STREAM-INF:", &ptr)) {
struct variant_info info = {{0}};
Expand Down Expand Up @@ -457,7 +457,7 @@ static int applehttp_read_packet(AVFormatContext *s, AVPacket *pkt)
if (var->pb && !var->pkt.data) {
ret = av_read_frame(var->ctx, &var->pkt);
if (ret < 0) {
if (!url_feof(var->pb))
if (!var->pb->eof_reached)
return ret;
reset_packet(&var->pkt);
}
Expand Down
2 changes: 1 addition & 1 deletion libavformat/applehttpproto.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ static int parse_playlist(URLContext *h, const char *url)

free_segment_list(s);
s->finished = 0;
while (!url_feof(in)) {
while (!in->eof_reached) {
read_chomp_line(in, line, sizeof(line));
if (av_strstart(line, "#EXT-X-STREAM-INF:", &ptr)) {
struct variant_info info = {{0}};
Expand Down
12 changes: 6 additions & 6 deletions libavformat/asfdec.c
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
continue;
} else if (!ff_guidcmp(&g, &ff_asf_marker_header)) {
asf_read_marker(s, gsize);
} else if (url_feof(pb)) {
} else if (pb->eof_reached) {
return -1;
} else {
if (!s->keylen) {
Expand All @@ -660,7 +660,7 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
avio_rl64(pb);
avio_r8(pb);
avio_r8(pb);
if (url_feof(pb))
if (pb->eof_reached)
return -1;
asf->data_offset = avio_tell(pb);
asf->packet_size_left = 0;
Expand Down Expand Up @@ -745,12 +745,12 @@ static int ff_asf_get_packet(AVFormatContext *s, AVIOContext *pb)
*/
if (url_ferror(pb) == AVERROR(EAGAIN))
return AVERROR(EAGAIN);
if (!url_feof(pb))
if (!pb->eof_reached)
av_log(s, AV_LOG_ERROR, "ff asf bad header %x at:%"PRId64"\n", c, avio_tell(pb));
}
if ((c & 0x8f) == 0x82) {
if (d || e) {
if (!url_feof(pb))
if (!pb->eof_reached)
av_log(s, AV_LOG_ERROR, "ff asf bad non zero\n");
return -1;
}
Expand Down Expand Up @@ -886,7 +886,7 @@ static int ff_asf_parse_packet(AVFormatContext *s, AVIOContext *pb, AVPacket *pk
ASFStream *asf_st = 0;
for (;;) {
int ret;
if(url_feof(pb))
if(pb->eof_reached)
return AVERROR_EOF;
if (asf->packet_size_left < FRAME_HEADER_SIZE
|| asf->packet_segments < 1) {
Expand Down Expand Up @@ -1195,7 +1195,7 @@ static void asf_build_simple_index(AVFormatContext *s, int stream_index)
skip them until the simple index object is reached */
while (ff_guidcmp(&g, &index_guid)) {
int64_t gsize= avio_rl64(s->pb);
if (gsize < 24 || url_feof(s->pb)) {
if (gsize < 24 || s->pb->eof_reached) {
avio_seek(s->pb, current_pos, SEEK_SET);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion libavformat/assdec.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap)
header_remaining= INT_MAX;
dst[0] = &st->codec->extradata;
dst[1] = &ass->event_buffer;
while(!url_feof(pb)){
while(!pb->eof_reached){
uint8_t line[MAX_LINESIZE];

len = ff_get_line(pb, line, sizeof(line));
Expand Down
12 changes: 6 additions & 6 deletions libavformat/avidec.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ static int read_braindead_odml_indx(AVFormatContext *s, int frame_num){
#ifdef DEBUG_SEEK
av_log(s, AV_LOG_ERROR, "pos:%"PRId64", len:%X\n", pos, len);
#endif
if(url_feof(pb))
if(pb->eof_reached)
return -1;

if(last_pos == pos || pos == base - 8)
Expand All @@ -195,7 +195,7 @@ static int read_braindead_odml_indx(AVFormatContext *s, int frame_num){
avio_rl32(pb); /* size */
duration = avio_rl32(pb);

if(url_feof(pb))
if(pb->eof_reached)
return -1;

pos = avio_tell(pb);
Expand Down Expand Up @@ -360,7 +360,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
codec_type = -1;
frame_period = 0;
for(;;) {
if (url_feof(pb))
if (pb->eof_reached)
goto fail;
tag = avio_rl32(pb);
size = avio_rl32(pb);
Expand Down Expand Up @@ -989,7 +989,7 @@ static int avi_read_packet(AVFormatContext *s, AVPacket *pkt)
}

memset(d, -1, sizeof(int)*8);
for(i=sync=avio_tell(pb); !url_feof(pb); i++) {
for(i=sync=avio_tell(pb); !pb->eof_reached; i++) {
int j;

for(j=0; j<7; j++)
Expand Down Expand Up @@ -1145,7 +1145,7 @@ static int avi_read_idx1(AVFormatContext *s, int size)
#if defined(DEBUG_SEEK)
av_log(s, AV_LOG_DEBUG, "%d cum_len=%"PRId64"\n", len, ast->cum_len);
#endif
if(url_feof(pb))
if(pb->eof_reached)
return -1;

if(last_pos == pos)
Expand Down Expand Up @@ -1203,7 +1203,7 @@ static int avi_load_index(AVFormatContext *s)
printf("movi_end=0x%"PRIx64"\n", avi->movi_end);
#endif
for(;;) {
if (url_feof(pb))
if (pb->eof_reached)
break;
tag = avio_rl32(pb);
size = avio_rl32(pb);
Expand Down
11 changes: 5 additions & 6 deletions libavformat/avio.h
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,11 @@ attribute_deprecated int url_fgetc(AVIOContext *s);
/**
* @}
*/

/**
* @deprecated use AVIOContext.eof_reached
*/
attribute_deprecated int url_feof(AVIOContext *s);
#endif

AVIOContext *avio_alloc_context(
Expand Down Expand Up @@ -494,12 +499,6 @@ int64_t avio_seek(AVIOContext *s, int64_t offset, int whence);
*/
int64_t avio_size(AVIOContext *s);

/**
* feof() equivalent for AVIOContext.
* @return non zero if and only if end of file
*/
int url_feof(AVIOContext *s);

int url_ferror(AVIOContext *s);

int av_url_read_fpause(AVIOContext *h, int pause);
Expand Down
10 changes: 6 additions & 4 deletions libavformat/aviobuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,14 @@ int64_t avio_size(AVIOContext *s)
return size;
}

#if FF_API_OLD_AVIO
int url_feof(AVIOContext *s)
{
if(!s)
return 0;
return s->eof_reached;
}
#endif

int url_ferror(AVIOContext *s)
{
Expand Down Expand Up @@ -598,7 +600,7 @@ int avio_read(AVIOContext *s, unsigned char *buf, int size)
}
if (size1 == size) {
if (url_ferror(s)) return url_ferror(s);
if (url_feof(s)) return AVERROR_EOF;
if (s->eof_reached) return AVERROR_EOF;
}
return size1 - size;
}
Expand All @@ -621,7 +623,7 @@ int ffio_read_partial(AVIOContext *s, unsigned char *buf, int size)
s->buf_ptr += len;
if (!len) {
if (url_ferror(s)) return url_ferror(s);
if (url_feof(s)) return AVERROR_EOF;
if (s->eof_reached) return AVERROR_EOF;
}
return len;
}
Expand Down Expand Up @@ -928,11 +930,11 @@ char *url_fgets(AVIOContext *s, char *buf, int buf_size)
char *q;

c = avio_r8(s);
if (url_feof(s))
if (s->eof_reached)
return NULL;
q = buf;
for(;;) {
if (url_feof(s) || c == '\n')
if (s->eof_reached || c == '\n')
break;
if ((q - buf) < buf_size - 1)
*q++ = c;
Expand Down
2 changes: 1 addition & 1 deletion libavformat/bethsoftvid.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ static int vid_read_packet(AVFormatContext *s,
int audio_length;
int ret_value;

if(vid->is_finished || url_feof(pb))
if(vid->is_finished || pb->eof_reached)
return AVERROR(EIO);

block_type = avio_r8(pb);
Expand Down
4 changes: 2 additions & 2 deletions libavformat/bfi.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,15 @@ static int bfi_read_packet(AVFormatContext * s, AVPacket * pkt)
BFIContext *bfi = s->priv_data;
AVIOContext *pb = s->pb;
int ret, audio_offset, video_offset, chunk_size, audio_size = 0;
if (bfi->nframes == 0 || url_feof(pb)) {
if (bfi->nframes == 0 || pb->eof_reached) {
return AVERROR(EIO);
}

/* If all previous chunks were completely read, then find a new one... */
if (!bfi->avflag) {
uint32_t state = 0;
while(state != MKTAG('S','A','V','I')){
if (url_feof(pb))
if (pb->eof_reached)
return AVERROR(EIO);
state = 256*state + avio_r8(pb);
}
Expand Down
6 changes: 3 additions & 3 deletions libavformat/cafdec.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ static int read_header(AVFormatContext *s,

/* parse each chunk */
found_data = 0;
while (!url_feof(pb)) {
while (!pb->eof_reached) {

/* stop at data chunk if seeking is not supported or
data chunk size is unknown */
Expand All @@ -228,7 +228,7 @@ static int read_header(AVFormatContext *s,

tag = avio_rb32(pb);
size = avio_rb64(pb);
if (url_feof(pb))
if (pb->eof_reached)
break;

switch (tag) {
Expand Down Expand Up @@ -307,7 +307,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
int res, pkt_size = 0, pkt_frames = 0;
int64_t left = CAF_MAX_PKT_SIZE;

if (url_feof(pb))
if (pb->eof_reached)
return AVERROR(EIO);

/* don't read past end of data chunk */
Expand Down
2 changes: 1 addition & 1 deletion libavformat/daud.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static int daud_header(AVFormatContext *s, AVFormatParameters *ap) {
static int daud_packet(AVFormatContext *s, AVPacket *pkt) {
AVIOContext *pb = s->pb;
int ret, size;
if (url_feof(pb))
if (pb->eof_reached)
return AVERROR(EIO);
size = avio_rb16(pb);
avio_rb16(pb); // unknown
Expand Down
2 changes: 1 addition & 1 deletion libavformat/dsicin.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ static int cin_read_frame_header(CinDemuxContext *cin, AVIOContext *pb) {
hdr->video_frame_size = avio_rl32(pb);
hdr->audio_frame_size = avio_rl32(pb);

if (url_feof(pb) || url_ferror(pb))
if (pb->eof_reached || url_ferror(pb))
return AVERROR(EIO);

if (avio_rl32(pb) != 0xAA55AA55)
Expand Down
2 changes: 1 addition & 1 deletion libavformat/dv.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ static int dv_read_header(AVFormatContext *s,

state = avio_rb32(s->pb);
while ((state & 0xffffff7f) != 0x1f07003f) {
if (url_feof(s->pb)) {
if (s->pb->eof_reached) {
av_log(s, AV_LOG_ERROR, "Cannot find DV header.\n");
return -1;
}
Expand Down
4 changes: 2 additions & 2 deletions libavformat/dxa.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ static int dxa_read_header(AVFormatContext *s, AVFormatParameters *ap)
return -1;
ff_get_wav_header(pb, ast->codec, fsize);
// find 'data' chunk
while(avio_tell(pb) < c->vidpos && !url_feof(pb)){
while(avio_tell(pb) < c->vidpos && !pb->eof_reached){
tag = avio_rl32(pb);
fsize = avio_rl32(pb);
if(tag == MKTAG('d', 'a', 't', 'a')) break;
Expand Down Expand Up @@ -162,7 +162,7 @@ static int dxa_read_packet(AVFormatContext *s, AVPacket *pkt)
return 0;
}
avio_seek(s->pb, c->vidpos, SEEK_SET);
while(!url_feof(s->pb) && c->frames){
while(!s->pb->eof_reached && c->frames){
avio_read(s->pb, buf, 4);
switch(AV_RL32(buf)){
case MKTAG('N', 'U', 'L', 'L'):
Expand Down
4 changes: 2 additions & 2 deletions libavformat/electronicarts.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ static int process_audio_header_elements(AVFormatContext *s)
ea->sample_rate = -1;
ea->num_channels = 1;

while (!url_feof(pb) && inHeader) {
while (!pb->eof_reached && inHeader) {
int inSubheader;
uint8_t byte;
byte = avio_r8(pb);
Expand All @@ -118,7 +118,7 @@ static int process_audio_header_elements(AVFormatContext *s)
case 0xFD:
av_log (s, AV_LOG_DEBUG, "entered audio subheader\n");
inSubheader = 1;
while (!url_feof(pb) && inSubheader) {
while (!pb->eof_reached && inSubheader) {
uint8_t subbyte;
subbyte = avio_r8(pb);

Expand Down
2 changes: 1 addition & 1 deletion libavformat/ffmdec.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ static int ffm_resync(AVFormatContext *s, int state)
{
av_log(s, AV_LOG_ERROR, "resyncing\n");
while (state != PACKET_ID) {
if (url_feof(s->pb)) {
if (s->pb->eof_reached) {
av_log(s, AV_LOG_ERROR, "cannot find FFM syncword\n");
return -1;
}
Expand Down
Loading

0 comments on commit 66e5b1d

Please sign in to comment.