fixes for volume adjustment on raspi
This commit is contained in:
parent
b801a72d29
commit
38199766ce
1 changed files with 17 additions and 4 deletions
|
@ -48,11 +48,24 @@ ScStwSoundPlayer::PlayResult ScStwSoundPlayer::play(ScStwSoundPlayer::StartSound
|
|||
// update currently playing action
|
||||
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) + "%");
|
||||
// set volume on raspi using amixer
|
||||
QProcess soundProcess;
|
||||
|
||||
// determine current audio output device
|
||||
soundProcess.start("amixer", {"scontrols"});
|
||||
soundProcess.waitForFinished();
|
||||
QStringList outputDeviceNameList = QString(soundProcess.readAllStandardOutput()).split("'");
|
||||
|
||||
if(outputDeviceNameList.length() == 3) {
|
||||
QString outputDeviceName = outputDeviceNameList[1];
|
||||
soundProcess.execute("amixer", {"sset", outputDeviceName, QString::number(volume * 100, 'f', 0) + "%"});
|
||||
}
|
||||
else {
|
||||
qDebug() << "[WARNING][SoundPlayer] Could not determine output device to set volume";
|
||||
}
|
||||
|
||||
this->soundEffect->setVolume(1);
|
||||
#else
|
||||
this->soundEffect->setVolume(volume);
|
||||
#endif
|
||||
|
|
Reference in a new issue