aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Voker572008-08-04 16:54:26 +0000
committerGravatar Voker572008-08-04 16:54:26 +0000
commit8c981bff3219e5ebe3f0aa96af657dbb77d2fba2 (patch)
tree5b95195c1563ece0fd18b5594117ea9b4d561268
parentfixed the second part of #196 (diff)
downloadKVIrc-8c981bff3219e5ebe3f0aa96af657dbb77d2fba2.tar.gz
KVIrc-8c981bff3219e5ebe3f0aa96af657dbb77d2fba2.tar.bz2
KVIrc-8c981bff3219e5ebe3f0aa96af657dbb77d2fba2.zip
Added Phonon cmake module from KDE4, now using it.
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@2177 17fca916-40b9-46aa-a4ea-0a15b648b75c
-rw-r--r--CMakeLists.txt20
-rw-r--r--cmake/modules/FindPhonon.cmake57
-rw-r--r--src/modules/snd/CMakeLists.txt2
-rw-r--r--src/modules/snd/libkvisnd.cpp32
4 files changed, 83 insertions, 28 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 06413f7e3..369f08f66 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -283,16 +283,6 @@ IF(QT4_FOUND)
SET(QT_USE_QTNETWORK true)
ENDIF()
- # Qt Phonon support
- IF(QT_PHONON_FOUND AND QT_PHONON_INCLUDE_DIR)
- SET(QT_USE_PHONON true)
- SET(COMPILE_PHONON_SUPPORT 1)
- SET(CMAKE_STATUS_PHONON_SUPPORT "Qt")
- LIST(APPEND CMAKE_KVIRC_BUILD_FLAGS COMPILE_PHONON_SUPPORT)
- ELSE()
- SET(CMAKE_STATUS_PHONON_SUPPORT "Not available")
- ENDIF()
-
SET(COMPILE_USE_QT4 1)
# DBus support
@@ -311,6 +301,16 @@ IF(QT4_FOUND)
LIST(APPEND LIBS ${QT_LIBRARIES})
ENDIF()
+# Phonon support
+FIND_PACKAGE(Phonon)
+IF(PHONON_FOUND)
+ SET(COMPILE_PHONON_SUPPORT 1)
+ SET(CMAKE_STATUS_PHONON_SUPPORT "Yes")
+ LIST(APPEND CMAKE_KVIRC_BUILD_FLAGS COMPILE_PHONON_SUPPORT)
+ELSE()
+ SET(CMAKE_STATUS_PHONON_SUPPORT "Not available")
+ENDIF()
+
############################################################################
# Check for KDE4
############################################################################
diff --git a/cmake/modules/FindPhonon.cmake b/cmake/modules/FindPhonon.cmake
new file mode 100644
index 000000000..14d15422f
--- /dev/null
+++ b/cmake/modules/FindPhonon.cmake
@@ -0,0 +1,57 @@
+# Find libphonon
+# Once done this will define
+#
+# PHONON_FOUND - system has Phonon Library
+# PHONON_INCLUDES - the Phonon include directory
+# PHONON_LIBS - link these to use Phonon
+
+# Copyright (c) 2008, Matthias Kretz <kretz@kde.org>
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+if(PHONON_FOUND)
+ # Already found, nothing more to do
+else(PHONON_FOUND)
+ if(PHONON_INCLUDE_DIR AND PHONON_LIBRARY)
+ set(PHONON_FIND_QUIETLY TRUE)
+ endif(PHONON_INCLUDE_DIR AND PHONON_LIBRARY)
+
+ # As discussed on kde-buildsystem: first look at CMAKE_PREFIX_PATH, then at the suggested PATHS (kde4 install dir)
+ find_library(PHONON_LIBRARY NAMES phonon PATHS ${KDE4_LIB_INSTALL_DIR} ${QT_LIBRARY_DIR} NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
+ # then at the default system locations (CMAKE_SYSTEM_PREFIX_PATH, i.e. /usr etc.)
+ find_library(PHONON_LIBRARY NAMES phonon)
+
+ find_path(PHONON_INCLUDE_DIR NAMES phonon/phonon_export.h PATHS ${KDE4_INCLUDE_INSTALL_DIR} ${QT_INCLUDE_DIR} ${INCLUDE_INSTALL_DIR} NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
+ find_path(PHONON_INCLUDE_DIR NAMES phonon/phonon_export.h)
+
+ if(PHONON_INCLUDE_DIR AND PHONON_LIBRARY)
+ set(PHONON_LIBS ${phonon_LIB_DEPENDS} ${PHONON_LIBRARY})
+ set(PHONON_INCLUDES ${PHONON_INCLUDE_DIR}/KDE ${PHONON_INCLUDE_DIR})
+ set(PHONON_FOUND TRUE)
+ else(PHONON_INCLUDE_DIR AND PHONON_LIBRARY)
+ set(PHONON_FOUND FALSE)
+ endif(PHONON_INCLUDE_DIR AND PHONON_LIBRARY)
+
+ if(PHONON_FOUND)
+ if(NOT PHONON_FIND_QUIETLY)
+ message(STATUS "Found Phonon: ${PHONON_LIBRARY}")
+ message(STATUS "Found Phonon Includes: ${PHONON_INCLUDES}")
+ endif(NOT PHONON_FIND_QUIETLY)
+ else(PHONON_FOUND)
+ if(Phonon_FIND_REQUIRED)
+ if(NOT PHONON_INCLUDE_DIR)
+ message(STATUS "Phonon includes NOT found!")
+ endif(NOT PHONON_INCLUDE_DIR)
+ if(NOT PHONON_LIBRARY)
+ message(STATUS "Phonon library NOT found!")
+ endif(NOT PHONON_LIBRARY)
+ message(FATAL_ERROR "Phonon library or includes NOT found!")
+ else(Phonon_FIND_REQUIRED)
+ message(STATUS "Unable to find Phonon")
+ endif(Phonon_FIND_REQUIRED)
+ endif(PHONON_FOUND)
+
+
+ mark_as_advanced(PHONON_INCLUDE_DIR PHONON_LIBRARY PHONON_INCLUDES)
+endif(PHONON_FOUND)
diff --git a/src/modules/snd/CMakeLists.txt b/src/modules/snd/CMakeLists.txt
index fcb3c60b0..6e287b597 100644
--- a/src/modules/snd/CMakeLists.txt
+++ b/src/modules/snd/CMakeLists.txt
@@ -1,5 +1,7 @@
# CMakeLists for src/modules/snd
+INCLUDE_DIRECTORIES(${PHONON_INCLUDE_DIR})
+
IF(WIN32)
LIST(APPEND LIBS -lwinmm)
ENDIF()
diff --git a/src/modules/snd/libkvisnd.cpp b/src/modules/snd/libkvisnd.cpp
index d6208d6d1..4152f59f6 100644
--- a/src/modules/snd/libkvisnd.cpp
+++ b/src/modules/snd/libkvisnd.cpp
@@ -37,15 +37,10 @@
#include <QSound>
#ifdef COMPILE_PHONON_SUPPORT
- #ifdef COMPILE_KDE_SUPPORT
- #include <Phonon/MediaObject>
- #include <Phonon/Path>
- #include <Phonon/Global>
- #else //!COMPILE_KDE_SUPPORT
- #include <phonon>
- #endif //!COMPILE_KDE_SUPPORT
- Phonon::MediaObject * g_pPhononPlayer=0;
- #include <QUrl>
+ #include <phonon/mediaobject.h>
+ #include <phonon/path.h>
+ Phonon::MediaObject * g_pPhononPlayer=0;
+ #include <QUrl>
#endif //!COMPILE_PHONON_SUPPORT
#if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW)
@@ -98,6 +93,7 @@ KviSoundPlayer::KviSoundPlayer()
m_pSoundSystemDict = new KviPointerHashTable<QString,SoundSystemRoutine>(17,false);
m_pSoundSystemDict->setAutoDelete(true);
#ifdef COMPILE_PHONON_SUPPORT
+ qDebug("Inserting phonon");
m_pSoundSystemDict->insert("phonon",new SoundSystemRoutine(KVI_PTR2MEMBER(KviSoundPlayer::playPhonon)));
#endif //!COMPILE_PHONON_SUPPORT
#if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW)
@@ -230,12 +226,12 @@ void KviSoundPlayer::detectSoundSystem()
#ifdef COMPILE_PHONON_SUPPORT
bool KviSoundPlayer::playPhonon(const QString &szFileName)
{
- if(isMuted()) return true;
+ if(isMuted()) return true;
if(!g_pPhononPlayer) g_pPhononPlayer= Phonon::createPlayer(Phonon::MusicCategory);
- if(g_pPhononPlayer->state()!=Phonon::ErrorState)
- {
+ if(g_pPhononPlayer->state()!=Phonon::ErrorState)
+ {
g_pPhononPlayer->setCurrentSource(QUrl(szFileName));
- g_pPhononPlayer->play();
+ g_pPhononPlayer->play();
}
return true;
}
@@ -590,12 +586,12 @@ void KviSoundThread::run()
KviPhononSoundThread::KviPhononSoundThread(const QString &szFileName)
: KviSoundThread(szFileName)
{
- if(!g_pPhononPlayer)
- {
+ if(!g_pPhononPlayer)
+ {
g_pPhononPlayer = Phonon::createPlayer(Phonon::MusicCategory);
- } else {
- if(g_pPhononPlayer->state()!=Phonon::ErrorState)
- g_pPhononPlayer->setCurrentSource(QUrl(szFileName));
+ } else {
+ if(g_pPhononPlayer->state()!=Phonon::ErrorState)
+ g_pPhononPlayer->setCurrentSource(QUrl(szFileName));
}
}