summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-07-15 02:19:35 +0200
committerCarl Hetherington <cth@carlh.net>2025-07-15 11:10:47 +0200
commit847daf7ec0f741eb6d50638c2096743ee731634c (patch)
tree8fba9c9571d0579151dcca8876cd22c5062825e6 /src/lib
parent66a6aea50054a5af8624c7d36949c642f4c8b619 (diff)
Change ExamineContentJob to take a vector of content.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/check_content_job.cc4
-rw-r--r--src/lib/examine_content_job.cc14
-rw-r--r--src/lib/examine_content_job.h6
-rw-r--r--src/lib/film.cc2
-rw-r--r--src/lib/transcode_job.cc4
5 files changed, 16 insertions, 14 deletions
diff --git a/src/lib/check_content_job.cc b/src/lib/check_content_job.cc
index bb43158ae..146fcd2a1 100644
--- a/src/lib/check_content_job.cc
+++ b/src/lib/check_content_job.cc
@@ -81,9 +81,7 @@ CheckContentJob::run ()
}
if (!changed.empty()) {
- for (auto i: changed) {
- JobManager::instance()->add(make_shared<ExamineContentJob>(_film, i, false));
- }
+ JobManager::instance()->add(make_shared<ExamineContentJob>(_film, changed, false));
set_message (_("Some files have been changed since they were added to the project.\n\nThese files will now be re-examined, so you may need to check their settings."));
}
diff --git a/src/lib/examine_content_job.cc b/src/lib/examine_content_job.cc
index 2466d8305..d12d736a7 100644
--- a/src/lib/examine_content_job.cc
+++ b/src/lib/examine_content_job.cc
@@ -29,14 +29,15 @@
#include "i18n.h"
-using std::string;
using std::cout;
using std::shared_ptr;
+using std::string;
+using std::vector;
-ExamineContentJob::ExamineContentJob(shared_ptr<const Film> film, shared_ptr<Content> content, bool tolerant)
+ExamineContentJob::ExamineContentJob(shared_ptr<const Film> film, vector<shared_ptr<Content>> content, bool tolerant)
: Job(film)
- , _content(content)
+ , _content(std::move(content))
, _tolerant(tolerant)
{
@@ -66,7 +67,12 @@ ExamineContentJob::json_name() const
void
ExamineContentJob::run()
{
- _content->examine(_film, shared_from_this(), _tolerant);
+ int n = 0;
+ for (auto c: _content) {
+ c->examine(_film, shared_from_this(), _tolerant);
+ set_progress(float(n) / _content.size());
+ ++n;
+ }
set_progress(1);
set_state(FINISHED_OK);
}
diff --git a/src/lib/examine_content_job.h b/src/lib/examine_content_job.h
index 093c396eb..ca298c252 100644
--- a/src/lib/examine_content_job.h
+++ b/src/lib/examine_content_job.h
@@ -28,19 +28,19 @@ class Content;
class ExamineContentJob : public Job
{
public:
- ExamineContentJob(std::shared_ptr<const Film> film, std::shared_ptr<Content> content, bool tolerant);
+ ExamineContentJob(std::shared_ptr<const Film> film, std::vector<std::shared_ptr<Content>> content, bool tolerant);
~ExamineContentJob();
std::string name() const override;
std::string json_name() const override;
void run() override;
- std::shared_ptr<Content> content() const {
+ std::vector<std::shared_ptr<Content>> content() const {
return _content;
}
private:
- std::shared_ptr<Content> _content;
+ std::vector<std::shared_ptr<Content>> _content;
bool _tolerant;
};
diff --git a/src/lib/film.cc b/src/lib/film.cc
index b73c2bac6..9dcc21918 100644
--- a/src/lib/film.cc
+++ b/src/lib/film.cc
@@ -1425,7 +1425,7 @@ Film::examine_and_add_content(shared_ptr<Content> content, bool disable_audio_an
run_ffprobe(content->path(0), file("ffprobe.log"));
}
- auto j = make_shared<ExamineContentJob>(shared_from_this(), content, false);
+ auto j = make_shared<ExamineContentJob>(shared_from_this(), vector<shared_ptr<Content>>{content}, false);
_job_connections.push_back(
j->Finished.connect(bind(&Film::maybe_add_content, this, weak_ptr<Job>(j), weak_ptr<Content>(content), disable_audio_analysis))
diff --git a/src/lib/transcode_job.cc b/src/lib/transcode_job.cc
index 2a408266f..50ae4e6b7 100644
--- a/src/lib/transcode_job.cc
+++ b/src/lib/transcode_job.cc
@@ -100,9 +100,7 @@ TranscodeJob::run ()
if (!changed.empty()) {
switch (_changed) {
case ChangedBehaviour::EXAMINE_THEN_STOP:
- for (auto i: changed) {
- JobManager::instance()->add(make_shared<ExamineContentJob>(_film, i, false));
- }
+ JobManager::instance()->add(make_shared<ExamineContentJob>(_film, changed, false));
set_progress (1);
set_message (_("Some files have been changed since they were added to the project.\n\nThese files will now be re-examined, so you may need to check their settings before trying again."));
set_error (_("Files have changed since they were added to the project."), _("Check their new settings, then try again."));