compose/raw_convert fiddling.
authorCarl Hetherington <cth@carlh.net>
Mon, 15 Aug 2016 13:56:42 +0000 (14:56 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 15 Aug 2016 13:56:42 +0000 (14:56 +0100)
cscript
src/lib/audio_decoder_stream.cc
src/lib/compose.hpp
src/lib/cross.cc
src/lib/cross.h
src/lib/dcp_video.cc
src/lib/encoder.cc

diff --git a/cscript b/cscript
index 4e6436ffb723f13490e3ba7b9691b7bef39701f4..434ae56a3a521e212fe16337970d0fd83fd0c92e 100644 (file)
--- a/cscript
+++ b/cscript
@@ -237,7 +237,7 @@ def dependencies(target):
         ffmpeg_options = {}
 
     return (('ffmpeg-cdist', '1d4a1a4', ffmpeg_options),
-            ('libdcp', '11777d1'),
+            ('libdcp', '943af65'),
             ('libsub', '067c21c'))
 
 def configure_options(target):
index 150e7c2429f0f329e33ee3819dc6bbbff726fa16..b7b96ddd4ad88e17b2b03057559f283a04e617da 100644 (file)
@@ -153,7 +153,7 @@ AudioDecoderStream::get (Frame frame, Frame length, bool accurate)
 void
 AudioDecoderStream::audio (shared_ptr<const AudioBuffers> data, ContentTime time)
 {
-       _log->log (String::compose ("ADS receives %1 %2", time, data->frames ()), LogEntry::TYPE_DEBUG_DECODE);
+       _log->log (String::compose ("ADS receives %1 %2", to_string(time), data->frames ()), LogEntry::TYPE_DEBUG_DECODE);
 
        if (_resampler) {
                data = _resampler->run (data);
index 425aceabf09725e135a867564c79cb3af810e5d2..2c44f148bdf05e9bb5c48e7902c15d6e7a3bf7d9 100644 (file)
@@ -34,6 +34,7 @@
 #ifndef STRING_COMPOSE_H
 #define STRING_COMPOSE_H
 
+#include <dcp/locale_convert.h>
 #include <boost/filesystem.hpp>
 #include <string>
 #include <list>
@@ -113,112 +114,11 @@ namespace StringPrivate
     }
   }
 
-  template <typename T>
-  inline void write(std::string& s, const T& obj)
-  {
-    /* Assume anything not specialized has a to_string() method */
-    s += to_string (obj);
-  }
-
-  template <>
-  inline void write(std::string& s, const int32_t& obj)
-  {
-    char buffer[64];
-#ifdef DCPOMATIC_WINDOWS
-    __mingw_snprintf(buffer, 64, "%" PRId32, obj);
-#else
-    snprintf(buffer, 64, "%" PRId32, obj);
-#endif
-    s += buffer;
-  }
-
-  template <>
-  inline void write(std::string& s, const uint32_t& obj)
-  {
-    char buffer[64];
-#ifdef DCPOMATIC_WINDOWS
-    __mingw_snprintf(buffer, 64, "%" PRIu32, obj);
-#else
-    snprintf(buffer, 64, "%" PRIu32, obj);
-#endif
-    s += buffer;
-  }
-
-  template <>
-  inline void write(std::string& s, const int64_t& obj)
-  {
-    char buffer[64];
-#ifdef DCPOMATIC_WINDOWS
-    __mingw_snprintf(buffer, 64, "%" PRId64, obj);
-#else
-    snprintf(buffer, 64, "%" PRId64, obj);
-#endif
-    s += buffer;
-  }
-
-  template <>
-  inline void write(std::string& s, const uint64_t& obj)
-  {
-    char buffer[64];
-#ifdef DCPOMATIC_WINDOWS
-    __mingw_snprintf(buffer, 64, "%" PRIu64, obj);
-#else
-    snprintf(buffer, 64, "%" PRIu64, obj);
-#endif
-    s += buffer;
-  }
-
-  template <>
-  inline void write(std::string& s, const float& obj)
-  {
-    char buffer[64];
-    snprintf(buffer, 64, "%f", obj);
-    s += buffer;
-  }
-
-  template <>
-  inline void write(std::string& s, const char& obj)
-  {
-    s += obj;
-  }
-
-  template <>
-  inline void write(std::string& s, const double& obj)
-  {
-    char buffer[64];
-    snprintf(buffer, 64, "%f", obj);
-    s += buffer;
-  }
-
-  template <>
-  inline void write(std::string& s, char const * const & obj)
-  {
-    s += obj;
-  }
-
-  template <>
-  inline void write(std::string& s, char* const & obj)
-  {
-    s += obj;
-  }
-
-  template <>
-  inline void write(std::string& s, const std::string& obj)
-  {
-    s += obj;
-  }
-
-  template <>
-  inline void write(std::string& s, const boost::filesystem::path & obj)
-  {
-    s += obj.string();
-  }
-
   // implementation of class Composition
   template <typename T>
   inline Composition &Composition::arg(const T &obj)
   {
-    write(os, obj);
+    os += dcp::locale_convert<std::string>(obj);
 
     if (!os.empty()) {         // manipulators don't produce output
       for (specification_map::const_iterator i = specs.lower_bound(arg_no), end = specs.upper_bound(arg_no); i != end; ++i) {
index 7996070982c84ec32b536d1decea82a20460bfb2..b33fa80ac81d3da7e235ded347a0088aabb744f8 100644 (file)
@@ -396,3 +396,9 @@ start_batch_converter (boost::filesystem::path dcpomatic)
        CreateProcess (0, cmd, 0, 0, FALSE, 0, 0, 0, &startup_info, &process_info);
 #endif
 }
+
+int
+thread_id ()
+{
+       return (int) pthread_self ();
+}
index 641900bc47922464b3447a59581c0c33f4faef91..6956b8efa926e25027db39e354b997346a5dbdcf 100644 (file)
@@ -48,6 +48,7 @@ extern boost::filesystem::path shared_path ();
 extern FILE * fopen_boost (boost::filesystem::path, std::string);
 extern int dcpomatic_fseek (FILE *, int64_t, int);
 extern void start_batch_converter (boost::filesystem::path dcpomatic);
+extern int thread_id ();
 
 /** @class Waker
  *  @brief A class which tries to keep the computer awake on various operating systems.
index e3ba7d20fdfb3dbec68cb4a165e00b44c6aa7522..89f541d8545d8c7333406ab73b76dbe108427aba 100644 (file)
@@ -177,17 +177,17 @@ DCPVideo::encode_remotely (EncodeServerDescription serv, int timeout)
        socket->write ((uint8_t *) xml.c_str(), xml.length() + 1);
 
        /* Send binary data */
-       LOG_TIMING("start-remote-send thread=%1", boost::this_thread::get_id());
+       LOG_TIMING("start-remote-send thread=%1", thread_id ());
        _frame->send_binary (socket);
 
        /* Read the response (JPEG2000-encoded data); this blocks until the data
           is ready and sent back.
        */
-       LOG_TIMING("start-remote-encode thread=%1", boost::this_thread::get_id ());
+       LOG_TIMING("start-remote-encode thread=%1", thread_id ());
        Data e (socket->read_uint32 ());
-       LOG_TIMING("start-remote-receive thread=%1", boost::this_thread::get_id ());
+       LOG_TIMING("start-remote-receive thread=%1", thread_id ());
        socket->read (e.data().get(), e.size());
-       LOG_TIMING("finish-remote-receive thread=%1", boost::this_thread::get_id ());
+       LOG_TIMING("finish-remote-receive thread=%1", thread_id ());
 
        LOG_DEBUG_ENCODE (N_("Finished remotely-encoded frame %1"), _index);
 
index 364d29fbed589228c60b9d304984914e944c1646..116dd5d1920472018d234dd7f535712de64d591f 100644 (file)
@@ -283,9 +283,9 @@ Encoder::encoder_thread (optional<EncodeServerDescription> server)
 try
 {
        if (server) {
-               LOG_TIMING ("start-encoder-thread thread=%1 server=%2", boost::this_thread::get_id (), server->host_name ());
+               LOG_TIMING ("start-encoder-thread thread=%1 server=%2", thread_id (), server->host_name ());
        } else {
-               LOG_TIMING ("start-encoder-thread thread=%1 server=localhost", boost::this_thread::get_id ());
+               LOG_TIMING ("start-encoder-thread thread=%1 server=localhost", thread_id ());
        }
 
        /* Number of seconds that we currently wait between attempts
@@ -296,15 +296,15 @@ try
 
        while (true) {
 
-               LOG_TIMING ("encoder-sleep thread=%1", boost::this_thread::get_id());
+               LOG_TIMING ("encoder-sleep thread=%1", thread_id ());
                boost::mutex::scoped_lock lock (_queue_mutex);
                while (_queue.empty ()) {
                        _empty_condition.wait (lock);
                }
 
-               LOG_TIMING ("encoder-wake thread=%1 queue=%2", boost::this_thread::get_id(), _queue.size());
+               LOG_TIMING ("encoder-wake thread=%1 queue=%2", thread_id(), _queue.size());
                shared_ptr<DCPVideo> vf = _queue.front ();
-               LOG_TIMING ("encoder-pop thread=%1 frame=%2 eyes=%3", boost::this_thread::get_id(), vf->index(), (int) vf->eyes ());
+               LOG_TIMING ("encoder-pop thread=%1 frame=%2 eyes=%3", thread_id(), vf->index(), (int) vf->eyes ());
                _queue.pop_front ();
 
                lock.unlock ();
@@ -336,9 +336,9 @@ try
 
                } else {
                        try {
-                               LOG_TIMING ("start-local-encode thread=%1 frame=%2", boost::this_thread::get_id(), vf->index());
+                               LOG_TIMING ("start-local-encode thread=%1 frame=%2", thread_id(), vf->index());
                                encoded = vf->encode_locally (boost::bind (&Log::dcp_log, _film->log().get(), _1, _2));
-                               LOG_TIMING ("finish-local-encode thread=%1 frame=%2", boost::this_thread::get_id(), vf->index());
+                               LOG_TIMING ("finish-local-encode thread=%1 frame=%2", thread_id(), vf->index());
                        } catch (std::exception& e) {
                                LOG_ERROR (N_("Local encode failed (%1)"), e.what ());
                                throw;
@@ -350,7 +350,7 @@ try
                        frame_done ();
                } else {
                        lock.lock ();
-                       LOG_GENERAL (N_("[%1] Encoder thread pushes frame %2 back onto queue after failure"), boost::this_thread::get_id(), vf->index());
+                       LOG_GENERAL (N_("[%1] Encoder thread pushes frame %2 back onto queue after failure"), thread_id(), vf->index());
                        _queue.push_front (vf);
                        lock.unlock ();
                }