Add NamedChannel and use it to hide the never-used channels
[dcpomatic.git] / src / wx / config_dialog.cc
index 7a4bb92c9e16e1589785d8aac07377e6ebd2e102..40bb4340761c432fb6a13cb61a5ff00845852e25 100644 (file)
@@ -927,7 +927,11 @@ SoundPage::sound_output_changed ()
        string default_device;
        try {
                default_device = audio.getDeviceInfo(audio.getDefaultOutputDevice()).name;
+#ifdef DCPOMATIC_USE_RTERROR
+       } catch (RtError&) {
+#else
        } catch (RtAudioError&) {
+#endif
                /* Never mind */
        }
        if (!so || *so == default_device) {
@@ -954,7 +958,11 @@ SoundPage::config_changed ()
                RtAudio audio (DCPOMATIC_RTAUDIO_API);
                try {
                        configured_so = audio.getDeviceInfo(audio.getDefaultOutputDevice()).name;
-               } catch (RtAudioError& e) {
+#ifdef DCPOMATIC_USE_RTERROR
+               } catch (RtError&) {
+#else
+               } catch (RtAudioError&) {
+#endif
                        /* Probably no audio devices at all */
                }
        }
@@ -987,9 +995,17 @@ SoundPage::config_changed ()
        int channels = 0;
        if (configured_so) {
                for (unsigned int i = 0; i < audio.getDeviceCount(); ++i) {
-                       RtAudio::DeviceInfo info = audio.getDeviceInfo(i);
-                       if (info.name == *configured_so && info.outputChannels > 0) {
-                               channels = info.outputChannels;
+                       try {
+                               RtAudio::DeviceInfo info = audio.getDeviceInfo(i);
+                               if (info.name == *configured_so && info.outputChannels > 0) {
+                                       channels = info.outputChannels;
+                               }
+#ifdef DCPOMATIC_USE_RTERROR
+                       } catch (RtError&) {
+#else
+                       } catch (RtAudioError&) {
+#endif
+                               /* Never mind */
                        }
                }
        }
@@ -1000,15 +1016,15 @@ SoundPage::config_changed ()
 
        _map->set (Config::instance()->audio_mapping(channels));
 
-       vector<string> input;
+       vector<NamedChannel> input;
        for (int i = 0; i < MAX_DCP_AUDIO_CHANNELS; ++i) {
-               input.push_back (short_audio_channel_name(i));
+               input.push_back (NamedChannel(short_audio_channel_name(i), i));
        }
        _map->set_input_channels (input);
 
-       vector<string> output;
+       vector<NamedChannel> output;
        for (int i = 0; i < channels; ++i) {
-               output.push_back (dcp::raw_convert<string>(i));
+               output.push_back (NamedChannel(dcp::raw_convert<string>(i), i));
        }
        _map->set_output_channels (output);