From 03ac4af4d6014bbd46b12d5fe89ee2cc73941080 Mon Sep 17 00:00:00 2001 From: simon Date: Wed, 11 Dec 2002 11:40:20 +0000 Subject: - slight simplification of XineControl constructor - fixed a race between the video resizing and the xine initialization --- (limited to 'noncore') diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp index 0d9a5b8..c230d6f 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp @@ -364,7 +364,7 @@ void MediaPlayer::recreateAudioAndVideoWidgets() connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); - xineControl = new XineControl( videoUI, videoUI->vidWidget(), mediaPlayerState ); + xineControl = new XineControl( videoUI->vidWidget(), mediaPlayerState ); connect( xineControl, SIGNAL( initialized() ), &mediaPlayerState, SLOT( setBackendInitialized() ) ); } diff --git a/noncore/multimedia/opieplayer2/xinecontrol.cpp b/noncore/multimedia/opieplayer2/xinecontrol.cpp index 14e71d9..e791c3b 100644 --- a/noncore/multimedia/opieplayer2/xinecontrol.cpp +++ b/noncore/multimedia/opieplayer2/xinecontrol.cpp @@ -38,16 +38,16 @@ #include #include "xinecontrol.h" #include "mediaplayerstate.h" +#include "xinevideowidget.h" -XineControl::XineControl( QWidget *videoContainerWidget, XineVideoWidget *xineWidget, +XineControl::XineControl( XineVideoWidget *xineWidget, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ) - : QObject( parent, name ), mediaPlayerState( _mediaPlayerState ) + : QObject( parent, name ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget ) { libXine = new XINE::Lib( xineWidget ); - connect ( videoContainerWidget, SIGNAL( videoResized( const QSize & )), this, SLOT( videoResized ( const QSize & ) ) ); connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pause( bool ) ) ); connect( this, SIGNAL( positionChanged( long ) ), &mediaPlayerState, SLOT( updatePosition( long ) ) ); connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) ); @@ -55,7 +55,7 @@ XineControl::XineControl( QWidget *videoContainerWidget, XineVideoWidget *xineWi connect( &mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) ); connect( &mediaPlayerState, SIGNAL( videoGammaChanged( int ) ), this, SLOT( setGamma( int ) ) ); connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) ); - connect( libXine, SIGNAL( initialized() ), this, SIGNAL( initialized() ) ); + connect( libXine, SIGNAL( initialized() ), this, SLOT( xineInitialized() ) ); disabledSuspendScreenSaver = FALSE; } @@ -126,6 +126,14 @@ void XineControl::setGamma( int value ) { libXine->setGamma( value ); } +void XineControl::xineInitialized() +{ + connect( xineVideoWidget, SIGNAL( videoResized( const QSize & ) ), this, SLOT( videoResized ( const QSize & ) ) ); + libXine->resize( xineVideoWidget->videoSize() ); + + emit initialized(); +} + void XineControl::stop( bool isSet ) { if ( !isSet ) { libXine->stop(); diff --git a/noncore/multimedia/opieplayer2/xinecontrol.h b/noncore/multimedia/opieplayer2/xinecontrol.h index 000529c..085de3f 100644 --- a/noncore/multimedia/opieplayer2/xinecontrol.h +++ b/noncore/multimedia/opieplayer2/xinecontrol.h @@ -42,7 +42,7 @@ class XineControl : public QObject { Q_OBJECT public: - XineControl( QWidget *videoContainerWidget, XineVideoWidget *xineWidget, + XineControl( XineVideoWidget *xineWidget, MediaPlayerState &_mediaPlayerState, QObject *parent = 0, const char *name =0 ); ~XineControl(); @@ -101,6 +101,9 @@ public slots: void setGamma( int ); +private slots: + void xineInitialized(); + private: XINE::Lib *libXine; long m_currentTime; @@ -111,6 +114,7 @@ private: bool hasVideoChannel : 1; bool hasAudioChannel : 1; MediaPlayerState &mediaPlayerState; + XineVideoWidget *xineVideoWidget; signals: void positionChanged( long ); diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.cpp b/noncore/multimedia/opieplayer2/xinevideowidget.cpp index 1d88cea..791818e 100644 --- a/noncore/multimedia/opieplayer2/xinevideowidget.cpp +++ b/noncore/multimedia/opieplayer2/xinevideowidget.cpp @@ -108,6 +108,21 @@ void XineVideoWidget::clear ( ) repaint ( false ); } +QSize XineVideoWidget::videoSize() const +{ + QSize s = size(); + bool fs = ( s == qApp->desktop()->size() ); + + // if we are in fullscreen mode, do not rotate the video + // (!! the paint routine uses m_rotation + qt_screen-> transformOrientation() !!) + m_rotation = fs ? - qt_screen->transformOrientation() : 0; + + if ( fs && qt_screen->isTransformed() ) + s = qt_screen->mapToDevice( s ); + + return s; +} + void XineVideoWidget::paintEvent ( QPaintEvent * ) { if ( m_buff == 0 ) { @@ -251,17 +266,7 @@ void XineVideoWidget::setVideoFrame ( uchar* img, int w, int h, int bpl ) void XineVideoWidget::resizeEvent ( QResizeEvent * ) { - QSize s = size ( ); - bool fs = ( s == qApp-> desktop ( )-> size ( )); - - // if we are in fullscreen mode, do not rotate the video - // (!! the paint routine uses m_rotation + qt_screen-> transformOrientation() !!) - m_rotation = fs ? -qt_screen-> transformOrientation ( ) : 0; - - if ( fs && qt_screen-> isTransformed ( )) - s = qt_screen-> mapToDevice ( s ); - - emit videoResized ( s ); + emit videoResized( videoSize() ); } diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.h b/noncore/multimedia/opieplayer2/xinevideowidget.h index 33f1470..8b3a3ea 100644 --- a/noncore/multimedia/opieplayer2/xinevideowidget.h +++ b/noncore/multimedia/opieplayer2/xinevideowidget.h @@ -50,6 +50,8 @@ public: void setVideoFrame ( uchar *image, int width, int height, int linestep ); void clear ( ); + QSize videoSize() const; + protected: void paintEvent( QPaintEvent *p ); void resizeEvent ( QResizeEvent *r ); @@ -69,6 +71,6 @@ private: int m_bytes_per_line_frame; int m_bytes_per_pixel; QImage *m_logo; - int m_rotation; + mutable int m_rotation; }; -- cgit v0.9.0.2