aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/depends/target/libandroidjni/Makefile2
-rw-r--r--xbmc/cores/AudioEngine/Sinks/AESinkAUDIOTRACK.cpp58
-rw-r--r--xbmc/cores/AudioEngine/Sinks/AESinkAUDIOTRACK.h2
3 files changed, 32 insertions, 30 deletions
diff --git a/tools/depends/target/libandroidjni/Makefile b/tools/depends/target/libandroidjni/Makefile
index 4c200919d3..6948c06dfd 100644
--- a/tools/depends/target/libandroidjni/Makefile
+++ b/tools/depends/target/libandroidjni/Makefile
@@ -3,7 +3,7 @@ DEPS= ../../Makefile.include Makefile
# lib name, version
LIBNAME=libandroidjni
-VERSION=3c0e79e4f1fd497434bf8cfda520c10af9009ce5
+VERSION=bfe01d03cfcef423ffbf3cd9aafef4a5a3539201
SOURCE=archive
ARCHIVE=$(VERSION).tar.gz
GIT_BASE_URL=https://github.com/xbmc
diff --git a/xbmc/cores/AudioEngine/Sinks/AESinkAUDIOTRACK.cpp b/xbmc/cores/AudioEngine/Sinks/AESinkAUDIOTRACK.cpp
index 2fc92e54fe..8885830c7e 100644
--- a/xbmc/cores/AudioEngine/Sinks/AESinkAUDIOTRACK.cpp
+++ b/xbmc/cores/AudioEngine/Sinks/AESinkAUDIOTRACK.cpp
@@ -35,8 +35,6 @@
#include "utils/AMLUtils.h"
-//#define DEBUG_VERBOSE 1
-
// This is an alternative to the linear weighted delay smoothing
// advantages: only one history value needs to be stored
// in tests the linear weighted average smoother yield better results
@@ -181,16 +179,35 @@ static int AEChannelMapToAUDIOTRACKChannelMask(CAEChannelInfo info)
jni::CJNIAudioTrack *CAESinkAUDIOTRACK::CreateAudioTrack(int stream, int sampleRate, int channelMask, int encoding, int bufferSize)
{
jni::CJNIAudioTrack *jniAt = NULL;
- m_jniAudioFormat = encoding;
try
{
- jniAt = new CJNIAudioTrack(stream,
- sampleRate,
- channelMask,
- encoding,
- bufferSize,
- CJNIAudioTrack::MODE_STREAM);
+ if (CJNIBase::GetSDKVersion() >= 21)
+ {
+ CJNIAudioAttributesBuilder attrBuilder;
+ attrBuilder.setUsage(CJNIAudioAttributes::USAGE_MEDIA);
+ attrBuilder.setFlags(CJNIAudioAttributes::FLAG_AUDIBILITY_ENFORCED);
+
+ CJNIAudioFormatBuilder fmtBuilder;
+ fmtBuilder.setChannelMask(channelMask);
+ fmtBuilder.setEncoding(encoding);
+ fmtBuilder.setSampleRate(sampleRate);
+
+ jniAt = new CJNIAudioTrack(attrBuilder.build(),
+ fmtBuilder.build(),
+ bufferSize,
+ CJNIAudioTrack::MODE_STREAM,
+ CJNIAudioManager::AUDIO_SESSION_ID_GENERATE);
+ }
+ else
+ {
+ jniAt = new CJNIAudioTrack(stream,
+ sampleRate,
+ channelMask,
+ encoding,
+ bufferSize,
+ CJNIAudioTrack::MODE_STREAM);
+ }
}
catch (const std::invalid_argument& e)
{
@@ -282,22 +299,7 @@ bool CAESinkAUDIOTRACK::VerifySinkConfiguration(int sampleRate, int channelMask,
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());
- }
+ jni::CJNIAudioTrack *jniAt = CreateAudioTrack(CJNIAudioManager::STREAM_MUSIC, sampleRate, channelMask, encoding, minBufferSize);
bool success = (jniAt && jniAt->getState() == CJNIAudioTrack::STATE_INITIALIZED);
@@ -423,7 +425,7 @@ bool CAESinkAUDIOTRACK::Initialize(AEAudioFormat &format, std::string &device)
while (!m_at_jni)
{
- CLog::Log(LOGNOTICE, "Trying to open: %u samplerate %d channelMask %d encoding", m_sink_sampleRate, atChannelMask, m_encoding);
+ CLog::Log(LOGNOTICE, "Trying to open: samplerate: %u, channelMask: %d, encoding: %d", m_sink_sampleRate, atChannelMask, m_encoding);
int min_buffer = CJNIAudioTrack::getMinBufferSize(m_sink_sampleRate,
atChannelMask,
m_encoding);
@@ -529,6 +531,7 @@ bool CAESinkAUDIOTRACK::Initialize(AEAudioFormat &format, std::string &device)
CLog::Log(LOGDEBUG, "Created Audiotrackbuffer with playing time of %lf ms min buffer size: %u bytes",
m_audiotrackbuffer_sec * 1000, m_min_buffer_size);
+ m_jniAudioFormat = m_encoding;
m_at_jni = CreateAudioTrack(stream, m_sink_sampleRate, atChannelMask,
m_encoding, m_min_buffer_size);
@@ -574,9 +577,8 @@ bool CAESinkAUDIOTRACK::Initialize(AEAudioFormat &format, std::string &device)
void CAESinkAUDIOTRACK::Deinitialize()
{
-#ifdef DEBUG_VERBOSE
CLog::Log(LOGDEBUG, "CAESinkAUDIOTRACK::Deinitialize");
-#endif
+
// Restore volume
if (m_volume != -1)
{
diff --git a/xbmc/cores/AudioEngine/Sinks/AESinkAUDIOTRACK.h b/xbmc/cores/AudioEngine/Sinks/AESinkAUDIOTRACK.h
index 2f28d1e269..87e1defab3 100644
--- a/xbmc/cores/AudioEngine/Sinks/AESinkAUDIOTRACK.h
+++ b/xbmc/cores/AudioEngine/Sinks/AESinkAUDIOTRACK.h
@@ -54,7 +54,7 @@ public:
static IAESink* Create(std::string &device, AEAudioFormat &desiredFormat);
protected:
- jni::CJNIAudioTrack *CreateAudioTrack(int stream, int sampleRate, int channelMask, int encoding, int bufferSize);
+ static jni::CJNIAudioTrack *CreateAudioTrack(int stream, int sampleRate, int channelMask, int encoding, int bufferSize);
static bool IsSupported(int sampleRateInHz, int channelConfig, int audioFormat);
static bool VerifySinkConfiguration(int sampleRate, int channelMask, int encoding);
static bool HasAmlHD();