mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-12-11 06:55:40 +00:00
(Android) Changed the default audio driver from AAudio to OpenSL ES
Also added an audio driver menu option to the Sound settings menu
This commit is contained in:
parent
9aab182c5c
commit
572cd9b8b0
|
@ -1176,6 +1176,26 @@ void GuiMenu::openSoundOptions()
|
||||||
{
|
{
|
||||||
auto s = new GuiSettings(_("SOUND SETTINGS"));
|
auto s = new GuiSettings(_("SOUND SETTINGS"));
|
||||||
|
|
||||||
|
#if defined(__ANDROID__)
|
||||||
|
// Audio driver.
|
||||||
|
auto audioDriver = std::make_shared<OptionListComponent<std::string>>(getHelpStyle(),
|
||||||
|
_("AUDIO DRIVER"), false);
|
||||||
|
std::string selectedDriver {Settings::getInstance()->getString("AudioDriver")};
|
||||||
|
audioDriver->add("OPENSL ES", "openslES", selectedDriver == "openslES");
|
||||||
|
audioDriver->add("AAUDIO", "AAudio", selectedDriver == "AAudio");
|
||||||
|
// If there are no objects returned, then there must be a manually modified entry in the
|
||||||
|
// configuration file. Simply set the audio driver to "openslES" in this case.
|
||||||
|
if (audioDriver->getSelectedObjects().size() == 0)
|
||||||
|
audioDriver->selectEntry(0);
|
||||||
|
s->addWithLabel(_("AUDIO DRIVER (REQUIRES RESTART)"), audioDriver);
|
||||||
|
s->addSaveFunc([audioDriver, s] {
|
||||||
|
if (audioDriver->getSelected() != Settings::getInstance()->getString("AudioDriver")) {
|
||||||
|
Settings::getInstance()->setString("AudioDriver", audioDriver->getSelected());
|
||||||
|
s->setNeedsSaving();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
#endif
|
||||||
|
|
||||||
// TODO: Implement system volume support for macOS and Android.
|
// TODO: Implement system volume support for macOS and Android.
|
||||||
#if !defined(__APPLE__) && !defined(__ANDROID__) && !defined(__FreeBSD__) && !defined(__HAIKU__)
|
#if !defined(__APPLE__) && !defined(__ANDROID__) && !defined(__FreeBSD__) && !defined(__HAIKU__)
|
||||||
// System volume.
|
// System volume.
|
||||||
|
|
|
@ -1027,6 +1027,15 @@ int main(int argc, char* argv[])
|
||||||
Utils::Platform::Android::setupFontFiles();
|
Utils::Platform::Android::setupFontFiles();
|
||||||
Utils::Platform::Android::setupLocalizationFiles();
|
Utils::Platform::Android::setupLocalizationFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
std::string audioDriver {Settings::getInstance()->getString("AudioDriver")};
|
||||||
|
if (audioDriver != "openslES" && audioDriver != "AAudio")
|
||||||
|
audioDriver = "openslES";
|
||||||
|
|
||||||
|
setenv("SDL_AUDIODRIVER", audioDriver.c_str(), 1);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Utils::Localization::setLocale();
|
Utils::Localization::setLocale();
|
||||||
|
|
|
@ -36,10 +36,28 @@ void AudioManager::init()
|
||||||
{
|
{
|
||||||
LOG(LogInfo) << "Setting up AudioManager...";
|
LOG(LogInfo) << "Setting up AudioManager...";
|
||||||
|
|
||||||
|
#if defined(__ANDROID__)
|
||||||
if (SDL_InitSubSystem(SDL_INIT_AUDIO) != 0) {
|
if (SDL_InitSubSystem(SDL_INIT_AUDIO) != 0) {
|
||||||
LOG(LogError) << "Error initializing SDL audio!\n" << SDL_GetError();
|
if (Settings::getInstance()->getString("AudioDriver") != "AAudio") {
|
||||||
|
LOG(LogWarning) << "Requested OpenSL ES audio driver does not seem to be available, "
|
||||||
|
"reverting to AAudio";
|
||||||
|
setenv("SDL_AUDIODRIVER", "AAudio", 1);
|
||||||
|
if (SDL_InitSubSystem(SDL_INIT_AUDIO) != 0) {
|
||||||
|
LOG(LogError) << "Couldn't initialize SDL audio: " << SDL_GetError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
LOG(LogError) << "Couldn't initialize SDL audio: " << SDL_GetError();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
if (SDL_InitSubSystem(SDL_INIT_AUDIO) != 0) {
|
||||||
|
LOG(LogError) << "Couldn't initialize SDL audio: " << SDL_GetError();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
LOG(LogInfo) << "Audio driver: " << SDL_GetCurrentAudioDriver();
|
LOG(LogInfo) << "Audio driver: " << SDL_GetCurrentAudioDriver();
|
||||||
|
|
||||||
|
|
|
@ -233,6 +233,9 @@ void Settings::setDefaults()
|
||||||
mBoolMap["ShowHelpPrompts"] = {true, true};
|
mBoolMap["ShowHelpPrompts"] = {true, true};
|
||||||
|
|
||||||
// Sound settings.
|
// Sound settings.
|
||||||
|
#if defined(__ANDROID__)
|
||||||
|
mStringMap["AudioDriver"] = {"openslES", "openslES"};
|
||||||
|
#endif
|
||||||
mIntMap["SoundVolumeNavigation"] = {70, 70};
|
mIntMap["SoundVolumeNavigation"] = {70, 70};
|
||||||
mIntMap["SoundVolumeVideos"] = {80, 80};
|
mIntMap["SoundVolumeVideos"] = {80, 80};
|
||||||
mBoolMap["ViewsVideoAudio"] = {true, true};
|
mBoolMap["ViewsVideoAudio"] = {true, true};
|
||||||
|
|
Loading…
Reference in a new issue