diff options
author | jstebbins <[email protected]> | 2015-06-29 16:05:38 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2015-06-29 16:05:38 +0000 |
commit | 10f6690cfa1ebbd5a837e03f70d011b51ea7690a (patch) | |
tree | 7cbd3196b1367cade621ae14fe932778bc4d86bd /libhb/stream.c | |
parent | af9de404779378e28af413d18291975dedd68861 (diff) |
libhb: detect read errors and propagate
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7332 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/stream.c')
-rw-r--r-- | libhb/stream.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/libhb/stream.c b/libhb/stream.c index cb669e52f..e404513e0 100644 --- a/libhb/stream.c +++ b/libhb/stream.c @@ -1125,6 +1125,12 @@ static const uint8_t *next_packet( hb_stream_t *stream ) if ( fread(stream->ts.packet, 1, stream->packetsize, stream->file_handle) != stream->packetsize ) { + int err; + if ((err = ferror(stream->file_handle)) != 0) + { + hb_error("next_packet: error (%d)", err); + hb_set_work_error(stream->h, HB_ERROR_READ); + } return NULL; } if (buf[0] == 0x47) @@ -2408,6 +2414,12 @@ static off_t align_to_next_packet(hb_stream_t *stream) } else { + int err; + if ((err = ferror(stream->file_handle)) != 0) + { + hb_error("align_to_next_packet: error (%d)", err); + hb_set_work_error(stream->h, HB_ERROR_READ); + } return 0; } } @@ -3352,9 +3364,18 @@ static int hb_ps_read_packet( hb_stream_t * stream, hb_buffer_t *b ) pos -= 4; fseeko( stream->file_handle, -4, SEEK_CUR ); } + done: // Parse packet for information we might need funlockfile( stream->file_handle ); + + int err; + if ((err = ferror(stream->file_handle)) != 0) + { + hb_error("hb_ps_read_packet: error (%d)", err); + hb_set_work_error(stream->h, HB_ERROR_READ); + } + int len = pos - b->size; b->size = pos; #undef cp @@ -5657,8 +5678,17 @@ hb_buffer_t * hb_ffmpeg_read( hb_stream_t *stream ) // use M$ 'packed b-frames' and occasionally have negative // sizes for the null frames these require. if ( err != AVERROR(ENOMEM) || stream->ffmpeg_pkt->size >= 0 ) - // eof + { + // error or eof + if (err != AVERROR_EOF) + { + char errstr[80]; + av_strerror(err, errstr, 80); + hb_error("av_read_frame error (%d): %s", err, errstr); + hb_set_work_error(stream->h, HB_ERROR_READ); + } return NULL; + } } if ( stream->ffmpeg_pkt->stream_index == stream->ffmpeg_video_id ) { |