Improved management of failed sources

Clone is failed if its origin is failed, handle MediaPlayer visitor and error message when fail, get SourceList of non-failed sources of a list.
This commit is contained in:
Bruno Herbelin
2023-01-29 10:50:00 +01:00
parent e69ac7ca28
commit 0051533ac8
7 changed files with 81 additions and 60 deletions

View File

@@ -22,7 +22,7 @@ public:
void replay () override; void replay () override;
guint64 playtime () const override; guint64 playtime () const override;
uint texture() const override; uint texture() const override;
bool failed() const override { return origin_ == nullptr; } bool failed() const override { return origin_ == nullptr || origin_->failed(); }
void accept (Visitor& v) override; void accept (Visitor& v) override;
void render() override; void render() override;
glm::ivec2 icon() const override; glm::ivec2 icon() const override;

View File

@@ -157,9 +157,10 @@ MediaInfo MediaPlayer::UriDiscoverer(const std::string &uri)
} }
break; break;
default: default:
case GST_DISCOVERER_OK:
break; break;
} }
if ( result == GST_DISCOVERER_OK ) {
// get videos in information found // get videos in information found
GList *streams = gst_discoverer_info_get_video_streams(info); GList *streams = gst_discoverer_info_get_video_streams(info);
if ( g_list_length(streams) > 0) { if ( g_list_length(streams) > 0) {
@@ -220,9 +221,10 @@ MediaInfo MediaPlayer::UriDiscoverer(const std::string &uri)
Log::Warning("'%s': Invalid video stream", uri.c_str()); Log::Warning("'%s': Invalid video stream", uri.c_str());
} }
else else
Log::Warning("'%s': No supported video stream", uri.c_str()); Log::Warning("'%s': No video stream", uri.c_str());
gst_discoverer_stream_info_list_free(streams); gst_discoverer_stream_info_list_free(streams);
}
if (info) if (info)
gst_discoverer_info_unref (info); gst_discoverer_info_unref (info);

View File

@@ -638,6 +638,7 @@ void SessionVisitor::visit (MediaSource& s)
if (!sessionFilePath_.empty()) if (!sessionFilePath_.empty())
uri->SetAttribute("relative", SystemToolkit::path_relative_to_path(s.path(), sessionFilePath_).c_str()); uri->SetAttribute("relative", SystemToolkit::path_relative_to_path(s.path(), sessionFilePath_).c_str());
if (!s.failed())
s.mediaplayer()->accept(*this); s.mediaplayer()->accept(*this);
} }

View File

@@ -109,6 +109,7 @@ public:
// cloning mechanism // cloning mechanism
virtual CloneSource *clone (uint64_t id = 0); virtual CloneSource *clone (uint64_t id = 0);
inline bool cloned() const { return !clones_.empty(); }
// Display mode // Display mode
typedef enum { typedef enum {

View File

@@ -45,6 +45,18 @@ SourceList playable_only (const SourceList &list)
return pl; return pl;
} }
bool isfailed (const Source *s) { return s->failed(); }
SourceList valid_only (const SourceList &list)
{
SourceList pl = list;
pl.remove_if(isfailed);
return pl;
}
bool notactive (const Source *s) { return !s->active(); } bool notactive (const Source *s) { return !s->active(); }
SourceList active_only (const SourceList &list) SourceList active_only (const SourceList &list)

View File

@@ -12,6 +12,7 @@ typedef std::list<Source *> SourceList;
typedef std::list<SourceCore *> SourceCoreList; typedef std::list<SourceCore *> SourceCoreList;
SourceList playable_only (const SourceList &list); SourceList playable_only (const SourceList &list);
SourceList valid_only (const SourceList &list);
SourceList active_only (const SourceList &list); SourceList active_only (const SourceList &list);
SourceList depth_sorted (const SourceList &list); SourceList depth_sorted (const SourceList &list);
SourceList mixing_sorted (const SourceList &list, glm::vec2 center = glm::vec2(0.f, 0.f)); SourceList mixing_sorted (const SourceList &list, glm::vec2 center = glm::vec2(0.f, 0.f));

View File

@@ -508,6 +508,10 @@ Source *TextureView::getEditOrCurrentSource()
} }
} }
if (_source != nullptr && _source->failed() ) {
_source = nullptr;
}
return _source; return _source;
} }