More error message improvements.
[dcpomatic.git] / src / lib / util.cc
index 79730d3472f7584e6aaccf95b2f46712e07f421d..dd9bbb7eb0ca648d568caf66e158c7e74774ef6c 100644 (file)
@@ -34,6 +34,7 @@
 #include "cross.h"
 #include "crypto.h"
 #include "dcp_content_type.h"
+#include "dcpomatic_log.h"
 #include "digester.h"
 #include "exceptions.h"
 #include "ffmpeg_image_proxy.h"
@@ -410,8 +411,8 @@ LIBDCP_ENABLE_WARNINGS
                optional<string>(), false, false, false, dcp::Colour(), 42, 1, dcp::Time(), dcp::Time(), 0, dcp::HAlign::CENTER, 0, dcp::VAlign::CENTER, dcp::Direction::LTR,
                "Hello dolly", dcp::Effect::NONE, dcp::Colour(), dcp::Time(), dcp::Time(), 0
                );
-       subs.push_back (StringText(ss, 0));
-       render_text (subs, list<shared_ptr<Font>>(), dcp::Size(640, 480), DCPTime(), 24);
+       subs.push_back (StringText(ss, 0, {}));
+       render_text (subs, dcp::Size(640, 480), DCPTime(), 24);
 #endif
 
        Ratio::setup_ratios ();
@@ -424,6 +425,8 @@ LIBDCP_ENABLE_WARNINGS
        curl_global_init (CURL_GLOBAL_ALL);
 
        ui_thread = boost::this_thread::get_id ();
+
+       capture_asdcp_logs ();
 }
 
 #ifdef DCPOMATIC_WINDOWS
@@ -591,14 +594,14 @@ short_audio_channel_name (int c)
                _("Rs"),
                _("HI"),
                _("VI"),
-               _("Lc"),
-               _("Rc"),
+               _("9"),
+               _("10"),
                _("BsL"),
                _("BsR"),
                _("DBP"),
                _("DBS"),
                _("Sign"),
-               ""
+               _("16")
        };
 
        return channels[c];
@@ -1118,6 +1121,9 @@ default_font_file ()
        if (!boost::filesystem::exists(liberation_normal)) {
                liberation_normal = "/usr/share/fonts/truetype/liberation/LiberationSans-Regular.ttf";
        }
+       if (!boost::filesystem::exists(liberation_normal)) {
+               liberation_normal = "/usr/share/fonts/liberation-sans/LiberationSans-Regular.ttf";
+       }
 
        return liberation_normal;
 }
@@ -1148,3 +1154,36 @@ start_of_thread (string)
 }
 #endif
 
+
+class LogSink : public Kumu::ILogSink
+{
+public:
+       LogSink () {}
+       LogSink (LogSink const&) = delete;
+       LogSink& operator= (LogSink const&) = delete;
+
+       void WriteEntry(const Kumu::LogEntry& entry) override {
+               Kumu::AutoMutex L(m_lock);
+               WriteEntryToListeners(entry);
+               if (entry.TestFilter(m_filter)) {
+                       string buffer;
+                       entry.CreateStringWithOptions(buffer, m_options);
+                       LOG_GENERAL("asdcplib: %1", buffer);
+               }
+       }
+};
+
+
+void
+capture_asdcp_logs ()
+{
+       static LogSink log_sink;
+       Kumu::SetDefaultLogSink(&log_sink);
+}
+
+
+string
+error_details(boost::system::error_code ec)
+{
+       return String::compose("%1:%2:%3", ec.category().name(), ec.value(), ec.message());
+}