Removed the deprecated VideoOmxComponent.

This commit is contained in:
Leon Styhre 2021-07-08 18:26:01 +02:00
parent 1d706ec7f3
commit 7ea91f08af
7 changed files with 4 additions and 444 deletions

View file

@ -10,9 +10,6 @@
#include "SystemScreensaver.h" #include "SystemScreensaver.h"
#include "components/VideoFFmpegComponent.h" #include "components/VideoFFmpegComponent.h"
#if defined(_RPI_)
#include "components/VideoOmxComponent.h"
#endif
#if defined(BUILD_VLC_PLAYER) #if defined(BUILD_VLC_PLAYER)
#include "components/VideoVlcComponent.h" #include "components/VideoVlcComponent.h"
#endif #endif
@ -163,15 +160,7 @@ void SystemScreensaver::startScreensaver(bool generateMediaList)
if (Settings::getInstance()->getBool("ScreensaverVideoGameInfo")) if (Settings::getInstance()->getBool("ScreensaverVideoGameInfo"))
generateOverlayInfo(); generateOverlayInfo();
#if defined(_RPI_) #if defined(BUILD_VLC_PLAYER)
// Create the correct type of video component.
if (Settings::getInstance()->getBool("ScreensaverOmxPlayer"))
mVideoScreensaver = new VideoOmxComponent(mWindow);
else if (Settings::getInstance()->getString("VideoPlayer") == "vlc")
mVideoScreensaver = new VideoVlcComponent(mWindow);
else
mVideoScreensaver = new VideoFFmpegComponent(mWindow);
#elif defined(BUILD_VLC_PLAYER)
if (Settings::getInstance()->getString("VideoPlayer") == "vlc") if (Settings::getInstance()->getString("VideoPlayer") == "vlc")
mVideoScreensaver = new VideoVlcComponent(mWindow); mVideoScreensaver = new VideoVlcComponent(mWindow);
else else

View file

@ -631,105 +631,6 @@ void GuiMenu::openSoundOptions()
}); });
if (UIModeController::getInstance()->isUIModeFull()) { 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
// make much sense to be able to select ALSA devices directly. Normally (always?)
// the selection doesn't make any difference at all. But maybe some PulseAudio
// settings could be added later on, if needed.
// The code is still active for Raspberry Pi though as I'm not sure if this is
// useful for that device.
// #if defined(__linux__)
#if defined(_RPI_)
// Audio card.
auto audio_card = std::make_shared<OptionListComponent<std::string>>(
mWindow, getHelpStyle(), "AUDIO CARD", false);
std::vector<std::string> audio_cards;
#if defined(_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, s] {
if (audio_card->getSelected() != Settings::getInstance()->getString("AudioCard")) {
Settings::getInstance()->setString("AudioCard", audio_card->getSelected());
VolumeControl::getInstance()->deinit();
VolumeControl::getInstance()->init();
s->setNeedsSaving();
}
});
// Volume control device.
auto vol_dev = std::make_shared<OptionListComponent<std::string>>(mWindow, getHelpStyle(),
"AUDIO DEVICE", false);
std::vector<std::string> transitions;
transitions.push_back("PCM");
transitions.push_back("Speaker");
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++)
vol_dev->add(*it, *it, Settings::getInstance()->getString("AudioDevice") == *it);
s->addWithLabel("AUDIO DEVICE", vol_dev);
s->addSaveFunc([vol_dev, s] {
if (vol_dev->getSelected() != Settings::getInstance()->getString("AudioDevice")) {
Settings::getInstance()->setString("AudioDevice", vol_dev->getSelected());
VolumeControl::getInstance()->deinit();
VolumeControl::getInstance()->init();
s->setNeedsSaving();
}
});
#endif
#if defined(_RPI_)
// OMXPlayer audio device.
auto omx_audio_dev = std::make_shared<OptionListComponent<std::string>>(
mWindow, getHelpStyle(), "OMX PLAYER AUDIO DEVICE", false);
std::vector<std::string> omx_cards;
// RPi Specific Audio Cards
omx_cards.push_back("local");
omx_cards.push_back("hdmi");
omx_cards.push_back("both");
omx_cards.push_back("alsa:hw:0,0");
omx_cards.push_back("alsa:hw:1,0");
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);
s->addWithLabel("OMX PLAYER AUDIO DEVICE", omx_audio_dev);
s->addSaveFunc([omx_audio_dev, s] {
if (omx_audio_dev->getSelected() != Settings::getInstance()->getString("OMXAudioDev")) {
Settings::getInstance()->setString("OMXAudioDev", omx_audio_dev->getSelected());
s->setNeedsSaving();
}
});
#endif
// Play audio for gamelist videos. // Play audio for gamelist videos.
auto gamelist_video_audio = std::make_shared<SwitchComponent>(mWindow); auto gamelist_video_audio = std::make_shared<SwitchComponent>(mWindow);
gamelist_video_audio->setState(Settings::getInstance()->getBool("GamelistVideoAudio")); gamelist_video_audio->setState(Settings::getInstance()->getBool("GamelistVideoAudio"));
@ -1000,21 +901,6 @@ void GuiMenu::openOtherOptions()
}); });
s->addRow(rowMediaDir); s->addRow(rowMediaDir);
#if defined(_RPI_)
// Video playing using OMXPlayer.
auto video_omx_player = std::make_shared<SwitchComponent>(mWindow);
video_omx_player->setState(Settings::getInstance()->getBool("VideoOmxPlayer"));
s->addWithLabel("USE OMX PLAYER (HW ACCELERATED)", video_omx_player);
s->addSaveFunc([video_omx_player, s] {
if (video_omx_player->getState() != Settings::getInstance()->getBool("VideoOmxPlayer")) {
Settings::getInstance()->setBool("VideoOmxPlayer", video_omx_player->getState());
s->setNeedsSaving();
// Need to reload all views to re-create the right video components.
s->setNeedsReloading();
}
});
#endif
#if defined(_WIN64) #if defined(_WIN64)
// Hide taskbar during the ES program session. // Hide taskbar during the ES program session.
auto hide_taskbar = std::make_shared<SwitchComponent>(mWindow); auto hide_taskbar = std::make_shared<SwitchComponent>(mWindow);

