diff --git a/app/gui/oven_control/soundplayer.cpp b/app/gui/oven_control/soundplayer.cpp index bac4fb9..ce3ebc1 100644 --- a/app/gui/oven_control/soundplayer.cpp +++ b/app/gui/oven_control/soundplayer.cpp @@ -1,4 +1,5 @@ #include "soundplayer.h" +#include "system.h" namespace { QThread playThread; @@ -15,6 +16,9 @@ void SoundPlayWorker::play(const QString &filename) if (current && !current->isFinished()) current->stop(); + if (click && click->isPlaying()) + click->stop(); + if (map.contains(filename)) current = map.value(filename); else @@ -23,11 +27,18 @@ void SoundPlayWorker::play(const QString &filename) map[filename] = current; } + System::setVolume(70); current->play(); } void SoundPlayWorker::playClick() { + if (current && !current->isFinished()) + current->stop(); + + if (click && click->isPlaying()) + click->stop(); + if (click == 0) { click = new QSoundEffect; @@ -35,6 +46,7 @@ void SoundPlayWorker::playClick() click->setVolume(1.0); } + System::setVolume(80); click->play(); } diff --git a/app/gui/oven_control/system.cpp b/app/gui/oven_control/system.cpp index 051e0c6..e47831e 100644 --- a/app/gui/oven_control/system.cpp +++ b/app/gui/oven_control/system.cpp @@ -14,3 +14,16 @@ void System::setBacklight(int level) QString command = QString("echo %1 > /sys/class/backlight/backlight_lvds.19/brightness").arg(level); system(command.toLocal8Bit().constData()); } + +void System::setVolume(int percentage) +{ + static int last = -1; + + if (percentage == last) + return; + + last = percentage; + + QString command = QString("/usr/bin/amixer -c 0 sset 'PCM',0 %1% %1% on").arg(percentage); + system(command.toLocal8Bit().constData()); +} diff --git a/app/gui/oven_control/system.h b/app/gui/oven_control/system.h index 8e5bfc2..a789f89 100644 --- a/app/gui/oven_control/system.h +++ b/app/gui/oven_control/system.h @@ -15,6 +15,8 @@ struct IPData void setIP(IPData &data); void setBacklight(int level); + +void setVolume(int percentage); } #endif // SYSTEM_H