summaryrefslogtreecommitdiff
path: root/formats/format_h264.c
diff options
context:
space:
mode:
authorSean Bright <sean.bright@gmail.com>2017-09-05 11:05:48 -0400
committerSean Bright <sean.bright@gmail.com>2017-09-05 11:05:48 -0400
commit3f7d0b63fcbbb995970f8c249e9202c8a2a9114a (patch)
treef3ecf189f152ca4e1954b323357b61bce155e9bb /formats/format_h264.c
parent7b240d173436ad828008d1cb3c1eae10932518be (diff)
formats: Restore previous fread() behavior
Some formats are able to handle short reads while others are not, so restore the previous behavior for the format modules so that we don't have spurious errors when playing back files. ASTERISK-27232 #close Reported by: Jens T. Change-Id: Iab7f52b25a394f277566c8a2a4b15a692280a300
Diffstat (limited to 'formats/format_h264.c')
-rw-r--r--formats/format_h264.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/formats/format_h264.c b/formats/format_h264.c
index f8906f423..30604004e 100644
--- a/formats/format_h264.c
+++ b/formats/format_h264.c
@@ -61,7 +61,7 @@ static int h264_open(struct ast_filestream *s)
static struct ast_frame *h264_read(struct ast_filestream *s, int *whennext)
{
- int res;
+ size_t res;
int mark = 0;
unsigned short len;
unsigned int ts;
@@ -79,15 +79,10 @@ static struct ast_frame *h264_read(struct ast_filestream *s, int *whennext)
}
AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, len);
if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) != s->fr.datalen) {
- if (feof(s->f)) {
- if (res) {
- ast_debug(3, "Incomplete frame data at end of %s file "
- "(expected %d bytes, read %d)\n",
- ast_format_get_name(s->fr.subclass.format), s->fr.datalen, res);
- }
- } else {
- ast_log(LOG_ERROR, "Error while reading %s file: %s\n",
- ast_format_get_name(s->fr.subclass.format), strerror(errno));
+ if (res) {
+ ast_log(LOG_WARNING, "Short read of %s data (expected %d bytes, read %zu): %s\n",
+ ast_format_get_name(s->fr.subclass.format), s->fr.datalen, res,
+ strerror(errno));
}
return NULL;
}