Commit 2c27c52f821ef4dcdf86446b48a652b0a21335b7
1 parent
65164fb59e
Exists in
master
and in
2 other branches
볼륨 조절 추가
Showing
3 changed files
with
27 additions
and
0 deletions
Show diff stats
app/gui/oven_control/soundplayer.cpp
1 | 1 | #include "soundplayer.h" |
2 | +#include "system.h" | |
2 | 3 | |
3 | 4 | namespace { |
4 | 5 | QThread playThread; |
... | ... | @@ -15,6 +16,9 @@ void SoundPlayWorker::play(const QString &filename) |
15 | 16 | if (current && !current->isFinished()) |
16 | 17 | current->stop(); |
17 | 18 | |
19 | + if (click && click->isPlaying()) | |
20 | + click->stop(); | |
21 | + | |
18 | 22 | if (map.contains(filename)) |
19 | 23 | current = map.value(filename); |
20 | 24 | else |
... | ... | @@ -23,11 +27,18 @@ void SoundPlayWorker::play(const QString &filename) |
23 | 27 | map[filename] = current; |
24 | 28 | } |
25 | 29 | |
30 | + System::setVolume(70); | |
26 | 31 | current->play(); |
27 | 32 | } |
28 | 33 | |
29 | 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 | 42 | if (click == 0) |
32 | 43 | { |
33 | 44 | click = new QSoundEffect; |
... | ... | @@ -35,6 +46,7 @@ void SoundPlayWorker::playClick() |
35 | 46 | click->setVolume(1.0); |
36 | 47 | } |
37 | 48 | |
49 | + System::setVolume(80); | |
38 | 50 | click->play(); |
39 | 51 | } |
40 | 52 | ... | ... |
app/gui/oven_control/system.cpp
... | ... | @@ -14,3 +14,16 @@ void System::setBacklight(int level) |
14 | 14 | QString command = QString("echo %1 > /sys/class/backlight/backlight_lvds.19/brightness").arg(level); |
15 | 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 | +} | ... | ... |