From 63ea6b6c5ee64f8ee067c2b488d004b6dfe363e0 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 24 Oct 2012 22:13:53 +0100 Subject: [PATCH] Use boost::signals2; fix bugs with x-thread signalling. --- src/lib/ab_transcode_job.cc | 4 +- src/lib/ab_transcoder.cc | 11 ++--- src/lib/check_hashes_job.cc | 18 ++++--- src/lib/config.cc | 9 ++-- src/lib/config.h | 4 +- src/lib/copy_from_dvd_job.cc | 14 +++--- src/lib/dcp_video_frame.cc | 16 +++--- src/lib/decoder.cc | 6 ++- src/lib/decoder.h | 6 +-- src/lib/decoder_factory.cc | 6 +-- src/lib/encoder_factory.cc | 5 +- src/lib/examine_content_job.cc | 9 ++-- src/lib/ffmpeg_decoder.cc | 8 +-- src/lib/film.cc | 90 ++++++++++++++++++++++------------ src/lib/film.h | 6 ++- src/lib/imagemagick_encoder.cc | 11 +++-- src/lib/j2k_still_encoder.cc | 5 +- src/lib/j2k_wav_encoder.cc | 10 +++- src/lib/job.cc | 8 +-- src/lib/job.h | 4 +- src/lib/job_manager.cc | 5 +- src/lib/make_dcp_job.cc | 6 +-- src/lib/scp_dcp_job.cc | 20 ++++---- src/lib/server.cc | 20 +++++--- src/lib/transcode_job.cc | 7 ++- src/lib/transcoder.cc | 10 ++-- src/lib/ui_signaller.h | 6 +-- src/tools/dvdomatic.cc | 2 +- src/tools/makedcp.cc | 9 +++- src/wx/config_dialog.cc | 4 +- src/wx/dcp_range_dialog.h | 4 +- src/wx/film_editor.cc | 6 +-- src/wx/film_editor.h | 3 +- src/wx/film_list.cc | 2 +- src/wx/film_viewer.cc | 8 +-- src/wx/filter_dialog.cc | 3 +- src/wx/filter_dialog.h | 3 +- src/wx/filter_view.h | 4 +- src/wx/job_manager_view.cc | 5 +- test/test.cc | 8 ++- 40 files changed, 235 insertions(+), 150 deletions(-) diff --git a/src/lib/ab_transcode_job.cc b/src/lib/ab_transcode_job.cc index 9e453d85d..c9fd5bc97 100644 --- a/src/lib/ab_transcode_job.cc +++ b/src/lib/ab_transcode_job.cc @@ -27,8 +27,8 @@ #include "encoder_factory.h" #include "config.h" -using namespace std; -using namespace boost; +using std::string; +using boost::shared_ptr; /** @param f Film to compare. * @param o Options. diff --git a/src/lib/ab_transcoder.cc b/src/lib/ab_transcoder.cc index 4f0ce0a71..beedd478f 100644 --- a/src/lib/ab_transcoder.cc +++ b/src/lib/ab_transcoder.cc @@ -19,7 +19,6 @@ #include #include -#include #include "ab_transcoder.h" #include "film.h" #include "decoder.h" @@ -34,8 +33,8 @@ * for the right half (to facilitate A/B comparisons of settings) */ -using namespace std; -using namespace boost; +using std::string; +using boost::shared_ptr; /** @param a Film to use for the left half of the screen. * @param b Film to use for the right half of the screen. @@ -56,9 +55,9 @@ ABTranscoder::ABTranscoder ( _da = decoder_factory (_film_a, o, j); _db = decoder_factory (_film_b, o, j); - _da->Video.connect (sigc::bind (sigc::mem_fun (*this, &ABTranscoder::process_video), 0)); - _db->Video.connect (sigc::bind (sigc::mem_fun (*this, &ABTranscoder::process_video), 1)); - _da->Audio.connect (sigc::mem_fun (*e, &Encoder::process_audio)); + _da->Video.connect (bind (&ABTranscoder::process_video, this, _1, _2, _3, 0)); + _db->Video.connect (bind (&ABTranscoder::process_video, this, _1, _2, _3, 1)); + _da->Audio.connect (bind (&Encoder::process_audio, e, _1)); } ABTranscoder::~ABTranscoder () diff --git a/src/lib/check_hashes_job.cc b/src/lib/check_hashes_job.cc index c6460ff60..88233ab66 100644 --- a/src/lib/check_hashes_job.cc +++ b/src/lib/check_hashes_job.cc @@ -28,8 +28,10 @@ #include "transcode_job.h" #include "film.h" -using namespace std; -using namespace boost; +using std::string; +using std::stringstream; +using std::ifstream; +using boost::shared_ptr; CheckHashesJob::CheckHashesJob (shared_ptr f, shared_ptr o, shared_ptr req) : Job (f, req) @@ -56,13 +58,13 @@ CheckHashesJob::run () string const j2k_file = _opt->frame_out_path (i, false); string const hash_file = j2k_file + ".md5"; - if (!filesystem::exists (j2k_file)) { + if (!boost::filesystem::exists (j2k_file)) { _film->log()->log (String::compose ("Frame %1 has a missing J2K file.", i)); - filesystem::remove (hash_file); + boost::filesystem::remove (hash_file); ++_bad; - } else if (!filesystem::exists (hash_file)) { + } else if (!boost::filesystem::exists (hash_file)) { _film->log()->log (String::compose ("Frame %1 has a missing hash file.", i)); - filesystem::remove (j2k_file); + boost::filesystem::remove (j2k_file); ++_bad; } else { ifstream ref (hash_file.c_str ()); @@ -70,8 +72,8 @@ CheckHashesJob::run () ref >> hash; if (hash != md5_digest (j2k_file)) { _film->log()->log (String::compose ("Frame %1 has wrong hash; deleting.", i)); - filesystem::remove (j2k_file); - filesystem::remove (hash_file); + boost::filesystem::remove (j2k_file); + boost::filesystem::remove (hash_file); ++_bad; } } diff --git a/src/lib/config.cc b/src/lib/config.cc index 44d110689..711963a26 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -29,8 +29,11 @@ #include "filter.h" #include "sound_processor.h" -using namespace std; -using namespace boost; +using std::vector; +using std::ifstream; +using std::string; +using std::ofstream; +using boost::shared_ptr; Config* Config::_instance = 0; @@ -99,7 +102,7 @@ Config::Config () string Config::file () const { - filesystem::path p; + boost::filesystem::path p; p /= g_get_user_config_dir (); p /= ".dvdomatic"; return p.string (); diff --git a/src/lib/config.h b/src/lib/config.h index 840dcdaef..1ded015f2 100644 --- a/src/lib/config.h +++ b/src/lib/config.h @@ -26,7 +26,7 @@ #include #include -#include +#include class ServerDescription; class Screen; @@ -176,7 +176,7 @@ public: void write () const; - sigc::signal0 Changed; + boost::signals2::signal Changed; static Config* instance (); diff --git a/src/lib/copy_from_dvd_job.cc b/src/lib/copy_from_dvd_job.cc index 573dd7866..dcf53ac54 100644 --- a/src/lib/copy_from_dvd_job.cc +++ b/src/lib/copy_from_dvd_job.cc @@ -29,8 +29,10 @@ #include "cross.h" #include "film.h" -using namespace std; -using namespace boost; +using std::string; +using std::list; +using std::stringstream; +using boost::shared_ptr; /** @param f Film to write DVD data into. */ @@ -50,7 +52,7 @@ void CopyFromDVDJob::run () { /* Remove any old DVD rips */ - filesystem::remove_all (_film->dir ("dvd")); + boost::filesystem::remove_all (_film->dir ("dvd")); string const dvd = find_dvd (); if (dvd.empty ()) { @@ -97,12 +99,12 @@ CopyFromDVDJob::run () 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); + for (boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator (dvd_dir); i != boost::filesystem::directory_iterator(); ++i) { + uintmax_t const s = boost::filesystem::file_size (*i); if (s > largest_size) { #if BOOST_FILESYSTEM_VERSION == 3 - largest_file = filesystem::path(*i).generic_string(); + largest_file = boost::filesystem::path(*i).generic_string(); #else largest_file = i->string (); #endif diff --git a/src/lib/dcp_video_frame.cc b/src/lib/dcp_video_frame.cc index 4f84a8302..d9d7e7c83 100644 --- a/src/lib/dcp_video_frame.cc +++ b/src/lib/dcp_video_frame.cc @@ -56,8 +56,10 @@ #include "log.h" #include "subtitle.h" -using namespace std; -using namespace boost; +using std::string; +using std::stringstream; +using std::ofstream; +using boost::shared_ptr; /** Construct a DCP video frame. * @param input Input image. @@ -306,10 +308,10 @@ DCPVideoFrame::encode_locally () shared_ptr DCPVideoFrame::encode_remotely (ServerDescription const * serv) { - asio::io_service io_service; - asio::ip::tcp::resolver resolver (io_service); - asio::ip::tcp::resolver::query query (serv->host_name(), boost::lexical_cast (Config::instance()->server_port ())); - asio::ip::tcp::resolver::iterator endpoint_iterator = resolver.resolve (query); + boost::asio::io_service io_service; + boost::asio::ip::tcp::resolver resolver (io_service); + boost::asio::ip::tcp::resolver::query query (serv->host_name(), boost::lexical_cast (Config::instance()->server_port ())); + boost::asio::ip::tcp::resolver::iterator endpoint_iterator = resolver.resolve (query); shared_ptr socket (new Socket); @@ -384,7 +386,7 @@ EncodedData::write (shared_ptr opt, int frame) string const real_j2k = opt->frame_out_path (frame, false); /* Rename the file from foo.j2c.tmp to foo.j2c now that it is complete */ - filesystem::rename (tmp_j2k, real_j2k); + boost::filesystem::rename (tmp_j2k, real_j2k); /* Write a file containing the hash */ string const hash = real_j2k + ".md5"; diff --git a/src/lib/decoder.cc b/src/lib/decoder.cc index 9c339737a..f6ddfbeff 100644 --- a/src/lib/decoder.cc +++ b/src/lib/decoder.cc @@ -49,8 +49,10 @@ extern "C" { #include "ffmpeg_compatibility.h" #include "subtitle.h" -using namespace std; -using namespace boost; +using std::string; +using std::stringstream; +using std::min; +using boost::shared_ptr; /** @param f Film. * @param o Options. diff --git a/src/lib/decoder.h b/src/lib/decoder.h index ed7eaeb17..39eaaf48e 100644 --- a/src/lib/decoder.h +++ b/src/lib/decoder.h @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include "util.h" #include "stream.h" @@ -92,10 +92,10 @@ public: * Second parameter is its index within the content. * Third parameter is either 0 or a subtitle that should be on this frame. */ - sigc::signal, int, boost::shared_ptr > Video; + boost::signals2::signal, int, boost::shared_ptr)> Video; /** Emitted when some audio data is ready */ - sigc::signal > Audio; + boost::signals2::signal)> Audio; protected: /** perform a single pass at our content */ diff --git a/src/lib/decoder_factory.cc b/src/lib/decoder_factory.cc index 56fb56296..06377e26c 100644 --- a/src/lib/decoder_factory.cc +++ b/src/lib/decoder_factory.cc @@ -27,15 +27,15 @@ #include "imagemagick_decoder.h" #include "film.h" -using namespace std; -using namespace boost; +using std::string; +using boost::shared_ptr; shared_ptr decoder_factory ( shared_ptr f, shared_ptr o, Job* j, bool minimal = false, bool ignore_length = false ) { - if (filesystem::is_directory (f->content_path ())) { + if (boost::filesystem::is_directory (f->content_path ())) { /* Assume a directory contains TIFFs */ return shared_ptr (new TIFFDecoder (f, o, j, minimal, ignore_length)); } diff --git a/src/lib/encoder_factory.cc b/src/lib/encoder_factory.cc index df45535cf..2da021ad8 100644 --- a/src/lib/encoder_factory.cc +++ b/src/lib/encoder_factory.cc @@ -26,13 +26,12 @@ #include "j2k_still_encoder.h" #include "film.h" -using namespace std; -using namespace boost; +using boost::shared_ptr; shared_ptr encoder_factory (shared_ptr f, shared_ptr o) { - if (!filesystem::is_directory (f->content_path()) && f->content_type() == STILL) { + if (!boost::filesystem::is_directory (f->content_path()) && f->content_type() == STILL) { return shared_ptr (new J2KStillEncoder (f, o)); } diff --git a/src/lib/examine_content_job.cc b/src/lib/examine_content_job.cc index 8fadce2f6..1e263ffa5 100644 --- a/src/lib/examine_content_job.cc +++ b/src/lib/examine_content_job.cc @@ -31,8 +31,9 @@ #include "log.h" #include "film.h" -using namespace std; -using namespace boost; +using std::string; +using std::vector; +using boost::shared_ptr; ExamineContentJob::ExamineContentJob (shared_ptr f, shared_ptr req) : Job (f, req) @@ -102,11 +103,11 @@ ExamineContentJob::run () string const tdir = _film->dir ("thumbs"); vector thumbs; - for (filesystem::directory_iterator i = filesystem::directory_iterator (tdir); i != filesystem::directory_iterator(); ++i) { + for (boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator (tdir); i != boost::filesystem::directory_iterator(); ++i) { /* Aah, the sweet smell of progress */ #if BOOST_FILESYSTEM_VERSION == 3 - string const l = filesystem::path(*i).leaf().generic_string(); + string const l = boost::filesystem::path(*i).leaf().generic_string(); #else string const l = i->leaf (); #endif diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index 30701797a..b6cdce0e4 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -49,10 +49,12 @@ extern "C" { #include "ffmpeg_decoder.h" #include "subtitle.h" -using namespace std; -using namespace boost; +using std::string; +using std::vector; +using std::stringstream; +using boost::shared_ptr; -FFmpegDecoder::FFmpegDecoder (boost::shared_ptr f, boost::shared_ptr o, Job* j, bool minimal, bool ignore_length) +FFmpegDecoder::FFmpegDecoder (shared_ptr f, shared_ptr o, Job* j, bool minimal, bool ignore_length) : Decoder (f, o, j, minimal, ignore_length) , _format_context (0) , _video_stream (-1) diff --git a/src/lib/film.cc b/src/lib/film.cc index 8b7700445..8750ab442 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -53,12 +53,24 @@ #include "version.h" #include "ui_signaller.h" -using namespace std; -using namespace boost; +using std::string; +using std::stringstream; +using std::multimap; +using std::pair; +using std::map; +using std::vector; +using std::ifstream; +using std::ofstream; +using std::setfill; +using boost::shared_ptr; +using boost::lexical_cast; +using boost::to_upper_copy; +using boost::ends_with; +using boost::starts_with; /** Construct a Film object in a given directory, reading any metadata * file that exists in that directory. An exception will be thrown if - * must_exist is true, and the specified directory does not exist. + * must_exist is true and the specified directory does not exist. * * @param d Film directory. * @param must_exist true to throw an exception if does not exist. @@ -90,11 +102,11 @@ Film::Film (string d, bool must_exist) (Code swiped from Adam Bowen on stackoverflow) */ - filesystem::path p (filesystem::system_complete (d)); - filesystem::path result; - for (filesystem::path::iterator i = p.begin(); i != p.end(); ++i) { + boost::filesystem::path p (boost::filesystem::system_complete (d)); + boost::filesystem::path result; + for (boost::filesystem::path::iterator i = p.begin(); i != p.end(); ++i) { if (*i == "..") { - if (filesystem::is_symlink (result) || result.filename() == "..") { + if (boost::filesystem::is_symlink (result) || result.filename() == "..") { result /= *i; } else { result = result.parent_path (); @@ -106,11 +118,11 @@ Film::Film (string d, bool must_exist) set_directory (result.string ()); - if (!filesystem::exists (directory())) { + if (!boost::filesystem::exists (directory())) { if (must_exist) { throw OpenFileError (directory()); } else { - filesystem::create_directory (directory()); + boost::filesystem::create_directory (directory()); } } @@ -173,7 +185,7 @@ Film::j2k_dir () const { assert (format()); - filesystem::path p; + boost::filesystem::path p; /* Start with j2c */ p /= "j2c"; @@ -282,13 +294,13 @@ Film::examine_content () } set_thumbs (vector ()); - filesystem::remove_all (dir ("thumbs")); + boost::filesystem::remove_all (dir ("thumbs")); /* This call will recreate the directory */ dir ("thumbs"); _examine_content_job.reset (new ExamineContentJob (shared_from_this(), shared_ptr ())); - _examine_content_job->Finished.connect (sigc::mem_fun (*this, &Film::examine_content_finished)); + _examine_content_job->Finished.connect (bind (&Film::examine_content_finished, this)); JobManager::instance()->add (_examine_content_job); } @@ -303,7 +315,7 @@ vector Film::audio_files () const { vector f; - for (filesystem::directory_iterator i = filesystem::directory_iterator (dir("wavs")); i != filesystem::directory_iterator(); ++i) { + for (boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator (dir("wavs")); i != boost::filesystem::directory_iterator(); ++i) { f.push_back (i->path().string ()); } @@ -336,9 +348,9 @@ Film::encoded_frames () const } int N = 0; - for (filesystem::directory_iterator i = filesystem::directory_iterator (j2k_dir ()); i != filesystem::directory_iterator(); ++i) { + for (boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator (j2k_dir ()); i != boost::filesystem::directory_iterator(); ++i) { ++N; - this_thread::interruption_point (); + boost::this_thread::interruption_point (); } return N; @@ -353,7 +365,7 @@ pair Film::thumb_subtitle (int n) const { string sub_file = thumb_base(n) + ".sub"; - if (!filesystem::exists (sub_file)) { + if (!boost::filesystem::exists (sub_file)) { return pair (); } @@ -379,7 +391,7 @@ Film::write_metadata () const { boost::mutex::scoped_lock lm (_state_mutex); - filesystem::create_directories (directory()); + boost::filesystem::create_directories (directory()); string const m = file_locked ("metadata"); ofstream f (m.c_str ()); @@ -541,7 +553,7 @@ Film::read_metadata () if (k == "thumb") { int const n = atoi (v.c_str ()); /* Only add it to the list if it still exists */ - if (filesystem::exists (thumb_file_for_frame (n))) { + if (boost::filesystem::exists (thumb_file_for_frame_locked (n))) { _thumbs.push_back (n); } } else if (k == "width") { @@ -587,6 +599,12 @@ Film::thumb_file_for_frame (int n) const return thumb_base_for_frame(n) + ".png"; } +string +Film::thumb_file_for_frame_locked (int n) const +{ + return thumb_base_for_frame_locked(n) + ".png"; +} + string Film::thumb_base (int n) const { @@ -595,19 +613,25 @@ Film::thumb_base (int n) const string Film::thumb_base_for_frame (int n) const +{ + boost::mutex::scoped_lock lm (_state_mutex); + return thumb_base_for_frame_locked (n); +} + +string +Film::thumb_base_for_frame_locked (int n) const { stringstream s; s.width (8); s << setfill('0') << n; - filesystem::path p; - p /= dir ("thumbs"); + boost::filesystem::path p; + p /= dir_locked ("thumbs"); p /= s.str (); return p.string (); } - /** @param n A thumb index. * @return The frame within the Film that it is for. */ @@ -635,10 +659,16 @@ string Film::dir (string d) const { boost::mutex::scoped_lock lm (_state_mutex); - filesystem::path p; + return dir_locked (d); +} + +string +Film::dir_locked (string d) const +{ + boost::filesystem::path p; p /= _directory; p /= d; - filesystem::create_directories (p); + boost::filesystem::create_directories (p); return p.string (); } @@ -653,7 +683,7 @@ Film::file (string f) const string Film::file_locked (string f) const { - filesystem::path p; + boost::filesystem::path p; p /= _directory; p /= f; return p.string (); @@ -666,7 +696,7 @@ string Film::content_path () const { boost::mutex::scoped_lock lm (_state_mutex); - if (filesystem::path(_content).has_root_directory ()) { + if (boost::filesystem::path(_content).has_root_directory ()) { return _content; } @@ -677,7 +707,7 @@ ContentType Film::content_type () const { #if BOOST_FILESYSTEM_VERSION == 3 - string ext = filesystem::path(_content).extension().string(); + string ext = boost::filesystem::path(_content).extension().string(); #else string ext = filesystem::path(_content).extension(); #endif @@ -788,8 +818,8 @@ Film::dci_name () const d << _studio << "_"; } - gregorian::date today = gregorian::day_clock::local_day (); - d << gregorian::to_iso_string (today) << "_"; + boost::gregorian::date today = boost::gregorian::day_clock::local_day (); + d << boost::gregorian::to_iso_string (today) << "_"; if (!_facility.empty ()) { d << _facility << "_"; @@ -848,7 +878,7 @@ Film::set_content (string c) string check = directory (); #if BOOST_FILESYSTEM_VERSION == 3 - filesystem::path slash ("/"); + boost::filesystem::path slash ("/"); string platform_slash = slash.make_preferred().string (); #else #ifdef DVDOMATIC_WINDOWS @@ -862,7 +892,7 @@ Film::set_content (string c) check += platform_slash; } - if (filesystem::path(c).has_root_directory () && starts_with (c, check)) { + if (boost::filesystem::path(c).has_root_directory () && starts_with (c, check)) { c = c.substr (_directory.length() + 1); } diff --git a/src/lib/film.h b/src/lib/film.h index 384cf8510..27be4331c 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -30,6 +30,7 @@ #include #include #include +#include extern "C" { #include } @@ -376,7 +377,7 @@ public: void set_frames_per_second (float); /** Emitted when some property has changed */ - mutable sigc::signal1 Changed; + mutable boost::signals2::signal Changed; private: @@ -387,9 +388,12 @@ private: boost::shared_ptr _examine_content_job; std::string thumb_file_for_frame (int) const; + std::string thumb_file_for_frame_locked (int) const; std::string thumb_base_for_frame (int) const; + std::string thumb_base_for_frame_locked (int) const; void signal_changed (Property); std::string file_locked (std::string) const; + std::string dir_locked (std::string d) const; void examine_content_finished (); /** Complete path to directory containing the film metadata; diff --git a/src/lib/imagemagick_encoder.cc b/src/lib/imagemagick_encoder.cc index e86888c36..8d42b3dbe 100644 --- a/src/lib/imagemagick_encoder.cc +++ b/src/lib/imagemagick_encoder.cc @@ -36,8 +36,9 @@ #include "image.h" #include "subtitle.h" -using namespace std; -using namespace boost; +using std::string; +using std::ofstream; +using boost::shared_ptr; /** @param f Film that we are encoding. * @param o Options. @@ -58,7 +59,7 @@ ImageMagickEncoder::process_video (shared_ptr image, int frame, shared_pt Magick::Image thumb (compact->size().width, compact->size().height, "RGB", MagickCore::CharPixel, compact->data()[0]); thumb.magick ("PNG"); thumb.write (tmp_file); - filesystem::rename (tmp_file, _opt->frame_out_path (frame, false)); + boost::filesystem::rename (tmp_file, _opt->frame_out_path (frame, false)); if (sub) { float const x_scale = float (_opt->out_size.width) / _film->size().width; @@ -77,13 +78,13 @@ ImageMagickEncoder::process_video (shared_ptr image, int frame, shared_pt Magick::Image sub_thumb (compact->size().width, compact->size().height, "RGBA", MagickCore::CharPixel, compact->data()[0]); sub_thumb.magick ("PNG"); sub_thumb.write (tmp_sub_file); - filesystem::rename (tmp_sub_file, _opt->frame_out_path (frame, false, ".sub.png")); + boost::filesystem::rename (tmp_sub_file, _opt->frame_out_path (frame, false, ".sub.png")); metadata << "x " << sub->position().x << "\n" << "y " << sub->position().y << "\n"; metadata.close (); - filesystem::rename (tmp_metadata_file, _opt->frame_out_path (frame, false, ".sub")); + boost::filesystem::rename (tmp_metadata_file, _opt->frame_out_path (frame, false, ".sub")); } frame_done (frame); diff --git a/src/lib/j2k_still_encoder.cc b/src/lib/j2k_still_encoder.cc index 51946372f..d8970d3a1 100644 --- a/src/lib/j2k_still_encoder.cc +++ b/src/lib/j2k_still_encoder.cc @@ -38,8 +38,9 @@ #include "imagemagick_decoder.h" #include "film.h" -using namespace std; -using namespace boost; +using std::string; +using std::pair; +using boost::shared_ptr; J2KStillEncoder::J2KStillEncoder (shared_ptr f, shared_ptr o) : Encoder (f, o) diff --git a/src/lib/j2k_wav_encoder.cc b/src/lib/j2k_wav_encoder.cc index 4dd9ce8b6..73a70910e 100644 --- a/src/lib/j2k_wav_encoder.cc +++ b/src/lib/j2k_wav_encoder.cc @@ -41,8 +41,14 @@ #include "cross.h" #include "film.h" -using namespace std; -using namespace boost; +using std::string; +using std::stringstream; +using std::list; +using std::vector; +using std::pair; +using boost::shared_ptr; +using boost::thread; +using boost::lexical_cast; J2KWAVEncoder::J2KWAVEncoder (shared_ptr f, shared_ptr o) : Encoder (f, o) diff --git a/src/lib/job.cc b/src/lib/job.cc index a7c2430b8..c5a254a2a 100644 --- a/src/lib/job.cc +++ b/src/lib/job.cc @@ -27,8 +27,10 @@ #include "job.h" #include "util.h" -using namespace std; -using namespace boost; +using std::string; +using std::list; +using std::stringstream; +using boost::shared_ptr; /** @param s Film that we are operating on. */ @@ -64,7 +66,7 @@ Job::run_wrapper () set_progress (1); set_state (FINISHED_ERROR); - set_error (String::compose ("%1 (%2)", e.what(), filesystem::path (e.filename()).leaf())); + set_error (String::compose ("%1 (%2)", e.what(), boost::filesystem::path (e.filename()).leaf())); } catch (std::exception& e) { diff --git a/src/lib/job.h b/src/lib/job.h index 1ada68e1f..b09964cf9 100644 --- a/src/lib/job.h +++ b/src/lib/job.h @@ -27,7 +27,7 @@ #include #include #include -#include +#include class Film; class Options; @@ -68,7 +68,7 @@ public: return _required; } - sigc::signal0 Finished; + boost::signals2::signal Finished; protected: diff --git a/src/lib/job_manager.cc b/src/lib/job_manager.cc index 2db91a177..5cc340357 100644 --- a/src/lib/job_manager.cc +++ b/src/lib/job_manager.cc @@ -27,8 +27,9 @@ #include "job.h" #include "cross.h" -using namespace std; -using namespace boost; +using std::string; +using std::list; +using boost::shared_ptr; JobManager* JobManager::_instance = 0; diff --git a/src/lib/make_dcp_job.cc b/src/lib/make_dcp_job.cc index 5a16abc1e..e2c90a854 100644 --- a/src/lib/make_dcp_job.cc +++ b/src/lib/make_dcp_job.cc @@ -36,8 +36,8 @@ extern "C" { #include "imagemagick_decoder.h" #include "film.h" -using namespace std; -using namespace boost; +using std::string; +using boost::shared_ptr; /** @param f Film we are making the DCP for. * @param o Options. @@ -73,7 +73,7 @@ MakeDCPJob::run () string const dcp_path = _film->dir (_film->dcp_name()); /* Remove any old DCP */ - filesystem::remove_all (dcp_path); + boost::filesystem::remove_all (dcp_path); int frames = 0; switch (_film->content_type ()) { diff --git a/src/lib/scp_dcp_job.cc b/src/lib/scp_dcp_job.cc index a455c72a2..22129f56c 100644 --- a/src/lib/scp_dcp_job.cc +++ b/src/lib/scp_dcp_job.cc @@ -34,8 +34,10 @@ #include "log.h" #include "film.h" -using namespace std; -using namespace boost; +using std::string; +using std::stringstream; +using std::min; +using boost::shared_ptr; class SSHSession { @@ -149,29 +151,29 @@ SCPDCPJob::run () string const dcp_dir = _film->dir (_film->dcp_name()); boost::uintmax_t bytes_to_transfer = 0; - for (filesystem::directory_iterator i = filesystem::directory_iterator (dcp_dir); i != filesystem::directory_iterator(); ++i) { - bytes_to_transfer += filesystem::file_size (*i); + for (boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator (dcp_dir); i != boost::filesystem::directory_iterator(); ++i) { + bytes_to_transfer += boost::filesystem::file_size (*i); } boost::uintmax_t buffer_size = 64 * 1024; char buffer[buffer_size]; boost::uintmax_t bytes_transferred = 0; - for (filesystem::directory_iterator i = filesystem::directory_iterator (dcp_dir); i != filesystem::directory_iterator(); ++i) { + for (boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator (dcp_dir); i != boost::filesystem::directory_iterator(); ++i) { /* Aah, the sweet smell of progress */ #if BOOST_FILESYSTEM_VERSION == 3 - string const leaf = filesystem::path(*i).leaf().generic_string (); + string const leaf = boost::filesystem::path(*i).leaf().generic_string (); #else string const leaf = i->leaf (); #endif set_status ("copying " + leaf); - boost::uintmax_t to_do = filesystem::file_size (*i); + boost::uintmax_t to_do = boost::filesystem::file_size (*i); ssh_scp_push_file (sc.scp, leaf.c_str(), to_do, S_IRUSR | S_IWUSR); - FILE* f = fopen (filesystem::path (*i).string().c_str(), "rb"); + FILE* f = fopen (boost::filesystem::path (*i).string().c_str(), "rb"); if (f == 0) { throw NetworkError (String::compose ("Could not open %1 to send", *i)); } @@ -180,7 +182,7 @@ SCPDCPJob::run () int const t = min (to_do, buffer_size); size_t const read = fread (buffer, 1, t, f); if (read != size_t (t)) { - throw ReadFileError (filesystem::path (*i).string()); + throw ReadFileError (boost::filesystem::path (*i).string()); } r = ssh_scp_write (sc.scp, buffer, t); diff --git a/src/lib/server.cc b/src/lib/server.cc index 10f64b482..c80527567 100644 --- a/src/lib/server.cc +++ b/src/lib/server.cc @@ -36,8 +36,16 @@ #include "config.h" #include "subtitle.h" -using namespace std; -using namespace boost; +using std::string; +using std::stringstream; +using std::multimap; +using std::vector; +using std::cerr; +using boost::shared_ptr; +using boost::algorithm::is_any_of; +using boost::algorithm::split; +using boost::thread; +using boost::bind; /** Create a server description from a string of metadata returned from as_metadata(). * @param v Metadata. @@ -132,7 +140,7 @@ void Server::worker_thread () { while (1) { - mutex::scoped_lock lock (_worker_mutex); + boost::mutex::scoped_lock lock (_worker_mutex); while (_queue.empty ()) { _worker_condition.wait (lock); } @@ -176,13 +184,13 @@ Server::run (int num_threads) _worker_threads.push_back (new thread (bind (&Server::worker_thread, this))); } - asio::io_service io_service; - asio::ip::tcp::acceptor acceptor (io_service, asio::ip::tcp::endpoint (asio::ip::tcp::v4(), Config::instance()->server_port ())); + boost::asio::io_service io_service; + boost::asio::ip::tcp::acceptor acceptor (io_service, boost::asio::ip::tcp::endpoint (boost::asio::ip::tcp::v4(), Config::instance()->server_port ())); while (1) { shared_ptr socket (new Socket); acceptor.accept (socket->socket ()); - mutex::scoped_lock lock (_worker_mutex); + boost::mutex::scoped_lock lock (_worker_mutex); /* Wait until the queue has gone down a bit */ while (int (_queue.size()) >= num_threads * 2) { diff --git a/src/lib/transcode_job.cc b/src/lib/transcode_job.cc index a4965ba44..cf16b8ab6 100644 --- a/src/lib/transcode_job.cc +++ b/src/lib/transcode_job.cc @@ -31,8 +31,11 @@ #include "log.h" #include "encoder_factory.h" -using namespace std; -using namespace boost; +using std::string; +using std::stringstream; +using std::fixed; +using std::setprecision; +using boost::shared_ptr; /** @param s Film to use. * @param o Options. diff --git a/src/lib/transcoder.cc b/src/lib/transcoder.cc index 8c02b7633..9515a4344 100644 --- a/src/lib/transcoder.cc +++ b/src/lib/transcoder.cc @@ -25,13 +25,13 @@ */ #include -#include +#include #include "transcoder.h" #include "encoder.h" #include "decoder_factory.h" -using namespace std; -using namespace boost; +using std::string; +using boost::shared_ptr; /** Construct a transcoder using a Decoder that we create and a supplied Encoder. * @param f Film that we are transcoding. @@ -46,8 +46,8 @@ Transcoder::Transcoder (shared_ptr f, shared_ptr o, Job* j, { assert (_encoder); - _decoder->Video.connect (sigc::mem_fun (*e, &Encoder::process_video)); - _decoder->Audio.connect (sigc::mem_fun (*e, &Encoder::process_audio)); + _decoder->Video.connect (bind (&Encoder::process_video, e, _1, _2, _3)); + _decoder->Audio.connect (bind (&Encoder::process_audio, e, _1)); } /** Run the decoder, passing its output to the encoder, until the decoder diff --git a/src/lib/ui_signaller.h b/src/lib/ui_signaller.h index 6b0e73c60..0797d911e 100644 --- a/src/lib/ui_signaller.h +++ b/src/lib/ui_signaller.h @@ -30,9 +30,9 @@ public: : _work (_service) {} - template - void emit (S signal) { - _service.post (boost::bind (boost::ref (signal))); + template + void emit (T f) { + _service.post (f); } void ui_idle () { diff --git a/src/tools/dvdomatic.cc b/src/tools/dvdomatic.cc index 4e3006c57..add0f6144 100644 --- a/src/tools/dvdomatic.cc +++ b/src/tools/dvdomatic.cc @@ -229,7 +229,7 @@ public: film_editor->setup_visibility (); film_viewer->setup_visibility (); - film_editor->FileChanged.connect (sigc::mem_fun (*this, &Frame::file_changed)); + film_editor->FileChanged.connect (bind (&Frame::file_changed, this, _1)); if (film) { file_changed (film->directory ()); } else { diff --git a/src/tools/makedcp.cc b/src/tools/makedcp.cc index 03e85e995..2d4df030c 100644 --- a/src/tools/makedcp.cc +++ b/src/tools/makedcp.cc @@ -36,8 +36,13 @@ #include "config.h" #include "log.h" -using namespace std; -using namespace boost; +using std::string; +using std::cerr; +using std::cout; +using std::vector; +using std::pair; +using std::list; +using boost::shared_ptr; static void help (string n) diff --git a/src/wx/config_dialog.cc b/src/wx/config_dialog.cc index b0bd6f2ee..f505b4bdc 100644 --- a/src/wx/config_dialog.cc +++ b/src/wx/config_dialog.cc @@ -35,7 +35,7 @@ #include "server_dialog.h" using namespace std; -using namespace boost; +using boost::bind; ConfigDialog::ConfigDialog (wxWindow* parent) : wxDialog (parent, wxID_ANY, _("DVD-o-matic Configuration"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) @@ -307,7 +307,7 @@ void ConfigDialog::edit_reference_filters_clicked (wxCommandEvent &) { FilterDialog* d = new FilterDialog (this, Config::instance()->reference_filters ()); - d->ActiveChanged.connect (sigc::mem_fun (*this, &ConfigDialog::reference_filters_changed)); + d->ActiveChanged.connect (boost::bind (&ConfigDialog::reference_filters_changed, this, _1)); d->ShowModal (); d->Destroy (); } diff --git a/src/wx/dcp_range_dialog.h b/src/wx/dcp_range_dialog.h index 706b0e430..ea15154ba 100644 --- a/src/wx/dcp_range_dialog.h +++ b/src/wx/dcp_range_dialog.h @@ -19,7 +19,7 @@ #include #include -#include +#include #include "lib/trim_action.h" class Film; @@ -29,7 +29,7 @@ class DCPRangeDialog : public wxDialog public: DCPRangeDialog (wxWindow *, Film *); - sigc::signal2 Changed; + boost::signals2::signal Changed; private: void whole_toggled (wxCommandEvent &); diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc index 502f3734c..542cde7d7 100644 --- a/src/wx/film_editor.cc +++ b/src/wx/film_editor.cc @@ -594,7 +594,7 @@ FilmEditor::set_film (Film* f) set_things_sensitive (_film != 0); if (_film) { - _film->Changed.connect (sigc::mem_fun (*this, &FilmEditor::film_changed)); + _film->Changed.connect (bind (&FilmEditor::film_changed, this, _1)); } if (_film) { @@ -663,7 +663,7 @@ void FilmEditor::edit_filters_clicked (wxCommandEvent &) { FilterDialog* d = new FilterDialog (this, _film->filters()); - d->ActiveChanged.connect (sigc::mem_fun (*_film, &Film::set_filters)); + d->ActiveChanged.connect (bind (&Film::set_filters, _film, _1)); d->ShowModal (); d->Destroy (); } @@ -758,7 +758,7 @@ void FilmEditor::change_dcp_range_clicked (wxCommandEvent &) { DCPRangeDialog* d = new DCPRangeDialog (this, _film); - d->Changed.connect (sigc::mem_fun (*this, &FilmEditor::dcp_range_changed)); + d->Changed.connect (bind (&FilmEditor::dcp_range_changed, this, _1, _2)); d->ShowModal (); } diff --git a/src/wx/film_editor.h b/src/wx/film_editor.h index 28afe7ff0..f6e180979 100644 --- a/src/wx/film_editor.h +++ b/src/wx/film_editor.h @@ -25,6 +25,7 @@ #include #include #include +#include #include "lib/trim_action.h" #include "lib/film.h" @@ -41,7 +42,7 @@ public: void set_film (Film *); void setup_visibility (); - sigc::signal1 FileChanged; + boost::signals2::signal FileChanged; private: /* Handle changes to the view */ diff --git a/src/wx/film_list.cc b/src/wx/film_list.cc index 1a9854450..05d9734f6 100644 --- a/src/wx/film_list.cc +++ b/src/wx/film_list.cc @@ -43,7 +43,7 @@ FilmList::FilmList (string d) } _list.set_headers_visible (false); - _list.get_selection()->signal_changed().connect (sigc::mem_fun (*this, &FilmList::selection_changed)); + _list.get_selection()->signal_changed().connect (bind (&FilmList::selection_changed, this)); } Gtk::Widget& diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc index e26423212..2496679aa 100644 --- a/src/wx/film_viewer.cc +++ b/src/wx/film_viewer.cc @@ -32,8 +32,10 @@ #include "film_viewer.h" #include "wx_util.h" -using namespace std; -using namespace boost; +using std::string; +using std::pair; +using std::max; +using boost::shared_ptr; class ThumbPanel : public wxPanel { @@ -304,7 +306,7 @@ FilmViewer::set_film (Film* f) return; } - _film->Changed.connect (sigc::mem_fun (*this, &FilmViewer::film_changed)); + _film->Changed.connect (bind (&FilmViewer::film_changed, this, _1)); film_changed (Film::CROP); film_changed (Film::THUMBS); setup_visibility (); diff --git a/src/wx/filter_dialog.cc b/src/wx/filter_dialog.cc index 028d082b4..2abe53026 100644 --- a/src/wx/filter_dialog.cc +++ b/src/wx/filter_dialog.cc @@ -26,6 +26,7 @@ #include "filter_view.h" using namespace std; +using boost::bind; FilterDialog::FilterDialog (wxWindow* parent, vector const & f) : wxDialog (parent, wxID_ANY, wxString (_("Filters"))) @@ -34,7 +35,7 @@ FilterDialog::FilterDialog (wxWindow* parent, vector const & f) wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL); sizer->Add (_filters, 1, wxEXPAND | wxALL, 6); - _filters->ActiveChanged.connect (sigc::mem_fun (*this, &FilterDialog::active_changed)); + _filters->ActiveChanged.connect (bind (&FilterDialog::active_changed, this)); wxSizer* buttons = CreateSeparatedButtonSizer (wxOK); if (buttons) { diff --git a/src/wx/filter_dialog.h b/src/wx/filter_dialog.h index 882d740cb..e76f8536b 100644 --- a/src/wx/filter_dialog.h +++ b/src/wx/filter_dialog.h @@ -22,6 +22,7 @@ */ #include +#include class Film; class FilterView; @@ -34,7 +35,7 @@ class FilterDialog : public wxDialog public: FilterDialog (wxWindow *, std::vector const &); - sigc::signal1 > ActiveChanged; + boost::signals2::signal)> ActiveChanged; private: void active_changed (); diff --git a/src/wx/filter_view.h b/src/wx/filter_view.h index 770b55da6..b8d5f644f 100644 --- a/src/wx/filter_view.h +++ b/src/wx/filter_view.h @@ -21,9 +21,9 @@ * @brief A panel to select FFmpeg filters. */ +#include #include #include -#include #include class Filter; @@ -38,7 +38,7 @@ public: std::vector active () const; - sigc::signal0 ActiveChanged; + boost::signals2::signal ActiveChanged; private: void filter_toggled (wxCommandEvent &); diff --git a/src/wx/job_manager_view.cc b/src/wx/job_manager_view.cc index a6eef6e34..bd2886231 100644 --- a/src/wx/job_manager_view.cc +++ b/src/wx/job_manager_view.cc @@ -28,8 +28,9 @@ #include "job_manager_view.h" #include "wx_util.h" -using namespace std; -using namespace boost; +using std::string; +using std::list; +using boost::shared_ptr; /** Must be called in the GUI thread */ JobManagerView::JobManagerView (wxWindow* parent) diff --git a/test/test.cc b/test/test.cc index 55505648d..2eaea1624 100644 --- a/test/test.cc +++ b/test/test.cc @@ -42,8 +42,12 @@ #define BOOST_TEST_MODULE dvdomatic_test #include -using namespace std; -using namespace boost; +using std::string; +using std::list; +using std::stringstream; +using std::vector; +using boost::shared_ptr; +using boost::thread; void setup_test_config () -- 2.30.2