Skip to content

Commit b300763

Browse files
committed
autoselect audio device if available and different from configured one in the previously saved patch (usually file from another computer)
1 parent 23d35bf commit b300763

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

src/ofxVisualProgramming.cpp

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,9 +1417,17 @@ void ofxVisualProgramming::loadPatch(string patchFile){
14171417
}
14181418
}
14191419
}
1420-
if(audioGUIINIndex == -1){ // no input devices available
1421-
isInputDeviceAvailable = false;
1422-
audioGUIINIndex = 0;
1420+
if(audioGUIINIndex == -1){ // no configured input device available
1421+
// check if there is one available
1422+
if(!audioDevicesID_IN.empty()){
1423+
isInputDeviceAvailable = true;
1424+
// select the first one available
1425+
audioGUIINIndex = audioDevicesID_IN.at(0);
1426+
audioINDev = audioDevicesID_IN.at(audioGUIINIndex);
1427+
}else{
1428+
isInputDeviceAvailable = false;
1429+
audioGUIINIndex = 0;
1430+
}
14231431
}else{
14241432
isInputDeviceAvailable = true;
14251433
audioINDev = audioDevicesID_IN.at(audioGUIINIndex);
@@ -1434,9 +1442,17 @@ void ofxVisualProgramming::loadPatch(string patchFile){
14341442
}
14351443
}
14361444
}
1437-
if(audioGUIOUTIndex == -1){ // no output devices available
1438-
isOutputDeviceAvailable = false;
1439-
audioGUIOUTIndex = 0;
1445+
if(audioGUIOUTIndex == -1){ // no configured output device available
1446+
// check if there is one available
1447+
if(!audioDevicesID_OUT.empty()){
1448+
isOutputDeviceAvailable = true;
1449+
// select the first one available
1450+
audioGUIOUTIndex = audioDevicesID_OUT.at(0);
1451+
audioOUTDev = audioDevicesID_OUT.at(audioGUIOUTIndex);
1452+
}else{
1453+
isOutputDeviceAvailable = false;
1454+
audioGUIOUTIndex = 0;
1455+
}
14401456
}else{
14411457
isOutputDeviceAvailable = true;
14421458
audioOUTDev = audioDevicesID_OUT.at(audioGUIOUTIndex);

0 commit comments

Comments
 (0)