Modify previous commit to move restriction code into the UI.
authorCarl Hetherington <cth@carlh.net>
Tue, 16 Jun 2015 18:40:43 +0000 (19:40 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 16 Jun 2015 18:40:43 +0000 (19:40 +0100)
src/lib/film.cc
src/lib/film.h
src/wx/dcp_panel.cc
src/wx/dcp_panel.h

index 98b9210293f34ac3e4df539425596920ff3b778a..66d651c27e06825c94425a61c55883e68da2fec0 100644 (file)
@@ -1232,18 +1232,3 @@ Film::audio_output_names () const
 
        return vector<string> (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);
-}
index a1daebe783f854d5e422a44bbc6dad47985cd0f2..96a79f9cf5abfd6179922da03e376e0a2aac472c 100644 (file)
@@ -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.
index 0759694f8802db016c07506b36559049c95e0ba0..2829d88fa3f0ef118f9c756aae26311a97528c49 100644 (file)
@@ -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<string> (_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<string> (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<pair<string, string> > 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<string> (i), dcp::raw_convert<string> (i)));
        }
 
index ab4e7f1d3cbc0cc9b033dee4955d0c9fd95c05de..ac6792dddf7649adff8ed7756c5fe4d4e98229ca 100644 (file)
@@ -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 ();