From 7ea91f08af6f4105bc614e11bb222183c9d74d7d Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Thu, 8 Jul 2021 18:26:01 +0200 Subject: [PATCH] Removed the deprecated VideoOmxComponent. --- es-app/src/SystemScreensaver.cpp | 13 +- es-app/src/guis/GuiMenu.cpp | 114 --------- es-app/src/guis/GuiScreensaverOptions.cpp | 15 -- .../src/views/gamelist/VideoGameListView.cpp | 15 +- es-core/CMakeLists.txt | 2 - es-core/src/components/VideoOmxComponent.cpp | 242 ------------------ es-core/src/components/VideoOmxComponent.h | 47 ---- 7 files changed, 4 insertions(+), 444 deletions(-) delete mode 100644 es-core/src/components/VideoOmxComponent.cpp delete mode 100644 es-core/src/components/VideoOmxComponent.h diff --git a/es-app/src/SystemScreensaver.cpp b/es-app/src/SystemScreensaver.cpp index e6aa7ea5c..e74b161d9 100644 --- a/es-app/src/SystemScreensaver.cpp +++ b/es-app/src/SystemScreensaver.cpp @@ -10,9 +10,6 @@ #include "SystemScreensaver.h" #include "components/VideoFFmpegComponent.h" -#if defined(_RPI_) -#include "components/VideoOmxComponent.h" -#endif #if defined(BUILD_VLC_PLAYER) #include "components/VideoVlcComponent.h" #endif @@ -163,15 +160,7 @@ void SystemScreensaver::startScreensaver(bool generateMediaList) if (Settings::getInstance()->getBool("ScreensaverVideoGameInfo")) generateOverlayInfo(); -#if defined(_RPI_) - // 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 defined(BUILD_VLC_PLAYER) if (Settings::getInstance()->getString("VideoPlayer") == "vlc") mVideoScreensaver = new VideoVlcComponent(mWindow); else diff --git a/es-app/src/guis/GuiMenu.cpp b/es-app/src/guis/GuiMenu.cpp index 2333b83ed..bc9a2f77f 100644 --- a/es-app/src/guis/GuiMenu.cpp +++ b/es-app/src/guis/GuiMenu.cpp @@ -631,105 +631,6 @@ void GuiMenu::openSoundOptions() }); 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>( - mWindow, getHelpStyle(), "AUDIO CARD", false); - std::vector 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>(mWindow, getHelpStyle(), - "AUDIO DEVICE", false); - std::vector 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>( - mWindow, getHelpStyle(), "OMX PLAYER AUDIO DEVICE", false); - std::vector 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. auto gamelist_video_audio = std::make_shared(mWindow); gamelist_video_audio->setState(Settings::getInstance()->getBool("GamelistVideoAudio")); @@ -1000,21 +901,6 @@ void GuiMenu::openOtherOptions() }); s->addRow(rowMediaDir); -#if defined(_RPI_) - // Video playing using OMXPlayer. - auto video_omx_player = std::make_shared(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) // Hide taskbar during the ES program session. auto hide_taskbar = std::make_shared(mWindow); diff --git a/es-app/src/guis/GuiScreensaverOptions.cpp b/es-app/src/guis/GuiScreensaverOptions.cpp index 41491e7d5..8c7dd71ca 100644 --- a/es-app/src/guis/GuiScreensaverOptions.cpp +++ b/es-app/src/guis/GuiScreensaverOptions.cpp @@ -257,21 +257,6 @@ void GuiScreensaverOptions::openVideoScreensaverOptions() } }); -#if defined(_RPI_) - // Use OMX player for screensaver. - auto screensaver_omx_player = std::make_shared(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) // Render scanlines using a shader. auto screensaver_video_scanlines = std::make_shared(mWindow); diff --git a/es-app/src/views/gamelist/VideoGameListView.cpp b/es-app/src/views/gamelist/VideoGameListView.cpp index 1431bd785..a1ddd7278 100644 --- a/es-app/src/views/gamelist/VideoGameListView.cpp +++ b/es-app/src/views/gamelist/VideoGameListView.cpp @@ -10,9 +10,6 @@ #include "animations/LambdaAnimation.h" #include "components/VideoFFmpegComponent.h" -#if defined(_RPI_) -#include "components/VideoOmxComponent.h" -#endif #if defined(BUILD_VLC_PLAYER) #include "components/VideoVlcComponent.h" #endif @@ -56,15 +53,9 @@ VideoGameListView::VideoGameListView(Window* window, FileData* root) { const float padding = 0.01f; -// Create the correct type of video window. -#if defined(_RPI_) - if (Settings::getInstance()->getBool("VideoOmxPlayer")) - 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) + // Create the correct type of video window. + +#if defined(BUILD_VLC_PLAYER) if (Settings::getInstance()->getString("VideoPlayer") == "vlc") mVideo = new VideoVlcComponent(window); else diff --git a/es-core/CMakeLists.txt b/es-core/CMakeLists.txt index bf9d750b1..422c27d35 100644 --- a/es-core/CMakeLists.txt +++ b/es-core/CMakeLists.txt @@ -48,7 +48,6 @@ set(CORE_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/src/components/TextListComponent.h ${CMAKE_CURRENT_SOURCE_DIR}/src/components/VideoComponent.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 # GUIs @@ -126,7 +125,6 @@ set(CORE_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/components/TextEditComponent.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/components/VideoComponent.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 # GUIs diff --git a/es-core/src/components/VideoOmxComponent.cpp b/es-core/src/components/VideoOmxComponent.cpp deleted file mode 100644 index 4d537f244..000000000 --- a/es-core/src/components/VideoOmxComponent.cpp +++ /dev/null @@ -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 -#include -#include - -class VolumeControl -{ -public: - static std::shared_ptr& 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(Renderer::getScreenOffsetX() + x); - const int y1 = static_cast(Renderer::getScreenOffsetY() + y); - const int x2 = static_cast(x1 + mSize.x()); - const int y2 = static_cast(y1 + mSize.y()); - sprintf(buf1, "%d,%d,%d,%d", x1, y1, x2, y2); - } break; - - case 1: { - const int x1 = - static_cast(Renderer::getWindowWidth() - - Renderer::getScreenOffsetY() - y - mSize.y()); - const int y1 = static_cast(Renderer::getScreenOffsetX() + x); - const int x2 = static_cast(x1 + mSize.y()); - const int y2 = static_cast(y1 + mSize.x()); - sprintf(buf1, "%d,%d,%d,%d", x1, y1, x2, y2); - } break; - - case 2: { - const int x1 = - static_cast(Renderer::getWindowWidth() - - Renderer::getScreenOffsetX() - x - mSize.x()); - const int y1 = - static_cast(Renderer::getWindowHeight() - - Renderer::getScreenOffsetY() - y - mSize.y()); - const int x2 = static_cast(x1 + mSize.x()); - const int y2 = static_cast(y1 + mSize.y()); - sprintf(buf1, "%d,%d,%d,%d", x1, y1, x2, y2); - } break; - - case 3: { - const int x1 = static_cast(Renderer::getScreenOffsetY() + y); - const int y1 = - static_cast(Renderer::getWindowHeight() - - Renderer::getScreenOffsetX() - x - mSize.x()); - const int x2 = static_cast(x1 + mSize.y()); - const int y2 = static_cast(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(0)); - } break; - case 1: { - sprintf(buf2, "%d", static_cast(90)); - } break; - case 2: { - sprintf(buf2, "%d", static_cast(180)); - } break; - case 3: { - sprintf(buf2, "%d", static_cast(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(VolumeControl::getInstance()->getVolume()) == 0) || - (!Settings::getInstance()->getBool("ScreensaverVideoAudio") && - mScreensaverMode)) { - argv[8] = "-1000000"; - } - else { - float percentVolume = - static_cast(VolumeControl::getInstance()->getVolume()); - int OMXVolume = static_cast((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 diff --git a/es-core/src/components/VideoOmxComponent.h b/es-core/src/components/VideoOmxComponent.h deleted file mode 100644 index 7a5b883ce..000000000 --- a/es-core/src/components/VideoOmxComponent.h +++ /dev/null @@ -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_