Permalink
Browse files

Merge pull request #4329 from t-nelson/droid_native_sr

Droid native sr
  • Loading branch information...
2 parents a159d38 + 9f7de7d commit 9abc85a7f7ce0705a42df1d039dd059cf0cf4c92 @t-nelson t-nelson committed Mar 5, 2014
@@ -116,3 +116,9 @@ int CJNIAudioTrack::getMinBufferSize(int sampleRateInHz, int channelConfig, int
sampleRateInHz, channelConfig, audioFormat);
}
+int CJNIAudioTrack::getNativeOutputSampleRate(int streamType)
+{
+ return call_static_method<int>( "android/media/AudioTrack", "getNativeOutputSampleRate", "(I)I",
+ streamType);
+}
+
@@ -45,6 +45,7 @@ class CJNIAudioTrack : public CJNIBase
static void PopulateStaticFields();
static int getMinBufferSize(int sampleRateInHz, int channelConfig, int audioFormat);
+ static int getNativeOutputSampleRate(int streamType);
};
};
@@ -94,19 +94,7 @@ bool CAESinkAUDIOTRACK::Initialize(AEAudioFormat &format, std::string &device)
aml_set_audio_passthrough(m_passthrough);
#endif
- // default to 44100, all android devices support it.
- // then check if we can support the requested rate.
- unsigned int sampleRate = 44100;
- for (size_t i = 0; i < m_info.m_sampleRates.size(); i++)
- {
- if (m_format.m_sampleRate == m_info.m_sampleRates[i])
- {
- sampleRate = m_format.m_sampleRate;
- break;
- }
- }
-
- m_format.m_sampleRate = sampleRate;
+ m_format.m_sampleRate = CJNIAudioTrack::getNativeOutputSampleRate(CJNIAudioManager::STREAM_MUSIC);
m_format.m_dataFormat = AE_FMT_S16LE;
m_format.m_channelLayout = m_info.m_channels;
m_format.m_frameSize = m_format.m_channelLayout.Count() *
@@ -259,8 +247,7 @@ void CAESinkAUDIOTRACK::EnumerateDevicesEx(AEDeviceInfoList &list, bool force)
m_info.m_displayNameExtra = "audiotrack";
m_info.m_channels += AE_CH_FL;
m_info.m_channels += AE_CH_FR;
- m_info.m_sampleRates.push_back(44100);
- m_info.m_sampleRates.push_back(48000);
+ m_info.m_sampleRates.push_back(CJNIAudioTrack::getNativeOutputSampleRate(CJNIAudioManager::STREAM_MUSIC));
m_info.m_dataFormats.push_back(AE_FMT_S16LE);
#if 0 //defined(__ARM_NEON__)
if (g_cpuInfo.GetCPUFeatures() & CPU_FEATURE_NEON)

0 comments on commit 9abc85a

Please sign in to comment.