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