diff options
author | fritsch <Peter.Fruehberger@gmail.com> | 2017-09-30 14:53:38 +0200 |
---|---|---|
committer | fritsch <Peter.Fruehberger@gmail.com> | 2017-10-05 19:22:41 +0200 |
commit | 4c4397764f38098b8d8509d104e2f7b7d6d95f8d (patch) | |
tree | dc3765f1c222e770a333238f462767e83256b217 | |
parent | 35c9e0300c01103af7dd0c4b377d2aa72657872c (diff) |
AESinkAUDIOTRACK: Implement VerifySinkConfiguration()
-rw-r--r-- | xbmc/cores/AudioEngine/Sinks/AESinkAUDIOTRACK.cpp | 87 | ||||
-rw-r--r-- | xbmc/cores/AudioEngine/Sinks/AESinkAUDIOTRACK.h | 1 |
2 files changed, 66 insertions, 22 deletions
diff --git a/xbmc/cores/AudioEngine/Sinks/AESinkAUDIOTRACK.cpp b/xbmc/cores/AudioEngine/Sinks/AESinkAUDIOTRACK.cpp index 8f559203fb..327a0c8172 100644 --- a/xbmc/cores/AudioEngine/Sinks/AESinkAUDIOTRACK.cpp +++ b/xbmc/cores/AudioEngine/Sinks/AESinkAUDIOTRACK.cpp @@ -212,6 +212,44 @@ CAESinkAUDIOTRACK::~CAESinkAUDIOTRACK() Deinitialize(); } +bool CAESinkAUDIOTRACK::VerifySinkConfiguration(int sampleRate, int channelMask, int encoding) +{ + int minBufferSize = CJNIAudioTrack::getMinBufferSize(sampleRate, channelMask, encoding); + if (minBufferSize < 0) + return false; + + // Try to construct a jniSink + jni::CJNIAudioTrack *jniAt = NULL; + + try + { + jniAt = new CJNIAudioTrack(CJNIAudioManager::STREAM_MUSIC, + sampleRate, + channelMask, + encoding, + minBufferSize, + CJNIAudioTrack::MODE_STREAM); + } + catch (const std::invalid_argument& e) + { + CLog::Log(LOGINFO, "AESinkAUDIOTRACK - AudioTrack creation faild: Encoding: %d ChannelMask: %d Error: %s", encoding, channelMask, e.what()); + } + + bool success = (jniAt && jniAt->getState() == CJNIAudioTrack::STATE_INITIALIZED); + + // Deinitialize + if (jniAt) + { + jniAt->stop(); + jniAt->flush(); + jniAt->release(); + delete jniAt; + } + + return success; +} + + bool CAESinkAUDIOTRACK::IsSupported(int sampleRateInHz, int channelConfig, int encoding) { int ret = CJNIAudioTrack::getMinBufferSize( sampleRateInHz, channelConfig, encoding); @@ -827,30 +865,35 @@ void CAESinkAUDIOTRACK::UpdateAvailablePassthroughCapabilities() // Android v24 and backports can do real IEC API if (CJNIAudioFormat::ENCODING_IEC61937 != -1) { - 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); - m_info.m_streamTypes.push_back(CAEStreamInfo::STREAM_TYPE_AC3); - m_info.m_streamTypes.push_back(CAEStreamInfo::STREAM_TYPE_DTSHD_CORE); - m_info.m_streamTypes.push_back(CAEStreamInfo::STREAM_TYPE_DTS_1024); - m_info.m_streamTypes.push_back(CAEStreamInfo::STREAM_TYPE_DTS_2048); - m_info.m_streamTypes.push_back(CAEStreamInfo::STREAM_TYPE_DTS_512); - CLog::Log(LOGDEBUG, "AESinkAUDIOTrack: Using IEC PT mode: %d", CJNIAudioFormat::ENCODING_IEC61937); - if (supports_192khz) + // check if we support opening an IEC sink at all: + bool supports_iec = VerifySinkConfiguration(48000, CJNIAudioFormat::CHANNEL_OUT_STEREO, CJNIAudioFormat::ENCODING_IEC61937); + if (supports_iec) { - m_info.m_streamTypes.push_back(CAEStreamInfo::STREAM_TYPE_EAC3); - // Check for IEC 8 channel 192 khz PT - int atChannelMask = AEChannelMapToAUDIOTRACKChannelMask(AE_CH_LAYOUT_7_1); - if (IsSupported(192000, atChannelMask, CJNIAudioFormat::ENCODING_IEC61937)) - { - m_info.m_streamTypes.push_back(CAEStreamInfo::STREAM_TYPE_DTSHD); - m_info.m_streamTypes.push_back(CAEStreamInfo::STREAM_TYPE_TRUEHD); - CLog::Log(LOGDEBUG, "8 Channel PT via IEC61937 is supported"); + 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); + m_info.m_streamTypes.push_back(CAEStreamInfo::STREAM_TYPE_AC3); + m_info.m_streamTypes.push_back(CAEStreamInfo::STREAM_TYPE_DTSHD_CORE); + m_info.m_streamTypes.push_back(CAEStreamInfo::STREAM_TYPE_DTS_1024); + m_info.m_streamTypes.push_back(CAEStreamInfo::STREAM_TYPE_DTS_2048); + m_info.m_streamTypes.push_back(CAEStreamInfo::STREAM_TYPE_DTS_512); + CLog::Log(LOGDEBUG, "AESinkAUDIOTrack: Using IEC PT mode: %d", CJNIAudioFormat::ENCODING_IEC61937); + if (supports_192khz) + { + m_info.m_streamTypes.push_back(CAEStreamInfo::STREAM_TYPE_EAC3); + // Check for IEC 8 channel 192 khz PT + int atChannelMask = AEChannelMapToAUDIOTRACKChannelMask(AE_CH_LAYOUT_7_1); + if (VerifySinkConfiguration(192000, atChannelMask, CJNIAudioFormat::ENCODING_IEC61937)) + { + m_info.m_streamTypes.push_back(CAEStreamInfo::STREAM_TYPE_DTSHD); + m_info.m_streamTypes.push_back(CAEStreamInfo::STREAM_TYPE_TRUEHD); + CLog::Log(LOGDEBUG, "8 Channel PT via IEC61937 is supported"); + } } - } - } - } + } + } + } } void CAESinkAUDIOTRACK::UpdateAvailablePCMCapabilities() diff --git a/xbmc/cores/AudioEngine/Sinks/AESinkAUDIOTRACK.h b/xbmc/cores/AudioEngine/Sinks/AESinkAUDIOTRACK.h index 5cdf0331ad..c3ebbc8eb0 100644 --- a/xbmc/cores/AudioEngine/Sinks/AESinkAUDIOTRACK.h +++ b/xbmc/cores/AudioEngine/Sinks/AESinkAUDIOTRACK.h @@ -54,6 +54,7 @@ public: protected: static bool IsSupported(int sampleRateInHz, int channelConfig, int audioFormat); + static bool VerifySinkConfiguration(int sampleRate, int channelMask, int encoding); static bool HasAmlHD(); static void UpdateAvailablePCMCapabilities(); static void UpdateAvailablePassthroughCapabilities(); |