From bad37718f9fb608ffdd271c96a17f071ad508464 Mon Sep 17 00:00:00 2001
Date: Mon, 18 Feb 2013 11:23:24 +0000
Subject: [PATCH] Change-fallthrough-logic-for-read_seek-to-be-based-o

---
 libavformat/asfdec.c |    2 +-
 libavformat/gxf.c    |    4 ++--
 libavformat/jvdec.c  |    2 +-
 libavformat/oggdec.c |    4 +++-
 libavformat/pmpdec.c |    2 +-
 libavformat/r3d.c    |    2 +-
 libavformat/utils.c  |    4 +++-
 7 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c
index 2dcdf56..2581307 100644
--- a/libavformat/asfdec.c
+++ b/libavformat/asfdec.c
@@ -1415,7 +1415,7 @@ static int asf_read_seek(AVFormatContext *s, int stream_index, int64_t pts, int
     AVStream *st = s->streams[stream_index];
 
     if (s->packet_size <= 0)
-        return -1;
+        return AVERROR(ENOSYS);
 
     /* Try using the protocol's read_seek if available */
     if(s->pb) {
diff --git a/libavformat/gxf.c b/libavformat/gxf.c
index 86e6291..b46e6d6 100644
--- a/libavformat/gxf.c
+++ b/libavformat/gxf.c
@@ -559,7 +559,7 @@ static int gxf_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int
     idx = av_index_search_timestamp(st, timestamp - start_time,
                                     AVSEEK_FLAG_ANY | AVSEEK_FLAG_BACKWARD);
     if (idx < 0)
-        return -1;
+        return AVERROR(ENOSYS);
     pos = st->index_entries[idx].pos;
     if (idx < st->nb_index_entries - 2)
         maxlen = st->index_entries[idx + 2].pos - pos;
@@ -569,7 +569,7 @@ static int gxf_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int
         return res;
     found = gxf_resync_media(s, maxlen, -1, timestamp);
     if (FFABS(found - timestamp) > 4)
-        return -1;
+        return AVERROR(ENOSYS);
     return 0;
 }
 
diff --git a/libavformat/jvdec.c b/libavformat/jvdec.c
index e941492..8039b2a 100644
--- a/libavformat/jvdec.c
+++ b/libavformat/jvdec.c
@@ -209,7 +209,7 @@ static int read_seek(AVFormatContext *s, int stream_index,
     }
 
     if (i < 0 || i >= ast->nb_index_entries)
-        return 0;
+        return -1;
     if (avio_seek(s->pb, ast->index_entries[i].pos, SEEK_SET) < 0)
         return -1;
 
diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index e51db61..7441615 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -808,8 +808,10 @@ static int ogg_read_seek(AVFormatContext *s, int stream_index,
 
     ret = ff_seek_frame_binary(s, stream_index, timestamp, flags);
     os  = ogg->streams + stream_index;
-    if (ret < 0)
+    if (ret < 0) {
         os->keyframe_seek = 0;
+        ret = AVERROR(ENOSYS);
+    }
     return ret;
 }
 
diff --git a/libavformat/pmpdec.c b/libavformat/pmpdec.c
index 2ea37ef..0a89650 100644
--- a/libavformat/pmpdec.c
+++ b/libavformat/pmpdec.c
@@ -161,7 +161,7 @@ static int pmp_seek(AVFormatContext *s, int stream_index, int64_t ts, int flags)
     PMPContext *pmp = s->priv_data;
     pmp->cur_stream = 0;
     // fallback to default seek now
-    return -1;
+    return AVERROR(ENOSYS);
 }
 
 static int pmp_close(AVFormatContext *s)
diff --git a/libavformat/r3d.c b/libavformat/r3d.c
index 35da81e..452849d 100644
--- a/libavformat/r3d.c
+++ b/libavformat/r3d.c
@@ -366,7 +366,7 @@ static int r3d_seek(AVFormatContext *s, int stream_index, int64_t sample_time, i
     int frame_num;
 
     if (!st->avg_frame_rate.num)
-        return -1;
+        return AVERROR(ENOSYS);
 
     frame_num = av_rescale_q(sample_time, st->time_base,
                              av_inv_q(st->avg_frame_rate));
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 5cbf7ca..4b8bcd1 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2059,10 +2059,12 @@ static int seek_frame_internal(AVFormatContext *s, int stream_index,
         ff_read_frame_flush(s);
         ret = s->iformat->read_seek(s, stream_index, timestamp, flags);
     } else
-        ret = -1;
+        ret = AVERROR(ENOSYS);
     if (ret >= 0) {
         return 0;
     }
+    if (ret != AVERROR(ENOSYS))
+        return ret;
 
     if (s->iformat->read_timestamp && !(s->iformat->flags & AVFMT_NOBINSEARCH)) {
         ff_read_frame_flush(s);
-- 
1.7.10.4

