mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-29 19:55:37 +00:00
commit
d57dee245c
|
@ -268,7 +268,6 @@ void FileData::launchGame(Window* window)
|
||||||
|
|
||||||
window->init();
|
window->init();
|
||||||
VolumeControl::getInstance()->init();
|
VolumeControl::getInstance()->init();
|
||||||
AudioManager::getInstance()->init();
|
|
||||||
window->normalizeNextUpdate();
|
window->normalizeNextUpdate();
|
||||||
|
|
||||||
//update number of times the game has been launched
|
//update number of times the game has been launched
|
||||||
|
@ -343,4 +342,4 @@ FileData::SortType getSortTypeFromString(std::string desc) {
|
||||||
}
|
}
|
||||||
// if not found default to name, ascending
|
// if not found default to name, ascending
|
||||||
return FileSorts::SortTypes.at(0);
|
return FileSorts::SortTypes.at(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,13 +76,11 @@ public:
|
||||||
inline void setSelectorOffsetY(float selectorOffsetY) { mSelectorOffsetY = selectorOffsetY; }
|
inline void setSelectorOffsetY(float selectorOffsetY) { mSelectorOffsetY = selectorOffsetY; }
|
||||||
inline void setSelectorColor(unsigned int color) { mSelectorColor = color; }
|
inline void setSelectorColor(unsigned int color) { mSelectorColor = color; }
|
||||||
inline void setSelectedColor(unsigned int color) { mSelectedColor = color; }
|
inline void setSelectedColor(unsigned int color) { mSelectedColor = color; }
|
||||||
inline void setScrollSound(const std::shared_ptr<Sound>& sound) { mScrollSound = sound; }
|
|
||||||
inline void setColor(unsigned int id, unsigned int color) { mColors[id] = color; }
|
inline void setColor(unsigned int id, unsigned int color) { mColors[id] = color; }
|
||||||
inline void setSound(const std::shared_ptr<Sound>& sound) { mScrollSound = sound; }
|
|
||||||
inline void setLineSpacing(float lineSpacing) { mLineSpacing = lineSpacing; }
|
inline void setLineSpacing(float lineSpacing) { mLineSpacing = lineSpacing; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void onScroll(int amt) { if(mScrollSound) mScrollSound->play(); }
|
virtual void onScroll(int amt) { if(!mScrollSound.empty()) Sound::get(mScrollSound)->play(); }
|
||||||
virtual void onCursorChanged(const CursorState& state);
|
virtual void onCursorChanged(const CursorState& state);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -105,7 +103,7 @@ private:
|
||||||
float mSelectorOffsetY;
|
float mSelectorOffsetY;
|
||||||
unsigned int mSelectorColor;
|
unsigned int mSelectorColor;
|
||||||
unsigned int mSelectedColor;
|
unsigned int mSelectedColor;
|
||||||
std::shared_ptr<Sound> mScrollSound;
|
std::string mScrollSound;
|
||||||
static const unsigned int COLOR_ID_COUNT = 2;
|
static const unsigned int COLOR_ID_COUNT = 2;
|
||||||
unsigned int mColors[COLOR_ID_COUNT];
|
unsigned int mColors[COLOR_ID_COUNT];
|
||||||
|
|
||||||
|
@ -354,7 +352,7 @@ void TextListComponent<T>::applyTheme(const std::shared_ptr<ThemeData>& theme, c
|
||||||
setSelectorHeight(selectorHeight);
|
setSelectorHeight(selectorHeight);
|
||||||
|
|
||||||
if(properties & SOUND && elem->has("scrollSound"))
|
if(properties & SOUND && elem->has("scrollSound"))
|
||||||
setSound(Sound::get(elem->get<std::string>("scrollSound")));
|
mScrollSound = elem->get<std::string>("scrollSound");
|
||||||
|
|
||||||
if(properties & ALIGNMENT)
|
if(properties & ALIGNMENT)
|
||||||
{
|
{
|
||||||
|
|
|
@ -120,7 +120,16 @@ void GuiMenu::openSoundSettings()
|
||||||
auto sounds_enabled = std::make_shared<SwitchComponent>(mWindow);
|
auto sounds_enabled = std::make_shared<SwitchComponent>(mWindow);
|
||||||
sounds_enabled->setState(Settings::getInstance()->getBool("EnableSounds"));
|
sounds_enabled->setState(Settings::getInstance()->getBool("EnableSounds"));
|
||||||
s->addWithLabel("ENABLE NAVIGATION SOUNDS", sounds_enabled);
|
s->addWithLabel("ENABLE NAVIGATION SOUNDS", sounds_enabled);
|
||||||
s->addSaveFunc([sounds_enabled] { Settings::getInstance()->setBool("EnableSounds", sounds_enabled->getState()); });
|
s->addSaveFunc([sounds_enabled] {
|
||||||
|
if (sounds_enabled->getState()
|
||||||
|
&& !Settings::getInstance()->getBool("EnableSounds")
|
||||||
|
&& PowerSaver::getMode() == PowerSaver::INSTANT)
|
||||||
|
{
|
||||||
|
Settings::getInstance()->setString("PowerSaverMode", "default");
|
||||||
|
PowerSaver::init();
|
||||||
|
}
|
||||||
|
Settings::getInstance()->setBool("EnableSounds", sounds_enabled->getState());
|
||||||
|
});
|
||||||
|
|
||||||
auto video_audio = std::make_shared<SwitchComponent>(mWindow);
|
auto video_audio = std::make_shared<SwitchComponent>(mWindow);
|
||||||
video_audio->setState(Settings::getInstance()->getBool("VideoAudio"));
|
video_audio->setState(Settings::getInstance()->getBool("VideoAudio"));
|
||||||
|
@ -316,6 +325,7 @@ void GuiMenu::openOtherSettings()
|
||||||
if (Settings::getInstance()->getString("PowerSaverMode") != "instant" && power_saver->getSelected() == "instant") {
|
if (Settings::getInstance()->getString("PowerSaverMode") != "instant" && power_saver->getSelected() == "instant") {
|
||||||
Settings::getInstance()->setString("TransitionStyle", "instant");
|
Settings::getInstance()->setString("TransitionStyle", "instant");
|
||||||
Settings::getInstance()->setBool("MoveCarousel", false);
|
Settings::getInstance()->setBool("MoveCarousel", false);
|
||||||
|
Settings::getInstance()->setBool("EnableSounds", false);
|
||||||
}
|
}
|
||||||
Settings::getInstance()->setString("PowerSaverMode", power_saver->getSelected());
|
Settings::getInstance()->setString("PowerSaverMode", power_saver->getSelected());
|
||||||
PowerSaver::init();
|
PowerSaver::init();
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "AudioManager.h"
|
#include "AudioManager.h"
|
||||||
|
#include "Settings.h"
|
||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
|
@ -62,7 +63,7 @@ AudioManager::~AudioManager()
|
||||||
std::shared_ptr<AudioManager> & AudioManager::getInstance()
|
std::shared_ptr<AudioManager> & AudioManager::getInstance()
|
||||||
{
|
{
|
||||||
//check if an AudioManager instance is already created, if not create one
|
//check if an AudioManager instance is already created, if not create one
|
||||||
if (sInstance == nullptr) {
|
if (sInstance == nullptr && Settings::getInstance()->getBool("EnableSounds")) {
|
||||||
sInstance = std::shared_ptr<AudioManager>(new AudioManager);
|
sInstance = std::shared_ptr<AudioManager>(new AudioManager);
|
||||||
}
|
}
|
||||||
return sInstance;
|
return sInstance;
|
||||||
|
@ -106,6 +107,7 @@ void AudioManager::deinit()
|
||||||
//completely tear down SDL audio. else SDL hogs audio resources and emulators might fail to start...
|
//completely tear down SDL audio. else SDL hogs audio resources and emulators might fail to start...
|
||||||
SDL_CloseAudio();
|
SDL_CloseAudio();
|
||||||
SDL_QuitSubSystem(SDL_INIT_AUDIO);
|
SDL_QuitSubSystem(SDL_INIT_AUDIO);
|
||||||
|
sInstance = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioManager::registerSound(std::shared_ptr<Sound> & sound)
|
void AudioManager::registerSound(std::shared_ptr<Sound> & sound)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "PowerSaver.h"
|
#include "PowerSaver.h"
|
||||||
|
#include "AudioManager.h"
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
@ -17,6 +18,9 @@ void PowerSaver::init()
|
||||||
|
|
||||||
int PowerSaver::getTimeout()
|
int PowerSaver::getTimeout()
|
||||||
{
|
{
|
||||||
|
if (SDL_GetAudioStatus() == SDL_AUDIO_PAUSED)
|
||||||
|
AudioManager::getInstance()->deinit();
|
||||||
|
|
||||||
// Used only for SDL_WaitEventTimeout. Use `getMode()` for modes.
|
// Used only for SDL_WaitEventTimeout. Use `getMode()` for modes.
|
||||||
return mRunningScreenSaver ? mWakeupTimeout : mScreenSaverTimeout;
|
return mRunningScreenSaver ? mWakeupTimeout : mScreenSaverTimeout;
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,6 +114,8 @@ void Sound::play()
|
||||||
if(!Settings::getInstance()->getBool("EnableSounds"))
|
if(!Settings::getInstance()->getBool("EnableSounds"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
AudioManager::getInstance();
|
||||||
|
|
||||||
SDL_LockAudio();
|
SDL_LockAudio();
|
||||||
if (playing)
|
if (playing)
|
||||||
{
|
{
|
||||||
|
|
|
@ -191,11 +191,6 @@ void VideoPlayerComponent::stopVideo()
|
||||||
int status;
|
int status;
|
||||||
kill(mPlayerPid, SIGKILL);
|
kill(mPlayerPid, SIGKILL);
|
||||||
waitpid(mPlayerPid, &status, WNOHANG);
|
waitpid(mPlayerPid, &status, WNOHANG);
|
||||||
// Restart AudioManager
|
|
||||||
if (boost::starts_with(Settings::getInstance()->getString("OMXAudioDev").c_str(), "alsa"))
|
|
||||||
{
|
|
||||||
AudioManager::getInstance()->init();
|
|
||||||
}
|
|
||||||
mPlayerPid = -1;
|
mPlayerPid = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue