mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-31 07:59:27 +02:00
Send event, so that DeviceManager does not depend on DeviceToolBar...
... freeing it and DevicePrefs from cycles
This commit is contained in:
parent
ccc49f8ccf
commit
7ef5ebc97a
@ -38,7 +38,8 @@
|
||||
#include "AudioIOBase.h"
|
||||
|
||||
#include "DeviceChange.h" // for HAVE_DEVICE_CHANGE
|
||||
#include "toolbars/DeviceToolBar.h"
|
||||
|
||||
wxDEFINE_EVENT(EVT_RESCANNED_DEVICES, wxCommandEvent);
|
||||
|
||||
DeviceManager DeviceManager::dm;
|
||||
|
||||
@ -299,13 +300,11 @@ void DeviceManager::Rescan()
|
||||
}
|
||||
|
||||
// If this was not an initial scan update each device toolbar.
|
||||
// Hosts may have disappeared or appeared so a complete repopulate is needed.
|
||||
if (m_inited) {
|
||||
for ( auto pProject : AllProjects{} ) {
|
||||
auto &dt = DeviceToolBar::Get( *pProject );
|
||||
dt.RefillCombos();
|
||||
}
|
||||
if ( m_inited ) {
|
||||
wxCommandEvent e{ EVT_RESCANNED_DEVICES };
|
||||
wxTheApp->ProcessEvent( e );
|
||||
}
|
||||
|
||||
m_inited = true;
|
||||
mRescanTime = std::chrono::steady_clock::now();
|
||||
}
|
||||
|
@ -23,12 +23,17 @@
|
||||
#include <chrono>
|
||||
#include <vector>
|
||||
|
||||
#include <wx/event.h> // to declare a custom event type
|
||||
#include <wx/string.h> // member variables
|
||||
|
||||
#if defined(EXPERIMENTAL_DEVICE_CHANGE_HANDLER)
|
||||
#include "DeviceChange.h"
|
||||
#endif
|
||||
|
||||
// Event sent to the application
|
||||
wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API,
|
||||
EVT_RESCANNED_DEVICES, wxCommandEvent);
|
||||
|
||||
typedef struct DeviceSourceMap {
|
||||
int deviceIndex;
|
||||
int sourceIndex;
|
||||
|
@ -75,6 +75,8 @@ static int DeviceToolbarPrefsID()
|
||||
DeviceToolBar::DeviceToolBar()
|
||||
: ToolBar(DeviceBarID, _("Device"), wxT("Device"), true)
|
||||
{
|
||||
wxTheApp->Bind( EVT_RESCANNED_DEVICES,
|
||||
&DeviceToolBar::OnRescannedDevices, this );
|
||||
}
|
||||
|
||||
DeviceToolBar::~DeviceToolBar()
|
||||
@ -628,6 +630,13 @@ void DeviceToolBar::FillHostDevices()
|
||||
// The setting of the Device is left up to OnChoice
|
||||
}
|
||||
|
||||
void DeviceToolBar::OnRescannedDevices( wxCommandEvent &event )
|
||||
{
|
||||
event.Skip();
|
||||
// Hosts may have disappeared or appeared so a complete repopulate is needed.
|
||||
RefillCombos();
|
||||
}
|
||||
|
||||
//return 1 if host changed, 0 otherwise.
|
||||
int DeviceToolBar::ChangeHost()
|
||||
{
|
||||
|
@ -59,6 +59,8 @@ class DeviceToolBar final : public ToolBar {
|
||||
void RefillCombos();
|
||||
|
||||
private:
|
||||
void OnRescannedDevices( wxCommandEvent& );
|
||||
|
||||
int ChangeHost();
|
||||
void ChangeDevice(bool isInput);
|
||||
void FillHosts();
|
||||
|
Loading…
x
Reference in New Issue
Block a user