Added volume controls for navigation sounds and the video player.

This commit is contained in:
Leon Styhre 2020-12-20 16:41:58 +01:00
parent bb7097a1af
commit 46c178af1d
5 changed files with 51 additions and 3 deletions

View file

@ -439,6 +439,36 @@ void GuiMenu::openSoundSettings()
});
#endif
// Volume for navigation sounds.
auto sound_volume_navigation =
std::make_shared<SliderComponent>(mWindow, 0.f, 100.f, 1.f, "%");
sound_volume_navigation->setValue(static_cast<float>(Settings::getInstance()->
getInt("SoundVolumeNavigation")));
s->addWithLabel("NAVIGATION VOLUME", sound_volume_navigation);
s->addSaveFunc([sound_volume_navigation, s] {
if (sound_volume_navigation->getValue() !=
static_cast<float>(Settings::getInstance()->getInt("SoundVolumeNavigation"))) {
Settings::getInstance()->setInt("SoundVolumeNavigation",
static_cast<int>(sound_volume_navigation->getValue()));
s->setNeedsSaving();
}
});
// Volume for videos.
auto sound_volume_videos =
std::make_shared<SliderComponent>(mWindow, 0.f, 100.f, 1.f, "%");
sound_volume_videos->setValue(static_cast<float>(Settings::getInstance()->
getInt("SoundVolumeVideos")));
s->addWithLabel("VIDEO VOLUME", sound_volume_videos);
s->addSaveFunc([sound_volume_videos, s] {
if (sound_volume_videos->getValue() !=
static_cast<float>(Settings::getInstance()->getInt("SoundVolumeVideos"))) {
Settings::getInstance()->setInt("SoundVolumeVideos",
static_cast<int>(sound_volume_videos->getValue()));
s->setNeedsSaving();
}
});
if (UIModeController::getInstance()->isUIModeFull()) {
// The ALSA Audio Card and Audio Device selection code is disabled at the moment.
// As PulseAudio controls the sound devices for the desktop environment, it doesn't

View file

@ -214,7 +214,7 @@ void GuiScreensaverOptions::openVideoScreensaverOptions()
screensaver_swap_video_timeout->setValue(static_cast<float>(Settings::getInstance()->
getInt("ScreensaverSwapVideoTimeout") / (1000)));
s->addWithLabel("SWAP VIDEOS AFTER (SECONDS)", screensaver_swap_video_timeout);
s->addSaveFunc([screensaver_swap_video_timeout,s ] {
s->addSaveFunc([screensaver_swap_video_timeout, s] {
if (screensaver_swap_video_timeout->getValue() !=
static_cast<float>(Settings::getInstance()->
getInt("ScreensaverSwapVideoTimeout") / (1000))) {

View file

@ -38,7 +38,7 @@ void AudioManager::mixAudio(void* /*unused*/, Uint8* stream, int len)
}
// Mix sample into stream.
SDL_MixAudio(stream, &(sound->getData()[sound->getPosition()]),
restLength, SDL_MIX_MAXVOLUME);
restLength, Settings::getInstance()->getInt("SoundVolumeNavigation") * 1.28);
if (sound->getPosition() + restLength < sound->getLength()) {
//sample hasn't ended yet
stillPlaying = true;
@ -103,6 +103,16 @@ void AudioManager::init()
LOG(LogError) << "AudioManager - Unable to open SDL audio: " <<
SDL_GetError() << std::endl;
}
// Just in case someone changed the es_settings.cfg file manually to invalid values.
if (Settings::getInstance()->getInt("SoundVolumeNavigation") > 100)
Settings::getInstance()->setInt("SoundVolumeNavigation", 100);
if (Settings::getInstance()->getInt("SoundVolumeNavigation") < 0)
Settings::getInstance()->setInt("SoundVolumeNavigation", 0);
if (Settings::getInstance()->getInt("SoundVolumeVideos") > 100)
Settings::getInstance()->setInt("SoundVolumeVideos", 100);
if (Settings::getInstance()->getInt("SoundVolumeVideos") < 0)
Settings::getInstance()->setInt("SoundVolumeVideos", 0);
}
void AudioManager::deinit()

View file

@ -170,6 +170,8 @@ void Settings::setDefaults()
//#else
// mStringMap["AudioDevice"] = { "Master", "Master" };
#endif
mIntMap["SoundVolumeNavigation"] = { 80, 80 };
mIntMap["SoundVolumeVideos"] = { 100, 100 };
mBoolMap["GamelistVideoAudio"] = { true, true };
mBoolMap["NavigationSounds"] = { true, true };

View file

@ -360,8 +360,14 @@ void VideoVlcComponent::startVideo()
if ((!Settings::getInstance()->getBool("GamelistVideoAudio") &&
!mScreensaverMode) ||
(!Settings::getInstance()->getBool("ScreensaverVideoAudio") &&
mScreensaverMode))
mScreensaverMode)) {
libvlc_audio_set_mute(mMediaPlayer, 1);
}
else {
libvlc_audio_set_mute(mMediaPlayer, 0);
libvlc_audio_set_volume(mMediaPlayer,
Settings::getInstance()->getInt("SoundVolumeVideos"));
}
libvlc_media_player_play(mMediaPlayer);
libvlc_video_set_callbacks(mMediaPlayer, lock, unlock, display,