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
|
// update currently playing action
|
||||||
this->currentlyPlayingSound = sound;
|
this->currentlyPlayingSound = sound;
|
||||||
|
|
||||||
// update volume
|
|
||||||
|
|
||||||
#ifdef RASPI
|
#ifdef RASPI
|
||||||
// set volume on raspi using alsamixer
|
// set volume on raspi using amixer
|
||||||
QProcess::execute("amixer -q -M sset PCM " + QString::number(volume * 100, 'f', 0) + "%");
|
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
|
#else
|
||||||
this->soundEffect->setVolume(volume);
|
this->soundEffect->setVolume(volume);
|
||||||
#endif
|
#endif
|
||||||
|
|
Reference in a new issue