summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-08-15 14:56:42 +0100
committerCarl Hetherington <cth@carlh.net>2016-08-15 14:56:42 +0100
commit8e96f8c1677146d224438ec040982532879d6c34 (patch)
tree9326d2610eaa8c8173037e20cf0d41fe8ded5e22 /src/lib
parent385c33e658479ebc1f6975efc5662ba7acd2877d (diff)
compose/raw_convert fiddling.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/audio_decoder_stream.cc2
-rw-r--r--src/lib/compose.hpp104
-rw-r--r--src/lib/cross.cc6
-rw-r--r--src/lib/cross.h1
-rw-r--r--src/lib/dcp_video.cc8
-rw-r--r--src/lib/encoder.cc16
6 files changed, 22 insertions, 115 deletions
diff --git a/src/lib/audio_decoder_stream.cc b/src/lib/audio_decoder_stream.cc
index 150e7c242..b7b96ddd4 100644
--- a/src/lib/audio_decoder_stream.cc
+++ b/src/lib/audio_decoder_stream.cc
@@ -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);
diff --git a/src/lib/compose.hpp b/src/lib/compose.hpp
index 425aceabf..2c44f148b 100644
--- a/src/lib/compose.hpp
+++ b/src/lib/compose.hpp
@@ -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) {
diff --git a/src/lib/cross.cc b/src/lib/cross.cc
index 799607098..b33fa80ac 100644
--- a/src/lib/cross.cc
+++ b/src/lib/cross.cc
@@ -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 ();
+}
diff --git a/src/lib/cross.h b/src/lib/cross.h
index 641900bc4..6956b8efa 100644
--- a/src/lib/cross.h
+++ b/src/lib/cross.h
@@ -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.
diff --git a/src/lib/dcp_video.cc b/src/lib/dcp_video.cc
index e3ba7d20f..89f541d85 100644
--- a/src/lib/dcp_video.cc
+++ b/src/lib/dcp_video.cc
@@ -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);
diff --git a/src/lib/encoder.cc b/src/lib/encoder.cc
index 364d29fbe..116dd5d19 100644
--- a/src/lib/encoder.cc
+++ b/src/lib/encoder.cc
@@ -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 ();
}