From 20eea989f452ea1a6af0af6b5c5b504d3b19480c Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 16 Jun 2015 19:40:43 +0100 Subject: [PATCH] Modify previous commit to move restriction code into the UI. --- src/lib/film.cc | 15 --------------- src/lib/film.h | 8 ++++---- src/wx/dcp_panel.cc | 21 ++++++++++++++++----- src/wx/dcp_panel.h | 2 ++ 4 files changed, 22 insertions(+), 24 deletions(-) diff --git a/src/lib/film.cc b/src/lib/film.cc index 98b921029..66d651c27 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -1232,18 +1232,3 @@ Film::audio_output_names () const return vector (n.begin(), n.begin() + audio_channels ()); } - -int -Film::audio_channels () const -{ - int minimum = 0; - if (_audio_processor) { - minimum = _audio_processor->out_channels (); - } - - if (minimum % 2 == 1) { - ++minimum; - } - - return max (minimum, _audio_channels); -} diff --git a/src/lib/film.h b/src/lib/film.h index a1daebe78..96a79f9cf 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -223,7 +223,9 @@ public: return _video_frame_rate; } - int audio_channels () const; + int audio_channels () const { + return _audio_channels; + } bool three_d () const { return _three_d; @@ -324,9 +326,7 @@ private: int _video_frame_rate; /** The date that we should use in a ISDCF name */ boost::gregorian::date _isdcf_date; - /** Number of audio channels requested for the DCP; this will be overridden - if we are using an audio processor which outputs more channels. - */ + /** Number of audio channels requested for the DCP */ int _audio_channels; /** If true, the DCP will be written in 3D mode; otherwise in 2D. This will be regardless of what content is on the playlist. diff --git a/src/wx/dcp_panel.cc b/src/wx/dcp_panel.cc index 0759694f8..2829d88fa 100644 --- a/src/wx/dcp_panel.cc +++ b/src/wx/dcp_panel.cc @@ -43,6 +43,7 @@ using std::list; using std::string; using std::vector; using std::pair; +using std::max; using std::make_pair; using boost::lexical_cast; using boost::shared_ptr; @@ -349,8 +350,12 @@ DCPPanel::film_changed (int p) break; } case Film::AUDIO_CHANNELS: - checked_set (_audio_channels, dcp::raw_convert (_film->audio_channels ())); - setup_dcp_name (); + if (_film->audio_channels () < minimum_allowed_audio_channels ()) { + _film->set_audio_channels (minimum_allowed_audio_channels ()); + } else { + checked_set (_audio_channels, dcp::raw_convert (max (minimum_allowed_audio_channels(), _film->audio_channels ()))); + setup_dcp_name (); + } break; case Film::THREE_D: checked_set (_three_d, _film->three_d ()); @@ -653,8 +658,8 @@ DCPPanel::make_video_panel () return panel; } -void -DCPPanel::setup_audio_channels_choice () +int +DCPPanel::minimum_allowed_audio_channels () const { int min = 2; if (_film && _film->audio_processor ()) { @@ -665,8 +670,14 @@ DCPPanel::setup_audio_channels_choice () ++min; } + return min; +} + +void +DCPPanel::setup_audio_channels_choice () +{ vector > items; - for (int i = min; i <= 12; i += 2) { + for (int i = minimum_allowed_audio_channels(); i <= 12; i += 2) { items.push_back (make_pair (dcp::raw_convert (i), dcp::raw_convert (i))); } diff --git a/src/wx/dcp_panel.h b/src/wx/dcp_panel.h index ab4e7f1d3..ac6792ddd 100644 --- a/src/wx/dcp_panel.h +++ b/src/wx/dcp_panel.h @@ -78,6 +78,8 @@ private: void setup_dcp_name (); void setup_audio_channels_choice (); + int minimum_allowed_audio_channels () const; + wxPanel* make_general_panel (); wxPanel* make_video_panel (); wxPanel* make_audio_panel (); -- 2.30.2