diff options
-rw-r--r-- | src/android/AudioPlayer_to_android.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/android/AudioPlayer_to_android.cpp b/src/android/AudioPlayer_to_android.cpp index 8acc499..5df053d 100644 --- a/src/android/AudioPlayer_to_android.cpp +++ b/src/android/AudioPlayer_to_android.cpp @@ -1609,19 +1609,23 @@ SLresult android_audioPlayer_realize(CAudioPlayer *pAudioPlayer, SLboolean async checkAndSetPerformanceModePre(pAudioPlayer); audio_output_flags_t policy; + audio_flags_mask_t attrFlags = AUDIO_FLAG_NONE; switch (pAudioPlayer->mPerformanceMode) { case ANDROID_PERFORMANCE_MODE_POWER_SAVING: policy = AUDIO_OUTPUT_FLAG_DEEP_BUFFER; + attrFlags = static_cast<audio_flags_mask_t>(attrFlags | AUDIO_FLAG_DEEP_BUFFER); break; case ANDROID_PERFORMANCE_MODE_NONE: policy = AUDIO_OUTPUT_FLAG_NONE; break; case ANDROID_PERFORMANCE_MODE_LATENCY_EFFECTS: policy = AUDIO_OUTPUT_FLAG_FAST; + attrFlags = static_cast<audio_flags_mask_t>(attrFlags | AUDIO_FLAG_LOW_LATENCY); break; case ANDROID_PERFORMANCE_MODE_LATENCY: default: policy = (audio_output_flags_t)(AUDIO_OUTPUT_FLAG_FAST | AUDIO_OUTPUT_FLAG_RAW); + attrFlags = static_cast<audio_flags_mask_t>(attrFlags | AUDIO_FLAG_LOW_LATENCY); break; } @@ -1633,9 +1637,13 @@ SLresult android_audioPlayer_realize(CAudioPlayer *pAudioPlayer, SLboolean async } else { notificationFrames = 0; } + audio_attributes_t attributes = AUDIO_ATTRIBUTES_INITIALIZER; + attributes.usage = usageForStreamType(pAudioPlayer->mStreamType); + attributes.flags = attrFlags; + const auto callbackHandle = android::sp<android::AudioTrackCallback>::make(pAudioPlayer); const auto pat = android::sp<android::AudioTrack>::make( - pAudioPlayer->mStreamType, // streamType + AUDIO_STREAM_DEFAULT, // streamType sampleRate, // sampleRate sles_to_android_sampleFormat(df_pcm), // format channelMask, // channel mask @@ -1643,7 +1651,12 @@ SLresult android_audioPlayer_realize(CAudioPlayer *pAudioPlayer, SLboolean async policy, // flags callbackHandle, // callback notificationFrames, // see comment above - pAudioPlayer->mSessionId); + pAudioPlayer->mSessionId, + android::AudioTrack::TRANSFER_DEFAULT, // transferType + nullptr, // offloadInfo + AttributionSourceState(), // attributionSource + &attributes // pAttributes + ); // Set it here so it can be logged by the destructor if the open failed. pat->setCallerName(ANDROID_OPENSLES_CALLER_NAME); |