changeset 34487:ebf95780af6e

Fix seeking with e.g. flv files. This is a regression that was introduced in r34461. Found and bisected by Anssi Hannula [anssi.hannula iki fi].
author reimar
date Sun, 15 Jan 2012 12:23:40 +0000
parents 6e2b26c5d6de
children 01c19d9b1e83
files stream/cache2.c
diffstat 1 files changed, 10 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/stream/cache2.c	Sun Jan 15 12:08:26 2012 +0000
+++ b/stream/cache2.c	Sun Jan 15 12:23:40 2012 +0000
@@ -320,7 +320,7 @@
       s->control_res = STREAM_UNSUPPORTED;
       break;
   }
-  if (needs_flush) {
+  if (s->control_res == STREAM_OK && needs_flush) {
     s->read_filepos = s->stream->pos;
     s->eof = s->stream->eof;
     cache_flush(s);
@@ -644,14 +644,19 @@
       return STREAM_UNSUPPORTED;
     }
   }
-  // to avoid unnecessary differences with non-cache behaviour,
-  // do this also on failure.
+  if (s->control_res != STREAM_OK)
+    return s->control_res;
+  // We cannot do this on failure, since this would cause the
+  // stream position to jump when e.g. STREAM_CTRL_SEEK_TO_TIME
+  // is unsupported - but in that case we need the old value
+  // to do the fallback seek.
+  // This unfortunately can lead to slightly different behaviour
+  // with and without cache if the protocol changes pos even
+  // when an error happened.
   if (pos_change) {
     stream->pos = s->read_filepos;
     stream->eof = s->eof;
   }
-  if (s->control_res != STREAM_OK)
-    return s->control_res;
   switch (cmd) {
     case STREAM_CTRL_GET_TIME_LENGTH:
     case STREAM_CTRL_GET_CURRENT_TIME: