PARA_ERROR(MP3DEC_CORRUPT, "too many corrupt frames"), \
PARA_ERROR(MP3DEC_EOF, "mp3dec: end of file"), \
PARA_ERROR(MP3_INFO, "could not read mp3 info"), \
+ PARA_ERROR(MP4_READ, "mp4: read error or unexpected end of file"), \
+ PARA_ERROR(MP4_CORRUPT, "invalid/corrupt mp4 file"), \
PARA_ERROR(MP4_BAD_CHANNEL_COUNT, "mp4: invalid number of channels"), \
PARA_ERROR(MP4_BAD_SAMPLE, "mp4: invalid sample number"), \
PARA_ERROR(MP4_BAD_SAMPLERATE, "mp4: invalid sample rate"), \
PARA_ERROR(MP4_BAD_SAMPLE_COUNT, "mp4: invalid number of samples"), \
- PARA_ERROR(MP4_OPEN, "mp4: open failed"), \
PARA_ERROR(MP4_TRACK, "mp4: no audio track"), \
PARA_ERROR(MP4_MISSING_ATOM, "mp4: essential atom not found"), \
PARA_ERROR(MPI_SCAN, "could not scan multi-precision integer"), \
};
/*
- * Returns -1, 0, or 1 on errors/EOF/success. Partial reads followed by EOF or
- * read errors are treated as errors.
+ * Returns -E_MP4_READ, 0, or 1 on errors/EOF/success. Partial reads followed
+ * by EOF or read errors are treated as errors.
*/
static int read_data(struct mp4 *f, void *data, size_t size)
{
continue;
/* regard EAGAIN as an error as reads should be blocking. */
if (ret <= 0)
- return ret < 0? -1 : 0;
+ return ret < 0? -E_MP4_READ : 0;
size -= ret;
}
return 1;
if (atom_type != ATOM_DATA)
continue;
skip_bytes(f, 8); /* version (1), flags (3), reserved (4) */
- ret = -ERRNO_TO_PARA_ERROR(EINVAL);
+ ret = -E_MP4_CORRUPT;
if (subsize < header_size + 8 || subsize > UINT_MAX)
goto fail;
len = subsize - (header_size + 8);
value[len] = '\0';
}
if (!value)
- return -ERRNO_TO_PARA_ERROR(EINVAL);
+ return -E_MP4_CORRUPT;
f->meta.tags = para_realloc(f->meta.tags, (f->meta.count + 1)
* sizeof(struct mp4_tag));
tag = f->meta.tags + f->meta.count;
if (ret <= 0)
return ret;
if (size == 0)
- return -1;
+ return -E_MP4_CORRUPT;
dest = get_position(f) + size - header_size;
if (atom_type == ATOM_TRAK && f->track.state == ATS_SEEN_MP4A) {
f->track.state = ATS_TRACK_CHANGE;
if (ret <= 0)
break;
}
- if (ret < 0) {
- ret = -E_MP4_OPEN;
+ if (ret < 0)
goto fail;
- }
ret = -E_MP4_TRACK;
if (f->track.channel_count == 0)
goto fail;