mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-31 04:25:40 +00:00
Fixes for USB sound cards
- Ability to change device used for Volume control (PCM/Speaker/Master) only on Pi. - Ability to change Audio device used for OMX player (local/hdmi/both/ALSA:HW:0,0/ALSA:HW:1,0)
This commit is contained in:
parent
0772c1f84f
commit
2d38605a08
|
@ -1,4 +1,5 @@
|
||||||
#include "VolumeControl.h"
|
#include "VolumeControl.h"
|
||||||
|
#include "Settings.h"
|
||||||
|
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
|
|
||||||
|
@ -73,6 +74,10 @@ void VolumeControl::init()
|
||||||
//try to open mixer device
|
//try to open mixer device
|
||||||
if (mixerHandle == nullptr)
|
if (mixerHandle == nullptr)
|
||||||
{
|
{
|
||||||
|
#ifdef _RPI_
|
||||||
|
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
|
||||||
snd_mixer_selem_id_set_index(mixerSelemId, mixerIndex);
|
snd_mixer_selem_id_set_index(mixerSelemId, mixerIndex);
|
||||||
|
|
|
@ -69,6 +69,23 @@ GuiMenu::GuiMenu(Window* window) : GuiComponent(window), mMenu(window, "MAIN MEN
|
||||||
[this] {
|
[this] {
|
||||||
auto s = new GuiSettings(mWindow, "SOUND SETTINGS");
|
auto s = new GuiSettings(mWindow, "SOUND SETTINGS");
|
||||||
|
|
||||||
|
#ifdef _RPI_
|
||||||
|
// volume control device
|
||||||
|
auto vol_dev = std::make_shared< OptionListComponent<std::string> >(mWindow, "AUDIO DEVICE", false);
|
||||||
|
std::vector<std::string> transitions;
|
||||||
|
transitions.push_back("PCM");
|
||||||
|
transitions.push_back("Speaker");
|
||||||
|
transitions.push_back("Master");
|
||||||
|
for(auto it = transitions.begin(); it != transitions.end(); it++)
|
||||||
|
vol_dev->add(*it, *it, Settings::getInstance()->getString("AudioDevice") == *it);
|
||||||
|
s->addWithLabel("AUDIO DEVICE", vol_dev);
|
||||||
|
s->addSaveFunc([vol_dev] {
|
||||||
|
Settings::getInstance()->setString("AudioDevice", vol_dev->getSelected());
|
||||||
|
VolumeControl::getInstance()->deinit();
|
||||||
|
VolumeControl::getInstance()->init();
|
||||||
|
});
|
||||||
|
#endif
|
||||||
|
|
||||||
// volume
|
// volume
|
||||||
auto volume = std::make_shared<SliderComponent>(mWindow, 0.f, 100.f, 1.f, "%");
|
auto volume = std::make_shared<SliderComponent>(mWindow, 0.f, 100.f, 1.f, "%");
|
||||||
volume->setValue((float)VolumeControl::getInstance()->getVolume());
|
volume->setValue((float)VolumeControl::getInstance()->getVolume());
|
||||||
|
@ -204,6 +221,23 @@ GuiMenu::GuiMenu(Window* window) : GuiComponent(window), mMenu(window, "MAIN MEN
|
||||||
if(needReload)
|
if(needReload)
|
||||||
ViewController::get()->reloadAll();
|
ViewController::get()->reloadAll();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// OMX player Audio Device
|
||||||
|
auto omx_audio_dev = std::make_shared< OptionListComponent<std::string> >(mWindow, "OMX PLAYER AUDIO DEVICE", false);
|
||||||
|
std::vector<std::string> devices;
|
||||||
|
devices.push_back("local");
|
||||||
|
devices.push_back("hdmi");
|
||||||
|
devices.push_back("both");
|
||||||
|
// USB audio
|
||||||
|
devices.push_back("alsa:hw:0,0");
|
||||||
|
devices.push_back("alsa:hw:1,0");
|
||||||
|
for (auto it = devices.begin(); it != devices.end(); it++)
|
||||||
|
omx_audio_dev->add(*it, *it, Settings::getInstance()->getString("OMXAudioDev") == *it);
|
||||||
|
s->addWithLabel("OMX PLAYER AUDIO DEVICE", omx_audio_dev);
|
||||||
|
s->addSaveFunc([omx_audio_dev] {
|
||||||
|
if (Settings::getInstance()->getString("OMXAudioDev") != omx_audio_dev->getSelected())
|
||||||
|
Settings::getInstance()->setString("OMXAudioDev", omx_audio_dev->getSelected());
|
||||||
|
});
|
||||||
#endif
|
#endif
|
||||||
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"));
|
||||||
|
|
|
@ -81,6 +81,15 @@ void Settings::setDefaults()
|
||||||
// we don't get a warning if we encounter it on a different platform
|
// we don't get a warning if we encounter it on a different platform
|
||||||
mBoolMap["VideoOmxPlayer"] = false;
|
mBoolMap["VideoOmxPlayer"] = false;
|
||||||
mBoolMap["VideoAudio"] = true;
|
mBoolMap["VideoAudio"] = true;
|
||||||
|
// Audio out device for Video playback using OMX player.
|
||||||
|
mStringMap["OMXAudioDev"] = "both";
|
||||||
|
|
||||||
|
// Audio out device for volume control
|
||||||
|
#ifdef _RPI_
|
||||||
|
mStringMap["AudioDevice"] = "PCM";
|
||||||
|
#else
|
||||||
|
mStringMap["AudioDevice"] = "Master";
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#ifdef _RPI_
|
#ifdef _RPI_
|
||||||
#include "components/VideoPlayerComponent.h"
|
#include "components/VideoPlayerComponent.h"
|
||||||
|
#include "AudioManager.h"
|
||||||
#include "Renderer.h"
|
#include "Renderer.h"
|
||||||
#include "ThemeData.h"
|
#include "ThemeData.h"
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
|
@ -57,6 +58,9 @@ void VideoPlayerComponent::startVideo()
|
||||||
// Set the video that we are going to be playing so we don't attempt to restart it
|
// Set the video that we are going to be playing so we don't attempt to restart it
|
||||||
mPlayingVideoPath = mVideoPath;
|
mPlayingVideoPath = mVideoPath;
|
||||||
|
|
||||||
|
// Disable AudioManager so video can play
|
||||||
|
AudioManager::getInstance()->deinit();
|
||||||
|
|
||||||
// Start the player process
|
// Start the player process
|
||||||
pid_t pid = fork();
|
pid_t pid = fork();
|
||||||
if (pid == -1)
|
if (pid == -1)
|
||||||
|
@ -84,7 +88,7 @@ void VideoPlayerComponent::startVideo()
|
||||||
// We need to specify the layer of 10000 or above to ensure the video is displayed on top
|
// We need to specify the layer of 10000 or above to ensure the video is displayed on top
|
||||||
// of our SDL display
|
// of our SDL display
|
||||||
|
|
||||||
const char* argv[] = { "", "--layer", "10010", "--loop", "--no-osd", "--aspect-mode", "letterbox", "--vol", "0", "--win", buf, "-b", "", "", "", "", NULL };
|
const char* argv[] = { "", "--layer", "10010", "--loop", "--no-osd", "--aspect-mode", "letterbox", "--vol", "0", "-o", "both","--win", buf, "-b", "", "", "", "", NULL };
|
||||||
|
|
||||||
// check if we want to mute the audio
|
// check if we want to mute the audio
|
||||||
if (!Settings::getInstance()->getBool("VideoAudio"))
|
if (!Settings::getInstance()->getBool("VideoAudio"))
|
||||||
|
@ -98,7 +102,9 @@ void VideoPlayerComponent::startVideo()
|
||||||
argv[6] = "stretch";
|
argv[6] = "stretch";
|
||||||
}
|
}
|
||||||
|
|
||||||
argv[11] = mPlayingVideoPath.c_str();
|
argv[10] = Settings::getInstance()->getString("OMXAudioDev").c_str();
|
||||||
|
|
||||||
|
argv[13] = mPlayingVideoPath.c_str();
|
||||||
|
|
||||||
const char* env[] = { "LD_LIBRARY_PATH=/opt/vc/libs:/usr/lib/omxplayer", NULL };
|
const char* env[] = { "LD_LIBRARY_PATH=/opt/vc/libs:/usr/lib/omxplayer", NULL };
|
||||||
|
|
||||||
|
@ -134,6 +140,8 @@ void VideoPlayerComponent::stopVideo()
|
||||||
int status;
|
int status;
|
||||||
kill(mPlayerPid, SIGKILL);
|
kill(mPlayerPid, SIGKILL);
|
||||||
waitpid(mPlayerPid, &status, WNOHANG);
|
waitpid(mPlayerPid, &status, WNOHANG);
|
||||||
|
// Restart AudioManager
|
||||||
|
AudioManager::getInstance()->init();
|
||||||
mPlayerPid = -1;
|
mPlayerPid = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue