# HG changeset patch # User reimar # Date 1326630220 0 # Node ID ebf95780af6eec3b8da33c147b5c3518046708e2 # Parent 6e2b26c5d6ded2487c7f935e4b7e143b290a0568 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]. diff -r 6e2b26c5d6de -r ebf95780af6e stream/cache2.c --- 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: