Merge "converter: Support 24bit converter" am: f8a6bdddf2 am: 4249588a97
Original change: https://android-review.googlesource.com/c/platform/frameworks/av/+/2166496
Change-Id: I76046f791a49efd145a6351b5db5ab8d5ada099f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/media/libmediaplayerservice/nuplayer/AWakeLock.cpp b/media/libmediaplayerservice/nuplayer/AWakeLock.cpp
index 25a8ae4..c3bd207 100644
--- a/media/libmediaplayerservice/nuplayer/AWakeLock.cpp
+++ b/media/libmediaplayerservice/nuplayer/AWakeLock.cpp
@@ -59,10 +59,11 @@
if (mPowerManager != NULL) {
sp<IBinder> binder = new BBinder();
int64_t token = IPCThreadState::self()->clearCallingIdentity();
- binder::Status status = mPowerManager->acquireWakeLockAsync(
+ binder::Status status = mPowerManager->acquireWakeLock(
binder, POWERMANAGER_PARTIAL_WAKE_LOCK,
String16("AWakeLock"), String16("media"),
- {} /* workSource */, {} /* historyTag */);
+ {} /* workSource */, {} /* historyTag */, -1 /* displayId */,
+ nullptr /* callback */);
IPCThreadState::self()->restoreCallingIdentity(token);
if (status.isOk()) {
mWakeLockToken = binder;
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp
index 2828d44..cb050f9 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp
@@ -73,6 +73,10 @@
// is closed to allow the audio DSP to power down.
static const int64_t kOffloadPauseMaxUs = 10000000LL;
+// Additional delay after teardown before releasing the wake lock to allow time for the audio path
+// to be completely released
+static const int64_t kWakelockReleaseDelayUs = 2000000LL;
+
// Maximum allowed delay from AudioSink, 1.5 seconds.
static const int64_t kMaxAllowedAudioSinkDelayUs = 1500000LL;
@@ -793,6 +797,20 @@
}
ALOGV("Audio Offload tear down due to pause timeout.");
onAudioTearDown(kDueToTimeout);
+ sp<AMessage> newMsg = new AMessage(kWhatReleaseWakeLock, this);
+ newMsg->setInt32("drainGeneration", generation);
+ newMsg->post(kWakelockReleaseDelayUs);
+ break;
+ }
+
+ case kWhatReleaseWakeLock:
+ {
+ int32_t generation;
+ CHECK(msg->findInt32("drainGeneration", &generation));
+ if (generation != mAudioOffloadPauseTimeoutGeneration) {
+ break;
+ }
+ ALOGV("releasing audio offload pause wakelock.");
mWakeLock->release();
break;
}
@@ -1785,6 +1803,8 @@
return;
}
+ startAudioOffloadPauseTimeout();
+
{
Mutex::Autolock autoLock(mLock);
// we do not increment audio drain generation so that we fill audio buffer during pause.
@@ -1799,7 +1819,6 @@
// Note: audio data may not have been decoded, and the AudioSink may not be opened.
mAudioSink->pause();
- startAudioOffloadPauseTimeout();
ALOGV("now paused audio queue has %zu entries, video has %zu entries",
mAudioQueue.size(), mVideoQueue.size());
diff --git a/media/libmediaplayerservice/nuplayer/include/nuplayer/NuPlayerRenderer.h b/media/libmediaplayerservice/nuplayer/include/nuplayer/NuPlayerRenderer.h
index 3d2b033..3640678 100644
--- a/media/libmediaplayerservice/nuplayer/include/nuplayer/NuPlayerRenderer.h
+++ b/media/libmediaplayerservice/nuplayer/include/nuplayer/NuPlayerRenderer.h
@@ -100,6 +100,7 @@
kWhatMediaRenderingStart = 'mdrd',
kWhatAudioTearDown = 'adTD',
kWhatAudioOffloadPauseTimeout = 'aOPT',
+ kWhatReleaseWakeLock = 'adRL',
};
enum AudioTearDownReason {
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index 56ebb6e..07e82a8 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -9560,6 +9560,12 @@
if (isOutput()) {
ret = AudioSystem::startOutput(portId);
} else {
+ {
+ // Add the track record before starting input so that the silent status for the
+ // client can be cached.
+ Mutex::Autolock _l(mLock);
+ setClientSilencedState_l(portId, false /*silenced*/);
+ }
ret = AudioSystem::startInput(portId);
}
@@ -9578,6 +9584,7 @@
} else {
mHalStream->stop();
}
+ eraseClientSilencedState_l(portId);
return PERMISSION_DENIED;
}
@@ -9586,6 +9593,9 @@
mChannelMask, mSessionId, isOutput(),
client.attributionSource,
IPCThreadState::self()->getCallingPid(), portId);
+ if (!isOutput()) {
+ track->setSilenced_l(isClientSilenced_l(portId));
+ }
if (isOutput()) {
// force volume update when a new track is added
@@ -9643,6 +9653,7 @@
}
mActiveTracks.remove(track);
+ eraseClientSilencedState_l(track->portId());
mLock.unlock();
if (isOutput()) {
@@ -10433,6 +10444,7 @@
broadcast_l();
}
}
+ setClientSilencedIfExists_l(portId, silenced);
}
void AudioFlinger::MmapCaptureThread::toAudioPortConfig(struct audio_port_config *config)
diff --git a/services/audioflinger/Threads.h b/services/audioflinger/Threads.h
index b2962ed8..074ae8f 100644
--- a/services/audioflinger/Threads.h
+++ b/services/audioflinger/Threads.h
@@ -2057,6 +2057,26 @@
virtual bool isStreamInitialized() { return false; }
+ void setClientSilencedState_l(audio_port_handle_t portId, bool silenced) {
+ mClientSilencedStates[portId] = silenced;
+ }
+
+ size_t eraseClientSilencedState_l(audio_port_handle_t portId) {
+ return mClientSilencedStates.erase(portId);
+ }
+
+ bool isClientSilenced_l(audio_port_handle_t portId) const {
+ const auto it = mClientSilencedStates.find(portId);
+ return it != mClientSilencedStates.end() ? it->second : false;
+ }
+
+ void setClientSilencedIfExists_l(audio_port_handle_t portId, bool silenced) {
+ const auto it = mClientSilencedStates.find(portId);
+ if (it != mClientSilencedStates.end()) {
+ it->second = silenced;
+ }
+ }
+
protected:
void dumpInternals_l(int fd, const Vector<String16>& args) override;
void dumpTracks_l(int fd, const Vector<String16>& args) override;
@@ -2076,6 +2096,7 @@
AudioHwDevice* const mAudioHwDev;
ActiveTracks<MmapTrack> mActiveTracks;
float mHalVolFloat;
+ std::map<audio_port_handle_t, bool> mClientSilencedStates;
int32_t mNoCallbackWarningCount;
static constexpr int32_t kMaxNoCallbackWarnings = 5;