From a20e7e2fc96a5352504ab49ab5fcc896b81b3e14 Mon Sep 17 00:00:00 2001 From: Dorian Zedler Date: Wed, 7 Oct 2020 09:48:15 +0200 Subject: [PATCH] - fix in setting - change to volume approach on raspi in sound player --- ScStwLibraries/headers/scstwsoundplayer.h | 4 ++++ ScStwLibraries/sources/client/scstwremoterace.cpp | 10 +++++++++- ScStwLibraries/sources/scstwsettings.cpp | 6 ++++-- ScStwLibraries/sources/scstwsoundplayer.cpp | 6 ++++++ 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/ScStwLibraries/headers/scstwsoundplayer.h b/ScStwLibraries/headers/scstwsoundplayer.h index 28d9bdc..e89915e 100644 --- a/ScStwLibraries/headers/scstwsoundplayer.h +++ b/ScStwLibraries/headers/scstwsoundplayer.h @@ -28,6 +28,10 @@ #include #include +#ifdef RASPI +#include +#endif + /*! * \brief The ScStwSoundPlayer class is used for ultra low latency sound playback of the speed clibing start tones and commands */ diff --git a/ScStwLibraries/sources/client/scstwremoterace.cpp b/ScStwLibraries/sources/client/scstwremoterace.cpp index 6d26201..2f9a756 100644 --- a/ScStwLibraries/sources/client/scstwremoterace.cpp +++ b/ScStwLibraries/sources/client/scstwremoterace.cpp @@ -22,6 +22,9 @@ ScStwRemoteRace::ScStwRemoteRace(ScStwClient *scStwClient, ScStwSettings *settin { this->isReadyForNextState = true; + this->remoteTimers = {}; + this->localTimers = {};********* + this->scStwClient = scStwClient; this->scStwClient->addSignalSubscription(ScStw::RaceDetailsChanged); @@ -213,6 +216,9 @@ void ScStwRemoteRace::refreshDetails(QVariantMap details) { } void ScStwRemoteRace::rebuildRemoteTimers(QVariantList remoteTimers) { + + qDebug() << "REBUILDING TIMERS"; + // delete all current timers foreach(ScStwTimer * oldTimer, this->timers){ oldTimer->deleteLater(); @@ -271,8 +277,10 @@ bool ScStwRemoteRace::refreshRemoteTimers(QVariantList remoteTimers) { } bool ScStwRemoteRace::addTimer(ScStwTimer* timer) { - if(this->local()) + if(this->local()) { + this->localTimers.append(timer); return ScStwRace::addTimer(timer); + } return false; } diff --git a/ScStwLibraries/sources/scstwsettings.cpp b/ScStwLibraries/sources/scstwsettings.cpp index 7a10865..6f39147 100644 --- a/ScStwLibraries/sources/scstwsettings.cpp +++ b/ScStwLibraries/sources/scstwsettings.cpp @@ -30,8 +30,10 @@ ScStwSettings::ScStwSettings(QObject *parent) : QObject(parent) if(!this->settingsFile->open(QFile::ReadWrite)) qFatal("[FATAL] Couldn't open settings file %s", qPrintable(path + "/settings.json")); - if(!this->loadSettingsFromFile() && this->settingsFile->size() != 0) - qFatal("[FATAL] Settings file (%s) is of invalid format!", qPrintable(path + "/settings.json")); + if(!this->loadSettingsFromFile() && this->settingsFile->size() != 0) { + this->writeSettingsToFile(); + qWarning("[WARNING] Settings file (%s) was of invalid format and therefore overwritten!", qPrintable(path + "/settings.json")); + } connect(this, &ScStwSettings::settingChanged, this, &ScStwSettings::writeSettingsToFile); diff --git a/ScStwLibraries/sources/scstwsoundplayer.cpp b/ScStwLibraries/sources/scstwsoundplayer.cpp index 180bc53..1dc116a 100644 --- a/ScStwLibraries/sources/scstwsoundplayer.cpp +++ b/ScStwLibraries/sources/scstwsoundplayer.cpp @@ -49,7 +49,13 @@ ScStwSoundPlayer::PlayResult ScStwSoundPlayer::play(ScStwSoundPlayer::StartSound this->currentlyPlayingSound = sound; // update volume + +#ifdef RASPI + // set volume on raspi using alsamixer + QProcess::execute("amixer -q -M sset PCM " + QString::number(volume * 100, 'f', 0) + "%"); +#else this->soundEffect->setVolume(volume); +#endif // load this->soundEffect->setSource(this->soundFiles[sound]["path"].toString());