Commit 266e88a4 authored by Paul B Mahol's avatar Paul B Mahol

mmf: return meaningful error codes

Signed-off-by: 's avatarPaul B Mahol <onemda@gmail.com>
parent b70251c0
...@@ -71,7 +71,7 @@ static int mmf_write_header(AVFormatContext *s) ...@@ -71,7 +71,7 @@ static int mmf_write_header(AVFormatContext *s)
rate = mmf_rate_code(s->streams[0]->codec->sample_rate); rate = mmf_rate_code(s->streams[0]->codec->sample_rate);
if(rate < 0) { if(rate < 0) {
av_log(s, AV_LOG_ERROR, "Unsupported sample rate %d, supported are 4000, 8000, 11025, 22050 and 44100\n", s->streams[0]->codec->sample_rate); av_log(s, AV_LOG_ERROR, "Unsupported sample rate %d, supported are 4000, 8000, 11025, 22050 and 44100\n", s->streams[0]->codec->sample_rate);
return -1; return AVERROR(EINVAL);
} }
ffio_wfourcc(pb, "MMMD"); ffio_wfourcc(pb, "MMMD");
...@@ -193,7 +193,7 @@ static int mmf_read_header(AVFormatContext *s) ...@@ -193,7 +193,7 @@ static int mmf_read_header(AVFormatContext *s)
tag = avio_rl32(pb); tag = avio_rl32(pb);
if (tag != MKTAG('M', 'M', 'M', 'D')) if (tag != MKTAG('M', 'M', 'M', 'D'))
return -1; return AVERROR_INVALIDDATA;
avio_skip(pb, 4); /* file_size */ avio_skip(pb, 4); /* file_size */
/* Skip some unused chunks that may or may not be present */ /* Skip some unused chunks that may or may not be present */
...@@ -208,11 +208,11 @@ static int mmf_read_header(AVFormatContext *s) ...@@ -208,11 +208,11 @@ static int mmf_read_header(AVFormatContext *s)
/* Tag = "ATRx", where "x" = track number */ /* Tag = "ATRx", where "x" = track number */
if ((tag & 0xffffff) == MKTAG('M', 'T', 'R', 0)) { if ((tag & 0xffffff) == MKTAG('M', 'T', 'R', 0)) {
av_log(s, AV_LOG_ERROR, "MIDI like format found, unsupported\n"); av_log(s, AV_LOG_ERROR, "MIDI like format found, unsupported\n");
return -1; return AVERROR_PATCHWELCOME;
} }
if ((tag & 0xffffff) != MKTAG('A', 'T', 'R', 0)) { if ((tag & 0xffffff) != MKTAG('A', 'T', 'R', 0)) {
av_log(s, AV_LOG_ERROR, "Unsupported SMAF chunk %08x\n", tag); av_log(s, AV_LOG_ERROR, "Unsupported SMAF chunk %08x\n", tag);
return -1; return AVERROR_PATCHWELCOME;
} }
avio_r8(pb); /* format type */ avio_r8(pb); /* format type */
...@@ -221,7 +221,7 @@ static int mmf_read_header(AVFormatContext *s) ...@@ -221,7 +221,7 @@ static int mmf_read_header(AVFormatContext *s)
rate = mmf_rate(params & 0x0f); rate = mmf_rate(params & 0x0f);
if(rate < 0) { if(rate < 0) {
av_log(s, AV_LOG_ERROR, "Invalid sample rate\n"); av_log(s, AV_LOG_ERROR, "Invalid sample rate\n");
return -1; return AVERROR_INVALIDDATA;
} }
avio_r8(pb); /* wave base bit */ avio_r8(pb); /* wave base bit */
avio_r8(pb); /* time base d */ avio_r8(pb); /* time base d */
...@@ -239,7 +239,7 @@ static int mmf_read_header(AVFormatContext *s) ...@@ -239,7 +239,7 @@ static int mmf_read_header(AVFormatContext *s)
/* Make sure it's followed by an Awa chunk, aka wave data */ /* Make sure it's followed by an Awa chunk, aka wave data */
if ((tag & 0xffffff) != MKTAG('A', 'w', 'a', 0)) { if ((tag & 0xffffff) != MKTAG('A', 'w', 'a', 0)) {
av_log(s, AV_LOG_ERROR, "Unexpected SMAF chunk %08x\n", tag); av_log(s, AV_LOG_ERROR, "Unexpected SMAF chunk %08x\n", tag);
return -1; return AVERROR_INVALIDDATA;
} }
mmf->data_size = size; mmf->data_size = size;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment