summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author David Zhao <qingxun@google.com> 2023-10-13 00:22:12 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2023-10-13 00:22:12 +0000
commitcdffc87a87c2873f69b93c9344864e7cb87e714e (patch)
tree2b4ab304e947810f1dcd390255cd6380bd9b12d1
parent6129afc2a9e1125bd9d2a29d6b094145ec6ef152 (diff)
parenteba913ffea25de812164f7ddb1dcde3c9bbbee7e (diff)
Merge "Use only one lock to access streams in JTvInputHal" into main
-rw-r--r--services/core/jni/tvinput/JTvInputHal.cpp9
-rw-r--r--services/core/jni/tvinput/JTvInputHal.h1
2 files changed, 4 insertions, 6 deletions
diff --git a/services/core/jni/tvinput/JTvInputHal.cpp b/services/core/jni/tvinput/JTvInputHal.cpp
index 68e2c9a57c24..c7366173ecda 100644
--- a/services/core/jni/tvinput/JTvInputHal.cpp
+++ b/services/core/jni/tvinput/JTvInputHal.cpp
@@ -147,7 +147,6 @@ int JTvInputHal::removeStream(int deviceId, int streamId) {
}
int JTvInputHal::setTvMessageEnabled(int deviceId, int streamId, int type, bool enabled) {
- Mutex::Autolock autoLock(&mLock);
if (!mTvInput->setTvMessageEnabled(deviceId, streamId,
static_cast<AidlTvMessageEventType>(type), enabled)
.isOk()) {
@@ -188,7 +187,7 @@ static const std::map<std::pair<AidlAudioDeviceType, std::string>, audio_devices
void JTvInputHal::onDeviceAvailable(const TvInputDeviceInfoWrapper& info) {
{
- Mutex::Autolock autoLock(&mLock);
+ Mutex::Autolock autoLock(&mStreamLock);
mConnections.add(info.deviceId, KeyedVector<int, Connection>());
}
JNIEnv* env = AndroidRuntime::getJNIEnv();
@@ -275,7 +274,7 @@ void JTvInputHal::onDeviceAvailable(const TvInputDeviceInfoWrapper& info) {
void JTvInputHal::onDeviceUnavailable(int deviceId) {
{
- Mutex::Autolock autoLock(&mLock);
+ Mutex::Autolock autoLock(&mStreamLock);
KeyedVector<int, Connection>& connections = mConnections.editValueFor(deviceId);
for (size_t i = 0; i < connections.size(); ++i) {
removeStream(deviceId, connections.keyAt(i));
@@ -289,7 +288,7 @@ void JTvInputHal::onDeviceUnavailable(int deviceId) {
void JTvInputHal::onStreamConfigurationsChanged(int deviceId, int cableConnectionStatus) {
{
- Mutex::Autolock autoLock(&mLock);
+ Mutex::Autolock autoLock(&mStreamLock);
KeyedVector<int, Connection>& connections = mConnections.editValueFor(deviceId);
for (size_t i = 0; i < connections.size(); ++i) {
removeStream(deviceId, connections.keyAt(i));
@@ -330,7 +329,7 @@ void JTvInputHal::onTvMessage(int deviceId, int streamId, AidlTvMessageEventType
void JTvInputHal::onCaptured(int deviceId, int streamId, uint32_t seq, bool succeeded) {
sp<BufferProducerThread> thread;
{
- Mutex::Autolock autoLock(&mLock);
+ Mutex::Autolock autoLock(&mStreamLock);
KeyedVector<int, Connection>& connections = mConnections.editValueFor(deviceId);
Connection& connection = connections.editValueFor(streamId);
if (connection.mThread == NULL) {
diff --git a/services/core/jni/tvinput/JTvInputHal.h b/services/core/jni/tvinput/JTvInputHal.h
index b7b4b1621512..1d8d1629f67d 100644
--- a/services/core/jni/tvinput/JTvInputHal.h
+++ b/services/core/jni/tvinput/JTvInputHal.h
@@ -220,7 +220,6 @@ private:
void onTvMessage(int deviceId, int streamId, AidlTvMessageEventType type,
AidlTvMessage& message, signed char data[], int dataLength);
- Mutex mLock;
Mutex mStreamLock;
jweak mThiz;
sp<Looper> mLooper;