diff --git a/src/audio/DirectSoundAPI.cpp b/src/audio/DirectSoundAPI.cpp index 8f85fd1a..ff2dc6dc 100644 --- a/src/audio/DirectSoundAPI.cpp +++ b/src/audio/DirectSoundAPI.cpp @@ -226,6 +226,11 @@ std::vector DirectSoundAPI::GetDevices() return TRUE; }, &result); + //Exclude default primary sound device if no other sound devices are available + if (result.size() == 1 && result.at(0).get()->GetIdentifier() == L"default") { + result.clear(); + } + return result; } diff --git a/src/audio/XAudio2API.cpp b/src/audio/XAudio2API.cpp index 0cc54651..795a0ebe 100644 --- a/src/audio/XAudio2API.cpp +++ b/src/audio/XAudio2API.cpp @@ -187,10 +187,6 @@ const std::vector& XAudio2API::RefreshDevices( // this function must be called from the same thread as we called CoInitializeEx s_devices.clear(); - // always add the default device - auto default_device = std::make_shared(L"Primary Sound Driver", L""); - s_devices.emplace_back(default_device); - if (FAILED(CoInitializeEx(nullptr, COINIT_MULTITHREADED | COINIT_DISABLE_OLE1DDE))) return s_devices; @@ -262,6 +258,12 @@ const std::vector& XAudio2API::RefreshDevices( } } + // Only add default device if audio devices exist + if (s_devices.size() > 0) { + auto default_device = std::make_shared(L"Primary Sound Driver", L""); + s_devices.insert(s_devices.begin(), default_device); + } + wbem_enum->Release(); // Clean up