summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2022-11-10 00:20:41 +0100
committerCarl Hetherington <cth@carlh.net>2022-11-13 00:12:26 +0100
commitc9bbf48f901c1f132306cbfaae967eda36f8bb60 (patch)
tree4beb3565e94998dcee0b354ecbe64d7d73ab7791
parentc2f74bf15f6f2a88138119a42a44f4241169f6e5 (diff)
Create only one RtAudio instance, in the FilmViewer, rather than
creating them on-the-fly in config as well.
-rw-r--r--src/tools/dcpomatic.cc2
-rw-r--r--src/tools/dcpomatic_player.cc2
-rw-r--r--src/wx/config_dialog.cc10
-rw-r--r--src/wx/config_dialog.h5
-rw-r--r--src/wx/film_viewer.h4
-rw-r--r--src/wx/full_config_dialog.cc6
-rw-r--r--src/wx/full_config_dialog.h3
-rw-r--r--src/wx/player_config_dialog.cc4
-rw-r--r--src/wx/player_config_dialog.h6
9 files changed, 28 insertions, 14 deletions
diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc
index 001d1859e..e1c973c14 100644
--- a/src/tools/dcpomatic.cc
+++ b/src/tools/dcpomatic.cc
@@ -766,7 +766,7 @@ private:
void edit_preferences ()
{
if (!_config_dialog) {
- _config_dialog = create_full_config_dialog ();
+ _config_dialog = create_full_config_dialog(&_film_viewer);
}
_config_dialog->Show (this);
}
diff --git a/src/tools/dcpomatic_player.cc b/src/tools/dcpomatic_player.cc
index 096da0004..21f07d1d0 100644
--- a/src/tools/dcpomatic_player.cc
+++ b/src/tools/dcpomatic_player.cc
@@ -775,7 +775,7 @@ private:
}
if (!_config_dialog) {
- _config_dialog = create_player_config_dialog ();
+ _config_dialog = create_player_config_dialog(&_viewer);
}
_config_dialog->Show (this);
}
diff --git a/src/wx/config_dialog.cc b/src/wx/config_dialog.cc
index b23b4bae8..0f7b2660f 100644
--- a/src/wx/config_dialog.cc
+++ b/src/wx/config_dialog.cc
@@ -23,6 +23,7 @@
#include "check_box.h"
#include "config_dialog.h"
#include "dcpomatic_button.h"
+#include "film_viewer.h"
#include "nag_dialog.h"
#include "static_text.h"
#include <dcp/file.h>
@@ -883,7 +884,7 @@ SoundPage::setup ()
font.SetPointSize (font.GetPointSize() - 1);
_sound_output_details->SetFont (font);
- RtAudio audio (DCPOMATIC_RTAUDIO_API);
+ auto& audio = _viewer->audio_backend();
for (unsigned int i = 0; i < audio.getDeviceCount(); ++i) {
try {
auto dev = audio.getDeviceInfo (i);
@@ -922,7 +923,7 @@ SoundPage::sound_changed ()
void
SoundPage::sound_output_changed ()
{
- RtAudio audio (DCPOMATIC_RTAUDIO_API);
+ auto& audio = _viewer->audio_backend();
auto const so = get_sound_output();
string default_device;
try {
@@ -947,11 +948,12 @@ SoundPage::config_changed ()
auto const current_so = get_sound_output ();
optional<string> configured_so;
+ auto& audio = _viewer->audio_backend();
+
if (config->sound_output()) {
configured_so = config->sound_output().get();
} else {
/* No configured output means we should use the default */
- RtAudio audio (DCPOMATIC_RTAUDIO_API);
try {
configured_so = audio.getDeviceInfo(audio.getDefaultOutputDevice()).name;
} catch (RtAudioError&) {
@@ -971,8 +973,6 @@ SoundPage::config_changed ()
}
}
- RtAudio audio (DCPOMATIC_RTAUDIO_API);
-
map<int, wxString> apis;
apis[RtAudio::MACOSX_CORE] = _("CoreAudio");
apis[RtAudio::WINDOWS_ASIO] = _("ASIO");
diff --git a/src/wx/config_dialog.h b/src/wx/config_dialog.h
index e0d7f15b8..5f2e02c23 100644
--- a/src/wx/config_dialog.h
+++ b/src/wx/config_dialog.h
@@ -50,6 +50,7 @@ LIBDCP_ENABLE_WARNINGS
class AudioMappingView;
class CheckBox;
+class FilmViewer;
class Page : public wxPreferencesPage
@@ -189,8 +190,9 @@ private:
class SoundPage : public Page
{
public:
- SoundPage (wxSize panel_size, int border)
+ SoundPage(wxSize panel_size, int border, FilmViewer* viewer)
: Page (panel_size, border)
+ , _viewer(viewer)
{}
wxString GetName() const override;
@@ -218,6 +220,7 @@ private:
wxStaticText* _sound_output_details;
AudioMappingView* _map;
Button* _reset_to_default;
+ FilmViewer* _viewer;
};
diff --git a/src/wx/film_viewer.h b/src/wx/film_viewer.h
index aea3f8c86..5d524de81 100644
--- a/src/wx/film_viewer.h
+++ b/src/wx/film_viewer.h
@@ -112,6 +112,10 @@ public:
int errored () const;
int gets () const;
+ RtAudio& audio_backend() {
+ return _audio;
+ }
+
int audio_callback (void* out, unsigned int frames);
StateTimer const & state_timer () const {
diff --git a/src/wx/full_config_dialog.cc b/src/wx/full_config_dialog.cc
index c688109c9..ec2546485 100644
--- a/src/wx/full_config_dialog.cc
+++ b/src/wx/full_config_dialog.cc
@@ -1803,7 +1803,7 @@ private:
wxPreferencesEditor*
-create_full_config_dialog ()
+create_full_config_dialog(FilmViewer* viewer)
{
auto e = new wxPreferencesEditor ();
@@ -1820,7 +1820,9 @@ create_full_config_dialog ()
#endif
e->AddPage (new FullGeneralPage (ps, border));
- e->AddPage (new SoundPage (ps, border));
+ if (viewer) {
+ e->AddPage(new SoundPage(ps, border, viewer));
+ }
e->AddPage (new DefaultsPage (ps, border));
e->AddPage (new EncodingServersPage(ps, border));
e->AddPage (new KeysPage (ps, border));
diff --git a/src/wx/full_config_dialog.h b/src/wx/full_config_dialog.h
index ae275b188..1df8a0e40 100644
--- a/src/wx/full_config_dialog.h
+++ b/src/wx/full_config_dialog.h
@@ -25,7 +25,8 @@
class wxPreferencesEditor;
+class FilmViewer;
-wxPreferencesEditor* create_full_config_dialog ();
+wxPreferencesEditor* create_full_config_dialog(FilmViewer* viewer = nullptr);
diff --git a/src/wx/player_config_dialog.cc b/src/wx/player_config_dialog.cc
index 0312a6621..270feab29 100644
--- a/src/wx/player_config_dialog.cc
+++ b/src/wx/player_config_dialog.cc
@@ -342,7 +342,7 @@ private:
wxPreferencesEditor*
-create_player_config_dialog ()
+create_player_config_dialog(FilmViewer* viewer)
{
auto e = new wxPreferencesEditor (_("DCP-o-matic Player Preferences"));
@@ -359,7 +359,7 @@ create_player_config_dialog ()
#endif
e->AddPage (new PlayerGeneralPage(wxSize(-1, 500), border));
- e->AddPage (new SoundPage(ps, border));
+ e->AddPage(new SoundPage(ps, border, viewer));
e->AddPage (new LocationsPage(ps, border));
e->AddPage (new KeysPage(ps, border));
e->AddPage (new PlayerAdvancedPage(ps, border));
diff --git a/src/wx/player_config_dialog.h b/src/wx/player_config_dialog.h
index 9834de376..9a4474fc9 100644
--- a/src/wx/player_config_dialog.h
+++ b/src/wx/player_config_dialog.h
@@ -18,10 +18,14 @@
*/
+
/** @file src/player_config_dialog.h
* @brief A dialogue to edit DCP-o-matic Player configuration.
*/
+
class wxPreferencesEditor;
+class FilmViewer;
+
-wxPreferencesEditor* create_player_config_dialog ();
+wxPreferencesEditor* create_player_config_dialog(FilmViewer* viewer);