diff options
| author | Carl Hetherington <cth@carlh.net> | 2017-04-19 10:56:44 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2017-04-19 23:04:32 +0100 |
| commit | 565a0ab9fc8be5c21685b019aa06d37e6c66160c (patch) | |
| tree | f69349ecb0231f9babeeba26749edd17be02e65b /src/lib | |
| parent | 7a68de9aa2aba678f9ae9c6f9e11d9fc20c1c8e2 (diff) | |
Config option to disable preview audio.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/butler.cc | 12 | ||||
| -rw-r--r-- | src/lib/butler.h | 3 | ||||
| -rw-r--r-- | src/lib/config.cc | 11 | ||||
| -rw-r--r-- | src/lib/config.h | 32 |
4 files changed, 41 insertions, 17 deletions
diff --git a/src/lib/butler.cc b/src/lib/butler.cc index aadfc4fe5..32d607c5d 100644 --- a/src/lib/butler.cc +++ b/src/lib/butler.cc @@ -44,6 +44,7 @@ Butler::Butler (weak_ptr<const Film> film, shared_ptr<Player> player, AudioMappi , _audio_mapping (audio_mapping) , _audio_channels (audio_channels) , _stop_thread (false) + , _disable_audio (false) { _player_video_connection = _player->Video.connect (bind (&Butler::video, this, _1, _2)); _player_audio_connection = _player->Audio.connect (bind (&Butler::audio, this, _1, _2)); @@ -158,8 +159,8 @@ Butler::audio (shared_ptr<AudioBuffers> audio, DCPTime time) { { boost::mutex::scoped_lock lm (_mutex); - if (_pending_seek_position) { - /* Don't store any audio while a seek is pending */ + if (_pending_seek_position || _disable_audio) { + /* Don't store any audio while a seek is pending, or if audio is disabled */ return; } } @@ -191,3 +192,10 @@ Butler::get_audio (float* out, Frame frames) _audio.get (out, _audio_channels, frames); _summon.notify_all (); } + +void +Butler::disable_audio () +{ + boost::mutex::scoped_lock lm (_mutex); + _disable_audio = true; +} diff --git a/src/lib/butler.h b/src/lib/butler.h index 943aa9e0f..948a78ea5 100644 --- a/src/lib/butler.h +++ b/src/lib/butler.h @@ -42,6 +42,8 @@ public: std::pair<boost::shared_ptr<PlayerVideo>, DCPTime> get_video (); void get_audio (float* out, Frame frames); + void disable_audio (); + private: void thread (); void video (boost::shared_ptr<PlayerVideo> video, DCPTime time); @@ -68,6 +70,7 @@ private: int _audio_channels; bool _stop_thread; + bool _disable_audio; boost::signals2::scoped_connection _player_video_connection; boost::signals2::scoped_connection _player_audio_connection; diff --git a/src/lib/config.cc b/src/lib/config.cc index b099cbc85..01a67522f 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -116,7 +116,8 @@ Config::set_defaults () _dcp_metadata_filename_format = dcp::NameFormat ("%t"); _dcp_asset_filename_format = dcp::NameFormat ("%t"); _jump_to_selected = true; - _sound_output = optional<string> (); + _preview_sound = false; + _preview_sound_output = optional<string> (); _allowed_dcp_frame_rates.clear (); _allowed_dcp_frame_rates.push_back (24); @@ -310,7 +311,8 @@ try _dcp_metadata_filename_format = dcp::NameFormat (f.optional_string_child("DCPMetadataFilenameFormat").get_value_or ("%t")); _dcp_asset_filename_format = dcp::NameFormat (f.optional_string_child("DCPAssetFilenameFormat").get_value_or ("%t")); _jump_to_selected = f.optional_bool_child("JumpToSelected").get_value_or (true); - _sound_output = f.optional_string_child("SoundOutput"); + _preview_sound = f.optional_bool_child("PreviewSound").get_value_or (false); + _preview_sound_output = f.optional_string_child("PreviewSoundOutput"); /* Replace any cinemas from config.xml with those from the configured file */ if (boost::filesystem::exists (_cinemas_file)) { @@ -479,8 +481,9 @@ Config::write_config () const root->add_child("DCPMetadataFilenameFormat")->add_child_text (_dcp_metadata_filename_format.specification ()); root->add_child("DCPAssetFilenameFormat")->add_child_text (_dcp_asset_filename_format.specification ()); root->add_child("JumpToSelected")->add_child_text (_jump_to_selected ? "1" : "0"); - if (_sound_output) { - root->add_child("SoundOutput")->add_child_text (_sound_output.get()); + root->add_child("PreviewSound")->add_child_text (_preview_sound ? "1" : "0"); + if (_preview_sound_output) { + root->add_child("PreviewSoundOutput")->add_child_text (_preview_sound_output.get()); } try { diff --git a/src/lib/config.h b/src/lib/config.h index 2fd36059a..a574cc261 100644 --- a/src/lib/config.h +++ b/src/lib/config.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2017 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -67,7 +67,8 @@ public: USE_ANY_SERVERS, SERVERS, CINEMAS, - SOUND_OUTPUT, + PREVIEW_SOUND, + PREVIEW_SOUND_OUTPUT, OTHER }; @@ -307,8 +308,12 @@ public: return _jump_to_selected; } - boost::optional<std::string> sound_output () const { - return _sound_output; + bool preview_sound () const { + return _preview_sound; + } + + boost::optional<std::string> preview_sound_output () const { + return _preview_sound_output; } /** @param n New number of local encoding threads */ @@ -526,18 +531,22 @@ public: maybe_set (_confirm_kdm_email, s); } - void set_sound_output (std::string o) + void set_preview_sound (bool s) { + maybe_set (_preview_sound, s, PREVIEW_SOUND); + } + + void set_preview_sound_output (std::string o) { - maybe_set (_sound_output, o, SOUND_OUTPUT); + maybe_set (_preview_sound_output, o, PREVIEW_SOUND_OUTPUT); } - void unset_sound_output () + void unset_preview_sound_output () { - if (!_sound_output) { + if (!_preview_sound_output) { return; } - _sound_output = boost::none; + _preview_sound_output = boost::none; changed (); } @@ -699,8 +708,9 @@ private: dcp::NameFormat _dcp_metadata_filename_format; dcp::NameFormat _dcp_asset_filename_format; bool _jump_to_selected; - /** name of a specific sound output stream to use for preview */ - boost::optional<std::string> _sound_output; + bool _preview_sound; + /** name of a specific sound output stream to use for preview, or empty to use the default */ + boost::optional<std::string> _preview_sound_output; /** Singleton instance, or 0 */ static Config* _instance; |
