Merge pull request #460 from tminit/custom-audio-rpi

Enhanced Audio settings
This commit is contained in:
John Rassa 2018-08-29 22:20:49 -04:00 committed by GitHub
commit 811e2cefdc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 61 additions and 19 deletions

View file

@ -15,8 +15,8 @@ EmulationStation has a few dependencies. For building, you'll need CMake, SDL2,
All of this be easily installed with apt-get: All of this be easily installed with apt-get:
```bash ```bash
sudo apt-get install libsdl2-dev libfreeimage-dev libfreetype6-dev libcurl4-openssl-dev \ sudo apt-get install libsdl2-dev libfreeimage-dev libfreetype6-dev libcurl4-openssl-dev \
libasound2-dev libgl1-mesa-dev build-essential cmake fonts-droid \ libasound2-dev libgl1-mesa-dev build-essential cmake fonts-droid-fallback libvlc-dev \
libvlc-dev libvlccore-dev vlc-nox libvlccore-dev vlc-bin
``` ```
**On Fedora:** **On Fedora:**
All of this be easily installed with dnf ( With rpmfusion activated) : All of this be easily installed with dnf ( With rpmfusion activated) :

View file

@ -86,9 +86,9 @@ void VolumeControl::init()
//try to open mixer device //try to open mixer device
if (mixerHandle == nullptr) if (mixerHandle == nullptr)
{ {
#ifdef _RPI_ // Allow users to override the AudioCard and MixerName in es_settings.cfg
mixerCard = Settings::getInstance()->getString("AudioCard").c_str();
mixerName = Settings::getInstance()->getString("AudioDevice").c_str(); mixerName = Settings::getInstance()->getString("AudioDevice").c_str();
#endif
snd_mixer_selem_id_alloca(&mixerSelemId); snd_mixer_selem_id_alloca(&mixerSelemId);
//sets simple-mixer index and name //sets simple-mixer index and name

View file

@ -16,6 +16,7 @@
#include "SystemData.h" #include "SystemData.h"
#include "VolumeControl.h" #include "VolumeControl.h"
#include <SDL_events.h> #include <SDL_events.h>
#include <algorithm>
GuiMenu::GuiMenu(Window* window) : GuiComponent(window), mMenu(window, "MAIN MENU"), mVersion(window) GuiMenu::GuiMenu(Window* window) : GuiComponent(window), mMenu(window, "MAIN MENU"), mVersion(window)
{ {
@ -94,13 +95,49 @@ void GuiMenu::openSoundSettings()
if (UIModeController::getInstance()->isUIModeFull()) if (UIModeController::getInstance()->isUIModeFull())
{ {
#if defined(__linux__)
// audio card
auto audio_card = std::make_shared< OptionListComponent<std::string> >(mWindow, "AUDIO CARD", false);
std::vector<std::string> audio_cards;
#ifdef _RPI_ #ifdef _RPI_
// RPi Specific Audio Cards
audio_cards.push_back("local");
audio_cards.push_back("hdmi");
audio_cards.push_back("both");
#endif
audio_cards.push_back("default");
audio_cards.push_back("sysdefault");
audio_cards.push_back("dmix");
audio_cards.push_back("hw");
audio_cards.push_back("plughw");
audio_cards.push_back("null");
if (Settings::getInstance()->getString("AudioCard") != "") {
if(std::find(audio_cards.begin(), audio_cards.end(), Settings::getInstance()->getString("AudioCard")) == audio_cards.end()) {
audio_cards.push_back(Settings::getInstance()->getString("AudioCard"));
}
}
for(auto ac = audio_cards.cbegin(); ac != audio_cards.cend(); ac++)
audio_card->add(*ac, *ac, Settings::getInstance()->getString("AudioCard") == *ac);
s->addWithLabel("AUDIO CARD", audio_card);
s->addSaveFunc([audio_card] {
Settings::getInstance()->setString("AudioCard", audio_card->getSelected());
VolumeControl::getInstance()->deinit();
VolumeControl::getInstance()->init();
});
// volume control device // volume control device
auto vol_dev = std::make_shared< OptionListComponent<std::string> >(mWindow, "AUDIO DEVICE", false); auto vol_dev = std::make_shared< OptionListComponent<std::string> >(mWindow, "AUDIO DEVICE", false);
std::vector<std::string> transitions; std::vector<std::string> transitions;
transitions.push_back("PCM"); transitions.push_back("PCM");
transitions.push_back("Speaker"); transitions.push_back("Speaker");
transitions.push_back("Master"); transitions.push_back("Master");
transitions.push_back("Digital");
transitions.push_back("Analogue");
if (Settings::getInstance()->getString("AudioDevice") != "") {
if(std::find(transitions.begin(), transitions.end(), Settings::getInstance()->getString("AudioDevice")) == transitions.end()) {
transitions.push_back(Settings::getInstance()->getString("AudioDevice"));
}
}
for(auto it = transitions.cbegin(); it != transitions.cend(); it++) for(auto it = transitions.cbegin(); it != transitions.cend(); it++)
vol_dev->add(*it, *it, Settings::getInstance()->getString("AudioDevice") == *it); vol_dev->add(*it, *it, Settings::getInstance()->getString("AudioDevice") == *it);
s->addWithLabel("AUDIO DEVICE", vol_dev); s->addWithLabel("AUDIO DEVICE", vol_dev);
@ -134,14 +171,19 @@ void GuiMenu::openSoundSettings()
#ifdef _RPI_ #ifdef _RPI_
// OMX player Audio Device // OMX player Audio Device
auto omx_audio_dev = std::make_shared< OptionListComponent<std::string> >(mWindow, "OMX PLAYER AUDIO DEVICE", false); auto omx_audio_dev = std::make_shared< OptionListComponent<std::string> >(mWindow, "OMX PLAYER AUDIO DEVICE", false);
std::vector<std::string> devices; std::vector<std::string> omx_cards;
devices.push_back("local"); // RPi Specific Audio Cards
devices.push_back("hdmi"); omx_cards.push_back("local");
devices.push_back("both"); omx_cards.push_back("hdmi");
// USB audio omx_cards.push_back("both");
devices.push_back("alsa:hw:0,0"); omx_cards.push_back("alsa:hw:0,0");
devices.push_back("alsa:hw:1,0"); omx_cards.push_back("alsa:hw:1,0");
for (auto it = devices.cbegin(); it != devices.cend(); it++) if (Settings::getInstance()->getString("OMXAudioDev") != "") {
if (std::find(omx_cards.begin(), omx_cards.end(), Settings::getInstance()->getString("OMXAudioDev")) == omx_cards.end()) {
omx_cards.push_back(Settings::getInstance()->getString("OMXAudioDev"));
}
}
for (auto it = omx_cards.cbegin(); it != omx_cards.cend(); it++)
omx_audio_dev->add(*it, *it, Settings::getInstance()->getString("OMXAudioDev") == *it); omx_audio_dev->add(*it, *it, Settings::getInstance()->getString("OMXAudioDev") == *it);
s->addWithLabel("OMX PLAYER AUDIO DEVICE", omx_audio_dev); s->addWithLabel("OMX PLAYER AUDIO DEVICE", omx_audio_dev);
s->addSaveFunc([omx_audio_dev] { s->addSaveFunc([omx_audio_dev] {