mirror of
https://github.com/cookiengineer/audacity
synced 2025-12-12 15:46:25 +01:00
(bug 29, P3: Input and/or output sliders operate incorrectly for any device when an external device is connected.)
If the Meter Toolbar was monitoring input, PrefsDialog can be opened, but then PrefsDialog::OnOK() needs to StopStream() or AudioIO::HandleDeviceChange() will no-op. We could instead disable the Preferences command while monitoring, i.e., set AudioIONotBusyFlag/AudioIOBusyFlag according to monitoring, as well as gAudioIO->IsAudioTokenActive(). Instead allow it because unlike recording, for example, monitoring is not clearly something that should prohibit opening prefs.
This may have been some of the occasions of bug 29, where user changed device while monitoring, but the AudioIO::HandleDeviceChange() code did not actually change the device, so it look like the user had specificied the motherboard/sound card default device, but Audacity was still using the USB 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 and handle the device change.
In AudacityProject::GetUpdateFlags(), don't need to check (GetAudioIOToken() == 0) alternative because gAudioIO->IsAudioTokenActive() checks that it's greater than zero.
In AudioIO.cpp, cleaned up some logic and encapsulation of boolean methods.
This commit is contained in:
@@ -720,6 +720,9 @@ wxArrayString AudioIO::GetInputSourceNames()
|
||||
void AudioIO::HandleDeviceChange()
|
||||
{
|
||||
// This should not happen, but it would screw things up if it did.
|
||||
// Vaughan, 2010-10-08: But it *did* happen, due to a bug, and nobody
|
||||
// caught it because this method just returned. Added wxASSERT().
|
||||
wxASSERT(!IsStreamActive());
|
||||
if (IsStreamActive())
|
||||
return;
|
||||
|
||||
@@ -1679,7 +1682,6 @@ bool AudioIO::IsStreamActive()
|
||||
bool isActive = false;
|
||||
if( mPortStreamV19 )
|
||||
isActive = (Pa_IsStreamActive( mPortStreamV19 ) > 0);
|
||||
else isActive = false;
|
||||
|
||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||
if( mMidiStreamActive && !mMidiOutputComplete )
|
||||
@@ -1690,10 +1692,7 @@ bool AudioIO::IsStreamActive()
|
||||
|
||||
bool AudioIO::IsStreamActive(int token)
|
||||
{
|
||||
if( IsStreamActive() && token > 0 && token == mStreamToken )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
return (this->IsStreamActive() && this->IsAudioTokenActive(token));
|
||||
}
|
||||
|
||||
bool AudioIO::IsAudioTokenActive(int token)
|
||||
|
||||
@@ -1354,8 +1354,7 @@ wxUint32 AudacityProject::GetUpdateFlags()
|
||||
// have changed, it's not necessary to even check for updates.
|
||||
wxUint32 flags = 0;
|
||||
|
||||
if (GetAudioIOToken() == 0 ||
|
||||
!gAudioIO->IsAudioTokenActive(GetAudioIOToken()))
|
||||
if (!gAudioIO->IsAudioTokenActive(GetAudioIOToken()))
|
||||
flags |= AudioIONotBusyFlag;
|
||||
else
|
||||
flags |= AudioIOBusyFlag;
|
||||
|
||||
@@ -209,6 +209,25 @@ void PrefsDialog::OnOK(wxCommandEvent & event)
|
||||
|
||||
#if USE_PORTMIXER
|
||||
if (gAudioIO) {
|
||||
// We cannot have opened this dialog 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 opening prefs.
|
||||
// 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();
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user