summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2021-03-05 19:26:38 +0100
committerMax Kellermann <max@musicpd.org>2021-03-05 19:27:52 +0100
commitfc20a1f10a79a84a081c177eeb2b74c91660d8d1 (patch)
treef0f913b9d265096ab3d4faed6bcde852e9cf1727 /src
parenta4257e51d5c5ad6f23e63cde38f14d72a8efd85c (diff)
output/wasapi: EnumerateDevices() logs, no std::vector
Diffstat (limited to 'src')
-rw-r--r--src/output/plugins/wasapi/WasapiOutputPlugin.cxx23
1 files changed, 7 insertions, 16 deletions
diff --git a/src/output/plugins/wasapi/WasapiOutputPlugin.cxx b/src/output/plugins/wasapi/WasapiOutputPlugin.cxx
index ea470f1a1..23c0e88e2 100644
--- a/src/output/plugins/wasapi/WasapiOutputPlugin.cxx
+++ b/src/output/plugins/wasapi/WasapiOutputPlugin.cxx
@@ -239,7 +239,6 @@ private:
bool is_exclusive;
bool enumerate_devices;
std::string device_config;
- std::vector<std::pair<unsigned int, AllocatedString>> device_desc;
ComPtr<IMMDeviceEnumerator> enumerator;
ComPtr<IMMDevice> device;
ComPtr<IAudioClient> client;
@@ -604,12 +603,11 @@ void WasapiOutput::OpenDevice() {
enumerator.CoCreateInstance(__uuidof(MMDeviceEnumerator), nullptr,
CLSCTX_INPROC_SERVER);
- if (enumerate_devices && SafeTry([this]() { EnumerateDevices(); })) {
- for (const auto &[device, desc] : device_desc) {
- FormatNotice(wasapi_output_domain,
- "Device \"%u\" \"%s\"",
- device,
- desc.c_str());
+ if (enumerate_devices) {
+ try {
+ EnumerateDevices();
+ } catch (...) {
+ LogError(std::current_exception());
}
}
@@ -625,8 +623,6 @@ void WasapiOutput::OpenDevice() {
} else {
device = GetDefaultAudioEndpoint(*enumerator);
}
-
- device_desc.clear();
}
/// run inside COMWorkerThread
@@ -800,15 +796,9 @@ void WasapiOutput::FindSharedFormatSupported(AudioFormat &audio_format) {
/// run inside COMWorkerThread
void WasapiOutput::EnumerateDevices() {
- if (!device_desc.empty()) {
- return;
- }
-
const auto device_collection = EnumAudioEndpoints(*enumerator);
const UINT count = GetCount(*device_collection);
-
- device_desc.reserve(count);
for (UINT i = 0; i < count; ++i) {
const auto enumerated_device = Item(*device_collection, i);
@@ -820,7 +810,8 @@ void WasapiOutput::EnumerateDevices() {
if (name == nullptr)
continue;
- device_desc.emplace_back(i, std::move(name));
+ FormatNotice(wasapi_output_domain,
+ "Device \"%u\" \"%s\"", i, name.c_str());
}
}