-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 @@ -69,9 +69,11 @@ extern "C" { } using namespace XINE; -Lib::Lib( XineVideoWidget* widget ) { +Lib::Lib( XineVideoWidget* widget ) +{ + ThreadUtil::AutoLock lock( m_initGuard ); m_initialized = false; m_video = false; m_wid = widget; printf("Lib"); @@ -86,8 +88,13 @@ Lib::Lib( XineVideoWidget* widget ) { ts << "misc.memcpy_method:glibc\n"; f.close(); } + start(); +} + +void Lib::run() +{ initialize(); } void Lib::initialize() @@ -123,9 +130,12 @@ void Lib::initialize() m_queue = xine_event_new_queue (m_stream); 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 ); } Lib::~Lib() { ThreadUtil::AutoLock lock( m_initGuard ); @@ -283,14 +293,21 @@ int Lib::error() const { 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 ); } void Lib::handleXineEvent( int type ) { assertInitialized(); 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 @@ -54,9 +54,10 @@ namespace XINE { * It supports playing, pausing, info, * stooping, seeking. */ class Frame; - class Lib : public ThreadUtil::Channel { + class Lib : public ThreadUtil::Channel, private ThreadUtil::Thread + { Q_OBJECT public: Lib(XineVideoWidget* = 0); ~Lib(); @@ -176,16 +177,31 @@ namespace XINE { signals: void stopped(); + void initialized(); + protected: virtual void receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ); + virtual void run(); + private: void initialize(); 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; int m_bytes_per_pixel; 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 @@ -364,9 +364,10 @@ void MediaPlayer::recreateAudioAndVideoWidgets() connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); xineControl = new XineControl( videoUI, videoUI->vidWidget(), mediaPlayerState ); - mediaPlayerState.setBackendInitialized(); + connect( xineControl, SIGNAL( initialized() ), + &mediaPlayerState, SLOT( setBackendInitialized() ) ); } void MediaPlayer::reloadSkins() { 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 @@ -54,8 +54,9 @@ XineControl::XineControl( QWidget *videoContainerWidget, XineVideoWidget *xineWi connect( &mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) ); 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() ) ); 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 @@ -113,8 +113,10 @@ private: MediaPlayerState &mediaPlayerState; signals: void positionChanged( long ); + + void initialized(); }; #endif |