Skip to content

Loading…

AE: make sure sink suppports required samplerate for AC3 and DTS #4338

Merged
merged 2 commits into from

6 participants

@FernetMenta
Team Kodi member

Output samplerates for DTS and AC3 maybe 44.1khz, or 48khz, or something else. We need to make sure that the sink does support required sample rate before opening passthrough mode.

@FernetMenta FernetMenta added the Gotham label
@t-nelson

Confirmed

jenkins build this please

@t-nelson

Needs some OMXPlayer love.

@FernetMenta FernetMenta commented on the diff
xbmc/cores/omxplayer/OMXPlayerAudio.cpp
@@ -511,12 +511,12 @@ AEDataFormat OMXPlayerAudio::GetDataFormat(CDVDStreamInfo hints)
/* check our audio capabilties */
/* pathrought is overriding hw decode*/
- if(hints.codec == AV_CODEC_ID_AC3 && CAEFactory::SupportsRaw(AE_FMT_AC3) && !CSettings::Get().GetBool("audiooutput.dualaudio"))
+ if(hints.codec == AV_CODEC_ID_AC3 && CAEFactory::SupportsRaw(AE_FMT_AC3, hints.samplerate) && !CSettings::Get().GetBool("audiooutput.dualaudio"))
@FernetMenta Team Kodi member

@popcornmix could you have a look at this. the PI sink pushes the supported samplerates to the list, right?

@popcornmix Team Kodi member

No. Do I just want to push formats supported by passthrough?
Technically I'd like all sample rate to be supported for PCM (the analogue output is driven by a PLL, and is genuinely has a continuous range).

@popcornmix Team Kodi member

Can you cherry-pick
popcornmix@b945a0e
if it looks okay.

@FernetMenta Team Kodi member

https://github.com/xbmc/xbmc/blob/master/xbmc/cores/AudioEngine/Sinks/AESinkPi.cpp#L285

I see you push 48khz AC3, DTS, EAC3. If the sink supports i.e. AC3 with 44.1khz, you should to push 44.1 too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@FernetMenta
Team Kodi member

jenkins build this please

