Commit 2c27c52f821ef4dcdf86446b48a652b0a21335b7

Authored by 김태훈
1 parent 65164fb59e
Exists in master and in 2 other branches fhd, fhd-demo

볼륨 조절 추가

app/gui/oven_control/soundplayer.cpp
1 #include "soundplayer.h" 1 #include "soundplayer.h"
  2 +#include "system.h"
2 3
3 namespace { 4 namespace {
4 QThread playThread; 5 QThread playThread;
@@ -15,6 +16,9 @@ void SoundPlayWorker::play(const QString &filename) @@ -15,6 +16,9 @@ void SoundPlayWorker::play(const QString &filename)
15 if (current && !current->isFinished()) 16 if (current && !current->isFinished())
16 current->stop(); 17 current->stop();
17 18
  19 + if (click && click->isPlaying())
  20 + click->stop();
  21 +
18 if (map.contains(filename)) 22 if (map.contains(filename))
19 current = map.value(filename); 23 current = map.value(filename);
20 else 24 else
@@ -23,11 +27,18 @@ void SoundPlayWorker::play(const QString &filename) @@ -23,11 +27,18 @@ void SoundPlayWorker::play(const QString &filename)
23 map[filename] = current; 27 map[filename] = current;
24 } 28 }
25 29
  30 + System::setVolume(70);
26 current->play(); 31 current->play();
27 } 32 }
28 33
29 void SoundPlayWorker::playClick() 34 void SoundPlayWorker::playClick()
30 { 35 {
  36 + if (current && !current->isFinished())
  37 + current->stop();
  38 +
  39 + if (click && click->isPlaying())
  40 + click->stop();
  41 +
31 if (click == 0) 42 if (click == 0)
32 { 43 {
33 click = new QSoundEffect; 44 click = new QSoundEffect;
@@ -35,6 +46,7 @@ void SoundPlayWorker::playClick() @@ -35,6 +46,7 @@ void SoundPlayWorker::playClick()
35 click->setVolume(1.0); 46 click->setVolume(1.0);
36 } 47 }
37 48
  49 + System::setVolume(80);
38 click->play(); 50 click->play();
39 } 51 }
40 52
app/gui/oven_control/system.cpp
@@ -14,3 +14,16 @@ void System::setBacklight(int level) @@ -14,3 +14,16 @@ void System::setBacklight(int level)
14 QString command = QString("echo %1 > /sys/class/backlight/backlight_lvds.19/brightness").arg(level); 14 QString command = QString("echo %1 > /sys/class/backlight/backlight_lvds.19/brightness").arg(level);
15 system(command.toLocal8Bit().constData()); 15 system(command.toLocal8Bit().constData());
16 } 16 }
  17 +
  18 +void System::setVolume(int percentage)
  19 +{
  20 + static int last = -1;
  21 +
  22 + if (percentage == last)
  23 + return;
  24 +
  25 + last = percentage;
  26 +
  27 + QString command = QString("/usr/bin/amixer -c 0 sset 'PCM',0 %1% %1% on").arg(percentage);
  28 + system(command.toLocal8Bit().constData());
  29 +}
app/gui/oven_control/system.h
@@ -15,6 +15,8 @@ struct IPData @@ -15,6 +15,8 @@ struct IPData
15 void setIP(IPData &data); 15 void setIP(IPData &data);
16 16
17 void setBacklight(int level); 17 void setBacklight(int level);
  18 +
  19 +void setVolume(int percentage);
18 } 20 }
19 21
20 #endif // SYSTEM_H 22 #endif // SYSTEM_H