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.
This commit is contained in:
Leon Styhre 2021-05-19 19:52:58 +02:00
parent 9d8cb889ac
commit 65e119cff9
7 changed files with 2 additions and 12 deletions

View file

@ -44,7 +44,6 @@ bool MediaViewer::startMediaViewer(FileData* game)
if (mHasVideo) { if (mHasVideo) {
ViewController::get()->onPauseVideo(); ViewController::get()->onPauseVideo();
AudioManager::getInstance()->clearStream();
} }
if (mHasVideo || mHasImages) if (mHasVideo || mHasImages)
@ -59,7 +58,6 @@ void MediaViewer::stopMediaViewer()
if (mVideo) { if (mVideo) {
ViewController::get()->onStopVideo(); ViewController::get()->onStopVideo();
AudioManager::getInstance()->clearStream();
delete mVideo; delete mVideo;
mVideo = nullptr; mVideo = nullptr;
} }
@ -191,7 +189,6 @@ void MediaViewer::showNext()
return; return;
} }
else if (mVideo && !Settings::getInstance()->getBool("MediaViewerKeepVideoRunning")) { else if (mVideo && !Settings::getInstance()->getBool("MediaViewerKeepVideoRunning")) {
AudioManager::getInstance()->clearStream();
delete mVideo; delete mVideo;
mVideo = nullptr; mVideo = nullptr;
showedVideo = true; showedVideo = true;

View file

@ -235,8 +235,6 @@ void SystemScreensaver::stopScreensaver()
if (mGameOverlay) if (mGameOverlay)
mGameOverlay.reset(); mGameOverlay.reset();
AudioManager::getInstance()->clearStream();
} }
void SystemScreensaver::nextGame() { void SystemScreensaver::nextGame() {

View file

@ -320,7 +320,6 @@ void ViewController::restoreViewPosition()
void ViewController::goToSystemView(SystemData* system, bool playTransition) void ViewController::goToSystemView(SystemData* system, bool playTransition)
{ {
AudioManager::getInstance()->clearStream();
bool applicationStartup = false; bool applicationStartup = false;
if (mState.viewing == NOTHING) if (mState.viewing == NOTHING)
@ -818,7 +817,6 @@ bool ViewController::input(InputConfig* config, Input input)
mCurrentView->stopListScrolling(); mCurrentView->stopListScrolling();
// Finally, if the camera is currently moving, reset its position. // Finally, if the camera is currently moving, reset its position.
cancelViewTransitions(); cancelViewTransitions();
AudioManager::getInstance()->clearStream();
mWindow->pushGui(new GuiMenu(mWindow)); mWindow->pushGui(new GuiMenu(mWindow));
return true; return true;
@ -842,7 +840,6 @@ void ViewController::update(int deltaTime)
updateSelf(deltaTime); updateSelf(deltaTime);
if (mGameToLaunch) { if (mGameToLaunch) {
AudioManager::getInstance()->clearStream();
launch(mGameToLaunch); launch(mGameToLaunch);
mGameToLaunch = nullptr; mGameToLaunch = nullptr;
} }

View file

@ -22,7 +22,6 @@ bool IGameListView::input(InputConfig* config, Input input)
config->isMappedTo("select", input) && input.value) { config->isMappedTo("select", input) && input.value) {
ViewController::get()->cancelViewTransitions(); ViewController::get()->cancelViewTransitions();
stopListScrolling(); stopListScrolling();
AudioManager::getInstance()->clearStream();
mWindow->pushGui(new GuiGamelistOptions(mWindow, this->mRoot->getSystem())); mWindow->pushGui(new GuiGamelistOptions(mWindow, this->mRoot->getSystem()));
return true; return true;
} }

View file

@ -395,7 +395,6 @@ void VideoGameListView::updateInfoPanel()
mThumbnail.setImage(file->getThumbnailPath()); mThumbnail.setImage(file->getThumbnailPath());
mMarquee.setImage(file->getMarqueePath()); mMarquee.setImage(file->getMarqueePath());
mVideo->setImage(file->getImagePath()); mVideo->setImage(file->getImagePath());
AudioManager::getInstance()->clearStream();
mVideo->onHide(); mVideo->onHide();

View file

@ -710,7 +710,6 @@ void Window::startScreensaver()
(*it)->onScreensaverActivate(); (*it)->onScreensaverActivate();
stopInfoPopup(); stopInfoPopup();
AudioManager::getInstance()->clearStream();
mScreensaver->startScreensaver(true); mScreensaver->startScreensaver(true);
mRenderScreensaver = true; mRenderScreensaver = true;
} }

View file

@ -217,7 +217,7 @@ void VideoFFmpegComponent::update(int deltaTime)
void VideoFFmpegComponent::frameProcessing() void VideoFFmpegComponent::frameProcessing()
{ {
while (mIsPlaying) { while (mIsPlaying && !mPause) {
readFrames(); readFrames();
if (!mEndOfVideo && mIsActuallyPlaying && 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. // This 1 ms wait makes sure that the thread does not consume all available CPU cycles.
SDL_Delay(1); SDL_Delay(1);
} }
AudioManager::getInstance()->clearStream();
} }
void VideoFFmpegComponent::readFrames() void VideoFFmpegComponent::readFrames()