Update of /cvsroot/audacity/audacity-src/src/toolbars In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv10184/src/toolbars
Modified Files: DeviceToolBar.cpp Log Message: Don't allow devices from different Host APIs in device toolbar; a possible fix for some JACK problems. Index: DeviceToolBar.cpp =================================================================== RCS file: /cvsroot/audacity/audacity-src/src/toolbars/DeviceToolBar.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- DeviceToolBar.cpp 29 May 2009 17:07:39 -0000 1.6 +++ DeviceToolBar.cpp 16 Nov 2009 17:51:53 -0000 1.7 @@ -209,6 +209,58 @@ void DeviceToolBar::OnChoice(wxCommandEvent &event) { + wxString oldInput = gPrefs->Read(wxT("/AudioIO/RecordingDevice"), wxT("")); + wxString newInput = mInput->GetString(mInput->GetSelection()); + wxString oldOutput = gPrefs->Read(wxT("/AudioIO/PlaybackDevice"), wxT("")); + wxString newOutput = mOutput->GetString(mOutput->GetSelection()); + int oldInIndex = -1, newInIndex = -1, oldOutIndex = -1, newOutIndex = -1; + int nDevices = Pa_GetDeviceCount(); + + // Find device indices for input and output + for (int i = 0; i < nDevices; ++i) + { + const PaDeviceInfo *info = Pa_GetDeviceInfo(i); + wxString name = DeviceName(info); + + if (name == oldInput) oldInIndex = i; + if (name == newInput) newInIndex = i; + if (name == oldOutput) oldOutIndex = i; + if (name == newOutput) newOutIndex = i; + } + + // This shouldn't happen for new choices (it's OK for old ones) + if (newInIndex < 0 || newOutIndex < 0) + { + wxLogDebug(wxT("DeviceToolBar::OnChoice(): couldn't find device indices")); + return; + } + + const PaDeviceInfo *inInfo = Pa_GetDeviceInfo(newInIndex); + const PaDeviceInfo *outInfo = Pa_GetDeviceInfo(newOutIndex); + if (oldInIndex != newInIndex) + { + // We changed input; be sure the output device has the same API + if (inInfo->hostApi != outInfo->hostApi) { + // Set output device to default for the API + const PaHostApiInfo *apiInfo = Pa_GetHostApiInfo(inInfo->hostApi); + outInfo = Pa_GetDeviceInfo(apiInfo->defaultOutputDevice); + mOutput->SetStringSelection(DeviceName(outInfo)); + } + } + else if (oldOutIndex != newOutIndex) + { + // We changed output; be sure the input device has the same API + if (outInfo->hostApi != inInfo->hostApi) { + // Set input device to default for the API + const PaHostApiInfo *apiInfo = Pa_GetHostApiInfo(outInfo->hostApi); + inInfo = Pa_GetDeviceInfo(apiInfo->defaultInputDevice); + mInput->SetStringSelection(DeviceName(inInfo)); + } + } + + gPrefs->Write(wxT("/AudioIO/Host"), + wxString(Pa_GetHostApiInfo(inInfo->hostApi)->name, wxConvLocal)); + gPrefs->Write(wxT("/AudioIO/RecordingDevice"), mInput->GetString(mInput->GetSelection())); ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Audacity-cvs mailing list Audacity-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/audacity-cvs