diff options
| author | Carl Hetherington <cth@carlh.net> | 2024-09-11 10:11:53 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2024-09-11 10:17:33 +0200 |
| commit | 6956a022841ab12e9ebf47b08cf8c18a6e1a2f86 (patch) | |
| tree | fc7d65ac7e0b5f67e076634b8992a295b419b05b | |
| parent | fb03de626d7b3f12b7ec1e97dc423791f2737152 (diff) | |
Cleanup: add AudioBackend::stream_open().
| -rw-r--r-- | src/wx/audio_backend.cc | 7 | ||||
| -rw-r--r-- | src/wx/audio_backend.h | 1 | ||||
| -rw-r--r-- | src/wx/film_viewer.cc | 15 |
3 files changed, 15 insertions, 8 deletions
diff --git a/src/wx/audio_backend.cc b/src/wx/audio_backend.cc index 2ebe34b3f..f3729ed10 100644 --- a/src/wx/audio_backend.cc +++ b/src/wx/audio_backend.cc @@ -227,3 +227,10 @@ AudioBackend::set_stream_time(double time) _rtaudio.setStreamTime(time); } + +bool +AudioBackend::stream_open() const +{ + return _rtaudio.isStreamOpen(); +} + diff --git a/src/wx/audio_backend.h b/src/wx/audio_backend.h index af834b8ee..6130f31ec 100644 --- a/src/wx/audio_backend.h +++ b/src/wx/audio_backend.h @@ -49,6 +49,7 @@ public: boost::optional<std::string> start_stream(); int stream_latency() const; + bool stream_open() const; void set_stream_time(double time); diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc index 6ab89fdaa..f38bb6878 100644 --- a/src/wx/film_viewer.cc +++ b/src/wx/film_viewer.cc @@ -239,7 +239,7 @@ FilmViewer::create_butler() DCPOMATIC_ASSERT(_player); - auto& audio = AudioBackend::instance()->rtaudio(); + auto audio = AudioBackend::instance(); _butler = std::make_shared<Butler>( _film, @@ -251,7 +251,7 @@ FilmViewer::create_butler() (opengl && _optimisation != Optimisation::NONE) ? Image::Alignment::COMPACT : Image::Alignment::PADDED, true, opengl && _optimisation == Optimisation::JPEG2000, - (Config::instance()->sound() && audio.isStreamOpen()) ? Butler::Audio::ENABLED : Butler::Audio::DISABLED + (Config::instance()->sound() && audio->stream_open()) ? Butler::Audio::ENABLED : Butler::Audio::DISABLED ); _closed_captions_dialog->set_butler (_butler); @@ -350,12 +350,11 @@ FilmViewer::suspend () void FilmViewer::start_audio_stream_if_open () { - auto& audio = AudioBackend::instance()->rtaudio(); + auto audio = AudioBackend::instance(); - if (audio.isStreamOpen()) { - AudioBackend::instance()->set_stream_time(_video_view->position().seconds()); - auto error = AudioBackend::instance()->start_stream(); - if (error) { + if (audio->stream_open()) { + audio->set_stream_time(_video_view->position().seconds()); + if (auto error = audio->start_stream()) { _audio_channels = 0; error_dialog( _video_view->get(), @@ -606,7 +605,7 @@ FilmViewer::config_changed (Config::Property p) auto backend = AudioBackend::instance(); auto& audio = backend->rtaudio(); - if (audio.isStreamOpen()) { + if (backend->stream_open()) { audio.closeStream(); } |
