Source replacement and create source with software decoder

This commit is contained in:
Bruno Herbelin
2023-05-31 19:27:08 +02:00
parent c2c7c37ef6
commit ced318637f
3 changed files with 33 additions and 11 deletions

View File

@@ -694,15 +694,29 @@ void ImGuiVisitor::visit (MediaSource& s)
if (ImGuiToolkit::IconButton(ICON_FA_FOLDER_OPEN, "Show in finder")) if (ImGuiToolkit::IconButton(ICON_FA_FOLDER_OPEN, "Show in finder"))
SystemToolkit::open(SystemToolkit::path_filename(s.path())); SystemToolkit::open(SystemToolkit::path_filename(s.path()));
ImGui::SetCursorPos(botom);
} }
else { else {
// failed
ImGui::SetCursorPos(top); ImGui::SetCursorPos(top);
if (ImGuiToolkit::IconButton(ICON_FA_COPY, "Copy message")) if (ImGuiToolkit::IconButton(ICON_FA_COPY, "Copy message"))
ImGui::SetClipboardText(info.str().c_str()); ImGui::SetClipboardText(info.str().c_str());
info.reset(); info.reset();
ImGui::SetCursorPos(botom);
// because sometimes the error comes from gpu decoding
if ( Settings::application.render.gpu_decoding )
{
// offer to reload the source without hardware decoding
if ( ImGui::Button( ICON_FA_REDO_ALT " Try again without\nhardware decoding", ImVec2(IMGUI_RIGHT_ALIGN, 0)) ) {
// replace current source with one created with a flag forcing software decoding
Mixer::manager().replaceSource(Mixer::manager().currentSource(),
Mixer::manager().createSourceFile(s.path(), true));
}
}
} }
ImGui::SetCursorPos(botom);
} }
void ImGuiVisitor::visit (SessionFileSource& s) void ImGuiVisitor::visit (SessionFileSource& s)

View File

@@ -31,6 +31,7 @@
#include <tinyxml2.h> #include <tinyxml2.h>
#include "ImageShader.h"
#include "defines.h" #include "defines.h"
#include "Settings.h" #include "Settings.h"
#include "Log.h" #include "Log.h"
@@ -42,6 +43,7 @@
#include "SessionSource.h" #include "SessionSource.h"
#include "CloneSource.h" #include "CloneSource.h"
#include "RenderSource.h" #include "RenderSource.h"
#include "MediaPlayer.h"
#include "MediaSource.h" #include "MediaSource.h"
#include "PatternSource.h" #include "PatternSource.h"
#include "DeviceSource.h" #include "DeviceSource.h"
@@ -186,8 +188,14 @@ void Mixer::update()
// if there is a source candidate for this session // if there is a source candidate for this session
if (candidate_sources_.size() > 0) { if (candidate_sources_.size() > 0) {
// the first element of the pair is the source to insert
// NB: only make the last candidate the current source in Mixing view // NB: only make the last candidate the current source in Mixing view
insertSource(candidate_sources_.front(), candidate_sources_.size() > 1 ? View::INVALID : View::MIXING); insertSource(candidate_sources_.front().first, candidate_sources_.size() > 1 ? View::INVALID : View::MIXING);
// the second element of the pair is the source to be replaced, i.e. deleted if provided
if (candidate_sources_.front().second != nullptr)
deleteSource(candidate_sources_.front().second);
candidate_sources_.pop_front(); candidate_sources_.pop_front();
} }
@@ -264,7 +272,7 @@ void Mixer::draw()
} }
// manangement of sources // manangement of sources
Source * Mixer::createSourceFile(const std::string &path) Source * Mixer::createSourceFile(const std::string &path, bool disable_hw_decoding)
{ {
// ready to create a source // ready to create a source
Source *s = nullptr; Source *s = nullptr;
@@ -283,6 +291,7 @@ Source * Mixer::createSourceFile(const std::string &path)
else { else {
// (try to) create media source by default // (try to) create media source by default
MediaSource *ms = new MediaSource; MediaSource *ms = new MediaSource;
ms->mediaplayer()->setSoftwareDecodingForced(disable_hw_decoding);
ms->setPath(path); ms->setPath(path);
s = ms; s = ms;
} }
@@ -451,7 +460,7 @@ Source * Mixer::createSourceClone(const std::string &namesource, bool copy_attri
void Mixer::addSource(Source *s) void Mixer::addSource(Source *s)
{ {
if (s != nullptr) if (s != nullptr)
candidate_sources_.push_back(s); candidate_sources_.push_back( std::make_pair(s, nullptr) );
} }
void delayed_notification( Source *source ) void delayed_notification( Source *source )
@@ -546,14 +555,11 @@ void Mixer::replaceSource(Source *previous, Source *s)
s->setImageProcessingEnabled( previous->imageProcessingEnabled() ); s->setImageProcessingEnabled( previous->imageProcessingEnabled() );
s->blendingShader()->blending = previous->blendingShader()->blending; s->blendingShader()->blending = previous->blendingShader()->blending;
// delete previous source
session_->deleteSource(previous);
// rename s // rename s
renameSource(s, previous_name); renameSource(s, previous_name);
// add source s // add source 's' and remove source 'previous'
candidate_sources_.push_back(s); candidate_sources_.push_back( std::make_pair(s, previous) );
} }

View File

@@ -48,7 +48,7 @@ public:
void draw (); void draw ();
// creation of sources // creation of sources
Source * createSourceFile (const std::string &path); Source * createSourceFile (const std::string &path, bool disable_hw_decoding = false);
Source * createSourceMultifile(const std::list<std::string> &list_files, uint fps); Source * createSourceMultifile(const std::list<std::string> &list_files, uint fps);
Source * createSourceClone (const std::string &namesource = "", bool copy_attributes = true); Source * createSourceClone (const std::string &namesource = "", bool copy_attributes = true);
Source * createSourceRender (); Source * createSourceRender ();
@@ -137,7 +137,9 @@ protected:
bool sessionSwapRequested_; bool sessionSwapRequested_;
void swap(); void swap();
SourceList candidate_sources_; // temporary buffer of sources to be inserted at next iteration,
// stored in pair with the source to replace, if provided
std::list< std::pair<Source *, Source *> > candidate_sources_;
SourceList stash_; SourceList stash_;
void insertSource (Source *s, View::Mode m = View::INVALID); void insertSource (Source *s, View::Mode m = View::INVALID);
bool recreateSource(Source *s); bool recreateSource(Source *s);