[vlc-devel] commit: Qt4: wait for VideoWidget::paintEvent ( Rémi Denis-Courmont )
git version control
git at videolan.org
Fri Jun 20 20:37:27 CEST 2008
vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> | Fri Jun 20 21:39:06 2008 +0300| [aeb8ed0fb0a896579de098b6a13ffcae41fc8ec7]
Qt4: wait for VideoWidget::paintEvent
This seems to solve the invalid handle problem, as pointed out by
Laurent. However, I get a poststamp-sized video output now...
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=aeb8ed0fb0a896579de098b6a13ffcae41fc8ec7
---
modules/gui/qt4/components/interface_widgets.cpp | 17 ++++++++++++++++-
modules/gui/qt4/components/interface_widgets.hpp | 8 ++++++++
2 files changed, 24 insertions(+), 1 deletions(-)
diff --git a/modules/gui/qt4/components/interface_widgets.cpp b/modules/gui/qt4/components/interface_widgets.cpp
index f31e75b..f702181 100644
--- a/modules/gui/qt4/components/interface_widgets.cpp
+++ b/modules/gui/qt4/components/interface_widgets.cpp
@@ -47,6 +47,7 @@
#include <QPalette>
#include <QResizeEvent>
#include <QDate>
+#include <QMutexLocker>
/**********************************************************************
* Video Widget. A simple frame on which video is drawn
@@ -58,6 +59,7 @@ VideoWidget::VideoWidget( intf_thread_t *_p_i ) : QFrame( NULL ), p_intf( _p_i )
/* Init */
vlc_mutex_init( &lock );
p_vout = NULL;
+ handleReady = false;
hide(); setMinimumSize( 16, 16 );
videoSize.rwidth() = -1;
videoSize.rheight() = -1;
@@ -80,6 +82,13 @@ VideoWidget::VideoWidget( intf_thread_t *_p_i ) : QFrame( NULL ), p_intf( _p_i )
// CONNECT( this, askResize( int, int ), this, SetSizing( int, int ) );
}
+void VideoWidget::paintEvent(QPaintEvent *ev)
+{
+ QFrame::paintEvent(ev);
+ handleReady = true;
+ handleWait.wakeAll();
+}
+
VideoWidget::~VideoWidget()
{
vlc_mutex_lock( &lock );
@@ -106,6 +115,7 @@ VideoWidget::~VideoWidget()
void *VideoWidget::request( vout_thread_t *p_nvout, int *pi_x, int *pi_y,
unsigned int *pi_width, unsigned int *pi_height )
{
+ QMutexLocker locker( &handleLock );
msg_Dbg( p_intf, "Video was requested %i, %i", *pi_x, *pi_y );
emit askVideoWidgetToShow();
if( p_vout )
@@ -114,7 +124,12 @@ void *VideoWidget::request( vout_thread_t *p_nvout, int *pi_x, int *pi_y,
return NULL;
}
p_vout = p_nvout;
- msg_Dbg( p_intf, "embedded video handle %p", winId() );
+ while( !handleReady )
+ {
+ msg_Dbg( p_intf, "embedded video pending (handle %p)", winId() );
+ handleWait.wait( &handleLock );
+ }
+ msg_Dbg( p_intf, "embedded video ready (handle %p)", winId() );
return ( void* )winId();
}
diff --git a/modules/gui/qt4/components/interface_widgets.hpp b/modules/gui/qt4/components/interface_widgets.hpp
index a64d266..f0b6586 100644
--- a/modules/gui/qt4/components/interface_widgets.hpp
+++ b/modules/gui/qt4/components/interface_widgets.hpp
@@ -40,6 +40,8 @@
#include <QWidget>
#include <QFrame>
+#include <QMutex>
+#include <QWaitCondition>
#define VOLUME_MAX 200
@@ -89,6 +91,9 @@ private:
vlc_mutex_t lock;
QSize videoSize;
+ QMutex handleLock;
+ QWaitCondition handleWait;
+ bool handleReady;
signals:
void askVideoWidgetToShow();
@@ -96,6 +101,9 @@ signals:
public slots:
void SetSizing( unsigned int, unsigned int );
+
+protected:
+ virtual void paintEvent(QPaintEvent *);
};
/******************** Background Widget ****************/
More information about the vlc-devel
mailing list