Skip to content

Commit

Permalink
Misc fixes to sound module related to autodetect (#2669)
Browse files Browse the repository at this point in the history
* Sound options: don't immediately save changes when sound system gets autodetected; fix #2667

* If the config-saved sound system is not available anymore, force an autodetect; fix #2668

* Fix  "qt" sound system under qt6 and unify the code path for Qt5.

* If phonon is available, prefer it over "qt" sound system (the latter can only play wav files)

* Nuke support for aRts (KDE2/3 sound server) and ESD (Gnome sound server before 2009)

* Sound module: replace SoundEffect with QmediaPlayer to support more file formats. Adjust the priority of "qt" sound system in autodetect

* Convert to smart pointers

* Sound options: force an autodetect if the current sound system is not valid
  • Loading branch information
ctrlaltca authored Aug 2, 2024
1 parent cf5a03a commit 1a1db49
Show file tree
Hide file tree
Showing 9 changed files with 123 additions and 198 deletions.
11 changes: 0 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -653,17 +653,6 @@ if(Qt${QT_VERSION_MAJOR}Multimedia_FOUND)
list(APPEND CMAKE_STATUS_AUDIO_BACKENDS "Qt${QT_VERSION_MAJOR}Multimedia")
endif()

# ESD
option(WANT_ESD "Whether to compile ESD support" ON)
if(WANT_ESD)
find_package(ESD)
if(ESD_FOUND)
set(COMPILE_ESD_SUPPORT 1)
list(APPEND LIBS ${ESD_LIBRARY})
list(APPEND CMAKE_STATUS_AUDIO_BACKENDS "Esd")
endif()
endif()

# oss + audiofile
option(WANT_OSS "Whether to compile OSS support" ON)
option(WANT_AUDIOFILE "Whether to compile audiofile support" ON)
Expand Down
1 change: 0 additions & 1 deletion cmake/kvi_sysconfig.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
#cmakedefine COMPILE_ZLIB_SUPPORT 1

#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
Expand Down
23 changes: 0 additions & 23 deletions cmake/modules/FindESD.cmake

This file was deleted.

2 changes: 1 addition & 1 deletion dist/debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ NOT_INSTALLED := \
override_dh_auto_configure:
dh_auto_configure -- -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DWANT_COEXISTENCE=OFF \
-DWANT_ESD=OFF -DWANT_OSS=OFF \
-DWANT_OSS=OFF \
-DWANT_STRIP=OFF \
-DMANUAL_REVISION="$(REV)" -DMANUAL_SOURCES_DATE=$(DATE)\
-DLIB_SUFFIX="/$(DEB_HOST_MULTIARCH)" -DCMAKE_VERBOSE_MAKEFILE=False
Expand Down
3 changes: 0 additions & 3 deletions src/kvilib/config/KviBuildInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ const QStringList feature_list{
#ifdef COMPILE_OSS_SUPPORT
"OSS",
#endif
#ifdef COMPILE_ESD_SUPPORT
"ESD",
#endif
#ifdef COMPILE_AUDIOFILE_SUPPORT
"Audiofile",
#endif
Expand Down
47 changes: 26 additions & 21 deletions src/modules/options/OptionsWidget_sound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,15 @@ void OptionsWidget_soundGeneral::soundAutoDetect()

g_pApp->setOverrideCursor(Qt::WaitCursor);

m->ctrl("detectSoundSystem", nullptr);
soundFillBox();
QString szSoundSystem;
if(m->ctrl("detectSoundSystem", &szSoundSystem) && !KviQString::equalCI(szSoundSystem, "null"))
{
int idx = m_pSoundSystemBox->findText(szSoundSystem);
if(idx > -1) {
m_pSoundSystemBox->setCurrentIndex(idx);
}
}

g_pApp->restoreOverrideCursor();
}
Expand All @@ -222,30 +229,28 @@ void OptionsWidget_soundGeneral::soundFillBox()
KviModule * m = g_pModuleManager->getModule("snd");

if(!m || !m->ctrl("getAvailableSoundSystems", &l))
goto disable;

m_pSoundSystemBox->clear();

for(const auto& it : l)
m_pSoundSystemBox->addItem(it);

cnt = m_pSoundSystemBox->count();
for(i = 0; i < cnt; i++)
{
QString t = m_pSoundSystemBox->itemText(i);
if(KviQString::equalCI(t, KVI_OPTION_STRING(KviOption_stringSoundSystem)))
{
m_pSoundSystemBox->setCurrentIndex(i);
break;
}
m_pSoundSystemBox->clear();
m_pSoundSystemBox->setEnabled(false);
m_pSoundTestButton->setEnabled(false);
m_pSoundAutoDetectButton->setEnabled(false);
return;
}

return;
disable:
m_pSoundSystemBox->clear();
m_pSoundSystemBox->setEnabled(false);
m_pSoundTestButton->setEnabled(false);
m_pSoundAutoDetectButton->setEnabled(false);
m_pSoundSystemBox->addItems(l);

int idx = m_pSoundSystemBox->findText(KVI_OPTION_STRING(KviOption_stringSoundSystem));
if(idx == -1) {
// the previously used sound system doesn't exist anymore, force an autodetect
g_pApp->setOverrideCursor(Qt::WaitCursor);
QString szSoundSystem;
m->ctrl("detectSoundSystem", &szSoundSystem);
g_pApp->restoreOverrideCursor();
idx = m_pSoundSystemBox->findText(szSoundSystem);
}

m_pSoundSystemBox->setCurrentIndex(idx);
}

void OptionsWidget_soundGeneral::mediaFillBox()
Expand Down
10 changes: 8 additions & 2 deletions src/modules/setup/libkvisetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,14 @@ KVIMODULEEXPORTFUNC void setup_finish()

// detect the most appropriate sound system
KviModule * m = g_pModuleManager->getModule("snd");
if(m)
m->ctrl("detectSoundSystem", nullptr);
if(m) {
QString szSoundSystem;
if (m->ctrl("detectSoundSystem", &szSoundSystem) &&
!KviQString::equalCI(szSoundSystem, "null"))
{
KVI_OPTION_STRING(KviOption_stringSoundSystem) = szSoundSystem;
}
}
}
}

Expand Down
Loading

0 comments on commit 1a1db49

Please sign in to comment.