Skip to content

Commit

Permalink
Add canHD and canHDLL (LL stands for lossless)) method to AudioOutput…
Browse files Browse the repository at this point in the history
…Settings class. Add preliminary detection to determine if a device can support HD Passthrough
  • Loading branch information
jyavenard committed Dec 13, 2010
1 parent 36b17e3 commit 3cf1de4
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 16 deletions.
21 changes: 16 additions & 5 deletions mythtv/libs/libmyth/audiooutputsettings.cpp
@@ -1,6 +1,6 @@
/* -*- Mode: c++ -*-
*
* Copyright (C) foobum@gmail.com 2010
* Copyright (C) 2010 foobum@gmail.com and jyavenard@gmail.com
*
* Licensed under the GPL v2 or a later version at your choosing.
*/
Expand All @@ -17,8 +17,8 @@ using namespace std;
#define LOC QString("AO: ")

AudioOutputSettings::AudioOutputSettings(bool invalid) :
m_passthrough(-1), m_AC3(false), m_DTS(false), m_LPCM(false),
m_invalid(invalid)
m_passthrough(-1), m_AC3(false), m_DTS(false), m_LPCM(false),
m_HD(false) , m_HDLL(false), m_invalid(invalid)
{
m_sr.assign(srs, srs +
sizeof(srs) / sizeof(int));
Expand Down Expand Up @@ -51,6 +51,8 @@ AudioOutputSettings& AudioOutputSettings::operator=(
m_AC3 = rhs.m_AC3;
m_DTS = rhs.m_DTS;
m_LPCM = rhs.m_LPCM;
m_HD = rhs.m_HD;
m_HDLL = rhs.m_HDLL;
m_invalid = rhs.m_invalid;
m_sr_it = m_sr.begin() + (rhs.m_sr_it - rhs.m_sr.begin());
m_sf_it = m_sf.begin() + (rhs.m_sf_it - rhs.m_sf.begin());
Expand Down Expand Up @@ -269,6 +271,12 @@ AudioOutputSettings* AudioOutputSettings::GetCleaned(bool newcopy)
int mchannels = BestSupportedChannels();

aosettings->m_LPCM = (mchannels > 2);
// E-AC3 is transferred as sterep PCM at 4 times the rates
// assume all amplifier supporting E-AC3 also supports 7.1 LPCM
// as it's required under the bluray standard
aosettings->m_HD = (mchannels == 8 && BestSupportedRate() == 192000);
aosettings->m_HDLL = (mchannels == 8 && BestSupportedRate() == 192000);

if (mchannels == 2 && m_passthrough >= 0)
{
VERBOSE(VB_AUDIO, LOC + QString("may be AC3 or DTS capable"));
Expand Down Expand Up @@ -306,8 +314,11 @@ AudioOutputSettings* AudioOutputSettings::GetUsers(bool newcopy)
bool bDTS = (aosettings->m_DTS || bForceDigital) &&
gCoreContext->GetNumSetting("DTSPassThru", false);
bool bLPCM = aosettings->m_LPCM &&
(aosettings->m_passthrough == -1 ||
!gCoreContext->GetNumSetting("StereoPCM", false));
!gCoreContext->GetNumSetting("StereoPCM", false);
bool bHD = bLPCM && aosettings->m_HD &&
gCoreContext->GetNumSetting("EAC3PassThru", false);
bool bHDLL = bLPCM && aosettings->m_HD &&
gCoreContext->GetNumSetting("TrueHDPassThru", false);

if (max_channels > 2 && !bLPCM)
max_channels = 2;
Expand Down
34 changes: 34 additions & 0 deletions mythtv/libs/libmyth/audiooutputsettings.h
Expand Up @@ -57,13 +57,44 @@ class MPUBLIC AudioOutputSettings

void setPassthrough(int val) { m_passthrough = val; };
int canPassthrough() { return m_passthrough; };
/**
* return true if device can or may support AC3
*/
bool canAC3() { return m_AC3; };
/**
* return true if device can or may support DTS
*/
bool canDTS() { return m_DTS; };
/**
* return true if device supports multichannels PCM
*/
bool canLPCM() { return m_LPCM; };
/**
* return true if device supports E-AC3 or DTS-HD passthrough
*/
bool canHD() { return m_HD; };
/**
* return true if device supports TrueHD or DTS-HD passthrough
*/
bool canHDLL() { return m_HDLL; };
/**
* return true if class instance is marked invalid.
* if true, you can not assume any of the other method returned
* values are valid
*/
bool IsInvalid() { return m_invalid; };
/**
* return true if device supports TrueHD or DTS-HD passthrough
*/
void setAC3(bool b) { m_AC3 = b; };
void setDTS(bool b) { m_DTS = b; };
void setLPCM(bool b) { m_LPCM = b; };
void setHD(bool b) { m_HD = b; };
void setHDLL(bool b) { m_HDLL = b; };
/**
* Force set the greatest number of channels supported by the audio
* device
*/
void SetBestSupportedChannels(int channels);

private:
Expand All @@ -78,6 +109,9 @@ class MPUBLIC AudioOutputSettings
bool m_AC3;
bool m_DTS;
bool m_LPCM;
bool m_HD;
bool m_HDLL;

bool m_invalid;

vector<int> m_sr, m_rates, m_channels;
Expand Down
23 changes: 12 additions & 11 deletions mythtv/programs/mythfrontend/audiogeneralsettings.cpp
Expand Up @@ -261,6 +261,8 @@ AudioOutputSettings AudioConfigSettings::UpdateCapabilities(
bool bAC3 = true;
bool bDTS = true;
bool bLPCM = true;
bool bHD = true;
bool bHDLL = true;

QString out = m_OutputDevice->getValue();
if (!audiodevs.contains(out))
Expand All @@ -278,10 +280,13 @@ AudioOutputSettings AudioConfigSettings::UpdateCapabilities(
m_AC3PassThrough->boolValue();
bDTS = (settings.canDTS() || bForceDigital) &&
m_DTSPassThrough->boolValue();
bLPCM = settings.canPassthrough() == -1 ||
(settings.canLPCM() &&
!gCoreContext->GetNumSetting("StereoPCM", false));

bLPCM = settings.canLPCM() &&
!gCoreContext->GetNumSetting("StereoPCM", false);
bHD = ((bLPCM && settings.canHD()) || bForceDigital) &&
m_EAC3PassThrough->boolValue();
bHDLL = ((bLPCM && settings.canHDLL()) || bForceDigital) &&
m_TrueHDPassThrough->boolValue();

if (max_speakers > 2 && !bLPCM)
max_speakers = 2;
if (max_speakers == 2 && (bAC3 || bDTS))
Expand All @@ -290,12 +295,8 @@ AudioOutputSettings AudioConfigSettings::UpdateCapabilities(

m_triggerDigital->setValue(invalid || bForceDigital ||
settings.canAC3() || settings.canDTS());

bool canhdpassthrough = (invalid || m_passthrough8 ||
(settings.canPassthrough() >= 0 &&
max_speakers >= 8));
m_EAC3PassThrough->setEnabled(canhdpassthrough);
m_TrueHDPassThrough->setEnabled(canhdpassthrough);
m_EAC3PassThrough->setEnabled(settings.canHD() && bLPCM);
m_TrueHDPassThrough->setEnabled(settings.canHDLL() & bLPCM);

int cur_speakers = m_MaxAudioChannels->getValue().toInt();

Expand Down Expand Up @@ -437,7 +438,7 @@ HostCheckBox *AudioConfigSettings::EAC3PassThrough()
HostCheckBox *AudioConfigSettings::TrueHDPassThrough()
{
HostCheckBox *gc = new HostCheckBox("TrueHDPassThru");
gc->setLabel(QObject::tr("TrueHD"));
gc->setLabel(QObject::tr("TrueHD/DTS-HD MA"));
gc->setValue(false);
gc->setHelpText(QObject::tr("Enable if your amplifier or sound decoder "
"supports Dolby TrueHD. You must use a hdmi connection."));
Expand Down

0 comments on commit 3cf1de4

Please sign in to comment.