@Jalle19 Jalle19 commented on the diff
xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAESink.cpp
@@ -124,7 +124,14 @@ bool CActiveAESink::SupportsFormat(const std::string &device, AEDataFormat forma
AEDataFormatList::iterator itt3;
itt3 = find(info.m_dataFormats.begin(), info.m_dataFormats.end(), format);
if (itt3 != info.m_dataFormats.end())
- return true;
+ {
+ AESampleRateList::iterator itt4;
+ itt4 = find(info.m_sampleRates.begin(), info.m_sampleRates.end(), samplerate);
+ if (itt4 != info.m_sampleRates.end())
@Jalle19 Team Kodi member
Jalle19 added a note

This could be changed to a one-liner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@FernetMenta
Team Kodi member

jenkins build this please

@KeyserSoze1

Should CAEDeviceInfo be re-structured so that sample rate/sample sizes are associated with a format. This way you could report 44.1 for PCM but not AC3 if for some reason your device did not support it.

@FernetMenta
Team Kodi member

If "some reason" is an actual case, we should consider this for G+1. For Gotham the risk is too high that something breaks,

@FernetMenta
Team Kodi member

jenkins build this please

@KeyserSoze1

Well I ask because for example, HDMI EDID could report 44.1 for PCM and not AC3 for example, now are there any devices that actually have this exact case I do not know. But the information is structured so it could. Just suggesting. And I do not argue with waiting till after Gotham for the exact reason you mention.

@FernetMenta
Team Kodi member

Please don't hesitate to remind us or pr some code with your ideas after release. There is lot of room for improvement in this area.

@jmarshallnz jmarshallnz merged commit b11df8b into xbmc:master

1 check passed

Details default Merged build #331 succeeded in 2 hr 41 min
@jmarshallnz jmarshallnz removed the Gotham label
@FernetMenta FernetMenta deleted the FernetMenta:google branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
View
4 xbmc/cores/AudioEngine/AEFactory.cpp
@@ -180,7 +180,7 @@ std::string CAEFactory::GetDefaultDevice(bool passthrough)
return "default";
}
-bool CAEFactory::SupportsRaw(AEDataFormat format)
+bool CAEFactory::SupportsRaw(AEDataFormat format, int samplerate)
{
// check if passthrough is enabled
if (!CSettings::Get().GetBool("audiooutput.passthrough"))
@@ -203,7 +203,7 @@ bool CAEFactory::SupportsRaw(AEDataFormat format)
return false;
if(AE)
- return AE->SupportsRaw(format);
+ return AE->SupportsRaw(format, samplerate);
return false;
}
View
2 xbmc/cores/AudioEngine/AEFactory.h
@@ -52,7 +52,7 @@ class CAEFactory
static void EnumerateOutputDevices(AEDeviceList &devices, bool passthrough);
static void VerifyOutputDevice(std::string &device, bool passthrough);
static std::string GetDefaultDevice(bool passthrough);
- static bool SupportsRaw(AEDataFormat format);
+ static bool SupportsRaw(AEDataFormat format, int samplerate);
static bool SupportsSilenceTimeout();
/**
View
10 xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp
@@ -2176,9 +2176,9 @@ void CActiveAE::OnSettingsChange(const std::string& setting)
}
}
-bool CActiveAE::SupportsRaw(AEDataFormat format)
+bool CActiveAE::SupportsRaw(AEDataFormat format, int samplerate)
{
- if (!m_sink.SupportsFormat(CSettings::Get().GetString("audiooutput.passthroughdevice"), format))
+ if (!m_sink.SupportsFormat(CSettings::Get().GetString("audiooutput.passthroughdevice"), format, samplerate))
return false;
return true;
@@ -2218,19 +2218,19 @@ bool CActiveAE::IsSettingVisible(const std::string &settingId)
}
else if (settingId == "audiooutput.truehdpassthrough")
{
- if (m_sink.SupportsFormat(CSettings::Get().GetString("audiooutput.passthroughdevice"), AE_FMT_TRUEHD) &&
+ if (m_sink.SupportsFormat(CSettings::Get().GetString("audiooutput.passthroughdevice"), AE_FMT_TRUEHD, 192000) &&
CSettings::Get().GetInt("audiooutput.config") != AE_CONFIG_FIXED)
return true;
}
else if (settingId == "audiooutput.dtshdpassthrough")
{
- if (m_sink.SupportsFormat(CSettings::Get().GetString("audiooutput.passthroughdevice"), AE_FMT_DTSHD) &&
+ if (m_sink.SupportsFormat(CSettings::Get().GetString("audiooutput.passthroughdevice"), AE_FMT_DTSHD, 192000) &&
CSettings::Get().GetInt("audiooutput.config") != AE_CONFIG_FIXED)
return true;
}
else if (settingId == "audiooutput.eac3passthrough")
{
- if (m_sink.SupportsFormat(CSettings::Get().GetString("audiooutput.passthroughdevice"), AE_FMT_EAC3) &&
+ if (m_sink.SupportsFormat(CSettings::Get().GetString("audiooutput.passthroughdevice"), AE_FMT_EAC3, 192000) &&
CSettings::Get().GetInt("audiooutput.config") != AE_CONFIG_FIXED)
return true;
}
View
2 xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.h
@@ -221,7 +221,7 @@ class CActiveAE : public IAE, private CThread
virtual void EnumerateOutputDevices(AEDeviceList &devices, bool passthrough);
virtual std::string GetDefaultDevice(bool passthrough);
- virtual bool SupportsRaw(AEDataFormat format);
+ virtual bool SupportsRaw(AEDataFormat format, int samplerate);
virtual bool SupportsSilenceTimeout();
virtual bool SupportsQualityLevel(enum AEQuality level);
virtual bool IsSettingVisible(const std::string &settingId);
View
11 xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAESink.cpp
@@ -107,7 +107,7 @@ bool CActiveAESink::HasPassthroughDevice()
return false;
}
-bool CActiveAESink::SupportsFormat(const std::string &device, AEDataFormat format)
+bool CActiveAESink::SupportsFormat(const std::string &device, AEDataFormat format, int samplerate)
{
std::string dev = device;
std::string dri;
@@ -124,7 +124,14 @@ bool CActiveAESink::SupportsFormat(const std::string &device, AEDataFormat forma
AEDataFormatList::iterator itt3;
itt3 = find(info.m_dataFormats.begin(), info.m_dataFormats.end(), format);
if (itt3 != info.m_dataFormats.end())
- return true;
+ {
+ AESampleRateList::iterator itt4;
+ itt4 = find(info.m_sampleRates.begin(), info.m_sampleRates.end(), samplerate);
+ if (itt4 != info.m_sampleRates.end())
@Jalle19 Team Kodi member
Jalle19 added a note

This could be changed to a one-liner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ return true;
+ else
+ return false;
+ }
else
return false;
}
View
2 xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAESink.h
@@ -97,7 +97,7 @@ class CActiveAESink : private CThread
void Dispose();
AEDeviceType GetDeviceType(const std::string &device);
bool HasPassthroughDevice();
- bool SupportsFormat(const std::string &device, AEDataFormat format);
+ bool SupportsFormat(const std::string &device, AEDataFormat format, int samplerate);
CSinkControlProtocol m_controlPort;
CSinkDataProtocol m_dataPort;
View
2 xbmc/cores/AudioEngine/Interfaces/AE.h
@@ -203,7 +203,7 @@ class IAE
* @see CAEPackIEC61937::CAEPackIEC61937()
* @returns true if the AudioEngine is capable of RAW output
*/
- virtual bool SupportsRaw(AEDataFormat format) { return false; }
+ virtual bool SupportsRaw(AEDataFormat format, int samplerate) { return false; }
/**
* Returns true if the AudioEngine supports drain mode which is not streaming silence when idle
View
5 xbmc/cores/AudioEngine/Sinks/AESinkPi.cpp
@@ -36,6 +36,8 @@
#define NUM_OMX_BUFFERS 2
#define AUDIO_PLAYBUFFER (1.0/20.0)
+static const unsigned int PassthroughSampleRates[] = { 8000, 11025, 16000, 22050, 24000, 32000, 41400, 48000, 88200, 96000, 176400, 192000 };
+
CAEDeviceInfo CAESinkPi::m_info;
CAESinkPi::CAESinkPi() :
@@ -282,7 +284,8 @@ void CAESinkPi::EnumerateDevicesEx(AEDeviceInfoList &list, bool force)
m_info.m_displayNameExtra = "";
m_info.m_channels += AE_CH_FL;
m_info.m_channels += AE_CH_FR;
- m_info.m_sampleRates.push_back(48000);
+ for (unsigned int i=0; i<sizeof PassthroughSampleRates/sizeof *PassthroughSampleRates; i++)
+ m_info.m_sampleRates.push_back(PassthroughSampleRates[i]);
m_info.m_dataFormats.push_back(AE_FMT_S16LE);
m_info.m_dataFormats.push_back(AE_FMT_AC3);
m_info.m_dataFormats.push_back(AE_FMT_DTS);
View
10 xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecPassthrough.cpp
@@ -40,11 +40,11 @@ CDVDAudioCodecPassthrough::~CDVDAudioCodecPassthrough(void)
bool CDVDAudioCodecPassthrough::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options)
{
- bool bSupportsAC3Out = CAEFactory::SupportsRaw(AE_FMT_AC3);
- bool bSupportsEAC3Out = CAEFactory::SupportsRaw(AE_FMT_EAC3);
- bool bSupportsDTSOut = CAEFactory::SupportsRaw(AE_FMT_DTS);
- bool bSupportsTrueHDOut = CAEFactory::SupportsRaw(AE_FMT_TRUEHD);
- bool bSupportsDTSHDOut = CAEFactory::SupportsRaw(AE_FMT_DTSHD);
+ bool bSupportsAC3Out = CAEFactory::SupportsRaw(AE_FMT_AC3, hints.samplerate);
+ bool bSupportsEAC3Out = CAEFactory::SupportsRaw(AE_FMT_EAC3, 192000);
+ bool bSupportsDTSOut = CAEFactory::SupportsRaw(AE_FMT_DTS, hints.samplerate);
+ bool bSupportsTrueHDOut = CAEFactory::SupportsRaw(AE_FMT_TRUEHD, 192000);
+ bool bSupportsDTSHDOut = CAEFactory::SupportsRaw(AE_FMT_DTSHD, 192000);
/* only get the dts core from the parser if we don't support dtsHD */
m_info.SetCoreOnly(!bSupportsDTSHDOut);
View
4 xbmc/cores/omxplayer/OMXPlayerAudio.cpp
@@ -511,12 +511,12 @@ AEDataFormat OMXPlayerAudio::GetDataFormat(CDVDStreamInfo hints)
/* check our audio capabilties */
/* pathrought is overriding hw decode*/
- if(hints.codec == AV_CODEC_ID_AC3 && CAEFactory::SupportsRaw(AE_FMT_AC3) && !CSettings::Get().GetBool("audiooutput.dualaudio"))
+ if(hints.codec == AV_CODEC_ID_AC3 && CAEFactory::SupportsRaw(AE_FMT_AC3, hints.samplerate) && !CSettings::Get().GetBool("audiooutput.dualaudio"))
@FernetMenta Team Kodi member

@popcornmix could you have a look at this. the PI sink pushes the supported samplerates to the list, right?

@popcornmix Team Kodi member

No. Do I just want to push formats supported by passthrough?
Technically I'd like all sample rate to be supported for PCM (the analogue output is driven by a PLL, and is genuinely has a continuous range).

@popcornmix Team Kodi member

Can you cherry-pick
popcornmix@b945a0e
if it looks okay.

@FernetMenta Team Kodi member

https://github.com/xbmc/xbmc/blob/master/xbmc/cores/AudioEngine/Sinks/AESinkPi.cpp#L285

I see you push 48khz AC3, DTS, EAC3. If the sink supports i.e. AC3 with 44.1khz, you should to push 44.1 too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
{
dataFormat = AE_FMT_AC3;
m_passthrough = true;
}
- if(hints.codec == AV_CODEC_ID_DTS && CAEFactory::SupportsRaw(AE_FMT_DTS) && !CSettings::Get().GetBool("audiooutput.dualaudio"))
+ if(hints.codec == AV_CODEC_ID_DTS && CAEFactory::SupportsRaw(AE_FMT_DTS, hints.samplerate) && !CSettings::Get().GetBool("audiooutput.dualaudio"))
{
dataFormat = AE_FMT_DTS;
m_passthrough = true;
View
4 xbmc/cores/playercorefactory/PlayerCoreFactory.cpp
@@ -191,8 +191,8 @@ void CPlayerCoreFactory::GetPlayers( const CFileItem& item, VECPLAYERCORES &vecC
if (bAdd)
{
- if ((url.GetFileType().Equals("ac3") && !CAEFactory::SupportsRaw(AE_FMT_AC3))
- || (url.GetFileType().Equals("dts") && !CAEFactory::SupportsRaw(AE_FMT_DTS)))
+ if ((url.GetFileType().Equals("ac3"))
+ || (url.GetFileType().Equals("dts")))
{
CLog::Log(LOGDEBUG, "CPlayerCoreFactory::GetPlayers: adding DVDPlayer (%d)", EPC_DVDPLAYER);
vecCores.push_back(EPC_DVDPLAYER);
Something went wrong with that request. Please try again.