Skip to content

Commit

Permalink
Check for QtMultimedia before using QSound; partially fix #2166
Browse files Browse the repository at this point in the history
  • Loading branch information
ctrlaltca committed Feb 11, 2024
1 parent 9b8fa92 commit cd7f1d3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Multimedia)
if(Qt${QT_VERSION_MAJOR}Multimedia_FOUND)
include_directories(${Qt${QT_VERSION_MAJOR}Multimedia_INCLUDE_DIRS})
list(APPEND qt_kvirc_modules Qt::Multimedia)
set(COMPILE_QTMULTIMEDIA_SUPPORT 1)
endif()

# Qt Concurrent
Expand Down
1 change: 1 addition & 0 deletions cmake/kvi_sysconfig.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#cmakedefine COMPILE_PHONON_SUPPORT 1
#cmakedefine COMPILE_ESD_SUPPORT 1
#cmakedefine COMPILE_OSS_SUPPORT 1
#cmakedefine COMPILE_QTMULTIMEDIA_SUPPORT 1
#cmakedefine HAVE_LINUX_SOUNDCARD_H 1
#cmakedefine HAVE_SYS_SOUNDCARD_H 1
#cmakedefine HAVE_MACHINE_SOUNDCARD_H 1
Expand Down
8 changes: 8 additions & 0 deletions src/modules/snd/libkvisnd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@
#include "KviLocale.h"
#include "KviQString.h"

#ifdef COMPILE_QTMULTIMEDIA_SUPPORT
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <QSound>
#else
#include <QSoundEffect>
#endif
#endif

#ifdef COMPILE_PHONON_SUPPORT
#include <phonon/mediaobject.h>
Expand Down Expand Up @@ -120,7 +122,9 @@ KviSoundPlayer::KviSoundPlayer()

#endif //!COMPILE_ON_WINDOWS

#ifdef COMPILE_QTMULTIMEDIA_SUPPORT
m_pSoundSystemDict->insert("qt", new KviSoundPlayerEntry(KVI_PTR2MEMBER(KviSoundPlayer::playQt), KVI_PTR2MEMBER(KviSoundPlayer::cleanupQt)));
#endif
m_pSoundSystemDict->insert("null", new KviSoundPlayerEntry(KVI_PTR2MEMBER(KviSoundPlayer::playNull), KVI_PTR2MEMBER(KviSoundPlayer::cleanupNull)));
}

Expand Down Expand Up @@ -234,7 +238,9 @@ void KviSoundPlayer::detectSoundSystem()
KVI_OPTION_STRING(KviOption_stringSoundSystem) = "oss";
#endif

#ifdef COMPILE_QTMULTIMEDIA_SUPPORT
KVI_OPTION_STRING(KviOption_stringSoundSystem) = "qt";
#endif
return;
#endif
}
Expand Down Expand Up @@ -347,6 +353,7 @@ void KviSoundPlayer::cleanupEsd()
#endif //COMPILE_ESD_SUPPORT
#endif //!COMPILE_ON_WINDOWS

#ifdef COMPILE_QTMULTIMEDIA_SUPPORT
bool KviSoundPlayer::playQt(const QString & szFileName)
{
if(isMuted())
Expand All @@ -366,6 +373,7 @@ void KviSoundPlayer::cleanupQt()
// how to stop Qt sounds ?
// using the play/stop slots instead of the static ::play (TODO)
}
#endif

bool KviSoundPlayer::playNull(const QString &)
{
Expand Down
2 changes: 2 additions & 0 deletions src/modules/snd/libkvisnd.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,10 @@ class KviSoundPlayer : public QObject
void cleanupEsd();
#endif //COMPILE_ESD_SUPPORT
#endif //!COMPILE_ON_WINDOWS
#ifdef COMPILE_QTMULTIMEDIA_SUPPORT
bool playQt(const QString & szFileName);
void cleanupQt();
#endif
bool playNull(const QString & szFileName);
void cleanupNull();
};
Expand Down

0 comments on commit cd7f1d3

Please sign in to comment.