mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-19 20:11:36 +00:00
Fix for trying to play videos when not supported
This commit is contained in:
parent
26660110e5
commit
9e842a0bbb
1 changed files with 63 additions and 62 deletions
|
@ -896,8 +896,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;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
@ -950,12 +948,6 @@ void VideoState::init(const std::string& resourceName)
|
||||||
this->stream_open(video_index, this->format_ctx);
|
this->stream_open(video_index, this->format_ctx);
|
||||||
|
|
||||||
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,8 +1092,14 @@ 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 ()
|
||||||
|
@ -1115,10 +1113,13 @@ 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();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue