SoundPool: Use caller thread for sound playback
A worker playback thread may be starved under high usage situations such as screenshots or camera snapshots. Also fix issue with caller thread playback when reusing stream on restart queue. Test: camera snapshot, screenshot Test: native soundpool_stress Test: android.media.cts.SoundPool*Test Bug: 143448491 Bug: 144540753 Change-Id: I126c3efffc1f1dfb0fcde7a71cdea64afbe0af0a
This commit is contained in:
@@ -38,7 +38,7 @@ static constexpr bool kStealActiveStream_OldestFirst = true;
|
||||
// kPlayOnCallingThread = true prior to R.
|
||||
// Changing to false means calls to play() are almost instantaneous instead of taking around
|
||||
// ~10ms to launch the AudioTrack. It is perhaps 100x faster.
|
||||
static constexpr bool kPlayOnCallingThread = false;
|
||||
static constexpr bool kPlayOnCallingThread = true;
|
||||
|
||||
// Amount of time for a StreamManager thread to wait before closing.
|
||||
static constexpr int64_t kWaitTimeBeforeCloseNs = 9 * NANOS_PER_SECOND;
|
||||
@@ -167,6 +167,7 @@ int32_t StreamManager::queueForPlay(const std::shared_ptr<Sound> &sound,
|
||||
if (!stream->getPairStream()->hasSound()) {
|
||||
if (stream->getSoundID() == soundID) {
|
||||
newStream = stream;
|
||||
fromAvailableQueue = false;
|
||||
break;
|
||||
} else if (newStream == nullptr) {
|
||||
newStream = stream;
|
||||
|
||||
Reference in New Issue
Block a user