From 0390c42a7fc648a116ac3fd0417eac92dfe79f6d Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 2 Sep 2014 22:57:44 +0100 Subject: Add a reasonably low timeout to curl fetches. --- src/lib/internet.cc | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/lib') diff --git a/src/lib/internet.cc b/src/lib/internet.cc index c28e650fd..1c61e96e3 100644 --- a/src/lib/internet.cc +++ b/src/lib/internet.cc @@ -56,6 +56,8 @@ get_from_zip_url (string url, string file, function Date: Wed, 3 Sep 2014 00:28:35 +0100 Subject: Speculative fix for Doremi certificate download on OS X. The while (wxTheApp->Pending ()) wxTheApp->Dispatch() appears to hang on OS X. --- src/lib/ui_signaller.h | 7 +++++++ src/wx/doremi_certificate_dialog.cc | 13 ++++++++++++- src/wx/doremi_certificate_dialog.h | 2 ++ 3 files changed, 21 insertions(+), 1 deletion(-) (limited to 'src/lib') diff --git a/src/lib/ui_signaller.h b/src/lib/ui_signaller.h index 1d62547f6..ee4d230d4 100644 --- a/src/lib/ui_signaller.h +++ b/src/lib/ui_signaller.h @@ -54,8 +54,15 @@ public: } } + /* Do something next time the UI is idle */ + template + void when_idle (T f) { + _service.post (f); + } + /** Call this in the UI when it is idle */ size_t ui_idle () { + /* This executes any functors that have been post()ed to _service */ return _service.poll (); } diff --git a/src/wx/doremi_certificate_dialog.cc b/src/wx/doremi_certificate_dialog.cc index b4cd14eaf..4b5d58b37 100644 --- a/src/wx/doremi_certificate_dialog.cc +++ b/src/wx/doremi_certificate_dialog.cc @@ -21,6 +21,7 @@ #include #include "lib/compose.hpp" #include "lib/util.h" +#include "lib/ui_signaller.h" #include "lib/internet.h" #include "doremi_certificate_dialog.h" #include "wx_util.h" @@ -51,8 +52,18 @@ DoremiCertificateDialog::download () } _message->SetLabel (_("Downloading certificate")); - run_gui_loop (); +#ifdef DCPOMATIC_OSX + /* This is necessary on OS X, otherwise the SetLabel() above has no visible effect */ + wxMilliSleep (200); +#endif + + ui_signaller->when_idle (boost::bind (&DoremiCertificateDialog::finish_download, this, serial)); +} + +void +DoremiCertificateDialog::finish_download (string serial) +{ /* Try dcp2000, imb and ims prefixes (see mantis #375) */ optional error = get_from_zip_url ( diff --git a/src/wx/doremi_certificate_dialog.h b/src/wx/doremi_certificate_dialog.h index 281184726..b249736ec 100644 --- a/src/wx/doremi_certificate_dialog.h +++ b/src/wx/doremi_certificate_dialog.h @@ -28,5 +28,7 @@ private: void download (); void set_sensitivity (); + void finish_download (std::string serial); + wxTextCtrl* _serial; }; -- cgit v1.2.3 From 4a33cfc3b4c51d4e047879051d70ae56ec8ee6e1 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 3 Sep 2014 23:34:32 +0100 Subject: Put the right 'actual' ratio in DCP titles even with no-stretch and no-scale. --- src/lib/film.cc | 18 +++++++++++------- src/lib/ratio.cc | 17 +++++++++++++++++ src/lib/ratio.h | 1 + 3 files changed, 29 insertions(+), 7 deletions(-) (limited to 'src/lib') diff --git a/src/lib/film.cc b/src/lib/film.cc index 2701d81b8..b4d12a062 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -580,18 +580,22 @@ Film::isdcf_name (bool if_created_now) const d << "_" << container()->isdcf_name(); } - /* XXX: this only works for content which has been scaled to a given ratio, - and uses the first bit of content only. - */ + /* XXX: this uses the first bit of content only */ /* The standard says we don't do this for trailers, for some strange reason */ if (dcp_content_type() && dcp_content_type()->libdcp_kind() != libdcp::TRAILER) { - ContentList cl = content (); Ratio const * content_ratio = 0; - for (ContentList::const_iterator i = cl.begin(); i != cl.end(); ++i) { + ContentList cl = content (); + for (ContentList::iterator i = cl.begin(); i != cl.end(); ++i) { shared_ptr vc = dynamic_pointer_cast (*i); - if (vc && (content_ratio == 0 || vc->scale().ratio() != content_ratio)) { - content_ratio = vc->scale().ratio(); + if (vc) { + /* Here's the first piece of video content */ + if (vc->scale().ratio ()) { + content_ratio = vc->scale().ratio (); + } else { + content_ratio = Ratio::from_ratio (vc->video_size().ratio ()); + } + break; } } diff --git a/src/lib/ratio.cc b/src/lib/ratio.cc index 4a5b39a22..554d3c36c 100644 --- a/src/lib/ratio.cc +++ b/src/lib/ratio.cc @@ -56,3 +56,20 @@ Ratio::from_id (string i) return *j; } + +/** @return Ratio corresponding to a given fractional ratio (+/- 0.01), or 0 */ +Ratio const * +Ratio::from_ratio (float r) +{ + vector::iterator j = _ratios.begin (); + while (j != _ratios.end() && fabs ((*j)->ratio() - r) > 0.01) { + ++j; + } + + if (j == _ratios.end ()) { + return 0; + } + + return *j; +} + diff --git a/src/lib/ratio.h b/src/lib/ratio.h index 8b1a1fc71..ab157a9bc 100644 --- a/src/lib/ratio.h +++ b/src/lib/ratio.h @@ -52,6 +52,7 @@ public: static void setup_ratios (); static Ratio const * from_id (std::string i); + static Ratio const * from_ratio (float r); static std::vector all () { return _ratios; } -- cgit v1.2.3