diff options
| author | Carl Hetherington <cth@carlh.net> | 2020-07-27 21:47:26 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2020-07-27 21:47:26 +0200 |
| commit | 2da4caba7871455c097c0ed940dd6f2332dbda5d (patch) | |
| tree | f87883d0fcfe4c19ae5f7490306d49cc4f5d02b3 /src/lib | |
| parent | 94aadbd62c259a73d7511522dd167d519c68c5f9 (diff) | |
| parent | 5d440e1133fc68dfffeaf53cf934b996dae811c7 (diff) | |
Merge branch 'warnings' into v2.15.x.
Clean up our handling of compiler warnings in a variety of ways,
and use #pragma rather than -Wno to only disable warnings where
necessary.
Diffstat (limited to 'src/lib')
45 files changed, 248 insertions, 31 deletions
diff --git a/src/lib/analyse_audio_job.h b/src/lib/analyse_audio_job.h index f7cc3e256..8f88b0fa1 100644 --- a/src/lib/analyse_audio_job.h +++ b/src/lib/analyse_audio_job.h @@ -66,8 +66,8 @@ private: dcpomatic::DCPTime _start; bool _from_zero; - int64_t _done; - int64_t _samples_per_point; + Frame _done; + Frame _samples_per_point; AudioPoint* _current; float* _sample_peak; diff --git a/src/lib/analytics.cc b/src/lib/analytics.cc index 34f67116e..f20b213e4 100644 --- a/src/lib/analytics.cc +++ b/src/lib/analytics.cc @@ -21,9 +21,12 @@ #include "analytics.h" #include "exceptions.h" #include "compose.hpp" +#include "warnings.h" #include <dcp/raw_convert.h> #include <libcxml/cxml.h> +DCPOMATIC_DISABLE_WARNINGS #include <libxml++/libxml++.h> +DCPOMATIC_ENABLE_WARNINGS #include <boost/filesystem.hpp> #include <boost/algorithm/string.hpp> diff --git a/src/lib/atmos_content.cc b/src/lib/atmos_content.cc index 2e59b92b7..0543437a3 100644 --- a/src/lib/atmos_content.cc +++ b/src/lib/atmos_content.cc @@ -20,8 +20,11 @@ #include "atmos_content.h" +#include "warnings.h" #include <dcp/raw_convert.h> +DCPOMATIC_DISABLE_WARNINGS #include <libxml++/libxml++.h> +DCPOMATIC_ENABLE_WARNINGS using std::string; diff --git a/src/lib/audio_analysis.cc b/src/lib/audio_analysis.cc index 446fcccef..f69bcd362 100644 --- a/src/lib/audio_analysis.cc +++ b/src/lib/audio_analysis.cc @@ -23,8 +23,11 @@ #include "util.h" #include "playlist.h" #include "audio_content.h" +#include "warnings.h" #include <dcp/raw_convert.h> +DCPOMATIC_DISABLE_WARNINGS #include <libxml++/libxml++.h> +DCPOMATIC_ENABLE_WARNINGS #include <boost/filesystem.hpp> #include <boost/foreach.hpp> #include <stdint.h> diff --git a/src/lib/audio_mapping.cc b/src/lib/audio_mapping.cc index 05dfb7e89..94efbe49b 100644 --- a/src/lib/audio_mapping.cc +++ b/src/lib/audio_mapping.cc @@ -19,12 +19,15 @@ */ #include "audio_mapping.h" -#include "util.h" -#include "digester.h" #include "audio_processor.h" +#include "digester.h" +#include "util.h" +#include "warnings.h" #include <dcp/raw_convert.h> #include <libcxml/cxml.h> +DCPOMATIC_DISABLE_WARNINGS #include <libxml++/libxml++.h> +DCPOMATIC_ENABLE_WARNINGS #include <boost/regex.hpp> #include <iostream> diff --git a/src/lib/audio_point.cc b/src/lib/audio_point.cc index b5ea2c31e..722673b96 100644 --- a/src/lib/audio_point.cc +++ b/src/lib/audio_point.cc @@ -19,8 +19,11 @@ */ #include "audio_point.h" +#include "warnings.h" #include <dcp/raw_convert.h> +DCPOMATIC_DISABLE_WARNINGS #include <libxml++/libxml++.h> +DCPOMATIC_ENABLE_WARNINGS using std::string; using dcp::raw_convert; diff --git a/src/lib/cinema_sound_processor.cc b/src/lib/cinema_sound_processor.cc index 1a3ba5a0f..bd60f7d71 100644 --- a/src/lib/cinema_sound_processor.cc +++ b/src/lib/cinema_sound_processor.cc @@ -107,7 +107,7 @@ CinemaSoundProcessor::as_index (CinemaSoundProcessor const * s) CinemaSoundProcessor const * CinemaSoundProcessor::from_index (int i) { - DCPOMATIC_ASSERT (i <= int(_cinema_sound_processors.size ())); + DCPOMATIC_ASSERT (i >= 0 && i < int(_cinema_sound_processors.size())); return _cinema_sound_processors[i]; } diff --git a/src/lib/colour_conversion.cc b/src/lib/colour_conversion.cc index 2e052060e..22404c279 100644 --- a/src/lib/colour_conversion.cc +++ b/src/lib/colour_conversion.cc @@ -22,6 +22,7 @@ #include "colour_conversion.h" #include "util.h" #include "digester.h" +#include "warnings.h" #include <dcp/raw_convert.h> #include <dcp/chromaticity.h> #include <dcp/gamma_transfer_function.h> @@ -29,7 +30,9 @@ #include <dcp/identity_transfer_function.h> #include <dcp/s_gamut3_transfer_function.h> #include <libcxml/cxml.h> +DCPOMATIC_DISABLE_WARNINGS #include <libxml++/libxml++.h> +DCPOMATIC_ENABLE_WARNINGS #include <boost/foreach.hpp> #include <iostream> diff --git a/src/lib/cross.h b/src/lib/cross.h index 4d3d2b2c7..64cb2e6b8 100644 --- a/src/lib/cross.h +++ b/src/lib/cross.h @@ -40,12 +40,13 @@ class Log; struct AVIOContext; -void dcpomatic_sleep_seconds (int); -void dcpomatic_sleep_milliseconds (int); +extern void dcpomatic_sleep_seconds (int); +extern void dcpomatic_sleep_milliseconds (int); extern std::string cpu_info (); extern void run_ffprobe (boost::filesystem::path, boost::filesystem::path); extern std::list<std::pair<std::string, std::string> > mount_info (); extern boost::filesystem::path openssl_path (); +extern void make_foreground_application (); #ifdef DCPOMATIC_DISK extern boost::filesystem::path disk_writer_path (); #endif diff --git a/src/lib/cross_common.cc b/src/lib/cross_common.cc index cf220fe53..edc806b58 100644 --- a/src/lib/cross_common.cc +++ b/src/lib/cross_common.cc @@ -21,9 +21,12 @@ #include "cross.h" #include "compose.hpp" #include "dcpomatic_log.h" +#include "warnings.h" #include <dcp/raw_convert.h> #include <boost/foreach.hpp> +DCPOMATIC_DISABLE_WARNINGS #include <libxml++/libxml++.h> +DCPOMATIC_ENABLE_WARNINGS #include <iostream> #include "i18n.h" diff --git a/src/lib/cross_linux.cc b/src/lib/cross_linux.cc index 25fd3490e..e17f188b9 100644 --- a/src/lib/cross_linux.cc +++ b/src/lib/cross_linux.cc @@ -113,7 +113,10 @@ run_ffprobe (boost::filesystem::path content, boost::filesystem::path out) { string ffprobe = "ffprobe \"" + content.string() + "\" 2> \"" + out.string() + "\""; LOG_GENERAL (N_("Probing with %1"), ffprobe); - system (ffprobe.c_str ()); + int const r = system (ffprobe.c_str()); + if (r == -1 || (WIFEXITED(r) && WEXITSTATUS(r) != 0)) { + LOG_GENERAL (N_("Could not run ffprobe (system returned %1"), r); + } } list<pair<string, string> > @@ -376,9 +379,10 @@ unprivileged () uid_t ruid, euid, suid; if (getresuid(&ruid, &euid, &suid) == -1) { cerr << "getresuid() failed.\n"; - exit (EXIT_FAILURE); } - seteuid (ruid); + if (seteuid(ruid) == -1) { + cerr << "seteuid() failed.\n"; + } } PrivilegeEscalator::~PrivilegeEscalator () @@ -388,7 +392,10 @@ PrivilegeEscalator::~PrivilegeEscalator () PrivilegeEscalator::PrivilegeEscalator () { - seteuid (0); + int const r = seteuid(0); + if (r < 0) { + throw PrivilegeError (String::compose("seteuid() call failed with %1", errno)); + } } boost::filesystem::path diff --git a/src/lib/cross_osx.cc b/src/lib/cross_osx.cc index 574cc8660..e91d3df16 100644 --- a/src/lib/cross_osx.cc +++ b/src/lib/cross_osx.cc @@ -24,6 +24,7 @@ #include "dcpomatic_log.h" #include "config.h" #include "exceptions.h" +#include "warnings.h" #include <dcp/raw_convert.h> #include <glib.h> extern "C" { @@ -35,6 +36,7 @@ extern "C" { #if BOOST_VERSION >= 106100 #include <boost/dll/runtime_symbol_info.hpp> #endif +#include <ApplicationServices/ApplicationServices.h> #include <sys/sysctl.h> #include <mach-o/dyld.h> #include <IOKit/pwr_mgt/IOPMLib.h> @@ -180,10 +182,7 @@ Waker::nudge () Waker::Waker () { boost::mutex::scoped_lock lm (_mutex); - /* We should use this */ - // IOPMAssertionCreateWithName (kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, CFSTR ("Encoding DCP"), &_assertion_id); - /* but it's not available on 10.5, so we use this */ - IOPMAssertionCreate (kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, &_assertion_id); + IOPMAssertionCreateWithName (kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, CFSTR ("Encoding DCP"), &_assertion_id); } Waker::~Waker () @@ -246,7 +245,7 @@ home_directory () } string -command_and_read (string cmd) +command_and_read (string) { return ""; } @@ -516,7 +515,7 @@ config_path () } -void done_callback(DADiskRef disk, DADissenterRef dissenter, void* context) +void done_callback(DADiskRef, DADissenterRef dissenter, void* context) { LOG_DISK_NC("Unmount finished"); bool* success = reinterpret_cast<bool*> (context); @@ -566,3 +565,14 @@ disk_write_finished () } + +void +make_foreground_application () +{ + ProcessSerialNumber serial; +DCPOMATIC_DISABLE_WARNINGS + GetCurrentProcess (&serial); +DCPOMATIC_ENABLE_WARNINGS + TransformProcessType (&serial, kProcessTransformToForegroundApplication); +} + diff --git a/src/lib/dcp_text_track.h b/src/lib/dcp_text_track.h index 913e77fa5..e6a146b3b 100644 --- a/src/lib/dcp_text_track.h +++ b/src/lib/dcp_text_track.h @@ -21,8 +21,11 @@ #ifndef DCPOMATIC_DCP_TEXT_TRACK_H #define DCPOMATIC_DCP_TEXT_TRACK_H +#include "warnings.h" #include <libcxml/cxml.h> +DCPOMATIC_DISABLE_WARNINGS #include <libxml++/libxml++.h> +DCPOMATIC_ENABLE_WARNINGS class DCPTextTrack { diff --git a/src/lib/dcp_video.cc b/src/lib/dcp_video.cc index 7b06f8cfc..d6b9d4f27 100644 --- a/src/lib/dcp_video.cc +++ b/src/lib/dcp_video.cc @@ -39,12 +39,15 @@ #include "cross.h" #include "player_video.h" #include "compose.hpp" +#include "warnings.h" #include <libcxml/cxml.h> #include <dcp/raw_convert.h> #include <dcp/openjpeg_image.h> #include <dcp/rgb_xyz.h> #include <dcp/j2k.h> +DCPOMATIC_DISABLE_WARNINGS #include <libxml++/libxml++.h> +DCPOMATIC_ENABLE_WARNINGS #include <boost/asio.hpp> #include <boost/thread.hpp> #include <stdint.h> diff --git a/src/lib/dkdm_wrapper.cc b/src/lib/dkdm_wrapper.cc index 0dd37b464..6638bc315 100644 --- a/src/lib/dkdm_wrapper.cc +++ b/src/lib/dkdm_wrapper.cc @@ -21,7 +21,10 @@ #include "compose.hpp" #include "dkdm_wrapper.h" #include "dcpomatic_assert.h" +#include "warnings.h" +DCPOMATIC_DISABLE_WARNINGS #include <libxml++/libxml++.h> +DCPOMATIC_ENABLE_WARNINGS #include <boost/foreach.hpp> using std::string; diff --git a/src/lib/edid.cc b/src/lib/edid.cc index 3df65d325..a530b8e38 100644 --- a/src/lib/edid.cc +++ b/src/lib/edid.cc @@ -20,8 +20,11 @@ #include "compose.hpp" #include "edid.h" +#include "warnings.h" #include <dcp/raw_convert.h> +DCPOMATIC_DISABLE_WARNINGS #include <libxml++/libxml++.h> +DCPOMATIC_ENABLE_WARNINGS #include <boost/filesystem.hpp> #include <boost/algorithm/string.hpp> #include <iostream> diff --git a/src/lib/encode_server.cc b/src/lib/encode_server.cc index c242cb216..c30fc8f30 100644 --- a/src/lib/encode_server.cc +++ b/src/lib/encode_server.cc @@ -36,9 +36,12 @@ #include "dcpomatic_log.h" #include "encoded_log_entry.h" #include "version.h" +#include "warnings.h" #include <dcp/raw_convert.h> #include <libcxml/cxml.h> +DCPOMATIC_DISABLE_WARNINGS #include <libxml++/libxml++.h> +DCPOMATIC_ENABLE_WARNINGS #include <boost/algorithm/string.hpp> #include <boost/scoped_array.hpp> #include <boost/foreach.hpp> @@ -236,9 +239,11 @@ EncodeServer::run () } for (int i = 0; i < _num_threads; ++i) { - boost::thread* t = _worker_threads.create_thread (bind(&EncodeServer::worker_thread, this)); #ifdef DCPOMATIC_LINUX + boost::thread* t = _worker_threads.create_thread (bind(&EncodeServer::worker_thread, this)); pthread_setname_np (t->native_handle(), "encode-server-worker"); +#else + _worker_threads.create_thread (bind(&EncodeServer::worker_thread, this)); #endif } diff --git a/src/lib/exceptions.h b/src/lib/exceptions.h index 98534bb32..05cda9659 100644 --- a/src/lib/exceptions.h +++ b/src/lib/exceptions.h @@ -369,4 +369,14 @@ private: std::string _message; int _number; }; + + +class PrivilegeError : public std::runtime_error +{ +public: + explicit PrivilegeError (std::string s) + : std::runtime_error (s) + {} +}; + #endif diff --git a/src/lib/ffmpeg.cc b/src/lib/ffmpeg.cc index 8eb19816c..0802fa159 100644 --- a/src/lib/ffmpeg.cc +++ b/src/lib/ffmpeg.cc @@ -70,9 +70,11 @@ FFmpeg::~FFmpeg () { boost::mutex::scoped_lock lm (_mutex); +DCPOMATIC_DISABLE_WARNINGS for (uint32_t i = 0; i < _format_context->nb_streams; ++i) { avcodec_close (_format_context->streams[i]->codec); } +DCPOMATIC_ENABLE_WARNINGS av_frame_free (&_frame); avformat_close_input (&_format_context); @@ -146,6 +148,7 @@ FFmpeg::setup_general () optional<int> video_stream_undefined_frame_rate; +DCPOMATIC_DISABLE_WARNINGS for (uint32_t i = 0; i < _format_context->nb_streams; ++i) { AVStream* s = _format_context->streams[i]; if (s->codec->codec_type == AVMEDIA_TYPE_VIDEO && avcodec_find_decoder(s->codec->codec_id)) { @@ -158,6 +161,7 @@ FFmpeg::setup_general () } } } +DCPOMATIC_ENABLE_WARNINGS /* Files from iTunes sometimes have two video streams, one with the avg_frame_rate.num and .den set to zero. Only use such a stream if there is no alternative. @@ -204,6 +208,7 @@ FFmpeg::setup_decoders () { boost::mutex::scoped_lock lm (_mutex); +DCPOMATIC_DISABLE_WARNINGS for (uint32_t i = 0; i < _format_context->nb_streams; ++i) { AVCodecContext* context = _format_context->streams[i]->codec; @@ -230,8 +235,10 @@ FFmpeg::setup_decoders () dcpomatic_log->log (String::compose ("No codec found for stream %1", i), LogEntry::TYPE_WARNING); } } +DCPOMATIC_ENABLE_WARNINGS } +DCPOMATIC_DISABLE_WARNINGS AVCodecContext * FFmpeg::video_codec_context () const { @@ -251,6 +258,7 @@ FFmpeg::subtitle_codec_context () const return _ffmpeg_content->subtitle_stream()->stream(_format_context)->codec; } +DCPOMATIC_ENABLE_WARNINGS int FFmpeg::avio_read (uint8_t* buffer, int const amount) diff --git a/src/lib/ffmpeg.h b/src/lib/ffmpeg.h index 10517055c..e6399c076 100644 --- a/src/lib/ffmpeg.h +++ b/src/lib/ffmpeg.h @@ -23,9 +23,12 @@ #include "file_group.h" #include "ffmpeg_subtitle_period.h" +#include "warnings.h" +DCPOMATIC_DISABLE_WARNINGS extern "C" { #include <libavcodec/avcodec.h> } +DCPOMATIC_ENABLE_WARNINGS #include <boost/shared_ptr.hpp> #include <boost/thread/mutex.hpp> diff --git a/src/lib/ffmpeg_audio_stream.cc b/src/lib/ffmpeg_audio_stream.cc index 1fc008d51..32828f13a 100644 --- a/src/lib/ffmpeg_audio_stream.cc +++ b/src/lib/ffmpeg_audio_stream.cc @@ -20,7 +20,10 @@ #include "ffmpeg_audio_stream.h" #include <dcp/raw_convert.h> +#include "warnings.h" +DCPOMATIC_DISABLE_WARNINGS #include <libxml++/libxml++.h> +DCPOMATIC_ENABLE_WARNINGS #include <libcxml/cxml.h> using std::string; diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index cfaf0361b..04c97ed3b 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -206,9 +206,11 @@ FFmpegDecoder::deinterleave_audio (shared_ptr<FFmpegAudioStream> stream) const { DCPOMATIC_ASSERT (bytes_per_audio_sample (stream)); +DCPOMATIC_DISABLE_WARNINGS int const size = av_samples_get_buffer_size ( 0, stream->stream(_format_context)->codec->channels, _frame->nb_samples, audio_sample_format (stream), 1 ); +DCPOMATIC_ENABLE_WARNINGS /* XXX: can't we just use _frame->nb_samples directly here? */ /* XXX: can't we use swr_convert() to do the format conversion? */ @@ -339,7 +341,9 @@ FFmpegDecoder::deinterleave_audio (shared_ptr<FFmpegAudioStream> stream) const AVSampleFormat FFmpegDecoder::audio_sample_format (shared_ptr<FFmpegAudioStream> stream) const { +DCPOMATIC_DISABLE_WARNINGS return stream->stream (_format_context)->codec->sample_fmt; +DCPOMATIC_ENABLE_WARNINGS } int @@ -401,9 +405,11 @@ FFmpegDecoder::seek (ContentTime time, bool accurate) avcodec_flush_buffers (video_codec_context()); } +DCPOMATIC_DISABLE_WARNINGS BOOST_FOREACH (shared_ptr<FFmpegAudioStream> i, ffmpeg_content()->ffmpeg_audio_streams()) { avcodec_flush_buffers (i->stream(_format_context)->codec); } +DCPOMATIC_ENABLE_WARNINGS if (subtitle_codec_context ()) { avcodec_flush_buffers (subtitle_codec_context ()); @@ -434,6 +440,7 @@ FFmpegDecoder::decode_audio_packet () return; } +DCPOMATIC_DISABLE_WARNINGS while (copy_packet.size > 0) { int frame_finished; @@ -493,6 +500,7 @@ FFmpegDecoder::decode_audio_packet () to_string(_pts_offset) ); } +DCPOMATIC_ENABLE_WARNINGS /* Give this data provided there is some, and its time is sane */ if (ct >= ContentTime() && data->frames() > 0) { @@ -511,9 +519,11 @@ FFmpegDecoder::decode_video_packet () DCPOMATIC_ASSERT (_video_stream); int frame_finished; +DCPOMATIC_DISABLE_WARNINGS if (avcodec_decode_video2 (video_codec_context(), _frame, &frame_finished, &_packet) < 0 || !frame_finished) { return false; } +DCPOMATIC_ENABLE_WARNINGS boost::mutex::scoped_lock lm (_filter_graphs_mutex); diff --git a/src/lib/ffmpeg_examiner.cc b/src/lib/ffmpeg_examiner.cc index 3fb9a53e4..cc6a62ff6 100644 --- a/src/lib/ffmpeg_examiner.cc +++ b/src/lib/ffmpeg_examiner.cc @@ -18,6 +18,14 @@ */ +#include "ffmpeg_examiner.h" +#include "ffmpeg_content.h" +#include "job.h" +#include "ffmpeg_audio_stream.h" +#include "ffmpeg_subtitle_stream.h" +#include "util.h" +#include "warnings.h" +DCPOMATIC_DISABLE_WARNINGS extern "C" { #include <libavcodec/avcodec.h> #include <libavformat/avformat.h> @@ -26,12 +34,7 @@ extern "C" { #include <libavutil/eval.h> #include <libavutil/display.h> } -#include "ffmpeg_examiner.h" -#include "ffmpeg_content.h" -#include "job.h" -#include "ffmpeg_audio_stream.h" -#include "ffmpeg_subtitle_stream.h" -#include "util.h" +DCPOMATIC_ENABLE_WARNINGS #include <boost/foreach.hpp> #include <iostream> @@ -44,6 +47,7 @@ using boost::shared_ptr; using boost::optional; using namespace dcpomatic; + /** @param job job that the examiner is operating in, or 0 */ FFmpegExaminer::FFmpegExaminer (shared_ptr<const FFmpegContent> c, shared_ptr<Job> job) : FFmpeg (c) @@ -54,6 +58,7 @@ FFmpegExaminer::FFmpegExaminer (shared_ptr<const FFmpegContent> c, shared_ptr<Jo for (uint32_t i = 0; i < _format_context->nb_streams; ++i) { AVStream* s = _format_context->streams[i]; +DCPOMATIC_DISABLE_WARNINGS if (s->codec->codec_type == AVMEDIA_TYPE_AUDIO) { /* This is a hack; sometimes it seems that _audio_codec_context->channel_layout isn't set up, @@ -119,6 +124,7 @@ FFmpegExaminer::FFmpegExaminer (shared_ptr<const FFmpegContent> c, shared_ptr<Jo } AVCodecContext* context = _format_context->streams[_packet.stream_index]->codec; +DCPOMATIC_ENABLE_WARNINGS if (_video_stream && _packet.stream_index == _video_stream.get()) { video_packet (context); @@ -175,6 +181,7 @@ FFmpegExaminer::FFmpegExaminer (shared_ptr<const FFmpegContent> c, shared_ptr<Jo #endif } + void FFmpegExaminer::video_packet (AVCodecContext* context) { @@ -185,7 +192,9 @@ FFmpegExaminer::video_packet (AVCodecContext* context) } int frame_finished; +DCPOMATIC_DISABLE_WARNINGS if (avcodec_decode_video2 (context, _frame, &frame_finished, &_packet) >= 0 && frame_finished) { +DCPOMATIC_ENABLE_WARNINGS if (!_first_video) { _first_video = frame_time (_format_context->streams[_video_stream.get()]); } @@ -197,6 +206,7 @@ FFmpegExaminer::video_packet (AVCodecContext* context) } } + void FFmpegExaminer::audio_packet (AVCodecContext* context, shared_ptr<FFmpegAudioStream> stream) { @@ -205,17 +215,22 @@ FFmpegExaminer::audio_packet (AVCodecContext* context, shared_ptr<FFmpegAudioStr } int frame_finished; +DCPOMATIC_DISABLE_WARNINGS if (avcodec_decode_audio4 (context, _frame, &frame_finished, &_packet) >= 0 && frame_finished) { +DCPOMATIC_ENABLE_WARNINGS stream->first_audio = frame_time (stream->stream (_format_context)); } } + optional<ContentTime> FFmpegExaminer::frame_time (AVStream* s) const { optional<ContentTime> t; +DCPOMATIC_DISABLE_WARNINGS int64_t const bet = av_frame_get_best_effort_timestamp (_frame); +DCPOMATIC_ENABLE_WARNINGS if (bet != AV_NOPTS_VALUE) { t = ContentTime::from_seconds (bet * av_q2d (s->time_base)); } @@ -223,6 +238,7 @@ FFmpegExaminer::frame_time (AVStream* s) const return t; } + optional<double> FFmpegExaminer::video_frame_rate () const { diff --git a/src/lib/ffmpeg_file_encoder.cc b/src/lib/ffmpeg_file_encoder.cc index 44ef3f072..f8bd14e76 100644 --- a/src/lib/ffmpeg_file_encoder.cc +++ b/src/lib/ffmpeg_file_encoder.cc @@ -113,11 +113,13 @@ FFmpegFileEncoder::FFmpegFileEncoder ( throw runtime_error ("could not create FFmpeg output audio stream"); } +DCPOMATIC_DISABLE_WARNINGS _video_stream->id = _video_stream_index; _video_stream->codec = _video_codec_context; _audio_stream->id = _audio_stream_index; _audio_stream->codec = _audio_codec_context; +DCPOMATIC_ENABLE_WARNINGS if (avcodec_open2 (_video_codec_context, _video_codec, &_video_options) < 0) { throw runtime_error ("could not open FFmpeg video codec"); @@ -239,7 +241,9 @@ FFmpegFileEncoder::flush () packet.size = 0; int got_packet; +DCPOMATIC_DISABLE_WARNINGS avcodec_encode_video2 (_video_codec_context, &packet, 0, &got_packet); +DCPOMATIC_ENABLE_WARNINGS if (got_packet) { packet.stream_index = 0; av_interleaved_write_frame (_format_context, &packet); @@ -252,7 +256,9 @@ FFmpegFileEncoder::flush () packet.data = 0; packet.size = 0; +DCPOMATIC_DISABLE_WARNINGS avcodec_encode_audio2 (_audio_codec_context, &packet, 0, &got_packet); +DCPOMATIC_ENABLE_WARNINGS if (got_packet) { packet.stream_index = 0; av_interleaved_write_frame (_format_context, &packet); @@ -307,9 +313,11 @@ FFmpegFileEncoder::video (shared_ptr<PlayerVideo> video, DCPTime time) packet.size = 0; int got_packet; +DCPOMATIC_DISABLE_WARNINGS if (avcodec_encode_video2 (_video_codec_context, &packet, frame, &got_packet) < 0) { throw EncodeError ("FFmpeg video encode failed"); } +DCPOMATIC_ENABLE_WARNINGS if (got_packet && packet.size) { packet.stream_index = _video_stream_index; @@ -403,9 +411,11 @@ FFmpegFileEncoder::audio_frame (int size) packet.size = 0; int got_packet; +DCPOMATIC_DISABLE_WARNINGS if (avcodec_encode_audio2 (_audio_codec_context, &packet, frame, &got_packet) < 0) { throw EncodeError ("FFmpeg audio encode failed"); } +DCPOMATIC_ENABLE_WARNINGS if (got_packet && packet.size) { packet.stream_index = _audio_stream_index; diff --git a/src/lib/ffmpeg_image_proxy.cc b/src/lib/ffmpeg_image_proxy.cc index db6059266..f2b72059b 100644 --- a/src/lib/ffmpeg_image_proxy.cc +++ b/src/lib/ffmpeg_image_proxy.cc @@ -25,12 +25,15 @@ #include "image.h" #include "compose.hpp" #include "util.h" +#include "warnings.h" #include <dcp/raw_convert.h> extern "C" { #include <libavcodec/avcodec.h> #include <libavformat/avformat.h> } +DCPOMATIC_DISABLE_WARNINGS #include <libxml++/libxml++.h> +DCPOMATIC_ENABLE_WARNINGS #include <iostream> #include "i18n.h" @@ -83,7 +86,7 @@ avio_seek_wrapper (void* data, int64_t offset, int whence) int FFmpegImageProxy::avio_read (uint8_t* buffer, int const amount) { - int const to_do = min(int64_t(amount), _data.size() - _pos); + int const to_do = min(static_cast<int64_t>(amount), static_cast<int64_t>(_data.size()) - _pos); if (to_do == 0) { return AVERROR_EOF; } @@ -112,6 +115,7 @@ FFmpegImageProxy::avio_seek (int64_t const pos, int whence) return _pos; } +DCPOMATIC_DISABLE_WARNINGS ImageProxy::Result FFmpegImageProxy::image (optional<dcp::Size>) const @@ -196,6 +200,8 @@ FFmpegImageProxy::image (optional<dcp::Size>) const return Result (_image, 0); } +DCPOMATIC_ENABLE_WARNINGS + void FFmpegImageProxy::add_metadata (xmlpp::Node* node) const { diff --git a/src/lib/ffmpeg_stream.cc b/src/lib/ffmpeg_stream.cc index 86108ce4d..60327ab0d 100644 --- a/src/lib/ffmpeg_stream.cc +++ b/src/lib/ffmpeg_stream.cc @@ -20,8 +20,11 @@ #include "ffmpeg_stream.h" #include "dcpomatic_assert.h" +#include "warnings.h" #include <dcp/raw_convert.h> +DCPOMATIC_DISABLE_WARNINGS #include <libxml++/libxml++.h> +DCPOMATIC_ENABLE_WARNINGS extern "C" { #include <libavformat/avformat.h> } diff --git a/src/lib/ffmpeg_subtitle_stream.cc b/src/lib/ffmpeg_subtitle_stream.cc index da8bafc0a..72698fa51 100644 --- a/src/lib/ffmpeg_subtitle_stream.cc +++ b/src/lib/ffmpeg_subtitle_stream.cc @@ -19,8 +19,11 @@ */ #include "ffmpeg_subtitle_stream.h" +#include "warnings.h" #include <dcp/raw_convert.h> +DCPOMATIC_DISABLE_WARNINGS #include <libxml++/libxml++.h> +DCPOMATIC_ENABLE_WARNINGS #include <boost/foreach.hpp> #include <iostream> diff --git a/src/lib/font.cc b/src/lib/font.cc index 019c9ab07..a52957376 100644 --- a/src/lib/font.cc +++ b/src/lib/font.cc @@ -20,7 +20,10 @@ #include "font.h" #include "dcpomatic_assert.h" +#include "warnings.h" +DCPOMATIC_DISABLE_WARNINGS #include <libxml++/libxml++.h> +DCPOMATIC_ENABLE_WARNINGS #include <boost/foreach.hpp> using std::string; diff --git a/src/lib/isdcf_metadata.cc b/src/lib/isdcf_metadata.cc index c333325a1..f4b256626 100644 --- a/src/lib/isdcf_metadata.cc +++ b/src/lib/isdcf_metadata.cc @@ -19,9 +19,12 @@ */ #include "isdcf_metadata.h" +#include "warnings.h" #include <dcp/raw_convert.h> #include <libcxml/cxml.h> +DCPOMATIC_DISABLE_WARNINGS #include <libxml++/libxml++.h> +DCPOMATIC_ENABLE_WARNINGS #include <iostream> #include "i18n.h" diff --git a/src/lib/j2k_encoder.cc b/src/lib/j2k_encoder.cc index 498050073..d8d8209c9 100644 --- a/src/lib/j2k_encoder.cc +++ b/src/lib/j2k_encoder.cc @@ -389,11 +389,15 @@ J2KEncoder::servers_list_changed () if (!Config::instance()->only_servers_encode ()) { for (int i = 0; i < Config::instance()->master_encoding_threads (); ++i) { - boost::thread* t = _threads->create_thread(boost::bind(&J2KEncoder::encoder_thread, this, optional<EncodeServerDescription>())); #ifdef DCPOMATIC_LINUX + boost::thread* t = _threads->create_thread(boost::bind(&J2KEncoder::encoder_thread, this, optional<EncodeServerDescription>())); pthread_setname_np (t->native_handle(), "encode-worker"); #endif +#ifdef DCPOMATIC_OSX + _threads->create_thread(boost::bind(&J2KEncoder::encoder_thread, this, optional<EncodeServerDescription>())); +#endif #ifdef DCPOMATIC_WINDOWS + boost::thread* t = _threads->create_thread(boost::bind(&J2KEncoder::encoder_thread, this, optional<EncodeServerDescription>())); if (windows_xp) { SetThreadAffinityMask (t->native_handle(), 1 << i); } diff --git a/src/lib/j2k_image_proxy.cc b/src/lib/j2k_image_proxy.cc index acf8bb052..08ebc343c 100644 --- a/src/lib/j2k_image_proxy.cc +++ b/src/lib/j2k_image_proxy.cc @@ -22,6 +22,7 @@ #include "dcpomatic_socket.h" #include "image.h" #include "dcpomatic_assert.h" +#include "warnings.h" #include <dcp/raw_convert.h> #include <dcp/openjpeg_image.h> #include <dcp/mono_picture_frame.h> @@ -30,7 +31,9 @@ #include <dcp/rgb_xyz.h> #include <dcp/j2k.h> #include <libcxml/cxml.h> +DCPOMATIC_DISABLE_WARNINGS #include <libxml++/libxml++.h> +DCPOMATIC_ENABLE_WARNINGS #include <iostream> #include "i18n.h" diff --git a/src/lib/json_server.cc b/src/lib/json_server.cc index 3f43a75eb..4cff27b6f 100644 --- a/src/lib/json_server.cc +++ b/src/lib/json_server.cc @@ -52,9 +52,11 @@ enum State { JSONServer::JSONServer (int port) { - thread* t = new thread (boost::bind (&JSONServer::run, this, port)); #ifdef DCPOMATIC_LINUX + thread* t = new thread (boost::bind (&JSONServer::run, this, port)); pthread_setname_np (t->native_handle(), "json-server"); +#else + new thread (boost::bind (&JSONServer::run, this, port)); #endif } diff --git a/src/lib/kdm_recipient.h b/src/lib/kdm_recipient.h index b68b4b7c7..e92fc3c48 100644 --- a/src/lib/kdm_recipient.h +++ b/src/lib/kdm_recipient.h @@ -21,9 +21,12 @@ #ifndef DCPOMATIC_KDM_RECIPIENT_H #define DCPOMATIC_KDM_RECIPIENT_H +#include "warnings.h" #include <dcp/certificate.h> #include <libcxml/cxml.h> +DCPOMATIC_DISABLE_WARNINGS #include <libxml++/libxml++.h> +DCPOMATIC_ENABLE_WARNINGS #include <boost/optional.hpp> #include <string> diff --git a/src/lib/raw_image_proxy.cc b/src/lib/raw_image_proxy.cc index 2509bd0d4..09902c3a2 100644 --- a/src/lib/raw_image_proxy.cc +++ b/src/lib/raw_image_proxy.cc @@ -20,13 +20,16 @@ #include "raw_image_proxy.h" #include "image.h" +#include "warnings.h" #include <dcp/raw_convert.h> #include <dcp/util.h> #include <libcxml/cxml.h> extern "C" { #include <libavutil/pixfmt.h> } +DCPOMATIC_DISABLE_WARNINGS #include <libxml++/libxml++.h> +DCPOMATIC_ENABLE_WARNINGS #include "i18n.h" diff --git a/src/lib/render_text.cc b/src/lib/render_text.cc index de33f9380..b0a958c16 100644 --- a/src/lib/render_text.cc +++ b/src/lib/render_text.cc @@ -24,10 +24,13 @@ #include "cross.h" #include "font.h" #include "dcpomatic_assert.h" +#include "warnings.h" #include <dcp/raw_convert.h> #include <fontconfig/fontconfig.h> #include <cairomm/cairomm.h> +DCPOMATIC_DISABLE_WARNINGS #include <pangomm.h> +DCPOMATIC_ENABLE_WARNINGS #include <pango/pangocairo.h> #ifndef DCPOMATIC_HAVE_SHOW_IN_CAIRO_CONTEXT #include <pango/pangocairo.h> diff --git a/src/lib/rgba.cc b/src/lib/rgba.cc index 6d58d97d1..1076af433 100644 --- a/src/lib/rgba.cc +++ b/src/lib/rgba.cc @@ -19,7 +19,10 @@ */ #include "rgba.h" +#include "warnings.h" +DCPOMATIC_DISABLE_WARNINGS #include <libxml++/libxml++.h> +DCPOMATIC_ENABLE_WARNINGS #include <boost/lexical_cast.hpp> using std::string; diff --git a/src/lib/scp_uploader.cc b/src/lib/scp_uploader.cc index d6fa67592..9bb0f1e55 100644 --- a/src/lib/scp_uploader.cc +++ b/src/lib/scp_uploader.cc @@ -24,6 +24,7 @@ #include "config.h" #include "cross.h" #include "compose.hpp" +#include "warnings.h" #include <sys/stat.h> #include "i18n.h" @@ -51,10 +52,12 @@ SCPUploader::SCPUploader (function<void (string)> set_status, function<void (flo throw NetworkError (String::compose (_("Could not connect to server %1 (%2)"), Config::instance()->tms_ip(), ssh_get_error (_session))); } +DCPOMATIC_DISABLE_WARNINGS r = ssh_is_server_known (_session); if (r == SSH_SERVER_ERROR) { throw NetworkError (String::compose (_("SSH error (%1)"), ssh_get_error (_session))); } +DCPOMATIC_ENABLE_WARNINGS r = ssh_userauth_password (_session, 0, Config::instance()->tms_password().c_str ()); if (r != SSH_AUTH_SUCCESS) { diff --git a/src/lib/spl.cc b/src/lib/spl.cc index ccf809f8b..7692df0ca 100644 --- a/src/lib/spl.cc +++ b/src/lib/spl.cc @@ -18,11 +18,14 @@ */ -#include "spl.h" #include "content_store.h" +#include "spl.h" +#include "warnings.h" #include <libcxml/cxml.h> #include <dcp/raw_convert.h> +DCPOMATIC_DISABLE_WARNINGS #include <libxml++/libxml++.h> +DCPOMATIC_ENABLE_WARNINGS #include <boost/foreach.hpp> #include <iostream> diff --git a/src/lib/spl_entry.cc b/src/lib/spl_entry.cc index 5b011a046..3cb1a9a36 100644 --- a/src/lib/spl_entry.cc +++ b/src/lib/spl_entry.cc @@ -21,7 +21,10 @@ #include "spl_entry.h" #include "dcp_content.h" #include "dcpomatic_assert.h" +#include "warnings.h" +DCPOMATIC_DISABLE_WARNINGS #include <libxml++/libxml++.h> +DCPOMATIC_ENABLE_WARNINGS using boost::shared_ptr; using boost::dynamic_pointer_cast; diff --git a/src/lib/subtitle_analysis.cc b/src/lib/subtitle_analysis.cc index f8254f00d..e6e8f310f 100644 --- a/src/lib/subtitle_analysis.cc +++ b/src/lib/subtitle_analysis.cc @@ -20,9 +20,12 @@ #include "subtitle_analysis.h" #include "exceptions.h" +#include "warnings.h" #include <libcxml/cxml.h> #include <dcp/raw_convert.h> +DCPOMATIC_DISABLE_WARNINGS #include <libxml++/libxml++.h> +DCPOMATIC_ENABLE_WARNINGS using std::string; using dcp::raw_convert; diff --git a/src/lib/types.cc b/src/lib/types.cc index d2df7f1a8..df57f2d47 100644 --- a/src/lib/types.cc +++ b/src/lib/types.cc @@ -21,12 +21,15 @@ #include "types.h" #include "compose.hpp" #include "dcpomatic_assert.h" +#include "warnings.h" #include <dcp/raw_convert.h> #include <dcp/cpl.h> #include <dcp/dcp.h> #include <dcp/reel_mxf.h> #include <dcp/reel_asset.h> +DCPOMATIC_DISABLE_WARNINGS #include <libxml++/libxml++.h> +DCPOMATIC_ENABLE_WARNINGS #include <libcxml/cxml.h> #include <boost/foreach.hpp> diff --git a/src/lib/util.cc b/src/lib/util.cc index 74951fc64..7ba9242fa 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -45,6 +45,7 @@ #include "image.h" #include "text_decoder.h" #include "job_manager.h" +#include "warnings.h" #include <dcp/decrypted_kdm.h> #include <dcp/locale_convert.h> #include <dcp/util.h> @@ -65,7 +66,9 @@ extern "C" { #include <boost/range/algorithm/replace_if.hpp> #include <boost/thread.hpp> #include <boost/filesystem.hpp> +DCPOMATIC_DISABLE_WARNINGS #include <boost/locale.hpp> +DCPOMATIC_ENABLE_WARNINGS #ifdef DCPOMATIC_WINDOWS #include <boost/locale.hpp> #include <dbghelp.h> @@ -230,6 +233,7 @@ addr2line (void const * const addr) return system(addr2line_cmd); } +DCPOMATIC_DISABLE_WARNINGS /** This is called when C signals occur on Windows (e.g. SIGSEGV) * (NOT C++ exceptions!). We write a backtrace to backtrace_file by dark means. * Adapted from code here: http://spin.atomicobject.com/2013/01/13/exceptions-stack-traces-c/ @@ -286,6 +290,7 @@ exception_handler(struct _EXCEPTION_POINTERS * info) return EXCEPTION_CONTINUE_SEARCH; } +DCPOMATIC_ENABLE_WARNINGS #endif void @@ -356,8 +361,10 @@ dcpomatic_setup () SetUnhandledExceptionFilter(exception_handler); #endif +DCPOMATIC_DISABLE_WARNINGS av_register_all (); avfilter_register_all (); +DCPOMATIC_ENABLE_WARNINGS #ifdef DCPOMATIC_OSX /* Add our library directory to the libltdl search path so that diff --git a/src/lib/video_filter_graph.cc b/src/lib/video_filter_graph.cc index 6075500e9..9b297c87b 100644 --- a/src/lib/video_filter_graph.cc +++ b/src/lib/video_filter_graph.cc @@ -18,9 +18,10 @@ */ -#include "video_filter_graph.h" -#include "image.h" #include "compose.hpp" +#include "image.h" +#include "video_filter_graph.h" +#include "warnings.h" extern "C" { #include <libavfilter/buffersrc.h> #include <libavfilter/buffersink.h> @@ -51,6 +52,7 @@ VideoFilterGraph::process (AVFrame* frame) { list<pair<shared_ptr<Image>, int64_t> > images; +DCPOMATIC_DISABLE_WARNINGS if (_copy) { images.push_back (make_pair (shared_ptr<Image> (new Image (frame)), av_frame_get_best_effort_timestamp (frame))); } else { @@ -68,6 +70,7 @@ VideoFilterGraph::process (AVFrame* frame) av_frame_unref (_frame); } } +DCPOMATIC_ENABLE_WARNINGS return images; } diff --git a/src/lib/warnings.h b/src/lib/warnings.h new file mode 100644 index 000000000..d182526ff --- /dev/null +++ b/src/lib/warnings.h @@ -0,0 +1,37 @@ +/* + Copyright (C) 2020 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/>. + +*/ + +#if __GNUC__ >= 9 +#define DCPOMATIC_DISABLE_WARNINGS \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") \ + _Pragma("GCC diagnostic ignored \"-Wmissing-field-initializers\"") \ + _Pragma("GCC diagnostic ignored \"-Wdeprecated-copy\"") \ + _Pragma("GCC diagnostic ignored \"-Wunused-parameter\"") +#else +#define DCPOMATIC_DISABLE_WARNINGS \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") \ + _Pragma("GCC diagnostic ignored \"-Wmissing-field-initializers\"") \ + _Pragma("GCC diagnostic ignored \"-Wunused-parameter\"") +#endif + +#define DCPOMATIC_ENABLE_WARNINGS \ + _Pragma("GCC diagnostic pop") diff --git a/src/lib/wscript b/src/lib/wscript index c2dfb55d8..0c9cddfa4 100644 --- a/src/lib/wscript +++ b/src/lib/wscript @@ -206,7 +206,7 @@ def build(bld): """ if bld.env.TARGET_OSX: - obj.framework = ['IOKit', 'Foundation', 'DiskArbitration'] + obj.framework = ['IOKit', 'Foundation', 'DiskArbitration', 'ApplicationServices'] obj.source = sources + ' version.cc' |
