Commit 4ac7c161 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen
Browse files

VLCThumbnailer: Fix error detection

parent 6f89d1b1
...@@ -144,13 +144,10 @@ void VLCThumbnailer::run(std::shared_ptr<Media> file, void *data ) ...@@ -144,13 +144,10 @@ void VLCThumbnailer::run(std::shared_ptr<Media> file, void *data )
bool VLCThumbnailer::startPlayback(std::shared_ptr<Media> file, VLC::MediaPlayer &mp, void* data ) bool VLCThumbnailer::startPlayback(std::shared_ptr<Media> file, VLC::MediaPlayer &mp, void* data )
{ {
bool failed = true;
std::unique_lock<std::mutex> lock( m_mutex ); std::unique_lock<std::mutex> lock( m_mutex );
mp.eventManager().onPlaying([this, &failed]() { mp.eventManager().onPlaying([this]() {
std::unique_lock<std::mutex> lock( m_mutex ); std::unique_lock<std::mutex> lock( m_mutex );
failed = false;
m_cond.notify_all(); m_cond.notify_all();
}); });
mp.eventManager().onEncounteredError([this]() { mp.eventManager().onEncounteredError([this]() {
...@@ -159,9 +156,10 @@ bool VLCThumbnailer::startPlayback(std::shared_ptr<Media> file, VLC::MediaPlayer ...@@ -159,9 +156,10 @@ bool VLCThumbnailer::startPlayback(std::shared_ptr<Media> file, VLC::MediaPlayer
}); });
mp.play(); mp.play();
bool success = m_cond.wait_for( lock, std::chrono::seconds( 3 ), [&mp]() { bool success = m_cond.wait_for( lock, std::chrono::seconds( 3 ), [&mp]() {
return mp.state() == libvlc_Playing || mp.state() == libvlc_Error; auto s = mp.state();
return s == libvlc_Playing || s == libvlc_Error || s == libvlc_Ended;
}); });
if ( success == false || failed == true ) if ( success == false || mp.state() == libvlc_Error || mp.state() == libvlc_Ended )
{ {
// In case of timeout or error, don't go any further // In case of timeout or error, don't go any further
m_cb->done( file, Status::Error, data ); m_cb->done( file, Status::Error, data );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment