Update of /cvsroot/audacity/audacity-src/src/prefs
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv10184/src/prefs

Modified Files:
        DevicePrefs.cpp 
Log Message:
Don't allow devices from different Host APIs in device toolbar; a possible fix 
for some JACK problems.


Index: DevicePrefs.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/prefs/DevicePrefs.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- DevicePrefs.cpp     18 Oct 2009 08:02:15 -0000      1.8
+++ DevicePrefs.cpp     16 Nov 2009 17:51:53 -0000      1.9
@@ -158,7 +158,23 @@
 
 void DevicePrefs::OnHost(wxCommandEvent & e)
 {
-   int index = mHost->GetCurrentSelection(); /* the hostAPI index the user has 
selected */
+   // Find the index for the host API selected
+   int index = -1;
+   wxString apiName = mHostNames[mHost->GetCurrentSelection()];
+   int nHosts = Pa_GetHostApiCount();
+   for (int i = 0; i < nHosts; ++i) {
+      wxString name(Pa_GetHostApiInfo(i)->name, wxConvLocal);
+      if (name == apiName) {
+         index = i;
+         break;
+      }
+   }
+   // We should always find the host!
+   if (index < 0) {
+      wxLogDebug(wxT("DevicePrefs::OnHost(): API index not found"));
+      return;
+   }
+
    int nDevices = Pa_GetDeviceCount();
 
    if (nDevices == 0) {
@@ -218,11 +234,19 @@
    if (mPlay->GetCount() && mPlay->GetSelection() == wxNOT_FOUND) {
       wxLogDebug(wxT("DevicePrefs::OnHost(): no play device selected"));
       mPlay->SetStringSelection(GetDefaultPlayDevice(index));
+
+      if (mPlay->GetSelection() == wxNOT_FOUND) {
+         mPlay->SetSelection(0);
+      }
    }
 
    if (mRecord->GetCount() && mRecord->GetSelection() == wxNOT_FOUND) {
       wxLogDebug(wxT("DevicePrefs::OnHost(): no record device selected"));
       mRecord->SetStringSelection(GetDefaultRecordDevice(index));
+
+      if (mPlay->GetSelection() == wxNOT_FOUND) {
+         mPlay->SetSelection(0);
+      }
    }
 
    ShuttleGui S(this, eIsCreating);


------------------------------------------------------------------------------
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

Reply via email to