Skip to content

Commit 30aa0be

Browse files
committed
alsa: mark surround71 also as device type hdmi
On t7 tdm-c is used for hbr audio passthrough.
1 parent af7b76a commit 30aa0be

File tree

6 files changed

+93
-16
lines changed

6 files changed

+93
-16
lines changed

xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp

+26-2
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ void CActiveAE::StateMachine(int signal, Protocol *port, Message *msg)
772772
if(stream)
773773
{
774774
msg->Reply(CActiveAEDataProtocol::ACC, &stream, sizeof(CActiveAEStream*));
775-
LoadSettings();
775+
LoadSettings(&streamMsg->format);
776776
Configure();
777777
if (!m_extError)
778778
{
@@ -2640,13 +2640,37 @@ void CActiveAE::Deamplify(CSoundPacket &dstSample)
26402640
// Configuration
26412641
//-----------------------------------------------------------------------------
26422642

2643-
void CActiveAE::LoadSettings()
2643+
void CActiveAE::LoadSettings(AEAudioFormat *format)
26442644
{
26452645
const std::shared_ptr<CSettings> settings = CServiceBroker::GetSettingsComponent()->GetSettings();
26462646

26472647
m_settings.device = settings->GetString(CSettings::SETTING_AUDIOOUTPUT_AUDIODEVICE);
26482648
m_settings.passthroughdevice = settings->GetString(CSettings::SETTING_AUDIOOUTPUT_PASSTHROUGHDEVICE);
26492649

2650+
switch (aml_get_cpufamily_id())
2651+
{
2652+
case AML_T7:
2653+
{
2654+
// find on NEWSTREAM the matching passthrough device by device type
2655+
if (format != NULL)
2656+
{
2657+
std::string device(m_settings.passthroughdevice);
2658+
if (SupportsFormat(*format, &device))
2659+
{
2660+
if (device != m_settings.passthroughdevice)
2661+
{
2662+
CLog::LogF(LOGINFO, "Change temporary passthrough output device because of Amlogic SoC '{}', stream type: {:d}",
2663+
aml_get_cpufamily_name(), format->m_streamInfo.m_type);
2664+
m_settings.passthroughdevice = device;
2665+
}
2666+
}
2667+
}
2668+
break;
2669+
}
2670+
default:
2671+
break;
2672+
}
2673+
26502674
m_settings.config = settings->GetInt(CSettings::SETTING_AUDIOOUTPUT_CONFIG);
26512675
m_settings.channels = (m_sink.GetDeviceType(m_settings.device) == AE_DEVTYPE_IEC958) ? AE_CH_LAYOUT_2_0 : settings->GetInt(CSettings::SETTING_AUDIOOUTPUT_CHANNELS);
26522676
m_settings.samplerate = settings->GetInt(CSettings::SETTING_AUDIOOUTPUT_SAMPLERATE);

xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ class CActiveAE : public IAE, public IDispResource, private CThread
309309
void DrainSink();
310310
void UnconfigureSink();
311311
void Dispose();
312-
void LoadSettings();
312+
void LoadSettings(AEAudioFormat *format = NULL);
313313
void ValidateOutputDevices(bool saveChanges);
314314
bool NeedReconfigureBuffers();
315315
bool NeedReconfigureSink();

xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAESettings.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,11 @@ void CActiveAESettings::SettingOptionsAudioDevicesFillerGeneral(
176176
{
177177
for (AEDeviceList::const_iterator sink = sinkList.begin(); sink != sinkList.end(); ++sink)
178178
{
179+
// filter L-PCM device when passthrough on Amlogic T7
180+
if (passthrough && aml_get_cpufamily_id() == AML_T7 &&
181+
StringUtils::StartsWith(sink->second, "ALSA:surround71"))
182+
continue;
183+
179184
if (sink == sinkList.begin())
180185
firstDevice = sink->second;
181186

xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAESink.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,10 @@ std::string CActiveAESink::ValidateOuputDevice(const std::string& device, bool p
751751
if (!passthrough && d.m_onlyPassthrough)
752752
continue;
753753

754+
// filter L-PCM device when passthrough on Amlogic T7
755+
if (passthrough && (d.m_deviceName.substr(0, d.m_deviceName.find(':')) == "surround71"))
756+
continue;
757+
754758
if (d.m_deviceName == dev.name)
755759
return d.ToDeviceString(sink.m_sinkName);
756760
}
@@ -773,6 +777,10 @@ std::string CActiveAESink::ValidateOuputDevice(const std::string& device, bool p
773777
if (!passthrough && d.m_onlyPassthrough)
774778
continue;
775779

780+
// filter L-PCM device when passthrough on Amlogic T7
781+
if (passthrough && (d.m_deviceName.substr(0, d.m_deviceName.find(':')) == "surround71"))
782+
continue;
783+
776784
if (d.GetFriendlyName() == dev.friendlyName)
777785
return d.ToDeviceString(sink.m_sinkName);
778786
}
@@ -797,6 +805,10 @@ std::string CActiveAESink::ValidateOuputDevice(const std::string& device, bool p
797805
if (!passthrough && d.m_onlyPassthrough)
798806
continue;
799807

808+
// filter L-PCM device when passthrough on Amlogic T7
809+
if (passthrough && (d.m_deviceName.substr(0, d.m_deviceName.find(':')) == "surround71"))
810+
continue;
811+
800812
if (firstDevice.empty())
801813
firstDevice = d.ToDeviceString(sink.m_sinkName);
802814

@@ -826,6 +838,10 @@ std::string CActiveAESink::ValidateOuputDevice(const std::string& device, bool p
826838
if (!passthrough && d.m_onlyPassthrough)
827839
continue;
828840

841+
// filter L-PCM device when passthrough on Amlogic T7
842+
if (passthrough && (d.m_deviceName.substr(0, d.m_deviceName.find(':')) == "surround71"))
843+
continue;
844+
829845
if (firstDevice.empty())
830846
firstDevice = d.ToDeviceString(sink.m_sinkName);
831847

xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAESink.h

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include "threads/SystemClock.h"
1717
#include "threads/Thread.h"
1818
#include "utils/ActorProtocol.h"
19+
#include "utils/AMLUtils.h"
20+
#include "utils/StringUtils.h"
1921

2022
#include <memory>
2123
#include <utility>

xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp

+43-13
Original file line numberDiff line numberDiff line change
@@ -1607,9 +1607,10 @@ void CAESinkALSA::EnumerateDevicesEx(AEDeviceInfoList &list, bool force)
16071607

16081608
AEDeviceType CAESinkALSA::AEDeviceTypeFromName(const std::string &name)
16091609
{
1610-
if (name.substr(0, 4) == "hdmi")
1610+
if (name.substr(0, name.find(':')) == "hdmi" ||
1611+
(aml_get_cpufamily_id() == AML_T7 && name.substr(0, name.find(':')) == "surround71"))
16111612
return AE_DEVTYPE_HDMI;
1612-
else if (name.substr(0, 6) == "iec958" || name.substr(0, 5) == "spdif")
1613+
else if (name.substr(0, name.find(':')) == "iec958" || name.substr(0, name.find(':')) == "spdif")
16131614
return AE_DEVTYPE_IEC958;
16141615

16151616
return AE_DEVTYPE_PCM;
@@ -1870,25 +1871,54 @@ void CAESinkALSA::EnumerateDevice(AEDeviceInfoList &list, const std::string &dev
18701871
info.m_displayNameExtra = "S/PDIF";
18711872
else if (info.m_deviceType != AE_DEVTYPE_HDMI)
18721873
{
1873-
if (device.substr(0, 10) == "surround71")
1874+
if (device.substr(0, device.find(':')) == "surround71")
18741875
info.m_displayNameExtra = "HDMI Multi Ch PCM";
18751876
else
18761877
info.m_displayNameExtra = "PCM";
18771878
}
1879+
else if (aml_get_cpufamily_id() == AML_T7 && info.m_deviceType == AE_DEVTYPE_HDMI)
1880+
{
1881+
if (device.substr(0, device.find(':')) == "surround71")
1882+
info.m_displayNameExtra = "HDMI Multi Ch PCM";
1883+
}
18781884
}
18791885

1886+
// we don't trust ELD information and push back our supported formats explicitly
18801887
if (info.m_deviceType == AE_DEVTYPE_HDMI)
18811888
{
1882-
// we don't trust ELD information and push back our supported formats explicitly
1883-
info.m_streamTypes.push_back(CAEStreamInfo::STREAM_TYPE_AC3);
1884-
info.m_streamTypes.push_back(CAEStreamInfo::STREAM_TYPE_DTSHD);
1885-
info.m_streamTypes.push_back(CAEStreamInfo::STREAM_TYPE_DTSHD_MA);
1886-
info.m_streamTypes.push_back(CAEStreamInfo::STREAM_TYPE_DTSHD_CORE);
1887-
info.m_streamTypes.push_back(CAEStreamInfo::STREAM_TYPE_DTS_1024);
1888-
info.m_streamTypes.push_back(CAEStreamInfo::STREAM_TYPE_DTS_2048);
1889-
info.m_streamTypes.push_back(CAEStreamInfo::STREAM_TYPE_DTS_512);
1890-
info.m_streamTypes.push_back(CAEStreamInfo::STREAM_TYPE_EAC3);
1891-
info.m_streamTypes.push_back(CAEStreamInfo::STREAM_TYPE_TRUEHD);
1889+
switch (aml_get_cpufamily_id())
1890+
{
1891+
case AML_T7:
1892+
{
1893+
if (device.substr(0, device.find(':')) == "surround71")
1894+
{
1895+
info.m_streamTypes.push_back(CAEStreamInfo::STREAM_TYPE_DTSHD_MA);
1896+
info.m_streamTypes.push_back(CAEStreamInfo::STREAM_TYPE_TRUEHD);
1897+
}
1898+
else
1899+
{
1900+
info.m_streamTypes.push_back(CAEStreamInfo::STREAM_TYPE_AC3);
1901+
info.m_streamTypes.push_back(CAEStreamInfo::STREAM_TYPE_DTSHD);
1902+
info.m_streamTypes.push_back(CAEStreamInfo::STREAM_TYPE_DTSHD_CORE);
1903+
info.m_streamTypes.push_back(CAEStreamInfo::STREAM_TYPE_DTS_1024);
1904+
info.m_streamTypes.push_back(CAEStreamInfo::STREAM_TYPE_DTS_2048);
1905+
info.m_streamTypes.push_back(CAEStreamInfo::STREAM_TYPE_DTS_512);
1906+
info.m_streamTypes.push_back(CAEStreamInfo::STREAM_TYPE_EAC3);
1907+
}
1908+
break;
1909+
}
1910+
default:
1911+
info.m_streamTypes.push_back(CAEStreamInfo::STREAM_TYPE_AC3);
1912+
info.m_streamTypes.push_back(CAEStreamInfo::STREAM_TYPE_DTSHD);
1913+
info.m_streamTypes.push_back(CAEStreamInfo::STREAM_TYPE_DTSHD_MA);
1914+
info.m_streamTypes.push_back(CAEStreamInfo::STREAM_TYPE_DTSHD_CORE);
1915+
info.m_streamTypes.push_back(CAEStreamInfo::STREAM_TYPE_DTS_1024);
1916+
info.m_streamTypes.push_back(CAEStreamInfo::STREAM_TYPE_DTS_2048);
1917+
info.m_streamTypes.push_back(CAEStreamInfo::STREAM_TYPE_DTS_512);
1918+
info.m_streamTypes.push_back(CAEStreamInfo::STREAM_TYPE_EAC3);
1919+
info.m_streamTypes.push_back(CAEStreamInfo::STREAM_TYPE_TRUEHD);
1920+
break;
1921+
}
18921922

18931923
// indicate that we can do AE_FMT_RAW
18941924
info.m_dataFormats.push_back(AE_FMT_RAW);

0 commit comments

Comments
 (0)