From 45e538ab481a441da0526ed22178aa04c1dca0a7 Mon Sep 17 00:00:00 2001 From: fritsch Date: Fri, 6 Sep 2024 21:54:00 +0200 Subject: [PATCH] AESinkAudiotrack: Use 192 khz for TrueHD The 48 khz is historically chosen. There is no way, that this bandwidth would be enough to do DTS-HD-MA or TrueHD. With this new check, we would not list that format anymore - as in the past - it auto fellback to normal DTS and on some machines failed for TrueHD directly. Packers of FireTV only pack DTS-HD-Core, so we keep it on 48 khz here. See also: https://forum.kodi.tv/showthread.php?tid=378616 --- .../AudioEngine/Sinks/AESinkAUDIOTRACK.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/xbmc/cores/AudioEngine/Sinks/AESinkAUDIOTRACK.cpp b/xbmc/cores/AudioEngine/Sinks/AESinkAUDIOTRACK.cpp index e0a42c62a437b..149bc7a2681b5 100644 --- a/xbmc/cores/AudioEngine/Sinks/AESinkAUDIOTRACK.cpp +++ b/xbmc/cores/AudioEngine/Sinks/AESinkAUDIOTRACK.cpp @@ -329,12 +329,19 @@ bool CAESinkAUDIOTRACK::Initialize(AEAudioFormat &format, std::string &device) m_encoding = AEStreamFormatToATFormat(m_format.m_streamInfo.m_type); m_format.m_channelLayout = AE_CH_LAYOUT_2_0; - if (m_format.m_streamInfo.m_type == CAEStreamInfo::STREAM_TYPE_DTSHD_MA || - m_format.m_streamInfo.m_type == CAEStreamInfo::STREAM_TYPE_TRUEHD) + if (m_format.m_streamInfo.m_type == CAEStreamInfo::STREAM_TYPE_DTSHD_MA) { + // we keep the 48 khz sample rate, reason: Androids packer only packs DTS Core + // even if we ask for DTS-HD-MA it seems. m_format.m_channelLayout = AE_CH_LAYOUT_7_1; } + if (m_format.m_streamInfo.m_type == CAEStreamInfo::STREAM_TYPE_TRUEHD) + { + m_format.m_channelLayout = AE_CH_LAYOUT_7_1; + m_sink_sampleRate = 192000; + } + // EAC3 needs real samplerate not the modulation if (m_format.m_streamInfo.m_type == CAEStreamInfo::STREAM_TYPE_EAC3) m_sink_sampleRate = m_format.m_streamInfo.m_sampleRate; @@ -1073,6 +1080,8 @@ void CAESinkAUDIOTRACK::UpdateAvailablePassthroughCapabilities(bool isRaw) m_info.m_wantsIECPassthrough = false; m_info.m_dataFormats.push_back(AE_FMT_RAW); m_info.m_streamTypes.clear(); + bool supports_192khz = m_sink_sampleRates.find(192000) != m_sink_sampleRates.end(); + if (isRaw) { bool canDoAC3 = false; @@ -1126,9 +1135,9 @@ void CAESinkAUDIOTRACK::UpdateAvailablePassthroughCapabilities(bool isRaw) m_info.m_streamTypes.push_back(CAEStreamInfo::STREAM_TYPE_DTSHD_MA); } } - if (CJNIAudioFormat::ENCODING_DOLBY_TRUEHD != -1) + if (CJNIAudioFormat::ENCODING_DOLBY_TRUEHD != -1 && supports_192khz) { - if (VerifySinkConfiguration(48000, AEChannelMapToAUDIOTRACKChannelMask(AE_CH_LAYOUT_7_1), + if (VerifySinkConfiguration(192000, AEChannelMapToAUDIOTRACKChannelMask(AE_CH_LAYOUT_7_1), CJNIAudioFormat::ENCODING_DOLBY_TRUEHD, true)) { CLog::Log(LOGDEBUG, "Firmware implements TrueHD RAW"); @@ -1146,7 +1155,6 @@ void CAESinkAUDIOTRACK::UpdateAvailablePassthroughCapabilities(bool isRaw) CJNIAudioFormat::ENCODING_IEC61937); if (supports_iec) { - bool supports_192khz = m_sink_sampleRates.find(192000) != m_sink_sampleRates.end(); m_info.m_wantsIECPassthrough = true; m_info.m_streamTypes.clear(); m_info.m_dataFormats.push_back(AE_FMT_RAW);