Fix for trying to play videos when not supported

This commit is contained in:
Chris Robinson 2012-12-17 00:41:04 -08:00
parent 26660110e5
commit 9e842a0bbb

View file

@ -895,8 +895,6 @@ int VideoState::stream_open(int stream_index, AVFormatContext *pFormatCtx)
} }
void VideoState::init(const std::string& resourceName) void VideoState::init(const std::string& resourceName)
{
try
{ {
int video_index = -1; int video_index = -1;
int audio_index = -1; int audio_index = -1;
@ -951,12 +949,6 @@ void VideoState::init(const std::string& resourceName)
this->parse_thread = boost::thread(decode_thread_loop, this); this->parse_thread = boost::thread(decode_thread_loop, this);
} }
catch(...)
{
this->quit = true;
throw;
}
}
void VideoState::deinit() void VideoState::deinit()
{ {
@ -997,7 +989,7 @@ public:
void init(const std::string& resourceName) void init(const std::string& resourceName)
{ {
throw std::runtime_error("FFmpeg not supported, cannot play video \""+resourceName+"\""); throw std::runtime_error("FFmpeg not supported, cannot play \""+resourceName+"\"");
} }
void deinit() { } void deinit() { }
@ -1100,9 +1092,15 @@ void VideoPlayer::playVideo(const std::string &resourceName)
MWBase::Environment::get().getSoundManager()->pauseAllSounds(); MWBase::Environment::get().getSoundManager()->pauseAllSounds();
try {
mState = new VideoState; mState = new VideoState;
mState->init(resourceName); mState->init(resourceName);
} }
catch(std::exception& e) {
std::cerr<< "Failed to play video: "<<e.what() <<std::endl;
close();
}
}
void VideoPlayer::update () void VideoPlayer::update ()
{ {
@ -1114,11 +1112,14 @@ void VideoPlayer::update ()
} }
void VideoPlayer::close() void VideoPlayer::close()
{
if(mState)
{ {
mState->deinit(); mState->deinit();
delete mState; delete mState;
mState = NULL; mState = NULL;
}
MWBase::Environment::get().getSoundManager()->resumeAllSounds(); MWBase::Environment::get().getSoundManager()->resumeAllSounds();