mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-18 09:00:07 +02:00
bug 11 followup fix input hotswapping while monitoring; enable/disable when recording/playing
This commit is contained in:
parent
8c645724a1
commit
14cc918d7f
@ -265,7 +265,7 @@ void DeviceToolBar::Populate()
|
||||
mInput->Enable(false);
|
||||
|
||||
|
||||
wxStaticText *channelsLabel = new wxStaticText(this, wxID_ANY, wxT("# Channels:"),
|
||||
wxStaticText *channelsLabel = new wxStaticText(this, wxID_ANY, _("Rec Channels:"),
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxALIGN_LEFT);
|
||||
Add(channelsLabel, 0, wxALIGN_CENTER);
|
||||
@ -304,6 +304,14 @@ void DeviceToolBar::Populate()
|
||||
wxFocusEventHandler(DeviceToolBar::OnFocus),
|
||||
NULL,
|
||||
this);
|
||||
mInputChannels->Connect(wxEVT_SET_FOCUS,
|
||||
wxFocusEventHandler(DeviceToolBar::OnFocus),
|
||||
NULL,
|
||||
this);
|
||||
mInputChannels->Connect(wxEVT_KILL_FOCUS,
|
||||
wxFocusEventHandler(DeviceToolBar::OnFocus),
|
||||
NULL,
|
||||
this);
|
||||
|
||||
FillHostDevices();
|
||||
FillInputChannels();
|
||||
@ -406,12 +414,26 @@ void DeviceToolBar::UpdatePrefs()
|
||||
ToolBar::UpdatePrefs();
|
||||
}
|
||||
|
||||
|
||||
void DeviceToolBar::EnableDisableButtons()
|
||||
{
|
||||
if (gAudioIO) {
|
||||
// we allow changes when monitoring, but not when recording
|
||||
bool audioStreamActive = gAudioIO->IsStreamActive() && !gAudioIO->IsMonitoring();
|
||||
mHost->Enable(!audioStreamActive);
|
||||
mInput->Enable(!audioStreamActive);
|
||||
mOutput->Enable(!audioStreamActive);
|
||||
mInputChannels->Enable(!audioStreamActive);
|
||||
}
|
||||
}
|
||||
|
||||
void DeviceToolBar::RegenerateTooltips()
|
||||
{
|
||||
#if wxUSE_TOOLTIPS
|
||||
mOutput->SetToolTip(_("Output Device"));
|
||||
mInput->SetToolTip(_("Input Device"));
|
||||
mHost->SetToolTip(_("Audio Host"));
|
||||
mInputChannels->SetToolTip(_("Input Channels"));
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -612,8 +634,28 @@ void DeviceToolBar::OnChoice(wxCommandEvent &event)
|
||||
SetDevices(&mInputDeviceSourceMaps[newInIndex], &mOutputDeviceSourceMaps[newOutIndex]);
|
||||
}
|
||||
|
||||
if (gAudioIO)
|
||||
if (gAudioIO) {
|
||||
// We cannot have gotten here if gAudioIO->IsAudioTokenActive(),
|
||||
// per the setting of AudioIONotBusyFlag and AudioIOBusyFlag in
|
||||
// AudacityProject::GetUpdateFlags().
|
||||
// However, we can have an invalid audio token (so IsAudioTokenActive()
|
||||
// is false), but be monitoring.
|
||||
// If monitoring, have to stop the stream, so HandleDeviceChange() can work.
|
||||
// We could disable the Preferences command while monitoring, i.e.,
|
||||
// set AudioIONotBusyFlag/AudioIOBusyFlag according to monitoring, as well.
|
||||
// Instead allow it because unlike recording, for example, monitoring
|
||||
// is not clearly something that should prohibit changing device.
|
||||
// TO-DO: We *could* be smarter in this method and call HandleDeviceChange()
|
||||
// only when the device choices actually changed. True of lots of prefs!
|
||||
// As is, we always stop monitoring before handling the device change.
|
||||
if (gAudioIO->IsMonitoring())
|
||||
{
|
||||
gAudioIO->StopStream();
|
||||
while (gAudioIO->IsBusy())
|
||||
wxMilliSleep(100);
|
||||
}
|
||||
gAudioIO->HandleDeviceChange();
|
||||
}
|
||||
GetActiveProject()->UpdatePrefs();
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ class DeviceToolBar:public ToolBar {
|
||||
|
||||
virtual void Populate();
|
||||
virtual void Repaint(wxDC *dc) {};
|
||||
virtual void EnableDisableButtons() {};
|
||||
virtual void EnableDisableButtons();
|
||||
|
||||
void OnFocus(wxFocusEvent &event);
|
||||
void OnCaptureKey(wxCommandEvent &event);
|
||||
|
Loading…
x
Reference in New Issue
Block a user