Add a cmake option to use phonon even on unix. Also fix a strange bug with the phonon backend that stopped the track slider from working.
This commit is contained in:
parent
96802bdf6e
commit
ef9780b44e
|
@ -10,6 +10,13 @@ if (CMAKE_FIND_ROOT_PATH)
|
|||
set(QT_PHONON_INCLUDE_DIR ${CMAKE_FIND_ROOT_PATH}/include/phonon)
|
||||
endif (CMAKE_FIND_ROOT_PATH)
|
||||
|
||||
option(FORCE_PHONON "Use the Phonon audio backend even on Unix")
|
||||
|
||||
if (FORCE_PHONON OR WIN32)
|
||||
set(USE_PHONON 1)
|
||||
add_definitions(-DUSE_PHONON)
|
||||
endif (FORCE_PHONON OR WIN32)
|
||||
|
||||
find_package(Qt4 REQUIRED)
|
||||
set(QT_USE_QTOPENGL 1)
|
||||
set(QT_USE_QTSQL 1)
|
||||
|
@ -18,9 +25,9 @@ set(QT_USE_QTXML 1)
|
|||
if(UNIX AND NOT APPLE)
|
||||
set(QT_USE_QTDBUS 1)
|
||||
endif(UNIX AND NOT APPLE)
|
||||
if(WIN32)
|
||||
if(USE_PHONON)
|
||||
set(QT_USE_PHONON 1)
|
||||
endif(WIN32)
|
||||
endif(USE_PHONON)
|
||||
|
||||
find_package(OpenGL REQUIRED)
|
||||
find_package(Boost REQUIRED)
|
||||
|
|
|
@ -191,13 +191,13 @@ endforeach(QM-FILE)
|
|||
file(APPEND ${CLEMENTINE-QM-RESOURCE} "</qresource></RCC>")
|
||||
|
||||
# Audio engine - phonon on windows, xine elsewhere
|
||||
if(WIN32)
|
||||
if(USE_PHONON)
|
||||
set(CLEMENTINE-SOURCES ${CLEMENTINE-SOURCES} phononengine.cpp)
|
||||
set(CLEMENTINE-MOC-HEADERS ${CLEMENTINE-MOC-HEADERS} phononengine.h)
|
||||
else(WIN32)
|
||||
else(USE_PHONON)
|
||||
set(CLEMENTINE-SOURCES ${CLEMENTINE-SOURCES} xine-engine.cpp xine-scope.c)
|
||||
set(CLEMENTINE-MOC-HEADERS ${CLEMENTINE-MOC-HEADERS} xine-engine.h)
|
||||
endif(WIN32)
|
||||
endif(USE_PHONON)
|
||||
|
||||
# OSD and DBus.
|
||||
if(APPLE)
|
||||
|
|
|
@ -21,7 +21,8 @@
|
|||
PhononEngine::PhononEngine()
|
||||
: media_object_(new Phonon::MediaObject(this)),
|
||||
audio_output_(new Phonon::AudioOutput(Phonon::MusicCategory, this)),
|
||||
state_timer_(new QTimer(this))
|
||||
state_timer_(new QTimer(this)),
|
||||
seek_offset_(-1)
|
||||
{
|
||||
Phonon::createPath(media_object_, audio_output_);
|
||||
|
||||
|
@ -52,6 +53,10 @@ bool PhononEngine::load(const QUrl &url, bool stream) {
|
|||
}
|
||||
|
||||
bool PhononEngine::play(uint offset) {
|
||||
// The seek happens in PhononStateChanged - phonon doesn't seem to change
|
||||
// currentTime() if we seek before we start playing :S
|
||||
seek_offset_ = offset;
|
||||
|
||||
media_object_->play();
|
||||
return true;
|
||||
}
|
||||
|
@ -109,12 +114,15 @@ void PhononEngine::PhononStateChanged(Phonon::State new_state) {
|
|||
if (new_state == Phonon::ErrorState) {
|
||||
emit error(media_object_->errorString());
|
||||
}
|
||||
if (new_state == Phonon::PlayingState && seek_offset_ != -1) {
|
||||
media_object_->seek(seek_offset_);
|
||||
seek_offset_ = -1;
|
||||
}
|
||||
|
||||
// Don't emit the state change straight away
|
||||
state_timer_->start(100);
|
||||
}
|
||||
|
||||
void PhononEngine::StateTimeoutExpired() {
|
||||
qDebug() << state();
|
||||
emit stateChanged(state());
|
||||
}
|
||||
|
|
|
@ -60,6 +60,8 @@ class PhononEngine : public Engine::Base {
|
|||
Phonon::AudioOutput* audio_output_;
|
||||
|
||||
QTimer* state_timer_;
|
||||
|
||||
qint64 seek_offset_;
|
||||
};
|
||||
|
||||
#endif // PHONONENGINE_H
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
# include <QDBusConnection>
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
#ifdef USE_PHONON
|
||||
# include "phononengine.h"
|
||||
#else
|
||||
# include "xine-engine.h"
|
||||
|
@ -65,7 +65,7 @@ Player::Player(Playlist* playlist, LastFMService* lastfm, QObject* parent)
|
|||
engine_(NULL),
|
||||
init_engine_watcher_(new QFutureWatcher<bool>(this))
|
||||
{
|
||||
#ifdef Q_OS_WIN32
|
||||
#ifdef USE_PHONON
|
||||
engine_ = new PhononEngine;
|
||||
#else
|
||||
engine_ = new XineEngine;
|
||||
|
|
Loading…
Reference in New Issue