-rw-r--r-- | noncore/multimedia/opieplayer2/lib.cpp | 23 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/lib.h | 18 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.cpp | 3 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinecontrol.cpp | 1 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinecontrol.h | 2 |
5 files changed, 42 insertions, 5 deletions
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp index 99d5de6..20fd1e2 100644 --- a/noncore/multimedia/opieplayer2/lib.cpp +++ b/noncore/multimedia/opieplayer2/lib.cpp @@ -71,5 +71,7 @@ extern "C" { using namespace XINE; -Lib::Lib( XineVideoWidget* widget ) { +Lib::Lib( XineVideoWidget* widget ) +{ + ThreadUtil::AutoLock lock( m_initGuard ); m_initialized = false; m_video = false; @@ -88,4 +90,9 @@ Lib::Lib( XineVideoWidget* widget ) { } + start(); +} + +void Lib::run() +{ initialize(); } @@ -125,5 +132,8 @@ void Lib::initialize() xine_event_create_listener_thread (m_queue, xine_event_handler, this); + ThreadUtil::AutoLock lock( m_initGuard ); m_initialized = true; + + send( new ThreadUtil::ChannelMessage( InitializationMessageType ), OneWay ); } @@ -285,10 +295,17 @@ void Lib::receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ) { assert( sendType == ThreadUtil::Channel::OneWay ); - handleXineEvent( msg->type() ); + switch ( msg->type() ) { + case XineMessageType: + handleXineEvent( static_cast<XineMessage *>( msg )->xineEvent ); + break; + case InitializationMessageType: + emit initialized(); + break; + } delete msg; } void Lib::handleXineEvent( const xine_event_t* t ) { - send( new ThreadUtil::ChannelMessage( t->type ), OneWay ); + send( new XineMessage( t->type ), OneWay ); } diff --git a/noncore/multimedia/opieplayer2/lib.h b/noncore/multimedia/opieplayer2/lib.h index 4b8dc81..34b85b9 100644 --- a/noncore/multimedia/opieplayer2/lib.h +++ b/noncore/multimedia/opieplayer2/lib.h @@ -56,5 +56,6 @@ namespace XINE { */ class Frame; - class Lib : public ThreadUtil::Channel { + class Lib : public ThreadUtil::Channel, private ThreadUtil::Thread + { Q_OBJECT public: @@ -178,7 +179,11 @@ namespace XINE { void stopped(); + void initialized(); + protected: virtual void receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ); + virtual void run(); + private: void initialize(); @@ -186,4 +191,15 @@ namespace XINE { void assertInitialized() const; + enum { XineMessageType = 1, InitializationMessageType }; + + struct XineMessage : public ThreadUtil::ChannelMessage + { + XineMessage( int _xineEvent ) : ThreadUtil::ChannelMessage( XineMessageType ), + xineEvent( _xineEvent ) + {} + + int xineEvent; + }; + mutable ThreadUtil::Mutex m_initGuard; bool m_initialized : 1; diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp index 5e91561..0d9a5b8 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp @@ -366,5 +366,6 @@ void MediaPlayer::recreateAudioAndVideoWidgets() xineControl = new XineControl( videoUI, videoUI->vidWidget(), mediaPlayerState ); - mediaPlayerState.setBackendInitialized(); + connect( xineControl, SIGNAL( initialized() ), + &mediaPlayerState, SLOT( setBackendInitialized() ) ); } diff --git a/noncore/multimedia/opieplayer2/xinecontrol.cpp b/noncore/multimedia/opieplayer2/xinecontrol.cpp index 0e81fa2..14e71d9 100644 --- a/noncore/multimedia/opieplayer2/xinecontrol.cpp +++ b/noncore/multimedia/opieplayer2/xinecontrol.cpp @@ -56,4 +56,5 @@ XineControl::XineControl( QWidget *videoContainerWidget, XineVideoWidget *xineWi connect( &mediaPlayerState, SIGNAL( videoGammaChanged( int ) ), this, SLOT( setGamma( int ) ) ); connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) ); + connect( libXine, SIGNAL( initialized() ), this, SIGNAL( initialized() ) ); disabledSuspendScreenSaver = FALSE; diff --git a/noncore/multimedia/opieplayer2/xinecontrol.h b/noncore/multimedia/opieplayer2/xinecontrol.h index 69a594f..000529c 100644 --- a/noncore/multimedia/opieplayer2/xinecontrol.h +++ b/noncore/multimedia/opieplayer2/xinecontrol.h @@ -115,4 +115,6 @@ private: signals: void positionChanged( long ); + + void initialized(); }; |