summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-07-22 10:06:10 +0100
committerCarl Hetherington <cth@carlh.net>2016-07-22 10:06:10 +0100
commit422be0eece2bf6ee80db1d3c21553cd82efff789 (patch)
tree57604c446361be99eb092f35e703445260ada84a /src
parente34db1b3cdb5bce5ddcb112ee03664a4e463032a (diff)
Rename SafeStringStream -> locked_stringstream. Bump deps for removal of stringstream.
Diffstat (limited to 'src')
-rw-r--r--src/lib/analyse_audio_job.cc2
-rw-r--r--src/lib/audio_filter_graph.cc2
-rw-r--r--src/lib/cinema_kdms.cc6
-rw-r--r--src/lib/compose.hpp32
-rw-r--r--src/lib/content.cc4
-rw-r--r--src/lib/dcp_content.cc2
-rw-r--r--src/lib/dcpomatic_time.h4
-rw-r--r--src/lib/digester.cc4
-rw-r--r--src/lib/emailer.cc2
-rw-r--r--src/lib/encode_server.cc2
-rw-r--r--src/lib/encoded_log_entry.cc4
-rw-r--r--src/lib/environment_info.cc4
-rw-r--r--src/lib/ffmpeg_content.cc4
-rw-r--r--src/lib/ffmpeg_examiner.cc6
-rw-r--r--src/lib/film.cc8
-rw-r--r--src/lib/filter_graph.cc2
-rw-r--r--src/lib/image_content.cc4
-rw-r--r--src/lib/internet.cc4
-rw-r--r--src/lib/job.cc2
-rw-r--r--src/lib/json_server.cc4
-rw-r--r--src/lib/log.cc2
-rw-r--r--src/lib/log_entry.cc4
-rw-r--r--src/lib/raw_convert.h4
-rw-r--r--src/lib/safe_stringstream.cc24
-rw-r--r--src/lib/safe_stringstream.h121
-rw-r--r--src/lib/string_log_entry.cc2
-rw-r--r--src/lib/subtitle_content.cc4
-rw-r--r--src/lib/transcode_job.cc4
-rw-r--r--src/lib/update_checker.cc2
-rw-r--r--src/lib/util.cc6
-rw-r--r--src/lib/video_content.cc6
-rw-r--r--src/lib/video_content_scale.cc4
-rw-r--r--src/lib/video_filter_graph.cc2
-rw-r--r--src/lib/wscript1
-rw-r--r--src/tools/dcpomatic.cc2
-rw-r--r--src/tools/dcpomatic_kdm_cli.cc4
-rw-r--r--src/tools/dcpomatic_server.cc2
-rw-r--r--src/wx/colour_conversion_editor.cc10
-rw-r--r--src/wx/dolby_doremi_certificate_panel.cc2
-rw-r--r--src/wx/time_picker.cc2
40 files changed, 82 insertions, 228 deletions
diff --git a/src/lib/analyse_audio_job.cc b/src/lib/analyse_audio_job.cc
index 8d0accf0f..3e771d3f6 100644
--- a/src/lib/analyse_audio_job.cc
+++ b/src/lib/analyse_audio_job.cc
@@ -169,7 +169,7 @@ AnalyseAudioJob::analyse (shared_ptr<const AudioBuffers> b)
float s = data[i];
float as = fabsf (s);
if (as < 10e-7) {
- /* SafeStringStream can't serialise and recover inf or -inf, so prevent such
+ /* locked_stringstream can't serialise and recover inf or -inf, so prevent such
values by replacing with this (140dB down) */
s = as = 10e-7;
}
diff --git a/src/lib/audio_filter_graph.cc b/src/lib/audio_filter_graph.cc
index 87a158a4e..6b70300fc 100644
--- a/src/lib/audio_filter_graph.cc
+++ b/src/lib/audio_filter_graph.cc
@@ -56,7 +56,7 @@ AudioFilterGraph::~AudioFilterGraph()
string
AudioFilterGraph::src_parameters () const
{
- SafeStringStream a;
+ locked_stringstream a;
char buffer[64];
av_get_channel_layout_string (buffer, sizeof(buffer), 0, _channel_layout);
diff --git a/src/lib/cinema_kdms.cc b/src/lib/cinema_kdms.cc
index 84cd9c18f..f76c96283 100644
--- a/src/lib/cinema_kdms.cc
+++ b/src/lib/cinema_kdms.cc
@@ -136,9 +136,9 @@ CinemaKDMs::email (
i.make_zip_file (film_name, zip_file);
string subject = config->kdm_subject();
- SafeStringStream start;
+ locked_stringstream start;
start << from.date() << " " << from.time_of_day();
- SafeStringStream end;
+ locked_stringstream end;
end << to.date() << " " << to.time_of_day();
boost::algorithm::replace_all (subject, "$CPL_NAME", cpl_name);
boost::algorithm::replace_all (subject, "$START_TIME", start.str ());
@@ -151,7 +151,7 @@ CinemaKDMs::email (
boost::algorithm::replace_all (body, "$END_TIME", end.str ());
boost::algorithm::replace_all (body, "$CINEMA_NAME", i.cinema->name);
- SafeStringStream screens;
+ locked_stringstream screens;
BOOST_FOREACH (ScreenKDM const & j, i.screen_kdms) {
screens << j.screen->name << ", ";
}
diff --git a/src/lib/compose.hpp b/src/lib/compose.hpp
index aa67b5a1f..ebabe671a 100644
--- a/src/lib/compose.hpp
+++ b/src/lib/compose.hpp
@@ -33,10 +33,10 @@
#ifndef STRING_COMPOSE_H
#define STRING_COMPOSE_H
+#include <locked_sstream.h>
#include <string>
#include <list>
#include <map> // for multimap
-#include "safe_stringstream.h"
namespace StringPrivate
{
@@ -56,7 +56,7 @@ namespace StringPrivate
std::string str() const;
private:
- SafeStringStream os;
+ locked_stringstream os;
int arg_no;
// we store the output as a list - when the output string is requested, the
@@ -104,7 +104,7 @@ namespace StringPrivate
case '8':
case '9':
return true;
-
+
default:
return false;
}
@@ -118,21 +118,21 @@ namespace StringPrivate
os << obj;
std::string rep = os.str();
-
+
if (!rep.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) {
output_list::iterator pos = i->second;
++pos;
-
+
output.insert(pos, rep);
}
-
+
os.str(std::string());
//os.clear();
++arg_no;
}
-
+
return *this;
}
@@ -140,7 +140,7 @@ namespace StringPrivate
: arg_no(1)
{
std::string::size_type b = 0, i = 0;
-
+
// fill in output with the strings between the %1 %2 %3 etc. and
// fill in specs with the positions
while (i < fmt.length()) {
@@ -152,7 +152,7 @@ namespace StringPrivate
else if (is_number(fmt[i + 1])) { // aha! a spec!
// save string
output.push_back(fmt.substr(b, i - b));
-
+
int n = 1; // number of digits
int spec_no = 0;
@@ -165,9 +165,9 @@ namespace StringPrivate
spec_no /= 10;
output_list::iterator pos = output.end();
--pos; // safe since we have just inserted a string>
-
+
specs.insert(specification_map::value_type(spec_no, pos));
-
+
// jump over spec string
i += n;
b = i;
@@ -178,7 +178,7 @@ namespace StringPrivate
else
++i;
}
-
+
if (i - b > 0) // add the rest of the string
output.push_back(fmt.substr(b, i - b));
}
@@ -187,17 +187,17 @@ namespace StringPrivate
{
// assemble string
std::string str;
-
+
for (output_list::const_iterator i = output.begin(), end = output.end();
i != end; ++i)
str += *i;
-
+
return str;
}
}
// now for the real thing(s)
-namespace String
+namespace String
{
// a series of functions which accept a format string on the form "text %1
// more %2 less %3" and a number of templated parameters and spits out the
@@ -308,7 +308,7 @@ namespace String
.arg(o10);
return c.str();
}
-
+
template <typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6, typename T7, typename T8, typename T9, typename T10,
typename T11>
diff --git a/src/lib/content.cc b/src/lib/content.cc
index 95713d323..a56573ed2 100644
--- a/src/lib/content.cc
+++ b/src/lib/content.cc
@@ -27,10 +27,10 @@
#include "content_factory.h"
#include "exceptions.h"
#include "film.h"
-#include "safe_stringstream.h"
#include "job.h"
#include "compose.hpp"
#include "raw_convert.h"
+#include <locked_sstream.h>
#include <libcxml/cxml.h>
#include <libxml++/libxml++.h>
#include <boost/thread/mutex.hpp>
@@ -254,7 +254,7 @@ Content::length_after_trim () const
string
Content::identifier () const
{
- SafeStringStream s;
+ locked_stringstream s;
s << Content::digest()
<< "_" << position().get()
diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc
index ca809df61..431492c7a 100644
--- a/src/lib/dcp_content.cc
+++ b/src/lib/dcp_content.cc
@@ -239,7 +239,7 @@ DCPContent::full_length () const
string
DCPContent::identifier () const
{
- SafeStringStream s;
+ locked_stringstream s;
s << Content::identifier() << "_" << video->identifier() << "_";
if (subtitle) {
s << subtitle->identifier () << " ";
diff --git a/src/lib/dcpomatic_time.h b/src/lib/dcpomatic_time.h
index c538357cc..e6ca493b2 100644
--- a/src/lib/dcpomatic_time.h
+++ b/src/lib/dcpomatic_time.h
@@ -26,8 +26,8 @@
#define DCPOMATIC_TIME_H
#include "frame_rate_change.h"
-#include "safe_stringstream.h"
#include "dcpomatic_assert.h"
+#include <locked_sstream.h>
#include <stdint.h>
#include <cmath>
#include <ostream>
@@ -181,7 +181,7 @@ public:
int f;
split (r, h, m, s, f);
- SafeStringStream o;
+ locked_stringstream o;
o.width (2);
o.fill ('0');
o << std::setw(2) << std::setfill('0') << h << ":"
diff --git a/src/lib/digester.cc b/src/lib/digester.cc
index 66e617de8..70c2babf5 100644
--- a/src/lib/digester.cc
+++ b/src/lib/digester.cc
@@ -19,7 +19,7 @@
*/
#include "digester.h"
-#include "safe_stringstream.h"
+#include <locked_sstream.h>
#include <nettle/md5.h>
#include <iomanip>
@@ -57,7 +57,7 @@ Digester::get () const
unsigned char digest[MD5_DIGEST_SIZE];
md5_digest (&_context, MD5_DIGEST_SIZE, digest);
- SafeStringStream s;
+ locked_stringstream s;
for (int i = 0; i < MD5_DIGEST_SIZE; ++i) {
s << hex << setfill('0') << setw(2) << ((int) digest[i]);
}
diff --git a/src/lib/emailer.cc b/src/lib/emailer.cc
index 5e645457d..71b29db1e 100644
--- a/src/lib/emailer.cc
+++ b/src/lib/emailer.cc
@@ -103,7 +103,7 @@ Emailer::send (string server, int port, string user, string password)
boost::posix_time::time_duration offset = local_now - utc_now;
sprintf (date_buffer + strlen(date_buffer), "%s%02d%02d", (offset.hours() >= 0 ? "+" : "-"), abs (offset.hours()), offset.minutes());
- SafeStringStream email;
+ locked_stringstream email;
email << "Date: " << date_buffer << "\r\n"
<< "To: " << address_list (_to) << "\r\n"
diff --git a/src/lib/encode_server.cc b/src/lib/encode_server.cc
index 7e0152003..cf5ec651a 100644
--- a/src/lib/encode_server.cc
+++ b/src/lib/encode_server.cc
@@ -31,11 +31,11 @@
#include "config.h"
#include "cross.h"
#include "player_video.h"
-#include "safe_stringstream.h"
#include "raw_convert.h"
#include "compose.hpp"
#include "log.h"
#include "encoded_log_entry.h"
+#include <locked_sstream.h>
#include <libcxml/cxml.h>
#include <libxml++/libxml++.h>
#include <boost/algorithm/string.hpp>
diff --git a/src/lib/encoded_log_entry.cc b/src/lib/encoded_log_entry.cc
index 3409319ac..84c7a6ca6 100644
--- a/src/lib/encoded_log_entry.cc
+++ b/src/lib/encoded_log_entry.cc
@@ -19,7 +19,7 @@
*/
#include "encoded_log_entry.h"
-#include "safe_stringstream.h"
+#include <locked_sstream.h>
using std::string;
using std::fixed;
@@ -38,7 +38,7 @@ EncodedLogEntry::EncodedLogEntry (int frame, string ip, double receive, double e
string
EncodedLogEntry::message () const
{
- SafeStringStream m;
+ locked_stringstream m;
m.precision (2);
m << fixed
<< "Encoded frame " << _frame << " from " << _ip << ": "
diff --git a/src/lib/environment_info.cc b/src/lib/environment_info.cc
index 810e24d66..eb241d512 100644
--- a/src/lib/environment_info.cc
+++ b/src/lib/environment_info.cc
@@ -57,7 +57,7 @@ static
string
ffmpeg_version_to_string (int v)
{
- SafeStringStream s;
+ locked_stringstream s;
s << ((v & 0xff0000) >> 16) << N_(".") << ((v & 0xff00) >> 8) << N_(".") << (v & 0xff);
return s.str ();
}
@@ -68,7 +68,7 @@ static
string
dependency_version_summary ()
{
- SafeStringStream s;
+ locked_stringstream s;
s << N_("libavcodec ") << ffmpeg_version_to_string (avcodec_version()) << N_(", ")
<< N_("libavfilter ") << ffmpeg_version_to_string (avfilter_version()) << N_(", ")
<< N_("libavformat ") << ffmpeg_version_to_string (avformat_version()) << N_(", ")
diff --git a/src/lib/ffmpeg_content.cc b/src/lib/ffmpeg_content.cc
index 76ee663ff..60c777b3c 100644
--- a/src/lib/ffmpeg_content.cc
+++ b/src/lib/ffmpeg_content.cc
@@ -32,9 +32,9 @@
#include "log.h"
#include "exceptions.h"
#include "frame_rate_change.h"
-#include "safe_stringstream.h"
#include "raw_convert.h"
#include "subtitle_content.h"
+#include <locked_sstream.h>
#include <libcxml/cxml.h>
extern "C" {
#include <libavformat/avformat.h>
@@ -388,7 +388,7 @@ FFmpegContent::set_filters (vector<Filter const *> const & filters)
string
FFmpegContent::identifier () const
{
- SafeStringStream s;
+ locked_stringstream s;
s << Content::identifier();
diff --git a/src/lib/ffmpeg_examiner.cc b/src/lib/ffmpeg_examiner.cc
index 18a87f40e..544cc11b9 100644
--- a/src/lib/ffmpeg_examiner.cc
+++ b/src/lib/ffmpeg_examiner.cc
@@ -30,7 +30,7 @@ extern "C" {
#include "ffmpeg_audio_stream.h"
#include "ffmpeg_subtitle_stream.h"
#include "util.h"
-#include "safe_stringstream.h"
+#include <locked_sstream.h>
#include <boost/foreach.hpp>
#include <iostream>
@@ -351,7 +351,7 @@ FFmpegExaminer::sample_aspect_ratio () const
string
FFmpegExaminer::subtitle_stream_name (AVStream* s) const
{
- SafeStringStream n;
+ locked_stringstream n;
n << stream_name (s);
@@ -365,7 +365,7 @@ FFmpegExaminer::subtitle_stream_name (AVStream* s) const
string
FFmpegExaminer::stream_name (AVStream* s) const
{
- SafeStringStream n;
+ locked_stringstream n;
if (s->metadata) {
AVDictionaryEntry const * lang = av_dict_get (s->metadata, "language", 0, 0);
diff --git a/src/lib/film.cc b/src/lib/film.cc
index 6764a5be6..0138211cf 100644
--- a/src/lib/film.cc
+++ b/src/lib/film.cc
@@ -38,7 +38,6 @@
#include "dcp_content_type.h"
#include "ratio.h"
#include "cross.h"
-#include "safe_stringstream.h"
#include "environment_info.h"
#include "raw_convert.h"
#include "audio_processor.h"
@@ -52,6 +51,7 @@
#include "dcp_content.h"
#include "screen_kdm.h"
#include "cinema.h"
+#include <locked_sstream.h>
#include <libcxml/cxml.h>
#include <dcp/cpl.h>
#include <dcp/certificate_chain.h>
@@ -197,7 +197,7 @@ Film::video_identifier () const
{
DCPOMATIC_ASSERT (container ());
- SafeStringStream s;
+ locked_stringstream s;
s.imbue (std::locale::classic ());
s << container()->id()
@@ -530,7 +530,7 @@ Film::mapped_audio_channels () const
string
Film::isdcf_name (bool if_created_now) const
{
- SafeStringStream d;
+ locked_stringstream d;
string raw_name = name ();
@@ -922,7 +922,7 @@ Film::j2c_path (int reel, Frame frame, Eyes eyes, bool tmp) const
p /= "j2c";
p /= video_identifier ();
- SafeStringStream s;
+ locked_stringstream s;
s.width (8);
s << setfill('0') << reel << "_" << frame;
diff --git a/src/lib/filter_graph.cc b/src/lib/filter_graph.cc
index db89d1695..d918f7dc8 100644
--- a/src/lib/filter_graph.cc
+++ b/src/lib/filter_graph.cc
@@ -26,7 +26,7 @@
#include "filter.h"
#include "exceptions.h"
#include "image.h"
-#include "safe_stringstream.h"
+#include <locked_sstream.h>
#include "compose.hpp"
extern "C" {
#include <libavfilter/avfiltergraph.h>
diff --git a/src/lib/image_content.cc b/src/lib/image_content.cc
index d4e736771..08b9fd6ae 100644
--- a/src/lib/image_content.cc
+++ b/src/lib/image_content.cc
@@ -26,8 +26,8 @@
#include "job.h"
#include "frame_rate_change.h"
#include "exceptions.h"
-#include "safe_stringstream.h"
#include "image_filename_sorter.h"
+#include <locked_sstream.h>
#include <libcxml/cxml.h>
#include <libxml++/libxml++.h>
#include <boost/foreach.hpp>
@@ -136,7 +136,7 @@ ImageContent::full_length () const
string
ImageContent::identifier () const
{
- SafeStringStream s;
+ locked_stringstream s;
s << Content::identifier();
s << "_" << video->identifier ();
s << "_" << video->length();
diff --git a/src/lib/internet.cc b/src/lib/internet.cc
index 5a909e470..c0a29bfbd 100644
--- a/src/lib/internet.cc
+++ b/src/lib/internet.cc
@@ -20,8 +20,8 @@
#include "scoped_temporary.h"
#include "compose.hpp"
-#include "safe_stringstream.h"
#include "exceptions.h"
+#include <locked_sstream.h>
#include <curl/curl.h>
#include <zip.h>
#include <boost/function.hpp>
@@ -149,7 +149,7 @@ ftp_ls (string url, bool pasv)
throw NetworkError (curl_easy_strerror (r));
}
- SafeStringStream s (ls_raw);
+ locked_stringstream s (ls_raw);
list<string> ls;
while (s.good ()) {
string line = s.getline ();
diff --git a/src/lib/job.cc b/src/lib/job.cc
index b316cddf7..585e8fb0d 100644
--- a/src/lib/job.cc
+++ b/src/lib/job.cc
@@ -376,7 +376,7 @@ Job::status () const
int const t = elapsed_sub_time ();
int const r = remaining_time ();
- SafeStringStream s;
+ locked_stringstream s;
if (!finished () && p) {
int pc = lrintf (p.get() * 100);
if (pc == 100) {
diff --git a/src/lib/json_server.cc b/src/lib/json_server.cc
index 0006201e6..4af133875 100644
--- a/src/lib/json_server.cc
+++ b/src/lib/json_server.cc
@@ -151,7 +151,7 @@ JSONServer::request (string url, shared_ptr<tcp::socket> socket)
action = r["action"];
}
- SafeStringStream json;
+ locked_stringstream json;
if (action == "status") {
list<shared_ptr<Job> > jobs = JobManager::instance()->get ();
@@ -187,7 +187,7 @@ JSONServer::request (string url, shared_ptr<tcp::socket> socket)
}
}
- SafeStringStream reply;
+ locked_stringstream reply;
reply << "HTTP/1.1 200 OK\r\n"
<< "Content-Length: " << json.str().length() << "\r\n"
<< "Content-Type: application/json\r\n"
diff --git a/src/lib/log.cc b/src/lib/log.cc
index b7edd4e29..c8ba74f23 100644
--- a/src/lib/log.cc
+++ b/src/lib/log.cc
@@ -25,8 +25,8 @@
#include "log.h"
#include "cross.h"
#include "config.h"
-#include "safe_stringstream.h"
#include "string_log_entry.h"
+#include <locked_sstream.h>
#include <time.h>
#include <cstdio>
diff --git a/src/lib/log_entry.cc b/src/lib/log_entry.cc
index 50796b69a..53605c389 100644
--- a/src/lib/log_entry.cc
+++ b/src/lib/log_entry.cc
@@ -19,7 +19,7 @@
*/
#include "log_entry.h"
-#include "safe_stringstream.h"
+#include <locked_sstream.h>
#include "i18n.h"
@@ -42,7 +42,7 @@ LogEntry::LogEntry (int type)
string
LogEntry::get () const
{
- SafeStringStream s;
+ locked_stringstream s;
if (_type & TYPE_TIMING) {
s << _time.tv_sec << ":" << _time.tv_usec << " ";
} else {
diff --git a/src/lib/raw_convert.h b/src/lib/raw_convert.h
index 46b7d0dff..92d8e3d32 100644
--- a/src/lib/raw_convert.h
+++ b/src/lib/raw_convert.h
@@ -21,7 +21,7 @@
#ifndef DCPOMATIC_RAW_CONVERT_H
#define DCPOMATIC_RAW_CONVERT_H
-#include "safe_stringstream.h"
+#include <locked_sstream.h>
#include <iomanip>
/** A sort-of version of boost::lexical_cast that does uses the "C"
@@ -31,7 +31,7 @@ template <typename P, typename Q>
P
raw_convert (Q v, int precision = 16)
{
- SafeStringStream s;
+ locked_stringstream s;
s.imbue (std::locale::classic ());
s << std::setprecision (precision);
s << v;
diff --git a/src/lib/safe_stringstream.cc b/src/lib/safe_stringstream.cc
deleted file mode 100644
index c8864bd95..000000000
--- a/src/lib/safe_stringstream.cc
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
-
- This file is part of DCP-o-matic.
-
- DCP-o-matic 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.
-
- DCP-o-matic 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 DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#include <boost/thread/mutex.hpp>
-#include "safe_stringstream.h"
-
-boost::mutex SafeStringStream::_mutex;
diff --git a/src/lib/safe_stringstream.h b/src/lib/safe_stringstream.h
deleted file mode 100644
index bf8407bad..000000000
--- a/src/lib/safe_stringstream.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
-
- This file is part of DCP-o-matic.
-
- DCP-o-matic 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.
-
- DCP-o-matic 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 DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#ifndef DCPOMATIC_SAFE_STRINGSTREAM_H
-#define DCPOMATIC_SAFE_STRINGSTREAM_H
-
-#include <boost/thread/mutex.hpp>
-
-/* I've not been able to reproduce it, but there have been reports that DCP-o-matic crashes
- * on OS X with two simultaneous backtraces that look like this:
- *
- * 0 libSystem.B.dylib 0x00007fff84ebe264 __numeric_load_locale + 125
- * 1 libSystem.B.dylib 0x00007fff84e2aac4 loadlocale + 323
- * 2 libstdc++.6.dylib 0x00007fff8976ba69 std::__convert_from_v(int* const&, char*, int, char const*, ...) + 199
- * 3 libstdc++.6.dylib 0x00007fff8974e99b std::ostreambuf_iterator<char, std::char_traits<char> > std::num_put<char, std::ostreambuf_iterator<char,
-std::char_traits<char> > >::_M_insert_float<double>(std::ostreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, char, char, double) const + 199
- * 4 libstdc++.6.dylib 0x00007fff8974ebc0 std::num_put<char, std::ostreambuf_iterator<char, std::char_traits<char> >
->::do_put(std::ostreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, char, double) const + 28
- * 5 libstdc++.6.dylib 0x00007fff897566a2 std::ostream& std::ostream::_M_insert<double>(double) + 178
- * 6 libdcpomatic.dylib 0x0000000100331e21 StringPrivate::Composition& StringPrivate::Composition::arg<float>(float const&) + 33
- *
- * in two different threads. I'm assuming that for some bizarre reason it is unsafe to use two separate stringstream
- * objects in different threads on OS X. This is a hack to work around it.
- */
-
-class SafeStringStream
-{
-public:
- SafeStringStream ()
- {}
-
- SafeStringStream (std::string s)
- : _stream (s)
- {}
-
- template <class T>
- std::ostream& operator<< (T val)
- {
- boost::mutex::scoped_lock lm (_mutex);
- _stream << val;
- return _stream;
- }
-
- template <class T>
- std::istream& operator>> (T& val)
- {
- boost::mutex::scoped_lock lm (_mutex);
- _stream >> val;
- return _stream;
- }
-
- std::string str () const {
- return _stream.str ();
- }
-
- void str (std::string const & s) {
- _stream.str (s);
- }
-
- void imbue (std::locale const & loc)
- {
- boost::mutex::scoped_lock lm (_mutex);
- _stream.imbue (loc);
- }
-
- void width (int w)
- {
- _stream.width (w);
- }
-
- void fill (int f)
- {
- _stream.fill (f);
- }
-
- void precision (int p)
- {
- _stream.precision (p);
- }
-
- bool good () const
- {
- return _stream.good ();
- }
-
- std::string getline ()
- {
- boost::mutex::scoped_lock lm (_mutex);
- std::string s;
- std::getline (_stream, s);
- return s;
- }
-
- void setf (std::ios_base::fmtflags flags, std::ios_base::fmtflags mask)
- {
- _stream.setf (flags, mask);
- }
-
-private:
- static boost::mutex _mutex;
- std::stringstream _stream;
-};
-
-#endif
diff --git a/src/lib/string_log_entry.cc b/src/lib/string_log_entry.cc
index 517ca090c..69c1130fb 100644
--- a/src/lib/string_log_entry.cc
+++ b/src/lib/string_log_entry.cc
@@ -19,7 +19,7 @@
*/
#include "string_log_entry.h"
-#include "safe_stringstream.h"
+#include <locked_sstream.h>
#include "i18n.h"
diff --git a/src/lib/subtitle_content.cc b/src/lib/subtitle_content.cc
index 2376aac68..422bb6565 100644
--- a/src/lib/subtitle_content.cc
+++ b/src/lib/subtitle_content.cc
@@ -21,10 +21,10 @@
#include "subtitle_content.h"
#include "util.h"
#include "exceptions.h"
-#include "safe_stringstream.h"
#include "font.h"
#include "raw_convert.h"
#include "content.h"
+#include <locked_sstream.h>
#include <libcxml/cxml.h>
#include <libxml++/libxml++.h>
#include <boost/foreach.hpp>
@@ -249,7 +249,7 @@ SubtitleContent::as_xml (xmlpp::Node* root) const
string
SubtitleContent::identifier () const
{
- SafeStringStream s;
+ locked_stringstream s;
s << raw_convert<string> (x_scale())
<< "_" << raw_convert<string> (y_scale())
<< "_" << raw_convert<string> (x_offset())
diff --git a/src/lib/transcode_job.cc b/src/lib/transcode_job.cc
index fe7132699..8e5660330 100644
--- a/src/lib/transcode_job.cc
+++ b/src/lib/transcode_job.cc
@@ -28,7 +28,7 @@
#include "film.h"
#include "transcoder.h"
#include "log.h"
-#include "safe_stringstream.h"
+#include <locked_sstream.h>
#include "compose.hpp"
#include <iostream>
#include <iomanip>
@@ -112,7 +112,7 @@ TranscodeJob::status () const
return Job::status ();
}
- SafeStringStream s;
+ locked_stringstream s;
s << Job::status ();
diff --git a/src/lib/update_checker.cc b/src/lib/update_checker.cc
index 58bc7c1b7..e6ee851a0 100644
--- a/src/lib/update_checker.cc
+++ b/src/lib/update_checker.cc
@@ -20,9 +20,9 @@
#include "update_checker.h"
#include "version.h"
-#include "safe_stringstream.h"
#include "util.h"
#include "raw_convert.h"
+#include <locked_sstream.h>
#include <libcxml/cxml.h>
#include <curl/curl.h>
#include <boost/algorithm/string.hpp>
diff --git a/src/lib/util.cc b/src/lib/util.cc
index f3795c264..4a0965858 100644
--- a/src/lib/util.cc
+++ b/src/lib/util.cc
@@ -35,8 +35,8 @@
#include "rect.h"
#include "digester.h"
#include "audio_processor.h"
-#include "safe_stringstream.h"
#include "compose.hpp"
+#include <locked_sstream.h>
#include <dcp/util.h>
#include <dcp/picture_asset.h>
#include <dcp/sound_asset.h>
@@ -115,7 +115,7 @@ seconds_to_hms (int s)
int h = m / 60;
m -= (h * 60);
- SafeStringStream hms;
+ locked_stringstream hms;
hms << h << N_(":");
hms.width (2);
hms << setfill ('0') << m << N_(":");
@@ -136,7 +136,7 @@ seconds_to_approximate_hms (int s)
int h = m / 60;
m -= (h * 60);
- SafeStringStream ap;
+ locked_stringstream ap;
bool const hours = h > 0;
bool const minutes = h < 6 && m > 0;
diff --git a/src/lib/video_content.cc b/src/lib/video_content.cc
index a59e9669d..335f8c6db 100644
--- a/src/lib/video_content.cc
+++ b/src/lib/video_content.cc
@@ -30,8 +30,8 @@
#include "exceptions.h"
#include "frame_rate_change.h"
#include "log.h"
-#include "safe_stringstream.h"
#include "raw_convert.h"
+#include <locked_sstream.h>
#include <libcxml/cxml.h>
#include <dcp/colour_matrix.h>
#include <libxml++/libxml++.h>
@@ -264,7 +264,7 @@ VideoContent::take_from_examiner (shared_ptr<VideoExaminer> d)
string
VideoContent::identifier () const
{
- SafeStringStream s;
+ locked_stringstream s;
s << crop().left
<< "_" << crop().right
<< "_" << crop().top
@@ -377,7 +377,7 @@ string
VideoContent::processing_description () const
{
/* stringstream is OK here as this string is just for presentation to the user */
- SafeStringStream d;
+ locked_stringstream d;
if (size().width && size().height) {
d << String::compose (
diff --git a/src/lib/video_content_scale.cc b/src/lib/video_content_scale.cc
index a1673d3de..47ceab5d1 100644
--- a/src/lib/video_content_scale.cc
+++ b/src/lib/video_content_scale.cc
@@ -21,8 +21,8 @@
#include "video_content_scale.h"
#include "video_content.h"
#include "ratio.h"
-#include "safe_stringstream.h"
#include "util.h"
+#include <locked_sstream.h>
#include <libcxml/cxml.h>
#include <libxml++/libxml++.h>
#include <boost/optional.hpp>
@@ -85,7 +85,7 @@ VideoContentScale::as_xml (xmlpp::Node* node) const
string
VideoContentScale::id () const
{
- SafeStringStream s;
+ locked_stringstream s;
if (_ratio) {
s << _ratio->id ();
diff --git a/src/lib/video_filter_graph.cc b/src/lib/video_filter_graph.cc
index 023226110..3549e0947 100644
--- a/src/lib/video_filter_graph.cc
+++ b/src/lib/video_filter_graph.cc
@@ -84,7 +84,7 @@ VideoFilterGraph::can_process (dcp::Size s, AVPixelFormat p) const
string
VideoFilterGraph::src_parameters () const
{
- SafeStringStream a;
+ locked_stringstream a;
a << "video_size=" << _size.width << "x" << _size.height << ":"
<< "pix_fmt=" << _pixel_format << ":"
diff --git a/src/lib/wscript b/src/lib/wscript
index f5de27bf4..9883f31d6 100644
--- a/src/lib/wscript
+++ b/src/lib/wscript
@@ -110,7 +110,6 @@ sources = """
render_subtitles.cc
resampler.cc
rgba.cc
- safe_stringstream.cc
scoped_temporary.cc
scp_uploader.cc
screen.cc
diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc
index 88310ad3e..ac5b8a544 100644
--- a/src/tools/dcpomatic.cc
+++ b/src/tools/dcpomatic.cc
@@ -927,7 +927,7 @@ private:
}
for (size_t i = 0; i < history.size(); ++i) {
- SafeStringStream s;
+ locked_stringstream s;
if (i < 9) {
s << "&" << (i + 1) << " ";
}
diff --git a/src/tools/dcpomatic_kdm_cli.cc b/src/tools/dcpomatic_kdm_cli.cc
index df828416f..4c527ee0c 100644
--- a/src/tools/dcpomatic_kdm_cli.cc
+++ b/src/tools/dcpomatic_kdm_cli.cc
@@ -29,7 +29,7 @@
#include "lib/config.h"
#include "lib/exceptions.h"
#include "lib/emailer.h"
-#include "lib/safe_stringstream.h"
+#include <locked_sstream.h>
#include <dcp/certificate.h>
#include <getopt.h>
#include <iostream>
@@ -82,7 +82,7 @@ time_from_string (string t)
static boost::posix_time::time_duration
duration_from_string (string d)
{
- SafeStringStream s (d);
+ locked_stringstream s (d);
int N;
string unit;
s >> N >> unit;
diff --git a/src/tools/dcpomatic_server.cc b/src/tools/dcpomatic_server.cc
index a23e56ccd..08a04f35c 100644
--- a/src/tools/dcpomatic_server.cc
+++ b/src/tools/dcpomatic_server.cc
@@ -191,7 +191,7 @@ private:
void update_state ()
{
- SafeStringStream s;
+ locked_stringstream s;
s << fixed << setprecision(1) << server_log->fps ();
_fps->SetLabel (std_to_wx (s.str()));
}
diff --git a/src/wx/colour_conversion_editor.cc b/src/wx/colour_conversion_editor.cc
index 01b1ca056..79365bf88 100644
--- a/src/wx/colour_conversion_editor.cc
+++ b/src/wx/colour_conversion_editor.cc
@@ -19,10 +19,10 @@
*/
#include "lib/colour_conversion.h"
-#include "lib/safe_stringstream.h"
#include "lib/raw_convert.h"
#include "wx_util.h"
#include "colour_conversion_editor.h"
+#include <locked_sstream.h>
#include <dcp/gamma_transfer_function.h>
#include <dcp/modified_gamma_transfer_function.h>
#include <wx/spinctrl.h>
@@ -247,7 +247,7 @@ ColourConversionEditor::set (ColourConversion conversion)
_ignore_chromaticity_changed = true;
- SafeStringStream s;
+ locked_stringstream s;
s.setf (std::ios::fixed, std::ios::floatfield);
s.precision (6);
@@ -394,7 +394,7 @@ ColourConversionEditor::update_bradford ()
boost::numeric::ublas::matrix<double> m = get().bradford ();
for (int i = 0; i < 3; ++i) {
for (int j = 0; j < 3; ++j) {
- SafeStringStream s;
+ locked_stringstream s;
s.setf (std::ios::fixed, std::ios::floatfield);
s.precision (7);
s << m (i, j);
@@ -409,7 +409,7 @@ ColourConversionEditor::update_rgb_to_xyz ()
boost::numeric::ublas::matrix<double> m = get().rgb_to_xyz ();
for (int i = 0; i < 3; ++i) {
for (int j = 0; j < 3; ++j) {
- SafeStringStream s;
+ locked_stringstream s;
s.setf (std::ios::fixed, std::ios::floatfield);
s.precision (7);
s << m (i, j);
@@ -442,7 +442,7 @@ ColourConversionEditor::set_spin_ctrl (wxSpinCtrlDouble* control, double value)
void
ColourConversionEditor::set_text_ctrl (wxTextCtrl* control, double value)
{
- SafeStringStream s;
+ locked_stringstream s;
s.precision (7);
s << value;
control->SetValue (std_to_wx (s.str ()));
diff --git a/src/wx/dolby_doremi_certificate_panel.cc b/src/wx/dolby_doremi_certificate_panel.cc
index c4238319c..fcff93a06 100644
--- a/src/wx/dolby_doremi_certificate_panel.cc
+++ b/src/wx/dolby_doremi_certificate_panel.cc
@@ -205,7 +205,7 @@ DolbyDoremiCertificatePanel::finish_download (string serial, wxStaticText* messa
} else {
message->SetLabel (wxT (""));
- SafeStringStream s;
+ locked_stringstream s;
BOOST_FOREACH (string e, errors) {
s << e << "\n";
}
diff --git a/src/wx/time_picker.cc b/src/wx/time_picker.cc
index 0853e4fcb..a18182138 100644
--- a/src/wx/time_picker.cc
+++ b/src/wx/time_picker.cc
@@ -82,7 +82,7 @@ TimePicker::update_text ()
_hours->SetValue (std_to_wx (raw_convert<string> (_hours_spin->GetValue ())));
- SafeStringStream m;
+ locked_stringstream m;
m << setfill('0') << setw(2) << _minutes_spin->GetValue();
_minutes->SetValue (std_to_wx (m.str()));