Skip to content
Snippets Groups Projects
Unverified Commit 2bdd0f58 authored by Sébastien Blin's avatar Sébastien Blin
Browse files

avmodel: fix media selection

Change-Id: I0c4616142839e155ebbf69182aa3a27b67b14065
parent 6c103318
Branches
No related tags found
No related merge requests found
......@@ -721,10 +721,10 @@ AVModelPimpl::getDevice(int type) const
std::string result = "";
std::vector<std::string> devices;
switch (type) {
case 0: // INPUT
case 1: // INPUT
devices = linked_.getAudioInputDevices();
break;
case 1: // OUTPUT
case 0: // OUTPUT
case 2: // RINGTONE
devices = linked_.getAudioOutputDevices();
break;
......@@ -734,17 +734,18 @@ AVModelPimpl::getDevice(int type) const
QStringList currentDevicesIdx = ConfigurationManager::instance()
.getCurrentAudioDevicesIndex();
try {
if (currentDevicesIdx.size() < 3
|| devices.size() != static_cast<size_t>(currentDevicesIdx.size())) {
if (currentDevicesIdx.size() < 3) {
// Should not happen, but cannot retrieve current ringtone device
return "";
}
auto deviceIdx = currentDevicesIdx[type].toUInt();
if (deviceIdx >= devices.size()) {
// Incorrect device index
result = devices[0];
for (const auto& dev : devices) {
int idx = ConfigurationManager::instance().getAudioInputDeviceIndex(dev.c_str());
if (idx == deviceIdx) {
return dev;
}
result = devices[deviceIdx];
}
return "";
} catch (std::bad_alloc& ba) {
qWarning() << "bad_alloc caught: " << ba.what();
return "";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment