summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Eric Laurent <elaurent@google.com> 2023-05-17 14:40:01 +0200
committer Eric Laurent <elaurent@google.com> 2023-05-17 18:02:58 +0000
commit7ab6103aae697d9166a57edbd9c17ee2330f1d14 (patch)
tree5a8a0e1f14d654d233f39857ea6611069d65e3e7
parent0f26a22cdb4be26e9b10a11c62a7489c2ebc6595 (diff)
Soundpool: use audio attributes instead of legacy stream type
Use audio attributes to specifcy the use case and make sure performance flags in audio attributes are reflecting the output flags passed to the AudioTrack by Stream::play_l(). Bug: 283003710 Test: make Change-Id: If9c53e807425abe71f4172b5160af0a5be24e81c
-rw-r--r--media/jni/soundpool/Stream.cpp6
-rw-r--r--media/jni/soundpool/StreamManager.cpp5
2 files changed, 6 insertions, 5 deletions
diff --git a/media/jni/soundpool/Stream.cpp b/media/jni/soundpool/Stream.cpp
index 4194a22bfb67..45dde7403950 100644
--- a/media/jni/soundpool/Stream.cpp
+++ b/media/jni/soundpool/Stream.cpp
@@ -282,8 +282,6 @@ void Stream::play_l(const std::shared_ptr<Sound>& sound, int32_t nextStreamID,
priority, loop, rate, playerIId);
// initialize track
- const audio_stream_type_t streamType =
- AudioSystem::attributesToStreamType(*mStreamManager->getAttributes());
const int32_t channelCount = sound->getChannelCount();
const auto sampleRate = (uint32_t)lround(double(sound->getSampleRate()) * rate);
size_t frameCount = 0;
@@ -328,8 +326,8 @@ void Stream::play_l(const std::shared_ptr<Sound>& sound, int32_t nextStreamID,
attributionSource.token = sp<BBinder>::make();
mCallback = sp<StreamCallback>::make(this, toggle),
// TODO b/182469354 make consistent with AudioRecord, add util for native source
- mAudioTrack = new AudioTrack(streamType, sampleRate, sound->getFormat(),
- channelMask, sound->getIMemory(), AUDIO_OUTPUT_FLAG_FAST,
+ mAudioTrack = new AudioTrack(AUDIO_STREAM_DEFAULT, sampleRate, sound->getFormat(),
+ channelMask, sound->getIMemory(), AUDIO_OUTPUT_FLAG_NONE,
mCallback,
0 /*default notification frames*/, AUDIO_SESSION_ALLOCATE,
AudioTrack::TRANSFER_DEFAULT,
diff --git a/media/jni/soundpool/StreamManager.cpp b/media/jni/soundpool/StreamManager.cpp
index acd4badad9b0..52060f1e6209 100644
--- a/media/jni/soundpool/StreamManager.cpp
+++ b/media/jni/soundpool/StreamManager.cpp
@@ -109,7 +109,10 @@ StreamManager::StreamManager(
int32_t streams, size_t threads, const audio_attributes_t& attributes,
std::string opPackageName)
: StreamMap(streams)
- , mAttributes(attributes)
+ , mAttributes([attributes](){
+ audio_attributes_t attr = attributes;
+ attr.flags = static_cast<audio_flags_mask_t>(attr.flags | AUDIO_FLAG_LOW_LATENCY);
+ return attr; }())
, mOpPackageName(std::move(opPackageName))
, mLockStreamManagerStop(streams == 1 || kForceLockStreamManagerStop)
{