Mercurial > hg > sonic-visualiser
comparison main/PreferencesDialog.cpp @ 1415:13eb1d55f129 3.0-integration
Avoid overflowing vector if number of devices becomes smaller
author | Chris Cannam |
---|---|
date | Mon, 12 Dec 2016 17:01:16 +0000 |
parents | a89ca5ccb958 |
children | 8bff263578ae |
comparison
equal
deleted
inserted
replaced
1414:65d34b07de85 | 1415:13eb1d55f129 |
---|---|
873 QString permishTag = QString("network-permission-%1").arg(SV_VERSION); | 873 QString permishTag = QString("network-permission-%1").arg(SV_VERSION); |
874 settings.setValue(permishTag, m_networkPermission); | 874 settings.setValue(permishTag, m_networkPermission); |
875 | 875 |
876 vector<string> names = breakfastquay::AudioFactory::getImplementationNames(); | 876 vector<string> names = breakfastquay::AudioFactory::getImplementationNames(); |
877 string implementationName; | 877 string implementationName; |
878 if (m_audioImplementation > int(names.size())) { | |
879 m_audioImplementation = 0; | |
880 } | |
878 if (m_audioImplementation > 0) { | 881 if (m_audioImplementation > 0) { |
879 implementationName = names[m_audioImplementation-1]; | 882 implementationName = names[m_audioImplementation-1]; |
880 } | 883 } |
881 settings.setValue("audio-target", implementationName.c_str()); | 884 settings.setValue("audio-target", implementationName.c_str()); |
882 | 885 |
885 suffix = "-" + QString(implementationName.c_str()); | 888 suffix = "-" + QString(implementationName.c_str()); |
886 } | 889 } |
887 | 890 |
888 names = breakfastquay::AudioFactory::getPlaybackDeviceNames(implementationName); | 891 names = breakfastquay::AudioFactory::getPlaybackDeviceNames(implementationName); |
889 string deviceName; | 892 string deviceName; |
893 if (m_audioPlaybackDevice > int(names.size())) { | |
894 m_audioPlaybackDevice = 0; | |
895 } | |
890 if (m_audioPlaybackDevice > 0) { | 896 if (m_audioPlaybackDevice > 0) { |
891 deviceName = names[m_audioPlaybackDevice-1]; | 897 deviceName = names[m_audioPlaybackDevice-1]; |
892 } | 898 } |
893 settings.setValue("audio-playback-device" + suffix, deviceName.c_str()); | 899 settings.setValue("audio-playback-device" + suffix, deviceName.c_str()); |
894 | 900 |
895 names = breakfastquay::AudioFactory::getRecordDeviceNames(implementationName); | 901 names = breakfastquay::AudioFactory::getRecordDeviceNames(implementationName); |
896 deviceName = ""; | 902 deviceName = ""; |
903 if (m_audioRecordDevice > int(names.size())) { | |
904 m_audioRecordDevice = 0; | |
905 } | |
897 if (m_audioRecordDevice > 0) { | 906 if (m_audioRecordDevice > 0) { |
898 deviceName = names[m_audioRecordDevice-1]; | 907 deviceName = names[m_audioRecordDevice-1]; |
899 } | 908 } |
900 settings.setValue("audio-record-device" + suffix, deviceName.c_str()); | 909 settings.setValue("audio-record-device" + suffix, deviceName.c_str()); |
901 | 910 |
920 m_changesOnRestart = false; | 929 m_changesOnRestart = false; |
921 } | 930 } |
922 | 931 |
923 if (m_audioDeviceChanged) { | 932 if (m_audioDeviceChanged) { |
924 emit audioDeviceChanged(); | 933 emit audioDeviceChanged(); |
934 m_audioDeviceChanged = false; | |
925 } | 935 } |
926 } | 936 } |
927 | 937 |
928 void | 938 void |
929 PreferencesDialog::cancelClicked() | 939 PreferencesDialog::cancelClicked() |