View file

@ -257,21 +257,6 @@ void GuiScreensaverOptions::openVideoScreensaverOptions()
} }
}); });
#if defined(_RPI_)
// Use OMX player for screensaver.
auto screensaver_omx_player = std::make_shared<SwitchComponent>(mWindow);
screensaver_omx_player->setState(Settings::getInstance()->getBool("ScreensaverOmxPlayer"));
s->addWithLabel("USE OMX PLAYER FOR SCREENSAVER", screensaver_omx_player);
s->addSaveFunc([screensaver_omx_player, s] {
if (screensaver_omx_player->getState() !=
Settings::getInstance()->getBool("ScreensaverOmxPlayer")) {
Settings::getInstance()->setBool("ScreensaverOmxPlayer",
screensaver_omx_player->getState());
s->setNeedsSaving();
}
});
#endif
#if defined(USE_OPENGL_21) #if defined(USE_OPENGL_21)
// Render scanlines using a shader. // Render scanlines using a shader.
auto screensaver_video_scanlines = std::make_shared<SwitchComponent>(mWindow); auto screensaver_video_scanlines = std::make_shared<SwitchComponent>(mWindow);

View file

@ -10,9 +10,6 @@
#include "animations/LambdaAnimation.h" #include "animations/LambdaAnimation.h"
#include "components/VideoFFmpegComponent.h" #include "components/VideoFFmpegComponent.h"
#if defined(_RPI_)
#include "components/VideoOmxComponent.h"
#endif
#if defined(BUILD_VLC_PLAYER) #if defined(BUILD_VLC_PLAYER)
#include "components/VideoVlcComponent.h" #include "components/VideoVlcComponent.h"
#endif #endif
@ -56,15 +53,9 @@ VideoGameListView::VideoGameListView(Window* window, FileData* root)
{ {
const float padding = 0.01f; const float padding = 0.01f;
// Create the correct type of video window. // Create the correct type of video window.
#if defined(_RPI_)
if (Settings::getInstance()->getBool("VideoOmxPlayer")) #if defined(BUILD_VLC_PLAYER)
mVideo = new VideoOmxComponent(window);
else if (Settings::getInstance()->getString("VideoPlayer") == "vlc")
mVideo = new VideoVlcComponent(window);
else
mVideo = new VideoFFmpegComponent(window);
#elif defined(BUILD_VLC_PLAYER)
if (Settings::getInstance()->getString("VideoPlayer") == "vlc") if (Settings::getInstance()->getString("VideoPlayer") == "vlc")
mVideo = new VideoVlcComponent(window); mVideo = new VideoVlcComponent(window);
else else

View file

@ -48,7 +48,6 @@ set(CORE_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/src/components/TextListComponent.h ${CMAKE_CURRENT_SOURCE_DIR}/src/components/TextListComponent.h
${CMAKE_CURRENT_SOURCE_DIR}/src/components/VideoComponent.h ${CMAKE_CURRENT_SOURCE_DIR}/src/components/VideoComponent.h
${CMAKE_CURRENT_SOURCE_DIR}/src/components/VideoFFmpegComponent.h ${CMAKE_CURRENT_SOURCE_DIR}/src/components/VideoFFmpegComponent.h
${CMAKE_CURRENT_SOURCE_DIR}/src/components/VideoOmxComponent.h
${CMAKE_CURRENT_SOURCE_DIR}/src/components/VideoVlcComponent.h ${CMAKE_CURRENT_SOURCE_DIR}/src/components/VideoVlcComponent.h
# GUIs # GUIs
@ -126,7 +125,6 @@ set(CORE_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/src/components/TextEditComponent.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/components/TextEditComponent.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/components/VideoComponent.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/components/VideoComponent.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/components/VideoFFmpegComponent.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/components/VideoFFmpegComponent.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/components/VideoOmxComponent.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/components/VideoVlcComponent.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/components/VideoVlcComponent.cpp
# GUIs # GUIs

View file

@ -1,242 +0,0 @@
// SPDX-License-Identifier: MIT
//
// EmulationStation Desktop Edition
// VideoOmxComponent.cpp
//
// Video playing using OMXPlayer for Raspberry Pi.
//
#if defined(_RPI_)
#include "components/VideoOmxComponent.h"
#include "AudioManager.h"
#include "Settings.h"
#include "renderers/Renderer.h"
#include "utils/StringUtil.h"
#include <fcntl.h>
#include <unistd.h>
#include <wait.h>
class VolumeControl
{
public:
static std::shared_ptr<VolumeControl>& getInstance();
int getVolume() const;
};
VideoOmxComponent::VideoOmxComponent(Window* window)
: VideoComponent(window)
, mPlayerPid(-1)
{
}
VideoOmxComponent::~VideoOmxComponent()
{
// Stop video when destroyed.
stopVideo();
}
void VideoOmxComponent::render(const Transform4x4f& parentTrans)
{
if (!isVisible())
return;
VideoComponent::render(parentTrans);
if (!mIsPlaying || mPlayerPid == -1)
VideoComponent::renderSnapshot(parentTrans);
}
void VideoOmxComponent::setResize(float width, float height)
{
setSize(width, height);
mTargetSize = Vector2f(width, height);
mTargetIsMax = false;
mStaticImage.setResize(width, height);
onSizeChanged();
}
void VideoOmxComponent::setMaxSize(float width, float height)
{
setSize(width, height);
mTargetSize = Vector2f(width, height);
mTargetIsMax = true;
mStaticImage.setMaxSize(width, height);
onSizeChanged();
}
void VideoOmxComponent::startVideo()
{
if (!mIsPlaying) {
mVideoWidth = 0;
mVideoHeight = 0;
std::string path(mVideoPath.c_str());
// Make sure we have a video path.
if ((path.size() > 0) && (mPlayerPid == -1)) {
// Set the video that we are going to be playing so we don't attempt to restart it.
mPlayingVideoPath = mVideoPath;
// Disable AudioManager so video can play, in case we're requesting ALSA.
if (Utils::String::startsWith(Settings::getInstance()->getString("OMXAudioDev").c_str(),
"alsa"))
AudioManager::getInstance()->deinit();
// Start the player process.
pid_t pid = fork();
if (pid == -1) {
// Failed.
mPlayingVideoPath = "";
}
else if (pid > 0) {
mPlayerPid = pid;
// Update the playing state.
signal(SIGCHLD, catch_child);
mIsPlaying = true;
mFadeIn = 0.0f;
}
else {
// Find out the pixel position of the video view and build a command line for
// OMXPlayer to position it in the right place.
char buf1[32];
char buf2[32];
float x = mPosition.x() - (mOrigin.x() * mSize.x());
float y = mPosition.y() - (mOrigin.y() * mSize.y());
// Fix x and y.
switch (Renderer::getScreenRotate()) {
case 0: {
const int x1 = static_cast<int>(Renderer::getScreenOffsetX() + x);
const int y1 = static_cast<int>(Renderer::getScreenOffsetY() + y);
const int x2 = static_cast<int>(x1 + mSize.x());
const int y2 = static_cast<int>(y1 + mSize.y());
sprintf(buf1, "%d,%d,%d,%d", x1, y1, x2, y2);
} break;
case 1: {
const int x1 =
static_cast<int>(Renderer::getWindowWidth() -
Renderer::getScreenOffsetY() - y - mSize.y());
const int y1 = static_cast<int>(Renderer::getScreenOffsetX() + x);
const int x2 = static_cast<int>(x1 + mSize.y());
const int y2 = static_cast<int>(y1 + mSize.x());
sprintf(buf1, "%d,%d,%d,%d", x1, y1, x2, y2);
} break;
case 2: {
const int x1 =
static_cast<int>(Renderer::getWindowWidth() -
Renderer::getScreenOffsetX() - x - mSize.x());
const int y1 =
static_cast<int>(Renderer::getWindowHeight() -
Renderer::getScreenOffsetY() - y - mSize.y());
const int x2 = static_cast<int>(x1 + mSize.x());
const int y2 = static_cast<int>(y1 + mSize.y());
sprintf(buf1, "%d,%d,%d,%d", x1, y1, x2, y2);
} break;
case 3: {
const int x1 = static_cast<int>(Renderer::getScreenOffsetY() + y);
const int y1 =
static_cast<int>(Renderer::getWindowHeight() -
Renderer::getScreenOffsetX() - x - mSize.x());
const int x2 = static_cast<int>(x1 + mSize.y());
const int y2 = static_cast<int>(y1 + mSize.x());
sprintf(buf1, "%d,%d,%d,%d", x1, y1, x2, y2);
} break;
}
// Rotate the video.
switch (Renderer::getScreenRotate()) {
case 0: {
sprintf(buf2, "%d", static_cast<int>(0));
} break;
case 1: {
sprintf(buf2, "%d", static_cast<int>(90));
} break;
case 2: {
sprintf(buf2, "%d", static_cast<int>(180));
} break;
case 3: {
sprintf(buf2, "%d", static_cast<int>(270));
} break;
}
// We need to specify the layer of 10000 or above to ensure the video is
// displayed on top of our SDL display.
const char* argv[] = { "", "--layer",
"10010", "--loop",
"--no-osd", "--aspect-mode",
"letterbox", "--vol",
"0", "-o",
"both", "--win",
buf1, "--orientation",
buf2, "",
"", "",
"", "",
"", "",
"", "",
"", "",
NULL };
// Check if we want to mute the audio.
if ((!Settings::getInstance()->getBool("GamelistVideoAudio") ||
static_cast<float>(VolumeControl::getInstance()->getVolume()) == 0) ||
(!Settings::getInstance()->getBool("ScreensaverVideoAudio") &&
mScreensaverMode)) {
argv[8] = "-1000000";
}
else {
float percentVolume =
static_cast<float>(VolumeControl::getInstance()->getVolume());
int OMXVolume = static_cast<int>((percentVolume - 98) * 105);
argv[8] = std::to_string(OMXVolume).c_str();
}
// If we are rendering a video gamelist.
if (!mTargetIsMax)
argv[6] = "stretch";
argv[15] = mPlayingVideoPath.c_str();
argv[10] = Settings::getInstance()->getString("OMXAudioDev").c_str();
const char* env[] = { "LD_LIBRARY_PATH=/opt/vc/libs:/usr/lib/omxplayer", NULL };
// Redirect stdout.
int fdin = open("/dev/null", O_RDONLY);
int fdout = open("/dev/null", O_WRONLY);
dup2(fdin, 0);
dup2(fdout, 1);
// Run the OMXPlayer binary.
execve("/usr/bin/omxplayer.bin", (char**)argv, (char**)env);
_exit(EXIT_FAILURE);
}
}
}
}
void catch_child(int sig_num)
{
// When we get here, we know there's a zombie child waiting.
int child_status;
wait(&child_status);
}
void VideoOmxComponent::stopVideo()
{
mIsPlaying = false;
mStartDelayed = false;
// Stop the player process.
if (mPlayerPid != -1) {
int status;
kill(mPlayerPid, SIGKILL);
waitpid(mPlayerPid, &status, WNOHANG);
mPlayerPid = -1;
}
}
#endif

View file

@ -1,47 +0,0 @@
// SPDX-License-Identifier: MIT
//
// EmulationStation Desktop Edition
// VideoOmxComponent.h
//
// Video playing using OMXPlayer for Raspberry Pi.
//
#if defined(_RPI_)
#ifndef ES_CORE_COMPONENTS_VIDEO_OMX_COMPONENT_H
#define ES_CORE_COMPONENTS_VIDEO_OMX_COMPONENT_H
#include "components/VideoComponent.h"
void catch_child(int sig_num);
class VideoOmxComponent : public VideoComponent
{
public:
VideoOmxComponent(Window* window);
virtual ~VideoOmxComponent();
void render(const Transform4x4f& parentTrans) override;
// Resize the video to fit this size. If one axis is zero, scale that axis to maintain
// aspect ratio. If both are non-zero, potentially break the aspect ratio. If both are
// zero, no resizing. This can be set before or after a video is loaded.
// setMaxSize() and setResize() are mutually exclusive.
void setResize(float width, float height) override;
// Resize the video to be as large as possible but fit within a box of this size.
// This can be set before or after a video is loaded.
// Never breaks the aspect ratio. setMaxSize() and setResize() are mutually exclusive.
void setMaxSize(float width, float height) override;
private:
// Start the video Immediately.
virtual void startVideo() override;
// Stop the video.
virtual void stopVideo() override;
private:
pid_t mPlayerPid;
};
#endif // ES_CORE_COMPONENTS_VIDEO_OMX_COMPONENT_H
#endif // _RPI_