[vlmc-devel] VLCSource: Remove sleep in thumbnail computation
Hugo Beauzée-Luyssen
git at videolan.org
Thu Mar 24 13:22:36 CET 2016
vlmc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Thu Mar 24 13:16:03 2016 +0100| [cb4c1cc85977ee2cef0ca85857321393f8f60a9d] | committer: Hugo Beauzée-Luyssen
VLCSource: Remove sleep in thumbnail computation
> https://code.videolan.org/videolan/vlmc/commit/cb4c1cc85977ee2cef0ca85857321393f8f60a9d
---
src/Backend/VLC/VLCSource.cpp | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/src/Backend/VLC/VLCSource.cpp b/src/Backend/VLC/VLCSource.cpp
index 55dfa12..73c7a0a 100644
--- a/src/Backend/VLC/VLCSource.cpp
+++ b/src/Backend/VLC/VLCSource.cpp
@@ -105,12 +105,21 @@ bool
VLCSource::computeSnapshot( VmemRenderer& renderer )
{
Q_ASSERT( m_snapshot == NULL );
+ renderer.start();
{
- renderer.setTime( m_length / 3 );
- //FIXME: This is bad and you should feel bad.
- QThread::usleep( 500000 );
+ QMutex mutex;
+ QWaitCondition cond;
+ auto em = renderer.mediaPlayer().eventManager();
+ em.onPositionChanged([&mutex, &cond](float pos) {
+ QMutexLocker lock( &mutex );
+ if ( pos > 0.2 )
+ cond.wakeAll();
+ });
+ QMutexLocker lock( &mutex );
+ renderer.setPosition( 0.3 );
+ if ( cond.wait( &mutex, 2000 ) == false )
+ return false;
}
- renderer.start();
m_snapshot = renderer.waitSnapshot();
return m_snapshot != NULL;
}
More information about the Vlmc-devel
mailing list