aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthexai <58434170+thexai@users.noreply.github.com>2022-01-17 16:17:51 +0100
committerGitHub <noreply@github.com>2022-01-17 16:17:51 +0100
commit7a91f047bb13aa206554ed0ccafdbee521e27a99 (patch)
treea5c07840ef652924d35cd71df36a9379e32dc693
parent7b899104dedc9b1d8dfcec92af383e0cfaab878c (diff)
parent2c774ac6d6989075202e9dc5806a4a3d6874a857 (diff)
Merge pull request #20856 from thexai/audio-devices-filter
[audio] Filters audio devices from audio devices lists according capabilities reported by sinks
-rw-r--r--xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAESink.cpp9
-rw-r--r--xbmc/cores/AudioEngine/Sinks/AESinkAUDIOTRACK.cpp4
-rw-r--r--xbmc/cores/AudioEngine/Sinks/AESinkWASAPI.cpp7
-rw-r--r--xbmc/cores/AudioEngine/Sinks/AESinkXAudio.cpp2
-rw-r--r--xbmc/cores/AudioEngine/Utils/AEDeviceInfo.h3
5 files changed, 24 insertions, 1 deletions
diff --git a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAESink.cpp b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAESink.cpp
index aea2c054be..65164b38c9 100644
--- a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAESink.cpp
+++ b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAESink.cpp
@@ -751,6 +751,15 @@ void CActiveAESink::EnumerateOutputDevices(AEDeviceList &devices, bool passthrou
if (passthrough && devInfo.m_deviceType == AE_DEVTYPE_PCM)
continue;
+ // filters devices that should not be shown in the list
+ // of AUDIO DEVICES or AUDIO PASSTHROUGH DEVICES
+ // according to the capabilities informed by each sink
+ if (devInfo.m_onlyPassthrough && !passthrough)
+ continue;
+
+ if (devInfo.m_onlyPCM && passthrough)
+ continue;
+
std::string device = sinkInfo.m_sinkName + ":" + devInfo.m_deviceName;
std::stringstream ss;
diff --git a/xbmc/cores/AudioEngine/Sinks/AESinkAUDIOTRACK.cpp b/xbmc/cores/AudioEngine/Sinks/AESinkAUDIOTRACK.cpp
index 9595f874b9..cef7374483 100644
--- a/xbmc/cores/AudioEngine/Sinks/AESinkAUDIOTRACK.cpp
+++ b/xbmc/cores/AudioEngine/Sinks/AESinkAUDIOTRACK.cpp
@@ -994,6 +994,10 @@ void CAESinkAUDIOTRACK::EnumerateDevicesEx(AEDeviceInfoList &list, bool force)
UpdateAvailablePassthroughCapabilities(isRaw);
m_info_raw = m_info;
+ // no need to display two PCM sinks - as they are the same
+ if (!list.empty())
+ m_info_raw.m_onlyPassthrough = true;
+
list.push_back(m_info_raw);
}
diff --git a/xbmc/cores/AudioEngine/Sinks/AESinkWASAPI.cpp b/xbmc/cores/AudioEngine/Sinks/AESinkWASAPI.cpp
index 3ebda06606..94e96043e3 100644
--- a/xbmc/cores/AudioEngine/Sinks/AESinkWASAPI.cpp
+++ b/xbmc/cores/AudioEngine/Sinks/AESinkWASAPI.cpp
@@ -12,6 +12,7 @@
#include "cores/AudioEngine/Utils/AEDeviceInfo.h"
#include "cores/AudioEngine/Utils/AEUtil.h"
#include "utils/StringUtils.h"
+#include "utils/SystemInfo.h"
#include "utils/TimeUtils.h"
#include "utils/XTimeUtils.h"
#include "utils/log.h"
@@ -404,6 +405,8 @@ void CAESinkWASAPI::EnumerateDevicesEx(AEDeviceInfoList &deviceInfoList, bool fo
WAVEFORMATEXTENSIBLE wfxex = {};
HRESULT hr;
+ const bool onlyPT = (CSysInfo::GetWindowsDeviceFamily() == CSysInfo::WindowsDeviceFamily::Xbox);
+
for(RendererDetail& details : CAESinkFactoryWin::GetRendererDetails())
{
deviceInfo.m_channels.Reset();
@@ -638,18 +641,20 @@ void CAESinkWASAPI::EnumerateDevicesEx(AEDeviceInfoList &deviceInfoList, bool fo
/* Store the device info */
deviceInfo.m_wantsIECPassthrough = true;
+ deviceInfo.m_onlyPassthrough = onlyPT;
if (!deviceInfo.m_streamTypes.empty())
deviceInfo.m_dataFormats.push_back(AE_FMT_RAW);
deviceInfoList.push_back(deviceInfo);
- if(details.bDefault)
+ if (details.bDefault)
{
deviceInfo.m_deviceName = std::string("default");
deviceInfo.m_displayName = std::string("default");
deviceInfo.m_displayNameExtra = std::string("");
deviceInfo.m_wantsIECPassthrough = true;
+ deviceInfo.m_onlyPassthrough = onlyPT;
deviceInfoList.push_back(deviceInfo);
}
diff --git a/xbmc/cores/AudioEngine/Sinks/AESinkXAudio.cpp b/xbmc/cores/AudioEngine/Sinks/AESinkXAudio.cpp
index 52bb8d6227..6e578f3012 100644
--- a/xbmc/cores/AudioEngine/Sinks/AESinkXAudio.cpp
+++ b/xbmc/cores/AudioEngine/Sinks/AESinkXAudio.cpp
@@ -577,6 +577,7 @@ void CAESinkXAudio::EnumerateDevicesEx(AEDeviceInfoList &deviceInfoList, bool fo
/* Store the device info */
deviceInfo.m_wantsIECPassthrough = true;
+ deviceInfo.m_onlyPCM = true;
if (!deviceInfo.m_streamTypes.empty())
deviceInfo.m_dataFormats.push_back(AE_FMT_RAW);
@@ -589,6 +590,7 @@ void CAESinkXAudio::EnumerateDevicesEx(AEDeviceInfoList &deviceInfoList, bool fo
deviceInfo.m_displayName = std::string("default");
deviceInfo.m_displayNameExtra = std::string("");
deviceInfo.m_wantsIECPassthrough = true;
+ deviceInfo.m_onlyPCM = true;
deviceInfoList.push_back(deviceInfo);
}
}
diff --git a/xbmc/cores/AudioEngine/Utils/AEDeviceInfo.h b/xbmc/cores/AudioEngine/Utils/AEDeviceInfo.h
index e0fcb4ae1e..387d61700f 100644
--- a/xbmc/cores/AudioEngine/Utils/AEDeviceInfo.h
+++ b/xbmc/cores/AudioEngine/Utils/AEDeviceInfo.h
@@ -42,6 +42,9 @@ public:
bool m_wantsIECPassthrough; /* if sink supports passthrough encapsulation is done when set to true */
+ bool m_onlyPassthrough{false}; // sink only only should be used for passthrough (audio PT device)
+ bool m_onlyPCM{false}; // sink only should be used for PCM (audio device)
+
operator std::string();
static std::string DeviceTypeToString(enum AEDeviceType deviceType);
};