From 65e119cff9862abdb3c5bd68aa82028484b3ddf0 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Wed, 19 May 2021 19:52:58 +0200 Subject: [PATCH] The audio stream is now only cleared from a single location in VideoFFmpegComponent. Also made the video player finish processing if the video is paused. --- es-app/src/MediaViewer.cpp | 3 --- es-app/src/SystemScreensaver.cpp | 2 -- es-app/src/views/ViewController.cpp | 3 --- es-app/src/views/gamelist/IGameListView.cpp | 1 - es-app/src/views/gamelist/VideoGameListView.cpp | 1 - es-core/src/Window.cpp | 1 - es-core/src/components/VideoFFmpegComponent.cpp | 3 ++- 7 files changed, 2 insertions(+), 12 deletions(-) diff --git a/es-app/src/MediaViewer.cpp b/es-app/src/MediaViewer.cpp index e58b2fd09..90e391a79 100644 --- a/es-app/src/MediaViewer.cpp +++ b/es-app/src/MediaViewer.cpp @@ -44,7 +44,6 @@ bool MediaViewer::startMediaViewer(FileData* game) if (mHasVideo) { ViewController::get()->onPauseVideo(); - AudioManager::getInstance()->clearStream(); } if (mHasVideo || mHasImages) @@ -59,7 +58,6 @@ void MediaViewer::stopMediaViewer() if (mVideo) { ViewController::get()->onStopVideo(); - AudioManager::getInstance()->clearStream(); delete mVideo; mVideo = nullptr; } @@ -191,7 +189,6 @@ void MediaViewer::showNext() return; } else if (mVideo && !Settings::getInstance()->getBool("MediaViewerKeepVideoRunning")) { - AudioManager::getInstance()->clearStream(); delete mVideo; mVideo = nullptr; showedVideo = true; diff --git a/es-app/src/SystemScreensaver.cpp b/es-app/src/SystemScreensaver.cpp index faccddbcf..6c60fa160 100644 --- a/es-app/src/SystemScreensaver.cpp +++ b/es-app/src/SystemScreensaver.cpp @@ -235,8 +235,6 @@ void SystemScreensaver::stopScreensaver() if (mGameOverlay) mGameOverlay.reset(); - - AudioManager::getInstance()->clearStream(); } void SystemScreensaver::nextGame() { diff --git a/es-app/src/views/ViewController.cpp b/es-app/src/views/ViewController.cpp index 286870d99..346efc5be 100644 --- a/es-app/src/views/ViewController.cpp +++ b/es-app/src/views/ViewController.cpp @@ -320,7 +320,6 @@ void ViewController::restoreViewPosition() void ViewController::goToSystemView(SystemData* system, bool playTransition) { - AudioManager::getInstance()->clearStream(); bool applicationStartup = false; if (mState.viewing == NOTHING) @@ -818,7 +817,6 @@ bool ViewController::input(InputConfig* config, Input input) mCurrentView->stopListScrolling(); // Finally, if the camera is currently moving, reset its position. cancelViewTransitions(); - AudioManager::getInstance()->clearStream(); mWindow->pushGui(new GuiMenu(mWindow)); return true; @@ -842,7 +840,6 @@ void ViewController::update(int deltaTime) updateSelf(deltaTime); if (mGameToLaunch) { - AudioManager::getInstance()->clearStream(); launch(mGameToLaunch); mGameToLaunch = nullptr; } diff --git a/es-app/src/views/gamelist/IGameListView.cpp b/es-app/src/views/gamelist/IGameListView.cpp index 603d153e7..e2d8d4a07 100644 --- a/es-app/src/views/gamelist/IGameListView.cpp +++ b/es-app/src/views/gamelist/IGameListView.cpp @@ -22,7 +22,6 @@ bool IGameListView::input(InputConfig* config, Input input) config->isMappedTo("select", input) && input.value) { ViewController::get()->cancelViewTransitions(); stopListScrolling(); - AudioManager::getInstance()->clearStream(); mWindow->pushGui(new GuiGamelistOptions(mWindow, this->mRoot->getSystem())); return true; } diff --git a/es-app/src/views/gamelist/VideoGameListView.cpp b/es-app/src/views/gamelist/VideoGameListView.cpp index b584198ba..655fde5d4 100644 --- a/es-app/src/views/gamelist/VideoGameListView.cpp +++ b/es-app/src/views/gamelist/VideoGameListView.cpp @@ -395,7 +395,6 @@ void VideoGameListView::updateInfoPanel() mThumbnail.setImage(file->getThumbnailPath()); mMarquee.setImage(file->getMarqueePath()); mVideo->setImage(file->getImagePath()); - AudioManager::getInstance()->clearStream(); mVideo->onHide(); diff --git a/es-core/src/Window.cpp b/es-core/src/Window.cpp index 79b9c9196..ffc5dcae9 100644 --- a/es-core/src/Window.cpp +++ b/es-core/src/Window.cpp @@ -710,7 +710,6 @@ void Window::startScreensaver() (*it)->onScreensaverActivate(); stopInfoPopup(); - AudioManager::getInstance()->clearStream(); mScreensaver->startScreensaver(true); mRenderScreensaver = true; } diff --git a/es-core/src/components/VideoFFmpegComponent.cpp b/es-core/src/components/VideoFFmpegComponent.cpp index b249baf91..0a73dffc2 100644 --- a/es-core/src/components/VideoFFmpegComponent.cpp +++ b/es-core/src/components/VideoFFmpegComponent.cpp @@ -217,7 +217,7 @@ void VideoFFmpegComponent::update(int deltaTime) void VideoFFmpegComponent::frameProcessing() { - while (mIsPlaying) { + while (mIsPlaying && !mPause) { readFrames(); if (!mEndOfVideo && mIsActuallyPlaying && @@ -229,6 +229,7 @@ void VideoFFmpegComponent::frameProcessing() // This 1 ms wait makes sure that the thread does not consume all available CPU cycles. SDL_Delay(1); } + AudioManager::getInstance()->clearStream(); } void VideoFFmpegComponent::readFrames()