Disallow referring to OV audio unless channel counts match (#2780).
[dcpomatic.git] / src / wx / audio_panel.cc
index 81a445efbce029fa7bf51842bf0ac9eba3d4c8f5..fcadd0c68fa6deccce4c48f9fda17ed0a9a50275 100644 (file)
@@ -34,6 +34,7 @@
 #include "lib/dcp_content.h"
 #include "lib/ffmpeg_audio_stream.h"
 #include "lib/ffmpeg_content.h"
+#include "lib/film.h"
 #include "lib/job_manager.h"
 #include "lib/maths_util.h"
 #include <dcp/warnings.h>
@@ -128,9 +129,9 @@ AudioPanel::create ()
        _delay->wrapped()->SetRange (-1000, 1000);
 
        content_selection_changed ();
-       film_changed (Film::Property::AUDIO_CHANNELS);
-       film_changed (Film::Property::VIDEO_FRAME_RATE);
-       film_changed (Film::Property::REEL_TYPE);
+       film_changed(FilmProperty::AUDIO_CHANNELS);
+       film_changed(FilmProperty::VIDEO_FRAME_RATE);
+       film_changed(FilmProperty::REEL_TYPE);
 
        _reference->bind(&AudioPanel::reference_clicked, this);
        _show->Bind                  (wxEVT_BUTTON,   boost::bind (&AudioPanel::show_clicked, this));
@@ -145,7 +146,7 @@ AudioPanel::create ()
 
        add_to_grid ();
 
-       _sizer->Layout ();
+       layout();
 }
 
 
@@ -196,23 +197,24 @@ AudioPanel::add_to_grid ()
 
 
 void
-AudioPanel::film_changed (Film::Property property)
+AudioPanel::film_changed (FilmProperty property)
 {
        if (!_parent->film()) {
                return;
        }
 
        switch (property) {
-       case Film::Property::AUDIO_CHANNELS:
-       case Film::Property::AUDIO_PROCESSOR:
+       case FilmProperty::AUDIO_CHANNELS:
+       case FilmProperty::AUDIO_PROCESSOR:
                _mapping->set_output_channels (_parent->film()->audio_output_names ());
                setup_peak ();
+               setup_sensitivity();
                break;
-       case Film::Property::VIDEO_FRAME_RATE:
+       case FilmProperty::VIDEO_FRAME_RATE:
                setup_description ();
                break;
-       case Film::Property::REEL_TYPE:
-       case Film::Property::INTEROP:
+       case FilmProperty::REEL_TYPE:
+       case FilmProperty::INTEROP:
                setup_sensitivity ();
                break;
        default:
@@ -304,18 +306,17 @@ AudioPanel::film_content_changed (int property)
 void
 AudioPanel::gain_calculate_button_clicked ()
 {
-       auto d = new GainCalculatorDialog (this);
-       auto const r = d->ShowModal ();
-       auto c = d->db_change();
+       GainCalculatorDialog dialog(this);
+       auto const r = dialog.ShowModal();
+       auto change = dialog.db_change();
 
-       if (r == wxID_CANCEL || !c) {
-               d->Destroy ();
+       if (r == wxID_CANCEL || !change) {
                return;
        }
 
        auto old_peak_dB = peak ();
        auto old_value = _gain->wrapped()->GetValue();
-       _gain->wrapped()->SetValue(old_value + *c);
+       _gain->wrapped()->SetValue(old_value + *change);
 
        /* This appears to be necessary, as the change is not signalled,
           I think.
@@ -328,8 +329,6 @@ AudioPanel::gain_calculate_button_clicked ()
                _gain->wrapped()->SetValue (old_value);
                _gain->view_changed ();
        }
-
-       d->Destroy ();
 }