Delay user notification for when source is ready

This commit is contained in:
Bruno Herbelin
2023-05-30 15:03:32 +02:00
parent 90207c6184
commit 8bc69ba0a4
2 changed files with 31 additions and 8 deletions

View File

@@ -51,7 +51,6 @@
#include "SrtReceiverSource.h" #include "SrtReceiverSource.h"
#include "SourceCallback.h" #include "SourceCallback.h"
#include "InfoVisitor.h"
#include "ActionManager.h" #include "ActionManager.h"
#include "MixingGroup.h" #include "MixingGroup.h"
#include "FrameGrabber.h" #include "FrameGrabber.h"
@@ -455,6 +454,33 @@ void Mixer::addSource(Source *s)
candidate_sources_.push_back(s); candidate_sources_.push_back(s);
} }
void delayed_notification( Source *source )
{
bool done = false;
while (!done) {
// give it a bit of time and avoid CPU overload
std::this_thread::sleep_for(std::chrono::milliseconds(30));
// to be safe, make sure we have a valid source
Session *session = Mixer::manager().session();
SourceList::iterator sit = session->find(source);
if ( sit != session->end() ) {
// voila! the source is valid : notify user if it's ready
if ( (*sit)->ready() ) {
Log::Notify("%s source %s is ready.", (*sit)->info().c_str(), (*sit)->name().c_str());
done = true;
}
// do not notify if failed
else if ( (*sit)->failed() )
done = true;
}
// end loop if invalid source
else
done = true;
}
}
void Mixer::insertSource(Source *s, View::Mode m) void Mixer::insertSource(Source *s, View::Mode m)
{ {
if ( s != nullptr ) if ( s != nullptr )
@@ -477,11 +503,9 @@ void Mixer::insertSource(Source *s, View::Mode m)
// new state in history manager // new state in history manager
Action::manager().store(s->name() + std::string(": source inserted")); Action::manager().store(s->name() + std::string(": source inserted"));
// notify creation of source // Log & notification
static InfoVisitor _more_info; Log::Info("Adding source '%s'...", s->name().c_str());
s->accept(_more_info); std::thread(delayed_notification, s).detach();
std::string moreinfo = BaseToolkit::unspace(_more_info.str(), ' ');
Log::Notify("Added %s source '%s' (%s)", s->info().c_str(), s->name().c_str(), moreinfo.c_str());
// if requested to show the source in a given view // if requested to show the source in a given view
// (known to work for View::MIXING et TRANSITION: other views untested) // (known to work for View::MIXING et TRANSITION: other views untested)

View File

@@ -656,13 +656,12 @@ View::Cursor MixingView::over (glm::vec2 pos)
if (s != nullptr && s->ready()) { if (s != nullptr && s->ready()) {
s->symbol_->color = glm::vec4( COLOR_HIGHLIGHT_SOURCE, 1.f ); s->symbol_->color = glm::vec4( COLOR_HIGHLIGHT_SOURCE, 1.f );
s->initial_0_->color = glm::vec4( COLOR_HIGHLIGHT_SOURCE, 1.f );
s->initial_1_->color = glm::vec4( COLOR_HIGHLIGHT_SOURCE, 1.f );
const ImVec4 h = ImGuiToolkit::HighlightColor(); const ImVec4 h = ImGuiToolkit::HighlightColor();
// overlay symbol // overlay symbol
if ( pick.first == s->symbol_ ) if ( pick.first == s->symbol_ )
s->symbol_->color = glm::vec4( h.x, h.y, h.z, 1.f ); s->symbol_->color = glm::vec4( h.x, h.y, h.z, 1.f );
} }
return ret; return ret;