}
+optional<string>
+AudioBackend::start_stream()
+{
+#if (RTAUDIO_VERSION_MAJOR >= 6)
+ if (_rtaudio.startStream() != RTAUDIO_NO_ERROR) {
+ return last_rtaudio_error();
+ }
+#else
+ try {
+ _rtaudio.startStream();
+ } catch (RtAudioError& e) {
+ return string(e.what());
+ }
+#endif
+
+ return {};
+}
+
+
}
void abort_stream_if_running();
+ boost::optional<std::string> start_stream();
+
#if (RTAUDIO_VERSION_MAJOR >= 6)
std::string last_rtaudio_error() const;
#endif
if (audio.isStreamOpen()) {
audio.setStreamTime(_video_view->position().seconds());
-#if (RTAUDIO_VERSION_MAJOR >= 6)
- if (audio.startStream() != RTAUDIO_NO_ERROR) {
+ auto error = AudioBackend::instance()->start_stream();
+ if (error) {
_audio_channels = 0;
error_dialog(
_video_view->get(),
- _("There was a problem starting audio playback. Please try another audio output device in Preferences."), std_to_wx(audio.last_rtaudio_error())
- );
- }
-#else
- try {
- audio.startStream ();
- } catch (RtAudioError& e) {
- _audio_channels = 0;
- error_dialog (
- _video_view->get(),
- _("There was a problem starting audio playback. Please try another audio output device in Preferences."), std_to_wx(e.what())
+ _("There was a problem starting audio playback. Please try another audio output device in Preferences."), std_to_wx(*error)
);
}
-#endif
}
}