mmf: return meaningful error codes

Signed-off-by: Paul B Mahol <onemda@gmail.com>
This commit is contained in:
Paul B Mahol 2012-12-04 11:59:46 +00:00
parent b70251c0ad
commit 266e88a47c

View File

@ -71,7 +71,7 @@ static int mmf_write_header(AVFormatContext *s)
rate = mmf_rate_code(s->streams[0]->codec->sample_rate);
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);
return -1;
return AVERROR(EINVAL);
}
ffio_wfourcc(pb, "MMMD");
@ -193,7 +193,7 @@ static int mmf_read_header(AVFormatContext *s)
tag = avio_rl32(pb);
if (tag != MKTAG('M', 'M', 'M', 'D'))
return -1;
return AVERROR_INVALIDDATA;
avio_skip(pb, 4); /* file_size */
/* Skip some unused chunks that may or may not be present */
@ -208,11 +208,11 @@ static int mmf_read_header(AVFormatContext *s)
/* Tag = "ATRx", where "x" = track number */
if ((tag & 0xffffff) == MKTAG('M', 'T', 'R', 0)) {
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)) {
av_log(s, AV_LOG_ERROR, "Unsupported SMAF chunk %08x\n", tag);
return -1;
return AVERROR_PATCHWELCOME;
}
avio_r8(pb); /* format type */
@ -221,7 +221,7 @@ static int mmf_read_header(AVFormatContext *s)
rate = mmf_rate(params & 0x0f);
if(rate < 0) {
av_log(s, AV_LOG_ERROR, "Invalid sample rate\n");
return -1;
return AVERROR_INVALIDDATA;
}
avio_r8(pb); /* wave base bit */
avio_r8(pb); /* time base d */
@ -239,7 +239,7 @@ static int mmf_read_header(AVFormatContext *s)
/* Make sure it's followed by an Awa chunk, aka wave data */
if ((tag & 0xffffff) != MKTAG('A', 'w', 'a', 0)) {
av_log(s, AV_LOG_ERROR, "Unexpected SMAF chunk %08x\n", tag);
return -1;
return AVERROR_INVALIDDATA;
}
mmf->data_size = size;