diff options
| author | Carl Hetherington <cth@carlh.net> | 2012-10-24 20:12:43 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2012-10-24 20:12:43 +0100 |
| commit | 977b36672892b14de4ecb68e98415c64946e8a93 (patch) | |
| tree | 2e264ce029fdd9d0abe6e9e958111a5ddd2cea45 /src/lib | |
| parent | baf6bc63df6577d6efdc12ae605aa94754b73882 (diff) | |
Tidy up now we have a x-thread signaller.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/copy_from_dvd_job.cc | 19 | ||||
| -rw-r--r-- | src/lib/examine_content_job.cc | 23 | ||||
| -rw-r--r-- | src/lib/film.cc | 52 | ||||
| -rw-r--r-- | src/lib/film.h | 3 | ||||
| -rw-r--r-- | src/lib/job.cc | 12 | ||||
| -rw-r--r-- | src/lib/job.h | 3 |
6 files changed, 46 insertions, 66 deletions
diff --git a/src/lib/copy_from_dvd_job.cc b/src/lib/copy_from_dvd_job.cc index c43723aa0..573dd7866 100644 --- a/src/lib/copy_from_dvd_job.cc +++ b/src/lib/copy_from_dvd_job.cc @@ -93,6 +93,25 @@ CopyFromDVDJob::run () } } + const string dvd_dir = _film->dir ("dvd"); + + string largest_file; + uintmax_t largest_size = 0; + for (filesystem::directory_iterator i = filesystem::directory_iterator (dvd_dir); i != filesystem::directory_iterator(); ++i) { + uintmax_t const s = filesystem::file_size (*i); + if (s > largest_size) { + +#if BOOST_FILESYSTEM_VERSION == 3 + largest_file = filesystem::path(*i).generic_string(); +#else + largest_file = i->string (); +#endif + largest_size = s; + } + } + + _film->set_content (largest_file); + int const r = pclose (f); if (WEXITSTATUS (r) != 0) { set_error ("call to vobcopy failed"); diff --git a/src/lib/examine_content_job.cc b/src/lib/examine_content_job.cc index 0187e1776..8fadce2f6 100644 --- a/src/lib/examine_content_job.cc +++ b/src/lib/examine_content_job.cc @@ -21,6 +21,7 @@ * @brief A class to run through content at high speed to find its length. */ +#include <boost/filesystem.hpp> #include "examine_content_job.h" #include "options.h" #include "decoder_factory.h" @@ -98,6 +99,28 @@ ExamineContentJob::run () } + string const tdir = _film->dir ("thumbs"); + vector<int> thumbs; + + for (filesystem::directory_iterator i = filesystem::directory_iterator (tdir); i != filesystem::directory_iterator(); ++i) { + + /* Aah, the sweet smell of progress */ +#if BOOST_FILESYSTEM_VERSION == 3 + string const l = filesystem::path(*i).leaf().generic_string(); +#else + string const l = i->leaf (); +#endif + + size_t const d = l.find (".png"); + size_t const t = l.find (".tmp"); + if (d != string::npos && t == string::npos) { + thumbs.push_back (atoi (l.substr (0, d).c_str())); + } + } + + sort (thumbs.begin(), thumbs.end()); + _film->set_thumbs (thumbs); + ascend (); set_progress (1); set_state (FINISHED_OK); diff --git a/src/lib/film.cc b/src/lib/film.cc index 8afa1e245..8b7700445 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -273,29 +273,6 @@ Film::make_dcp (bool transcode) JobManager::instance()->add (shared_ptr<Job> (new MakeDCPJob (shared_from_this(), o, r))); } -void -Film::copy_from_dvd_post_gui () -{ - const string dvd_dir = dir ("dvd"); - - string largest_file; - uintmax_t largest_size = 0; - for (filesystem::directory_iterator i = filesystem::directory_iterator (dvd_dir); i != filesystem::directory_iterator(); ++i) { - uintmax_t const s = filesystem::file_size (*i); - if (s > largest_size) { - -#if BOOST_FILESYSTEM_VERSION == 3 - largest_file = filesystem::path(*i).generic_string(); -#else - largest_file = i->string (); -#endif - largest_size = s; - } - } - - set_content (largest_file); -} - /** Start a job to examine our content file */ void Film::examine_content () @@ -311,40 +288,16 @@ Film::examine_content () dir ("thumbs"); _examine_content_job.reset (new ExamineContentJob (shared_from_this(), shared_ptr<Job> ())); - _examine_content_job->Finished.connect (sigc::mem_fun (*this, &Film::examine_content_post_gui)); + _examine_content_job->Finished.connect (sigc::mem_fun (*this, &Film::examine_content_finished)); JobManager::instance()->add (_examine_content_job); } void -Film::examine_content_post_gui () +Film::examine_content_finished () { - set_length (_examine_content_job->last_video_frame ()); _examine_content_job.reset (); - - string const tdir = dir ("thumbs"); - vector<int> thumbs; - - for (filesystem::directory_iterator i = filesystem::directory_iterator (tdir); i != filesystem::directory_iterator(); ++i) { - - /* Aah, the sweet smell of progress */ -#if BOOST_FILESYSTEM_VERSION == 3 - string const l = filesystem::path(*i).leaf().generic_string(); -#else - string const l = i->leaf (); -#endif - - size_t const d = l.find (".png"); - size_t const t = l.find (".tmp"); - if (d != string::npos && t == string::npos) { - thumbs.push_back (atoi (l.substr (0, d).c_str())); - } - } - - sort (thumbs.begin(), thumbs.end()); - set_thumbs (thumbs); } - /** @return full paths to any audio files that this Film has */ vector<string> Film::audio_files () const @@ -369,7 +322,6 @@ void Film::copy_from_dvd () { shared_ptr<Job> j (new CopyFromDVDJob (shared_from_this(), shared_ptr<Job> ())); - j->Finished.connect (sigc::mem_fun (*this, &Film::copy_from_dvd_post_gui)); JobManager::instance()->add (j); } diff --git a/src/lib/film.h b/src/lib/film.h index bf5fb936d..384cf8510 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -61,9 +61,7 @@ public: std::vector<std::string> audio_files () const; std::pair<Position, std::string> thumb_subtitle (int) const; - void copy_from_dvd_post_gui (); void examine_content (); - void examine_content_post_gui (); void send_dcp_to_tms (); void copy_from_dvd (); @@ -392,6 +390,7 @@ private: std::string thumb_base_for_frame (int) const; void signal_changed (Property); std::string file_locked (std::string) const; + void examine_content_finished (); /** Complete path to directory containing the film metadata; * must not be relative. diff --git a/src/lib/job.cc b/src/lib/job.cc index f3d7deac0..a7c2430b8 100644 --- a/src/lib/job.cc +++ b/src/lib/job.cc @@ -125,20 +125,10 @@ Job::set_state (State s) if (_state == FINISHED_OK || _state == FINISHED_ERROR) { _ran_for = elapsed_time (); + Finished (); } } -/** A hack to work around our lack of cross-thread - * signalling; this emits Finished, and listeners - * assume that it will be emitted in the GUI thread, - * so this method must be called from the GUI thread. - */ -void -Job::emit_finished () -{ - Finished (); -} - /** @return Time (in seconds) that this job has been running */ int Job::elapsed_time () const diff --git a/src/lib/job.h b/src/lib/job.h index b608f5da2..1ada68e1f 100644 --- a/src/lib/job.h +++ b/src/lib/job.h @@ -64,13 +64,10 @@ public: void descend (float); float overall_progress () const; - void emit_finished (); - boost::shared_ptr<Job> required () const { return _required; } - /** Emitted from the GUI thread */ sigc::signal0<void> Finished; protected: |
