Create only one RtAudio instance, in the FilmViewer, rather than
authorCarl Hetherington <cth@carlh.net>
Wed, 9 Nov 2022 23:20:41 +0000 (00:20 +0100)
committerCarl Hetherington <cth@carlh.net>
Sat, 12 Nov 2022 23:12:26 +0000 (00:12 +0100)
creating them on-the-fly in config as well.

src/tools/dcpomatic.cc
src/tools/dcpomatic_player.cc
src/wx/config_dialog.cc
src/wx/config_dialog.h
src/wx/film_viewer.h
src/wx/full_config_dialog.cc
src/wx/full_config_dialog.h
src/wx/player_config_dialog.cc
src/wx/player_config_dialog.h

index 001d1859eec93fd51219f229b02ee386ab333c89..e1c973c1444b54cdc3caf625c455c594f50c8cf8 100644 (file)
@@ -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);
        }
index 096da00047d24538388a5237d07b4543aa85682e..21f07d1d0d01d71e98283c5c17e8043065b6a552 100644 (file)
@@ -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);
        }
index b23b4bae80542c359aad86bea14b2dabd48cc44e..0f7b2660fa21606fb6f817ab288178dff69e72b6 100644 (file)
@@ -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");
index e0d7f15b8447cc1c9f59f35f6ab5113882671a7d..5f2e02c23eb469071b5171c6194401be7bbddf87 100644 (file)
@@ -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;
 };
 
 
index aea3f8c8633465933af11c5e5ccad26610d87d4d..5d524de81b37c20ce4a5cb096969087dd9dbfa8c 100644 (file)
@@ -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 {
index c688109c9a8ee640129897293700e94c56759b92..ec25464856e8a3ea6223eb8fb005c6ab6f009fc8 100644 (file)
@@ -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));
index ae275b188a1aad7f4859607dfcfe4ec25490a2d9..1df8a0e40131ed73a8a58e5317b8896380021459 100644 (file)
@@ -25,7 +25,8 @@
 
 
 class wxPreferencesEditor;
+class FilmViewer;
 
 
-wxPreferencesEditor* create_full_config_dialog ();
+wxPreferencesEditor* create_full_config_dialog(FilmViewer* viewer = nullptr);
 
index 0312a66218e66f718d1c866bcf6c2c56145c8dd6..270feab2911dd3779fd32f155bb0e40dafdaf477 100644 (file)
@@ -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));
index 9834de3765b10c3df4196a5083d039219557c0db..9a4474fc9fb2a503317d05ffa5e09fb89bc429fd 100644 (file)
 
 */
 
+
 /** @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);