From c53a56ed6eac74704c846af834d597997493cfaa Mon Sep 17 00:00:00 2001 From: scrawl Date: Tue, 21 Apr 2015 16:10:11 +0200 Subject: [PATCH] clear stream errors before attempting the read --- apps/openmw/mwsound/ffmpeg_decoder.cpp | 4 +++- extern/osg-ffmpeg-videoplayer/videostate.cpp | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwsound/ffmpeg_decoder.cpp b/apps/openmw/mwsound/ffmpeg_decoder.cpp index 55607b5b72..6a586e81d5 100644 --- a/apps/openmw/mwsound/ffmpeg_decoder.cpp +++ b/apps/openmw/mwsound/ffmpeg_decoder.cpp @@ -31,8 +31,8 @@ int FFmpeg_Decoder::readPacket(void *user_data, uint8_t *buf, int buf_size) try { std::istream& stream = *static_cast(user_data)->mDataStream; - stream.read((char*)buf, buf_size); stream.clear(); + stream.read((char*)buf, buf_size); return stream.gcount(); } catch (std::exception& ) @@ -52,6 +52,8 @@ int64_t FFmpeg_Decoder::seek(void *user_data, int64_t offset, int whence) whence &= ~AVSEEK_FORCE; + stream.clear(); + if(whence == AVSEEK_SIZE) { size_t prev = stream.tellg(); diff --git a/extern/osg-ffmpeg-videoplayer/videostate.cpp b/extern/osg-ffmpeg-videoplayer/videostate.cpp index 6a054d99e6..72fc82f860 100644 --- a/extern/osg-ffmpeg-videoplayer/videostate.cpp +++ b/extern/osg-ffmpeg-videoplayer/videostate.cpp @@ -173,8 +173,8 @@ int VideoState::istream_read(void *user_data, uint8_t *buf, int buf_size) try { std::istream& stream = *static_cast(user_data)->stream; - stream.read((char*)buf, buf_size); stream.clear(); + stream.read((char*)buf, buf_size); return stream.gcount(); } catch (std::exception& ) @@ -194,6 +194,8 @@ int64_t VideoState::istream_seek(void *user_data, int64_t offset, int whence) whence &= ~AVSEEK_FORCE; + stream.clear(); + if(whence == AVSEEK_SIZE) { size_t prev = stream.tellg();