mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-19 00:42:14 -07:00
Fix SoundEngine on Mac
This commit is contained in:
parent
1a3df84f0a
commit
acd18986b2
3 changed files with 23 additions and 11 deletions
|
|
@ -292,7 +292,8 @@ if(APPLE)
|
|||
set(plugin_dest_dir cockatrice.app/Contents/Plugins)
|
||||
set(qtconf_dest_dir cockatrice.app/Contents/Resources)
|
||||
|
||||
# Qt plugins: audio (Qt5), iconengines, imageformats, platforms, printsupport (Qt5), styles, tls (Qt6)
|
||||
# Qt plugins: audio (Qt5), iconengines, imageformats, multimedia (Qt6),
|
||||
# platforms, printsupport (Qt5), styles, tls (Qt6)
|
||||
install(
|
||||
DIRECTORY "${QT_PLUGINS_DIR}/"
|
||||
DESTINATION ${plugin_dest_dir}
|
||||
|
|
@ -303,6 +304,7 @@ if(APPLE)
|
|||
PATTERN "audio/*.dylib"
|
||||
PATTERN "iconengines/*.dylib"
|
||||
PATTERN "imageformats/*.dylib"
|
||||
PATTERN "multimedia/*.dylib"
|
||||
PATTERN "platforms/*.dylib"
|
||||
PATTERN "printsupport/*.dylib"
|
||||
PATTERN "styles/*.dylib"
|
||||
|
|
|
|||
|
|
@ -28,6 +28,10 @@ SoundEngine::~SoundEngine()
|
|||
player->deleteLater();
|
||||
player = nullptr;
|
||||
}
|
||||
if (audioOutput) {
|
||||
audioOutput->deleteLater();
|
||||
audioOutput = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void SoundEngine::soundEnabledChanged()
|
||||
|
|
@ -37,8 +41,8 @@ void SoundEngine::soundEnabledChanged()
|
|||
if (!player) {
|
||||
player = new QMediaPlayer;
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
auto qAudioOutput = new QAudioOutput;
|
||||
player->setAudioOutput(qAudioOutput);
|
||||
audioOutput = new QAudioOutput(player);
|
||||
player->setAudioOutput(audioOutput);
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
|
|
@ -48,6 +52,10 @@ void SoundEngine::soundEnabledChanged()
|
|||
player->deleteLater();
|
||||
player = nullptr;
|
||||
}
|
||||
if (audioOutput) {
|
||||
audioOutput->deleteLater();
|
||||
audioOutput = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -102,14 +110,15 @@ QStringMap &SoundEngine::getAvailableThemes()
|
|||
}
|
||||
|
||||
// load themes from cockatrice system dir
|
||||
dir.setPath(qApp->applicationDirPath() +
|
||||
#ifdef Q_OS_MAC
|
||||
"/../Resources/sounds"
|
||||
#elif defined(Q_OS_WIN)
|
||||
"/sounds"
|
||||
#else // linux
|
||||
"/../share/cockatrice/sounds"
|
||||
#endif
|
||||
// dir.setPath(qApp->applicationDirPath() +
|
||||
//#ifdef Q_OS_MAC
|
||||
// "/../Resources/sounds"
|
||||
//#elif defined(Q_OS_WIN)
|
||||
// "/sounds"
|
||||
//#else // linux
|
||||
// "/../share/cockatrice/sounds"
|
||||
//#endif
|
||||
dir.setPath("/Applications/Cockatrice.app/Contents/Resources/sounds"
|
||||
);
|
||||
|
||||
for (const QString &themeName : dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name)) {
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ public:
|
|||
private:
|
||||
QStringMap availableThemes;
|
||||
QMap<QString, QString> audioData;
|
||||
QAudioOutput *audioOutput;
|
||||
QMediaPlayer *player;
|
||||
|
||||
protected:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue