clear stream errors before attempting the read

pull/638/head
scrawl 10 years ago
parent 4ea6d4aa01
commit c53a56ed6e

@ -31,8 +31,8 @@ int FFmpeg_Decoder::readPacket(void *user_data, uint8_t *buf, int buf_size)
try try
{ {
std::istream& stream = *static_cast<FFmpeg_Decoder*>(user_data)->mDataStream; std::istream& stream = *static_cast<FFmpeg_Decoder*>(user_data)->mDataStream;
stream.read((char*)buf, buf_size);
stream.clear(); stream.clear();
stream.read((char*)buf, buf_size);
return stream.gcount(); return stream.gcount();
} }
catch (std::exception& ) catch (std::exception& )
@ -52,6 +52,8 @@ int64_t FFmpeg_Decoder::seek(void *user_data, int64_t offset, int whence)
whence &= ~AVSEEK_FORCE; whence &= ~AVSEEK_FORCE;
stream.clear();
if(whence == AVSEEK_SIZE) if(whence == AVSEEK_SIZE)
{ {
size_t prev = stream.tellg(); size_t prev = stream.tellg();

@ -173,8 +173,8 @@ int VideoState::istream_read(void *user_data, uint8_t *buf, int buf_size)
try try
{ {
std::istream& stream = *static_cast<VideoState*>(user_data)->stream; std::istream& stream = *static_cast<VideoState*>(user_data)->stream;
stream.read((char*)buf, buf_size);
stream.clear(); stream.clear();
stream.read((char*)buf, buf_size);
return stream.gcount(); return stream.gcount();
} }
catch (std::exception& ) catch (std::exception& )
@ -194,6 +194,8 @@ int64_t VideoState::istream_seek(void *user_data, int64_t offset, int whence)
whence &= ~AVSEEK_FORCE; whence &= ~AVSEEK_FORCE;
stream.clear();
if(whence == AVSEEK_SIZE) if(whence == AVSEEK_SIZE)
{ {
size_t prev = stream.tellg(); size_t prev = stream.tellg();

Loading…
Cancel
Save