Commit 93f872e5 authored by Kateryna Kostiuk's avatar Kateryna Kostiuk Committed by Adrien Béraud
Browse files

audio: get device index by name

Change-Id: I3eb0f0a6ecfec16b9032defd1836f7de37159206
parent 019d948c
...@@ -47,28 +47,34 @@ CoreLayer::~CoreLayer() ...@@ -47,28 +47,34 @@ CoreLayer::~CoreLayer()
std::vector<std::string> std::vector<std::string>
CoreLayer::getCaptureDeviceList() const CoreLayer::getCaptureDeviceList() const
{ {
auto list = getDeviceList(true);
std::vector<std::string> ret; std::vector<std::string> ret;
ret.reserve(list.size());
for (const auto& x : getDeviceList(true)) for (auto& x : list)
ret.push_back(x.name_); ret.emplace_back(std::move(x.name_));
return ret; return ret;
} }
std::vector<std::string> std::vector<std::string>
CoreLayer::getPlaybackDeviceList() const CoreLayer::getPlaybackDeviceList() const
{ {
auto list = getDeviceList(false);
std::vector<std::string> ret; std::vector<std::string> ret;
ret.reserve(list.size());
for (const auto& x : getDeviceList(false)) for (auto& x : list)
ret.push_back(x.name_); ret.emplace_back(std::move(x.name_));
return ret; return ret;
} }
int int
CoreLayer::getAudioDeviceIndex(const std::string& name, DeviceType type) const CoreLayer::getAudioDeviceIndex(const std::string& name, DeviceType type) const
{ {
int i = 0;
for (const auto& device : getDeviceList(type == DeviceType::CAPTURE)) {
if (device.name_ == name)
return i;
i++;
}
return 0; return 0;
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment