From ea73ac38b9ee0e75a264cec907e6ac99d2f5d54a Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 25 Nov 2013 15:13:40 +0000 Subject: Link boost locale. --- wscript | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'wscript') diff --git a/wscript b/wscript index 9d2450d34..138f947e4 100644 --- a/wscript +++ b/wscript @@ -185,6 +185,14 @@ def configure(conf): lib=['boost_date_time%s' % boost_lib_suffix, 'boost_system%s' % boost_lib_suffix], uselib_store='BOOST_DATETIME') + conf.check_cxx(fragment=""" + #include \n + int main() { std::locale::global (boost::locale::generator().generate ("")); }\n + """, msg='Checking for boost locale library', + libpath='/usr/local/lib', + lib=['boost_locale%s' % boost_lib_suffix, 'boost_system%s' % boost_lib_suffix], + uselib_store='BOOST_LOCALE') + conf.check_cxx(fragment=""" #include \n int main() { boost::signals2::signal x; }\n -- cgit v1.2.3 From 72eedf0b240c71b9dbd27d1f95b109b48e3200a2 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 26 Nov 2013 22:23:15 +0000 Subject: A whole load of UTF-8/-16 confusion fixes for Windows. --- ChangeLog | 5 +++ cscript | 2 +- doc/manual/diagrams/file-structure.svg | 32 +++++++++--------- platform/windows/installer.nsi.32.in | 3 +- platform/windows/installer.nsi.64.in | 3 +- src/lib/audio_analysis.cc | 31 +++++++++--------- src/lib/audio_analysis.h | 5 ++- src/lib/config.cc | 2 +- src/lib/cross.cc | 19 +++++++++++ src/lib/cross.h | 1 + src/lib/dcp_video_frame.cc | 5 +-- src/lib/film.cc | 2 -- src/lib/log.cc | 8 +++-- src/lib/still_image_examiner.cc | 3 +- src/lib/util.cc | 56 +++++++++++++++++++------------ src/lib/writer.cc | 8 +++-- src/lib/wscript | 2 +- src/tools/dcpomatic.cc | 19 +++++++++-- src/wx/film_editor.cc | 11 +++++-- src/wx/new_film_dialog.cc | 4 +-- src/wx/new_film_dialog.h | 2 +- src/wx/wx_util.cc | 2 +- test/audio_analysis_test.cc | 60 ++++++++++++++++++++++++++++++++++ test/wscript | 1 + wscript | 8 +++++ 25 files changed, 215 insertions(+), 79 deletions(-) create mode 100644 test/audio_analysis_test.cc (limited to 'wscript') diff --git a/ChangeLog b/ChangeLog index 6b9a3e435..779871d9b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2013-11-26 Carl Hetherington + + * A whole load of fixes for lots of bugs when handling filenames + using non-Latin characters on Windows. + 2013-11-22 Carl Hetherington * Version 1.34 released. diff --git a/cscript b/cscript index 125a4d34c..3830cdc81 100644 --- a/cscript +++ b/cscript @@ -4,7 +4,7 @@ import os def dependencies(target): return (('ffmpeg-cdist', '0b7ef017aca8b572914518c759db1e234d8fc505'), - ('libdcp', 'f38137b21051ce770bbb4d829ae9d6229e97508f')) + ('libdcp', 'd0b7892cbab3618fca85a4c95d70d8a1c26a5c4d')) def build(target): cmd = './waf configure --prefix=%s' % target.work_dir_cscript() diff --git a/doc/manual/diagrams/file-structure.svg b/doc/manual/diagrams/file-structure.svg index e72636903..c19a6f023 100644 --- a/doc/manual/diagrams/file-structure.svg +++ b/doc/manual/diagrams/file-structure.svg @@ -15,7 +15,7 @@ id="svg2" version="1.1" inkscape:version="0.48.4 r9939" - sodipodi:docname="New document 1"> + sodipodi:docname="file-structure.svg"> @@ -2542,7 +2542,7 @@ image/svg+xml - + @@ -5736,43 +5736,43 @@ sodipodi:nodetypes="cc" /> DCP-o-matic'sworkingfiles DCP diff --git a/platform/windows/installer.nsi.32.in b/platform/windows/installer.nsi.32.in index 9b719f825..629edd50c 100644 --- a/platform/windows/installer.nsi.32.in +++ b/platform/windows/installer.nsi.32.in @@ -33,6 +33,7 @@ File "%static_deps%/bin/libboost_filesystem-mt.dll" File "%static_deps%/bin/libboost_system-mt.dll" File "%static_deps%/bin/libboost_thread_win32-mt.dll" File "%static_deps%/bin/libboost_date_time-mt.dll" +File "%static_deps%/bin/libboost_locale-mt.dll" File "%static_deps%/bin/libeay32.dll" File "%static_deps%/bin/libgcc_s_sjlj-1.dll" File "%static_deps%/bin/libgio-2.0-0.dll" @@ -40,7 +41,7 @@ File "%static_deps%/bin/libglib-2.0-0.dll" File "%static_deps%/bin/libgobject-2.0-0.dll" File "%static_deps%/bin/libiconv-2.dll" File "%static_deps%/bin/libjpeg-8.dll" -File "%static_deps%/bin/libMagick++-6.Q16-2.dll" +File "%static_deps%/bin/libMagick++-6.Q16-3.dll" File "%static_deps%/bin/libMagickCore-6.Q16-1.dll" File "%static_deps%/bin/libMagickWand-6.Q16-1.dll" File "%static_deps%/bin/libpng15-15.dll" diff --git a/platform/windows/installer.nsi.64.in b/platform/windows/installer.nsi.64.in index c53c2cacc..de1e09107 100644 --- a/platform/windows/installer.nsi.64.in +++ b/platform/windows/installer.nsi.64.in @@ -43,6 +43,7 @@ File "%static_deps%/bin/libboost_filesystem-mt.dll" File "%static_deps%/bin/libboost_system-mt.dll" File "%static_deps%/bin/libboost_thread_win32-mt.dll" File "%static_deps%/bin/libboost_date_time-mt.dll" +File "%static_deps%/bin/libboost_locale-mt.dll" File "%static_deps%/bin/libeay32.dll" File "%static_deps%/bin/libgcc_s_sjlj-1.dll" File "%static_deps%/bin/libgio-2.0-0.dll" @@ -50,7 +51,7 @@ File "%static_deps%/bin/libglib-2.0-0.dll" File "%static_deps%/bin/libgobject-2.0-0.dll" File "%static_deps%/bin/libiconv-2.dll" File "%static_deps%/bin/libjpeg-8.dll" -File "%static_deps%/bin/libMagick++-6.Q16-2.dll" +File "%static_deps%/bin/libMagick++-6.Q16-3.dll" File "%static_deps%/bin/libMagickCore-6.Q16-1.dll" File "%static_deps%/bin/libMagickWand-6.Q16-1.dll" File "%static_deps%/bin/libpng15-15.dll" diff --git a/src/lib/audio_analysis.cc b/src/lib/audio_analysis.cc index bc59bccca..1488f89fc 100644 --- a/src/lib/audio_analysis.cc +++ b/src/lib/audio_analysis.cc @@ -20,15 +20,14 @@ #include #include #include -#include +#include #include #include "audio_analysis.h" +#include "cross.h" using std::ostream; using std::istream; using std::string; -using std::ofstream; -using std::ifstream; using std::vector; using std::cout; using std::max; @@ -41,10 +40,10 @@ AudioPoint::AudioPoint () } } -AudioPoint::AudioPoint (istream& s) +AudioPoint::AudioPoint (FILE* f) { for (int i = 0; i < COUNT; ++i) { - s >> _data[i]; + fscanf (f, "%f", &_data[i]); } } @@ -70,10 +69,10 @@ AudioPoint::operator= (AudioPoint const & other) } void -AudioPoint::write (ostream& s) const +AudioPoint::write (FILE* f) const { for (int i = 0; i < COUNT; ++i) { - s << _data[i] << "\n"; + fprintf (f, "%f\n", _data[i]); } } @@ -85,15 +84,15 @@ AudioAnalysis::AudioAnalysis (int channels) AudioAnalysis::AudioAnalysis (boost::filesystem::path filename) { - ifstream f (filename.string().c_str ()); + FILE* f = fopen_boost (filename, "r"); int channels; - f >> channels; + fscanf (f, "%d", &channels); _data.resize (channels); for (int i = 0; i < channels; ++i) { int points; - f >> points; + fscanf (f, "%d", &points); for (int j = 0; j < points; ++j) { _data[i].push_back (AudioPoint (f)); } @@ -130,17 +129,19 @@ AudioAnalysis::points (int c) const void AudioAnalysis::write (boost::filesystem::path filename) { - string tmp = filename.string() + ".tmp"; + boost::filesystem::path tmp = filename; + tmp.replace_extension (".tmp"); - ofstream f (tmp.c_str ()); - f << _data.size() << "\n"; + FILE* f = fopen_boost (tmp, "w"); + + fprintf (f, "%ld\n", _data.size ()); for (vector >::iterator i = _data.begin(); i != _data.end(); ++i) { - f << i->size () << "\n"; + fprintf (f, "%ld\n", i->size ()); for (vector::iterator j = i->begin(); j != i->end(); ++j) { j->write (f); } } - f.close (); + fclose (f); boost::filesystem::rename (tmp, filename); } diff --git a/src/lib/audio_analysis.h b/src/lib/audio_analysis.h index cfc170c84..824472dda 100644 --- a/src/lib/audio_analysis.h +++ b/src/lib/audio_analysis.h @@ -20,7 +20,6 @@ #ifndef DCPOMATIC_AUDIO_ANALYSIS_H #define DCPOMATIC_AUDIO_ANALYSIS_H -#include #include #include #include @@ -35,11 +34,11 @@ public: }; AudioPoint (); - AudioPoint (std::istream &); + AudioPoint (FILE *); AudioPoint (AudioPoint const &); AudioPoint& operator= (AudioPoint const &); - void write (std::ostream &) const; + void write (FILE *) const; float& operator[] (int t) { return _data[t]; diff --git a/src/lib/config.cc b/src/lib/config.cc index 4b6455f51..54b9168f2 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -41,7 +41,6 @@ using std::vector; using std::ifstream; using std::string; -using std::ofstream; using std::list; using std::max; using std::exception; @@ -182,6 +181,7 @@ Config::read () void Config::read_old_metadata () { + /* XXX: this won't work with non-Latin filenames */ ifstream f (file(true).string().c_str ()); string line; diff --git a/src/lib/cross.cc b/src/lib/cross.cc index 41051ee2e..7436dbf26 100644 --- a/src/lib/cross.cc +++ b/src/lib/cross.cc @@ -70,6 +70,9 @@ cpu_info () string info; #ifdef DCPOMATIC_LINUX + /* This use of ifstream is ok; the filename can never + be non-Latin + */ ifstream f ("/proc/cpuinfo"); while (f.good ()) { string l; @@ -269,3 +272,19 @@ openssl_path () #endif } + +/* Apparently there is no way to create an ofstream using a UTF-8 + filename under Windows. We are hence reduced to using fopen + with this wrapper. +*/ +FILE * +fopen_boost (boost::filesystem::path p, string t) +{ +#ifdef DCPOMATIC_WINDOWS + wstring w (t.begin(), t.end()); + /* c_str() here should give a UTF-16 string */ + return _wfopen (p.c_str(), w.c_str ()); +#else + return fopen (p.c_str(), t.c_str ()); +#endif +} diff --git a/src/lib/cross.h b/src/lib/cross.h index 1fe34edbe..931e7d890 100644 --- a/src/lib/cross.h +++ b/src/lib/cross.h @@ -33,3 +33,4 @@ extern boost::filesystem::path openssl_path (); #ifdef DCPOMATIC_OSX extern boost::filesystem::path app_contents (); #endif +extern FILE * fopen_boost (boost::filesystem::path, std::string); diff --git a/src/lib/dcp_video_frame.cc b/src/lib/dcp_video_frame.cc index 25abd6f0d..679a0490e 100644 --- a/src/lib/dcp_video_frame.cc +++ b/src/lib/dcp_video_frame.cc @@ -59,12 +59,12 @@ #include "scaler.h" #include "image.h" #include "log.h" +#include "cross.h" #include "i18n.h" using std::string; using std::stringstream; -using std::ofstream; using std::cout; using boost::shared_ptr; using boost::lexical_cast; @@ -379,8 +379,9 @@ void EncodedData::write_info (shared_ptr film, int frame, Eyes eyes, libdcp::FrameInfo fin) const { boost::filesystem::path const info = film->info_path (frame, eyes); - ofstream h (info.string().c_str()); + FILE* h = fopen_boost (info, "w"); fin.write (h); + fclose (h); } /** Send this data to a socket. diff --git a/src/lib/film.cc b/src/lib/film.cc index eab91c7d2..b1b868984 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -64,8 +64,6 @@ using std::multimap; using std::pair; using std::map; using std::vector; -using std::ifstream; -using std::ofstream; using std::setfill; using std::min; using std::make_pair; diff --git a/src/lib/log.cc b/src/lib/log.cc index 86de21bdd..9ddf460d4 100644 --- a/src/lib/log.cc +++ b/src/lib/log.cc @@ -21,9 +21,10 @@ * @brief A very simple logging class. */ -#include #include +#include #include "log.h" +#include "cross.h" #include "i18n.h" @@ -102,7 +103,8 @@ FileLog::FileLog (boost::filesystem::path file) void FileLog::do_log (string m) { - ofstream f (_file.string().c_str(), fstream::app); - f << m << N_("\n"); + FILE* f = fopen_boost (_file, "a"); + fprintf (f, "%s\n", m.c_str ()); + fclose (f); } diff --git a/src/lib/still_image_examiner.cc b/src/lib/still_image_examiner.cc index 5f45d6365..d5e863634 100644 --- a/src/lib/still_image_examiner.cc +++ b/src/lib/still_image_examiner.cc @@ -26,6 +26,7 @@ #include "i18n.h" using std::cout; +using std::string; using boost::shared_ptr; StillImageExaminer::StillImageExaminer (shared_ptr f, shared_ptr c) @@ -33,7 +34,7 @@ StillImageExaminer::StillImageExaminer (shared_ptr f, shared_ptrpath().string()); + Magick::Image* image = new Magick::Image (_still_image_content->path().string ()); _video_size = libdcp::Size (image->columns(), image->rows()); delete image; } diff --git a/src/lib/util.cc b/src/lib/util.cc index 484c4fb9b..e70440271 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -80,7 +81,6 @@ using std::endl; using std::vector; using std::hex; using std::setw; -using std::ifstream; using std::ios; using std::min; using std::max; @@ -89,7 +89,6 @@ using std::multimap; using std::istream; using std::numeric_limits; using std::pair; -using std::ofstream; using std::cout; using boost::shared_ptr; using boost::thread; @@ -260,8 +259,11 @@ seconds (struct timeval t) LONG WINAPI exception_handler(struct _EXCEPTION_POINTERS *) { dbg::stack s; - ofstream f (backtrace_file.string().c_str()); - std::copy(s.begin(), s.end(), std::ostream_iterator(f, "\n")); + FILE* f = fopen_boost (backtrace_file, "w"); + for (dbg::stack::const_iterator i = s.begin(); i != s.end(); ++i) { + fprintf (f, "%p %s %d %s", i->instruction, i->function.c_str(), i->line, i->module.c_str()); + } + fclose (f); return EXCEPTION_CONTINUE_SEARCH; } #endif @@ -276,6 +278,21 @@ dcpomatic_setup () backtrace_file /= g_get_user_config_dir (); backtrace_file /= "backtrace.txt"; SetUnhandledExceptionFilter(exception_handler); + + /* Dark voodoo which, I think, gets boost::filesystem::path to + correctly convert UTF-8 strings to paths, and also paths + back to UTF-8 strings (on path::string()). + + After this, constructing boost::filesystem::paths from strings + converts from UTF-8 to UTF-16 inside the path. Then + path::string().c_str() gives UTF-8 and + path::c_str() gives UTF-16. + + This is all Windows-only. AFAICT Linux/OS X use UTF-8 everywhere, + so things are much simpler. + */ + std::locale::global (boost::locale::generator().generate ("")); + boost::filesystem::path::imbue (std::locale ()); #endif avfilter_register_all (); @@ -392,29 +409,28 @@ md5_digest (void const * data, int size) string md5_digest (boost::filesystem::path file) { - ifstream f (file.string().c_str(), std::ios::binary); - if (!f.good ()) { + FILE* f = fopen_boost (file, "rb"); + if (!f) { throw OpenFileError (file.string()); } - - f.seekg (0, std::ios::end); - int bytes = f.tellg (); - f.seekg (0, std::ios::beg); - int const buffer_size = 64 * 1024; + boost::uintmax_t bytes = boost::filesystem::file_size (file); + + boost::uintmax_t const buffer_size = 64 * 1024; char buffer[buffer_size]; MD5_CTX md5_context; MD5_Init (&md5_context); while (bytes > 0) { int const t = min (bytes, buffer_size); - f.read (buffer, t); + fread (buffer, 1, t, f); MD5_Update (&md5_context, buffer, t); bytes -= t; } unsigned char digest[MD5_DIGEST_LENGTH]; MD5_Final (digest, &md5_context); + fclose (f); stringstream s; for (int i = 0; i < MD5_DIGEST_LENGTH; ++i) { @@ -428,7 +444,7 @@ md5_digest (boost::filesystem::path file) string md5_digest_directory (boost::filesystem::path directory, shared_ptr job) { - int const buffer_size = 64 * 1024; + boost::uintmax_t const buffer_size = 64 * 1024; char buffer[buffer_size]; MD5_CTX md5_context; @@ -443,18 +459,16 @@ md5_digest_directory (boost::filesystem::path directory, shared_ptr job) int j = 0; for (boost::filesystem::directory_iterator i(directory); i != boost::filesystem::directory_iterator(); ++i) { - ifstream f (i->path().string().c_str(), std::ios::binary); - if (!f.good ()) { + FILE* f = fopen_boost (i->path(), "rb"); + if (!f) { throw OpenFileError (i->path().string()); } - - f.seekg (0, std::ios::end); - int bytes = f.tellg (); - f.seekg (0, std::ios::beg); + + boost::uintmax_t bytes = boost::filesystem::file_size (i->path ()); while (bytes > 0) { int const t = min (bytes, buffer_size); - f.read (buffer, t); + fread (buffer, 1, t, f); MD5_Update (&md5_context, buffer, t); bytes -= t; } @@ -463,6 +477,8 @@ md5_digest_directory (boost::filesystem::path directory, shared_ptr job) job->set_progress (float (j) / files); ++j; } + + fclose (f); } unsigned char digest[MD5_DIGEST_LENGTH]; diff --git a/src/lib/writer.cc b/src/lib/writer.cc index 103ac2ba1..f4128e6c5 100644 --- a/src/lib/writer.cc +++ b/src/lib/writer.cc @@ -36,13 +36,13 @@ #include "audio_mapping.h" #include "config.h" #include "job.h" +#include "cross.h" #include "i18n.h" using std::make_pair; using std::pair; using std::string; -using std::ifstream; using std::list; using std::cout; using boost::shared_ptr; @@ -141,8 +141,9 @@ Writer::fake_write (int frame, Eyes eyes) { boost::mutex::scoped_lock lock (_mutex); - ifstream ifi (_film->info_path (frame, eyes).string().c_str()); + FILE* ifi = fopen_boost (_film->info_path (frame, eyes), "r"); libdcp::FrameInfo info (ifi); + fclose (ifi); QueueItem qi; qi.type = QueueItem::FAKE; @@ -430,8 +431,9 @@ bool Writer::check_existing_picture_mxf_frame (FILE* mxf, int f, Eyes eyes) { /* Read the frame info as written */ - ifstream ifi (_film->info_path (f, eyes).string().c_str()); + FILE* ifi = fopen_boost (_film->info_path (f, eyes), "r"); libdcp::FrameInfo info (ifi); + fclose (ifi); if (info.size == 0) { _film->log()->log (String::compose ("Existing frame %1 has no info file", f)); return false; diff --git a/src/lib/wscript b/src/lib/wscript index 852bb1aed..e317026f3 100644 --- a/src/lib/wscript +++ b/src/lib/wscript @@ -74,7 +74,7 @@ def build(bld): obj.export_includes = ['..'] obj.uselib = """ AVCODEC AVUTIL AVFORMAT AVFILTER SWSCALE SWRESAMPLE - BOOST_FILESYSTEM BOOST_THREAD BOOST_DATETIME BOOST_SIGNALS2 + BOOST_FILESYSTEM BOOST_THREAD BOOST_DATETIME BOOST_SIGNALS2 BOOST_LOCALE SNDFILE OPENJPEG POSTPROC TIFF MAGICK SSH DCP CXML GLIB LZMA XML++ CURL ZIP QUICKMAIL """ diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc index 1d01e4da8..2a0cb9cd3 100644 --- a/src/tools/dcpomatic.cc +++ b/src/tools/dcpomatic.cc @@ -62,7 +62,6 @@ using std::map; using std::make_pair; using std::list; using std::exception; -using std::ofstream; using boost::shared_ptr; using boost::dynamic_pointer_cast; @@ -247,6 +246,22 @@ public: : wxFrame (NULL, -1, title) , _servers_list_dialog (0) { +#ifdef DCPOMATIC_WINDOWS_CONSOLE + AllocConsole(); + + HANDLE handle_out = GetStdHandle(STD_OUTPUT_HANDLE); + int hCrt = _open_osfhandle((intptr_t) handle_out, _O_TEXT); + FILE* hf_out = _fdopen(hCrt, "w"); + setvbuf(hf_out, NULL, _IONBF, 1); + *stdout = *hf_out; + + HANDLE handle_in = GetStdHandle(STD_INPUT_HANDLE); + hCrt = _open_osfhandle((intptr_t) handle_in, _O_TEXT); + FILE* hf_in = _fdopen(hCrt, "r"); + setvbuf(hf_in, NULL, _IONBF, 128); + *stdin = *hf_in; +#endif + wxMenuBar* bar = new wxMenuBar; setup_menu (bar); SetMenuBar (bar); @@ -332,7 +347,7 @@ private: std_to_wx ( String::compose (wx_to_std (_("The directory %1 already exists and is not empty. " "Are you sure you want to use it?")), - d->get_path().c_str()) + d->get_path().string().c_str()) ) )) { return; diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc index 9cf840614..ef3534939 100644 --- a/src/wx/film_editor.cc +++ b/src/wx/film_editor.cc @@ -731,11 +731,14 @@ FilmEditor::setup_content () void FilmEditor::content_add_file_clicked () { - wxFileDialog* d = new wxFileDialog (this, _("Choose a file or files"), wxT (""), wxT (""), wxT ("*.*"), wxFD_MULTIPLE); + /* The wxFD_CHANGE_DIR here prevents a `could not set working directory' error 123 on Windows when using + non-Latin filenames or paths. + */ + wxFileDialog* d = new wxFileDialog (this, _("Choose a file or files"), wxT (""), wxT (""), wxT ("*.*"), wxFD_MULTIPLE | wxFD_CHANGE_DIR); int const r = d->ShowModal (); - d->Destroy (); if (r != wxID_OK) { + d->Destroy (); return; } @@ -745,8 +748,10 @@ FilmEditor::content_add_file_clicked () /* XXX: check for lots of files here and do something */ for (unsigned int i = 0; i < paths.GetCount(); ++i) { - _film->examine_and_add_content (content_factory (_film, wx_to_std (paths[i]))); + _film->examine_and_add_content (content_factory (_film, wx_to_std (d->GetPath ()))); } + + d->Destroy (); } void diff --git a/src/wx/new_film_dialog.cc b/src/wx/new_film_dialog.cc index 2612a6afe..be5af999e 100644 --- a/src/wx/new_film_dialog.cc +++ b/src/wx/new_film_dialog.cc @@ -74,11 +74,11 @@ NewFilmDialog::~NewFilmDialog () _directory = wx_to_std (_folder->GetPath ()); } -string +boost::filesystem::path NewFilmDialog::get_path () const { filesystem::path p; p /= wx_to_std (_folder->GetPath ()); p /= wx_to_std (_name->GetValue ()); - return p.string (); + return p; } diff --git a/src/wx/new_film_dialog.h b/src/wx/new_film_dialog.h index 4176b060d..a835c7ceb 100644 --- a/src/wx/new_film_dialog.h +++ b/src/wx/new_film_dialog.h @@ -29,7 +29,7 @@ public: NewFilmDialog (wxWindow *); ~NewFilmDialog (); - std::string get_path () const; + boost::filesystem::path get_path () const; private: wxTextCtrl* _name; diff --git a/src/wx/wx_util.cc b/src/wx/wx_util.cc index 27a4554ca..103d36d00 100644 --- a/src/wx/wx_util.cc +++ b/src/wx/wx_util.cc @@ -105,7 +105,7 @@ confirm_dialog (wxWindow* parent, wxString m) string wx_to_std (wxString s) { - return string (s.mb_str ()); + return string (s.ToUTF8 ()); } /** @param s STL string. diff --git a/test/audio_analysis_test.cc b/test/audio_analysis_test.cc new file mode 100644 index 000000000..77b2aeaf6 --- /dev/null +++ b/test/audio_analysis_test.cc @@ -0,0 +1,60 @@ +/* + Copyright (C) 2012 Carl Hetherington + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include +#include "lib/audio_analysis.h" + +static float +random_float () +{ + return (float (rand ()) / RAND_MAX) * 2 - 1; +} + +/* Check serialisation of audio analyses */ +BOOST_AUTO_TEST_CASE (audio_analysis_test) +{ + int const channels = 3; + int const points = 4096; + + srand (1); + + AudioAnalysis a (3); + for (int i = 0; i < channels; ++i) { + for (int j = 0; j < points; ++j) { + AudioPoint p; + p[AudioPoint::PEAK] = random_float (); + p[AudioPoint::RMS] = random_float (); + a.add_point (i, p); + } + } + + a.write ("build/test/audio_analysis_test"); + + srand (1); + + AudioAnalysis b ("build/test/audio_analysis_test"); + for (int i = 0; i < channels; ++i) { + BOOST_CHECK (b.points(i) == points); + for (int j = 0; j < points; ++j) { + AudioPoint p = b.get_point (i, j); + BOOST_CHECK_CLOSE (p[AudioPoint::PEAK], random_float (), 1); + BOOST_CHECK_CLOSE (p[AudioPoint::RMS], random_float (), 1); + } + } +} diff --git a/test/wscript b/test/wscript index b40b69475..76de63a52 100644 --- a/test/wscript +++ b/test/wscript @@ -16,6 +16,7 @@ def build(bld): obj.use = 'libdcpomatic' obj.source = """ test.cc + audio_analysis_test.cc scaling_test.cc film_metadata_test.cc frame_rate_test.cc diff --git a/wscript b/wscript index 9d2450d34..138f947e4 100644 --- a/wscript +++ b/wscript @@ -185,6 +185,14 @@ def configure(conf): lib=['boost_date_time%s' % boost_lib_suffix, 'boost_system%s' % boost_lib_suffix], uselib_store='BOOST_DATETIME') + conf.check_cxx(fragment=""" + #include \n + int main() { std::locale::global (boost::locale::generator().generate ("")); }\n + """, msg='Checking for boost locale library', + libpath='/usr/local/lib', + lib=['boost_locale%s' % boost_lib_suffix, 'boost_system%s' % boost_lib_suffix], + uselib_store='BOOST_LOCALE') + conf.check_cxx(fragment=""" #include \n int main() { boost::signals2::signal x; }\n -- cgit v1.2.3 From 52c7a765b76efbba439411a78ca31b72ef17fe6e Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 27 Nov 2013 10:53:49 +0000 Subject: We only need boost locale on Windows. --- src/lib/util.cc | 2 ++ src/lib/wscript | 4 ++-- wscript | 17 ++++++++++------- 3 files changed, 14 insertions(+), 9 deletions(-) (limited to 'wscript') diff --git a/src/lib/util.cc b/src/lib/util.cc index e70440271..9dffffa98 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -39,7 +39,9 @@ #include #include #include +#ifdef DCPOMATIC_WINDOWS #include +#endif #include #include #include diff --git a/src/lib/wscript b/src/lib/wscript index e317026f3..5098d4069 100644 --- a/src/lib/wscript +++ b/src/lib/wscript @@ -74,7 +74,7 @@ def build(bld): obj.export_includes = ['..'] obj.uselib = """ AVCODEC AVUTIL AVFORMAT AVFILTER SWSCALE SWRESAMPLE - BOOST_FILESYSTEM BOOST_THREAD BOOST_DATETIME BOOST_SIGNALS2 BOOST_LOCALE + BOOST_FILESYSTEM BOOST_THREAD BOOST_DATETIME BOOST_SIGNALS2 SNDFILE OPENJPEG POSTPROC TIFF MAGICK SSH DCP CXML GLIB LZMA XML++ CURL ZIP QUICKMAIL """ @@ -82,7 +82,7 @@ def build(bld): obj.source = sources + ' version.cc' if bld.env.TARGET_WINDOWS: - obj.uselib += ' WINSOCK2 BFD DBGHELP IBERTY SHLWAPI MSWSOCK' + obj.uselib += ' WINSOCK2 BFD DBGHELP IBERTY SHLWAPI MSWSOCK BOOST_LOCALE' obj.source += ' stack.cpp' if bld.env.STATIC: obj.uselib += ' XML++' diff --git a/wscript b/wscript index 138f947e4..54a1a3eb0 100644 --- a/wscript +++ b/wscript @@ -185,13 +185,16 @@ def configure(conf): lib=['boost_date_time%s' % boost_lib_suffix, 'boost_system%s' % boost_lib_suffix], uselib_store='BOOST_DATETIME') - conf.check_cxx(fragment=""" - #include \n - int main() { std::locale::global (boost::locale::generator().generate ("")); }\n - """, msg='Checking for boost locale library', - libpath='/usr/local/lib', - lib=['boost_locale%s' % boost_lib_suffix, 'boost_system%s' % boost_lib_suffix], - uselib_store='BOOST_LOCALE') + # Only Windows versions require boost::locale, which is handy, as it was only introduced in + # boost 1.48 and so isn't (easily) available on old Ubuntus. + if conf.env.TARGET_WINDOWS: + conf.check_cxx(fragment=""" + #include \n + int main() { std::locale::global (boost::locale::generator().generate ("")); }\n + """, msg='Checking for boost locale library', + libpath='/usr/local/lib', + lib=['boost_locale%s' % boost_lib_suffix, 'boost_system%s' % boost_lib_suffix], + uselib_store='BOOST_LOCALE') conf.check_cxx(fragment=""" #include \n -- cgit v1.2.3 From 15b8cca90c9135bf49bdfce08ebd10b92e5a4d0b Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 27 Nov 2013 14:57:05 +0000 Subject: Update libdcp version. --- cscript | 2 +- wscript | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'wscript') diff --git a/cscript b/cscript index f6b18881e..9298b47fc 100644 --- a/cscript +++ b/cscript @@ -4,7 +4,7 @@ import os def dependencies(target): return (('ffmpeg-cdist', '0b7ef017aca8b572914518c759db1e234d8fc505'), - ('libdcp', 'a86a53096f632f63afc6130c23291c28acb9686a')) + ('libdcp', 'v0.84')) def build(target): cmd = './waf configure --prefix=%s' % target.work_dir_cscript() diff --git a/wscript b/wscript index a1ed6ec23..87999f7de 100644 --- a/wscript +++ b/wscript @@ -88,7 +88,7 @@ def configure(conf): # Dependencies which are dynamically linked everywhere except --static # Get libs only when we are dynamically linking - conf.check_cfg(package='libdcp', atleast_version='0.83', args=pkg_config_args(conf), uselib_store='DCP', mandatory=True) + conf.check_cfg(package='libdcp', atleast_version='0.84', args=pkg_config_args(conf), uselib_store='DCP', mandatory=True) # Remove erroneous escaping of quotes from xmlsec1 defines conf.env.DEFINES_DCP = [f.replace('\\', '') for f in conf.env.DEFINES_DCP] conf.check_cfg(package='libcxml', atleast_version='0.08', args=pkg_config_args(conf), uselib_store='CXML', mandatory=True) -- cgit v1.2.3 From 3300c4218ffb463d4f4a3f85c5a13b499885eed5 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 27 Nov 2013 14:57:49 +0000 Subject: Bump version --- ChangeLog | 4 ++++ debian/changelog | 5 +++-- wscript | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) (limited to 'wscript') diff --git a/ChangeLog b/ChangeLog index b245dfc85..dd217c37e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2013-11-27 Carl Hetherington + + * Version 1.35 released. + 2013-11-26 Carl Hetherington * Updated fr_FR translation from Lilian Lefranc. diff --git a/debian/changelog b/debian/changelog index fd971efe3..6b220e982 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -dcpomatic (1.34-1) UNRELEASED; urgency=low +dcpomatic (1.35-1) UNRELEASED; urgency=low * New upstream release. * New upstream release. @@ -38,8 +38,9 @@ dcpomatic (1.34-1) UNRELEASED; urgency=low * New upstream release. * New upstream release. * New upstream release. + * New upstream release. - -- Carl Hetherington Fri, 22 Nov 2013 23:07:30 +0000 + -- Carl Hetherington Wed, 27 Nov 2013 14:57:48 +0000 dcpomatic (0.87-1) UNRELEASED; urgency=low diff --git a/wscript b/wscript index 87999f7de..f25588355 100644 --- a/wscript +++ b/wscript @@ -3,7 +3,7 @@ import os import sys APPNAME = 'dcpomatic' -VERSION = '1.35pre' +VERSION = '1.35' def options(opt): opt.load('compiler_cxx') -- cgit v1.2.3 From f6837f5c77b663c8718e454a10c7933896faaa6e Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 27 Nov 2013 14:57:49 +0000 Subject: Bump version --- wscript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'wscript') diff --git a/wscript b/wscript index f25588355..178b461c2 100644 --- a/wscript +++ b/wscript @@ -3,7 +3,7 @@ import os import sys APPNAME = 'dcpomatic' -VERSION = '1.35' +VERSION = '1.36pre' def options(opt): opt.load('compiler_cxx') -- cgit v1.2.3 From 60b532743f84fd29f87de75edcbd7872cb640f6e Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 27 Nov 2013 15:23:06 +0000 Subject: Bump libdcp version. --- cscript | 2 +- wscript | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'wscript') diff --git a/cscript b/cscript index 9298b47fc..a1cee78f2 100644 --- a/cscript +++ b/cscript @@ -4,7 +4,7 @@ import os def dependencies(target): return (('ffmpeg-cdist', '0b7ef017aca8b572914518c759db1e234d8fc505'), - ('libdcp', 'v0.84')) + ('libdcp', 'v0.85')) def build(target): cmd = './waf configure --prefix=%s' % target.work_dir_cscript() diff --git a/wscript b/wscript index 87999f7de..029bedf1e 100644 --- a/wscript +++ b/wscript @@ -88,7 +88,7 @@ def configure(conf): # Dependencies which are dynamically linked everywhere except --static # Get libs only when we are dynamically linking - conf.check_cfg(package='libdcp', atleast_version='0.84', args=pkg_config_args(conf), uselib_store='DCP', mandatory=True) + conf.check_cfg(package='libdcp', atleast_version='0.85', args=pkg_config_args(conf), uselib_store='DCP', mandatory=True) # Remove erroneous escaping of quotes from xmlsec1 defines conf.env.DEFINES_DCP = [f.replace('\\', '') for f in conf.env.DEFINES_DCP] conf.check_cfg(package='libcxml', atleast_version='0.08', args=pkg_config_args(conf), uselib_store='CXML', mandatory=True) -- cgit v1.2.3 From 2b6abb23ac0c91ee2a5716942d8486cd19c85f42 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 27 Nov 2013 15:37:01 +0000 Subject: Bump version --- ChangeLog | 4 ++++ debian/changelog | 5 +++-- wscript | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) (limited to 'wscript') diff --git a/ChangeLog b/ChangeLog index dd217c37e..b2a11749f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2013-11-27 Carl Hetherington + + * Version 1.36 released. + 2013-11-27 Carl Hetherington * Version 1.35 released. diff --git a/debian/changelog b/debian/changelog index 6b220e982..d37ba9da9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -dcpomatic (1.35-1) UNRELEASED; urgency=low +dcpomatic (1.36-1) UNRELEASED; urgency=low * New upstream release. * New upstream release. @@ -39,8 +39,9 @@ dcpomatic (1.35-1) UNRELEASED; urgency=low * New upstream release. * New upstream release. * New upstream release. + * New upstream release. - -- Carl Hetherington Wed, 27 Nov 2013 14:57:48 +0000 + -- Carl Hetherington Wed, 27 Nov 2013 15:37:00 +0000 dcpomatic (0.87-1) UNRELEASED; urgency=low diff --git a/wscript b/wscript index 5f6238b37..b3f69a961 100644 --- a/wscript +++ b/wscript @@ -3,7 +3,7 @@ import os import sys APPNAME = 'dcpomatic' -VERSION = '1.36pre' +VERSION = '1.36' def options(opt): opt.load('compiler_cxx') -- cgit v1.2.3 From e149860b8eabddfd6d1972f0a01a3996fedd6149 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 27 Nov 2013 15:37:01 +0000 Subject: Bump version --- wscript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'wscript') diff --git a/wscript b/wscript index b3f69a961..32aa591b6 100644 --- a/wscript +++ b/wscript @@ -3,7 +3,7 @@ import os import sys APPNAME = 'dcpomatic' -VERSION = '1.36' +VERSION = '1.37pre' def options(opt): opt.load('compiler_cxx') -- cgit v1.2.3 From fcb8b5131df5bf02966441076c2131b73a3f61ed Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 27 Nov 2013 16:03:57 +0000 Subject: Fix bad merge. --- wscript | 8 -------- 1 file changed, 8 deletions(-) (limited to 'wscript') diff --git a/wscript b/wscript index 32aa591b6..bb7558c43 100644 --- a/wscript +++ b/wscript @@ -196,14 +196,6 @@ def configure(conf): lib=['boost_locale%s' % boost_lib_suffix, 'boost_system%s' % boost_lib_suffix], uselib_store='BOOST_LOCALE') - conf.check_cxx(fragment=""" - #include \n - int main() { std::locale::global (boost::locale::generator().generate ("")); }\n - """, msg='Checking for boost locale library', - libpath='/usr/local/lib', - lib=['boost_locale%s' % boost_lib_suffix, 'boost_system%s' % boost_lib_suffix], - uselib_store='BOOST_LOCALE') - conf.check_cxx(fragment=""" #include \n int main() { boost::signals2::signal x; }\n -- cgit v1.2.3 From 22ec85d585d7b626f2b577944abf96362ec5f8e7 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 27 Nov 2013 16:04:55 +0000 Subject: Bump version --- ChangeLog | 4 ++++ debian/changelog | 5 +++-- wscript | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) (limited to 'wscript') diff --git a/ChangeLog b/ChangeLog index b2a11749f..1c404dde3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2013-11-27 Carl Hetherington + + * Version 1.37 released. + 2013-11-27 Carl Hetherington * Version 1.36 released. diff --git a/debian/changelog b/debian/changelog index d37ba9da9..f03c6b5b7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -dcpomatic (1.36-1) UNRELEASED; urgency=low +dcpomatic (1.37-1) UNRELEASED; urgency=low * New upstream release. * New upstream release. @@ -40,8 +40,9 @@ dcpomatic (1.36-1) UNRELEASED; urgency=low * New upstream release. * New upstream release. * New upstream release. + * New upstream release. - -- Carl Hetherington Wed, 27 Nov 2013 15:37:00 +0000 + -- Carl Hetherington Wed, 27 Nov 2013 16:04:55 +0000 dcpomatic (0.87-1) UNRELEASED; urgency=low diff --git a/wscript b/wscript index bb7558c43..bd08e1e86 100644 --- a/wscript +++ b/wscript @@ -3,7 +3,7 @@ import os import sys APPNAME = 'dcpomatic' -VERSION = '1.37pre' +VERSION = '1.37' def options(opt): opt.load('compiler_cxx') -- cgit v1.2.3 From 53cafa3ad6410431cbc80743a0e189c8692c0296 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 27 Nov 2013 16:04:55 +0000 Subject: Bump version --- wscript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'wscript') diff --git a/wscript b/wscript index bd08e1e86..5276b2843 100644 --- a/wscript +++ b/wscript @@ -3,7 +3,7 @@ import os import sys APPNAME = 'dcpomatic' -VERSION = '1.37' +VERSION = '1.38pre' def options(opt): opt.load('compiler_cxx') -- cgit v1.2.3