aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuca Barbato <lu_zero@gentoo.org>2013-05-04 07:40:09 +0200
committerLuca Barbato <lu_zero@gentoo.org>2013-10-16 23:05:50 +0200
commite930b112d14d7acd050d5087d11b6dd4c56a8e4e (patch)
tree42a7a65207b763398fa2503da8f60f761be55fbc
parent5312fb828751109798780f4e17d5f77dfd3d5398 (diff)
downloadffmpeg-e930b112d14d7acd050d5087d11b6dd4c56a8e4e.tar.gz
oma: refactor seek function
Properly propagate seek errors from avio and the generic pcm seek. (cherry picked from commit 4f03a77e52596cbe9ec179666ddb3e0345a8133a) Signed-off-by: Luca Barbato <lu_zero@gentoo.org> Conflicts: libavformat/omadec.c
-rw-r--r--libavformat/omadec.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/libavformat/omadec.c b/libavformat/omadec.c
index 48cc4327b9..42272480f9 100644
--- a/libavformat/omadec.c
+++ b/libavformat/omadec.c
@@ -422,22 +422,26 @@ static int oma_read_seek(struct AVFormatContext *s, int stream_index, int64_t ti
{
OMAContext *oc = s->priv_data;
- pcm_read_seek(s, stream_index, timestamp, flags);
-
- if (oc->encrypted) {
- /* readjust IV for CBC */
- int64_t pos = avio_tell(s->pb);
- if (pos < oc->content_start)
- memset(oc->iv, 0, 8);
- else {
- if (avio_seek(s->pb, -8, SEEK_CUR) < 0 || avio_read(s->pb, oc->iv, 8) < 8) {
- memset(oc->iv, 0, 8);
- return -1;
- }
- }
+ int err = pcm_read_seek(s, stream_index, timestamp, flags);
+
+ if (!oc->encrypted)
+ return err;
+
+ /* readjust IV for CBC */
+ if (err || avio_tell(s->pb) < oc->content_start)
+ goto wipe;
+ if ((err = avio_seek(s->pb, -8, SEEK_CUR)) < 0)
+ goto wipe;
+ if ((err = avio_read(s->pb, oc->iv, 8)) < 8) {
+ if (err >= 0)
+ err = AVERROR_EOF;
+ goto wipe;
}
return 0;
+wipe:
+ memset(oc->iv, 0, 8);
+ return err;
}
AVInputFormat ff_oma_demuxer = {