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(plugin_dest_dir cockatrice.app/Contents/Plugins)
|
||||||
set(qtconf_dest_dir cockatrice.app/Contents/Resources)
|
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(
|
install(
|
||||||
DIRECTORY "${QT_PLUGINS_DIR}/"
|
DIRECTORY "${QT_PLUGINS_DIR}/"
|
||||||
DESTINATION ${plugin_dest_dir}
|
DESTINATION ${plugin_dest_dir}
|
||||||
|
|
@ -303,6 +304,7 @@ if(APPLE)
|
||||||
PATTERN "audio/*.dylib"
|
PATTERN "audio/*.dylib"
|
||||||
PATTERN "iconengines/*.dylib"
|
PATTERN "iconengines/*.dylib"
|
||||||
PATTERN "imageformats/*.dylib"
|
PATTERN "imageformats/*.dylib"
|
||||||
|
PATTERN "multimedia/*.dylib"
|
||||||
PATTERN "platforms/*.dylib"
|
PATTERN "platforms/*.dylib"
|
||||||
PATTERN "printsupport/*.dylib"
|
PATTERN "printsupport/*.dylib"
|
||||||
PATTERN "styles/*.dylib"
|
PATTERN "styles/*.dylib"
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,10 @@ SoundEngine::~SoundEngine()
|
||||||
player->deleteLater();
|
player->deleteLater();
|
||||||
player = nullptr;
|
player = nullptr;
|
||||||
}
|
}
|
||||||
|
if (audioOutput) {
|
||||||
|
audioOutput->deleteLater();
|
||||||
|
audioOutput = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundEngine::soundEnabledChanged()
|
void SoundEngine::soundEnabledChanged()
|
||||||
|
|
@ -37,8 +41,8 @@ void SoundEngine::soundEnabledChanged()
|
||||||
if (!player) {
|
if (!player) {
|
||||||
player = new QMediaPlayer;
|
player = new QMediaPlayer;
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||||
auto qAudioOutput = new QAudioOutput;
|
audioOutput = new QAudioOutput(player);
|
||||||
player->setAudioOutput(qAudioOutput);
|
player->setAudioOutput(audioOutput);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -48,6 +52,10 @@ void SoundEngine::soundEnabledChanged()
|
||||||
player->deleteLater();
|
player->deleteLater();
|
||||||
player = nullptr;
|
player = nullptr;
|
||||||
}
|
}
|
||||||
|
if (audioOutput) {
|
||||||
|
audioOutput->deleteLater();
|
||||||
|
audioOutput = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -102,14 +110,15 @@ QStringMap &SoundEngine::getAvailableThemes()
|
||||||
}
|
}
|
||||||
|
|
||||||
// load themes from cockatrice system dir
|
// load themes from cockatrice system dir
|
||||||
dir.setPath(qApp->applicationDirPath() +
|
// dir.setPath(qApp->applicationDirPath() +
|
||||||
#ifdef Q_OS_MAC
|
//#ifdef Q_OS_MAC
|
||||||
"/../Resources/sounds"
|
// "/../Resources/sounds"
|
||||||
#elif defined(Q_OS_WIN)
|
//#elif defined(Q_OS_WIN)
|
||||||
"/sounds"
|
// "/sounds"
|
||||||
#else // linux
|
//#else // linux
|
||||||
"/../share/cockatrice/sounds"
|
// "/../share/cockatrice/sounds"
|
||||||
#endif
|
//#endif
|
||||||
|
dir.setPath("/Applications/Cockatrice.app/Contents/Resources/sounds"
|
||||||
);
|
);
|
||||||
|
|
||||||
for (const QString &themeName : dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name)) {
|
for (const QString &themeName : dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name)) {
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ public:
|
||||||
private:
|
private:
|
||||||
QStringMap availableThemes;
|
QStringMap availableThemes;
|
||||||
QMap<QString, QString> audioData;
|
QMap<QString, QString> audioData;
|
||||||
|
QAudioOutput *audioOutput;
|
||||||
QMediaPlayer *player;
|
QMediaPlayer *player;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue