MAX_AUDIO_CHANNELS -> MAX_DCP_AUDIO_CHANNELS.
[dcpomatic.git] / src / wx / audio_dialog.cc
index 462eb8d50d02c65c6201172b7dcc9b2b5e76563c..0e1316cf31979f21d3ec4790f1a3ba5bb7154461 100644 (file)
@@ -20,6 +20,7 @@
 #include <boost/filesystem.hpp>
 #include "lib/audio_analysis.h"
 #include "lib/film.h"
+#include "lib/audio_content.h"
 #include "audio_dialog.h"
 #include "audio_plot.h"
 #include "wx_util.h"
@@ -44,7 +45,7 @@ AudioDialog::AudioDialog (wxWindow* parent)
                side->Add (m, 1, wxALIGN_CENTER_VERTICAL | wxTOP, 16);
        }
 
-       for (int i = 0; i < MAX_AUDIO_CHANNELS; ++i) {
+       for (int i = 0; i < MAX_DCP_AUDIO_CHANNELS; ++i) {
                _channel_checkbox[i] = new wxCheckBox (this, wxID_ANY, std_to_wx (audio_channel_name (i)));
                side->Add (_channel_checkbox[i], 1, wxEXPAND | wxALL, 3);
                _channel_checkbox[i]->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&AudioDialog::channel_clicked, this, _1));
@@ -86,7 +87,7 @@ void
 AudioDialog::set_content (shared_ptr<AudioContent> c)
 {
        _content_changed_connection.disconnect ();
-       
+
        _content = c;
 
        try_to_load_analysis ();
@@ -94,14 +95,18 @@ AudioDialog::set_content (shared_ptr<AudioContent> c)
 
        _content_changed_connection = _content->Changed.connect (bind (&AudioDialog::content_changed, this, _2));
 
-       SetTitle (wxString::Format (_("DCP-o-matic audio - %s"), std_to_wx(_content->path().filename().string()).data()));
+       SetTitle (wxString::Format (_("DCP-o-matic audio - %s"), std_to_wx(_content->path_summary()).data()));
 }
 
 void
 AudioDialog::try_to_load_analysis ()
 {
-       if (!boost::filesystem::exists (_content->audio_analysis_path()) && IsShown ()) {
-               _content->analyse_audio (bind (&AudioDialog::analysis_finished, this));
+       if (!IsShown ()) {
+               return;
+       }
+
+       if (!boost::filesystem::exists (_content->audio_analysis_path())) {
+               _analysis_finished_connection = _content->analyse_audio (bind (&AudioDialog::analysis_finished, this));
                return;
        }
        
@@ -139,11 +144,11 @@ void
 AudioDialog::channel_clicked (wxCommandEvent& ev)
 {
        int c = 0;
-       while (c < MAX_AUDIO_CHANNELS && ev.GetEventObject() != _channel_checkbox[c]) {
+       while (c < MAX_DCP_AUDIO_CHANNELS && ev.GetEventObject() != _channel_checkbox[c]) {
                ++c;
        }
 
-       assert (c < MAX_AUDIO_CHANNELS);
+       assert (c < MAX_DCP_AUDIO_CHANNELS);
 
        _plot->set_channel_visible (c, _channel_checkbox[c]->GetValue ());
 }