-rw-r--r-- | noncore/multimedia/opieplayer2/lib.cpp | 4 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.cpp | 12 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.h | 6 |
3 files changed, 20 insertions, 2 deletions
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp index 299239b..8896cfe 100644 --- a/noncore/multimedia/opieplayer2/lib.cpp +++ b/noncore/multimedia/opieplayer2/lib.cpp @@ -73,55 +73,57 @@ using namespace XINE; Lib::Lib( InitializationMode initMode, XineVideoWidget* widget ) { m_initialized = false; m_duringInitialization = false; m_video = false; m_wid = widget; printf("Lib"); QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; // get the configuration // not really OO, should be an extra class, later if ( !QFile::exists(configPath) ) { QFile f(configPath); 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 ); + start(); } void Lib::run() { + qDebug( "Lib::run() started" ); initialize(); m_initialized = true; + qDebug( "Lib::run() finished" ); } 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 ); //xine_open_video_driver( m_xine, NULL, XINE_VISUAL_TYPE_FB, NULL); // null_display_handler( m_videoOutput, xine_display_frame, this ); m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput ); diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp index d6fbb53..0ec6fad 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp @@ -14,78 +14,84 @@ #include "playlistwidget.h" #include "audiowidget.h" #include "videowidget.h" #include "volumecontrol.h" #include "lib.h" #include "mediaplayerstate.h" // for setBacklight() #include <linux/fb.h> #include <sys/file.h> #include <sys/ioctl.h> #define FBIOBLANK 0x4611 MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ) : QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) { m_audioUI = 0; m_videoUI = 0; m_xineControl = 0; + xine = new XINE::Lib( XINE::Lib::InitializeInThread ); fd=-1;fl=-1; playList.setCaption( tr( "OpiePlayer: Initializating" ) ); qApp->processEvents(); // QPEApplication::grabKeyboard(); // EVIL connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); // What is pauseCheck good for? (Simon) // connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); connect( &mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); connect( &mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); connect( &mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) ); volControl = new VolumeControl; Config cfg( "OpiePlayer" ); cfg.setGroup("PlayList"); QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); playList.setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() ); m_skinLoader = new SkinLoader; m_skinLoader->schedule( AudioWidget::guiInfo() ); m_skinLoader->schedule( VideoWidget::guiInfo() ); m_skinLoader->start(); } MediaPlayer::~MediaPlayer() { + // this shold never happen, but one never knows... + if ( xine ) { + xine->ensureInitialized(); + delete xine; + } delete m_xineControl; delete m_audioUI; delete m_videoUI; delete volControl; } void MediaPlayer::pauseCheck( bool b ) { if ( b && !mediaPlayerState.isPlaying() ) { mediaPlayerState.setPaused( FALSE ); } } void MediaPlayer::play() { mediaPlayerState.setPlaying( FALSE ); mediaPlayerState.setPlaying( TRUE ); } void MediaPlayer::setPlaying( bool play ) { if ( !play ) { return; } if ( mediaPlayerState.isPaused() ) { mediaPlayerState.setPaused( FALSE ); @@ -350,50 +356,54 @@ void MediaPlayer::cleanUp() {// this happens on closing // QPEApplication::grabKeyboard(); // QPEApplication::ungrabKeyboard(); } void MediaPlayer::recreateAudioAndVideoWidgets() const { delete m_skinLoader; delete m_xineControl; delete m_audioUI; delete m_videoUI; m_audioUI = new AudioWidget( playList, mediaPlayerState, 0, "audioUI" ); m_videoUI = new VideoWidget( playList, mediaPlayerState, 0, "videoUI" ); connect( m_audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); connect( m_audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); connect( m_audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); connect( m_audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); connect( m_videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); connect( m_videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); connect( m_videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); connect( m_videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); - XINE::Lib *xine = new XINE::Lib( XINE::Lib::InitializeImmediately ); + if ( !xine ) + xine = new XINE::Lib( XINE::Lib::InitializeImmediately ); + m_xineControl = new XineControl( xine, m_videoUI->vidWidget(), mediaPlayerState ); + + xine = 0; } AudioWidget *MediaPlayer::audioUI() const { if ( !m_audioUI ) recreateAudioAndVideoWidgets(); return m_audioUI; } VideoWidget *MediaPlayer::videoUI() const { if ( !m_videoUI ) recreateAudioAndVideoWidgets(); return m_videoUI; } XineControl *MediaPlayer::xineControl() const { if ( !m_xineControl ) recreateAudioAndVideoWidgets(); return m_xineControl; } void MediaPlayer::reloadSkins() diff --git a/noncore/multimedia/opieplayer2/mediaplayer.h b/noncore/multimedia/opieplayer2/mediaplayer.h index 351c884..cbe4d86 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.h +++ b/noncore/multimedia/opieplayer2/mediaplayer.h @@ -27,73 +27,79 @@ -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef MEDIA_PLAYER_H #define MEDIA_PLAYER_H #include <qmainwindow.h> #include <qframe.h> #include "xinecontrol.h" #include "playlistwidget.h" #include "skin.h" class DocLnk; class VolumeControl; class MediaPlayerState; class AudioWidget; class VideoWidget; +namespace XINE +{ + class Lib; +}; + class MediaPlayer : public QObject { Q_OBJECT public: MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ); ~MediaPlayer(); public slots: void reloadSkins(); private slots: void setPlaying( bool ); void pauseCheck( bool ); void play(); void next(); void prev(); void startIncreasingVolume(); void startDecreasingVolume(); void stopChangingVolume(); void cleanUp(); void blank( bool ); protected: void timerEvent( QTimerEvent *e ); void keyReleaseEvent( QKeyEvent *e); private: AudioWidget *audioUI() const; VideoWidget *videoUI() const; XineControl *xineControl() const; bool isBlanked, l, r; int fd, fl; int volumeDirection; VolumeControl *volControl; MediaPlayerState &mediaPlayerState; PlayListWidget &playList; void recreateAudioAndVideoWidgets() const; mutable XineControl *m_xineControl; mutable AudioWidget *m_audioUI; mutable VideoWidget *m_videoUI; + mutable XINE::Lib *xine; QGuardedPtr<SkinLoader> m_skinLoader; }; #endif // MEDIA_PLAYER_H |