+ optional<unsigned int> chosen_device_id;
+#if (RTAUDIO_VERSION_MAJOR >= 6)
+ if (Config::instance()->sound_output()) {
+ for (auto device_id: _audio.getDeviceIds()) {
+ if (_audio.getDeviceInfo(device_id).name == Config::instance()->sound_output().get()) {
+ chosen_device_id = device_id;
+ break;
+ }
+ }
+ }
+
+ if (!chosen_device_id) {
+ chosen_device_id = _audio.getDefaultOutputDevice();
+ }
+ _audio_channels = _audio.getDeviceInfo(*chosen_device_id).outputChannels;
+ RtAudio::StreamParameters sp;
+ sp.deviceId = *chosen_device_id;
+ sp.nChannels = _audio_channels;
+ sp.firstChannel = 0;
+ if (_audio.openStream(&sp, 0, RTAUDIO_FLOAT32, 48000, &_audio_block_size, &rtaudio_callback, this) != RTAUDIO_NO_ERROR) {
+ _audio_channels = 0;
+ error_dialog(
+ _video_view->get(),
+ _("Could not set up audio output. There will be no audio during the preview."), std_to_wx(last_rtaudio_error())
+ );
+ }
+#else