-rw-r--r-- | noncore/multimedia/opieplayer2/lib.cpp | 13 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/lib.h | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinecontrol.cpp | 3 |
3 files changed, 16 insertions, 2 deletions
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp index cef46a1..84194b7 100644 --- a/noncore/multimedia/opieplayer2/lib.cpp +++ b/noncore/multimedia/opieplayer2/lib.cpp @@ -86,33 +86,34 @@ Lib::Lib( InitializationMode initMode, XineVideoWidget* widget ) f.open(IO_WriteOnly); QTextStream ts( &f ); ts << "misc.memcpy_method:glibc\n"; f.close(); } if ( initMode == InitializeImmediately ) { initialize(); m_initialized = true; } else assert( false ); } void Lib::run() { - assert( false ); + initialize(); + m_initialized = true; } void Lib::initialize() { m_duringInitialization = true; m_xine = xine_new( ); QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; xine_config_load( m_xine, QFile::encodeName( configPath ) ); xine_init( m_xine ); // allocate oss for sound // and fb for framebuffer m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL ); m_videoOutput = ::init_video_out_plugin( m_xine, NULL, xine_display_frame, this ); @@ -270,32 +271,42 @@ Frame Lib::currentFrame() const { Frame frame; return frame; }; QString Lib::metaInfo( int number) const { assert( m_initialized ); return xine_get_meta_info( m_stream, number ); } int Lib::error() const { assert( m_initialized ); return xine_get_error( m_stream ); }; +void Lib::ensureInitialized() +{ + if ( m_initialized ) + return; + + qDebug( "waiting for initialization thread to finish" ); + wait(); + qDebug( "initialization thread finished!" ); +} + void Lib::receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ) { assert( sendType == ThreadUtil::Channel::OneWay ); handleXineEvent( msg->type() ); delete msg; } void Lib::handleXineEvent( const xine_event_t* t ) { send( new ThreadUtil::ChannelMessage( t->type ), OneWay ); } void Lib::handleXineEvent( int type ) { assert( m_initialized ); if ( type == XINE_EVENT_UI_PLAYBACK_FINISHED ) { emit stopped(); diff --git a/noncore/multimedia/opieplayer2/lib.h b/noncore/multimedia/opieplayer2/lib.h index 9dd7385..6b67f67 100644 --- a/noncore/multimedia/opieplayer2/lib.h +++ b/noncore/multimedia/opieplayer2/lib.h @@ -164,32 +164,34 @@ namespace XINE { void setGamma( int ); /** * test */ Frame currentFrame() const; /** * Returns the error code * XINE_ERROR_NONE 0 * XINE_ERROR_NO_INPUT_PLUGIN 1 * XINE_ERROR_NO_DEMUXER_PLUGIN 2 * XINE_ERROR_DEMUXER_FAILED 3 */ int error() const; + void ensureInitialized(); + signals: void stopped(); void initialized(); protected: virtual void receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ); virtual void run(); private: void initialize(); int m_bytes_per_pixel; bool m_initialized:1; diff --git a/noncore/multimedia/opieplayer2/xinecontrol.cpp b/noncore/multimedia/opieplayer2/xinecontrol.cpp index 1aa3daa..7c54499 100644 --- a/noncore/multimedia/opieplayer2/xinecontrol.cpp +++ b/noncore/multimedia/opieplayer2/xinecontrol.cpp @@ -32,43 +32,44 @@ */ #include <qtimer.h> #include <qmessagebox.h> #include <qpe/qcopenvelope_qws.h> #include <qpe/qpeapplication.h> #include "xinecontrol.h" #include "mediaplayerstate.h" #include "xinevideowidget.h" XineControl::XineControl( XineVideoWidget *xineWidget, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ) : QObject( parent, name ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget ) { - libXine = new XINE::Lib( XINE::Lib::InitializeImmediately, xineWidget ); init(); } XineControl::XineControl( XINE::Lib *xine, XineVideoWidget *xineWidget, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ) : QObject( parent, name ), libXine( xine ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget ) { + xine->ensureInitialized(); + init(); } void XineControl::init() { 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 ) ) ); 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( xineVideoWidget, SIGNAL( videoResized( const QSize & ) ), this, SLOT( videoResized ( const QSize & ) ) ); disabledSuspendScreenSaver = FALSE; } |