Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
platform_frameworks_base-old
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Farzin Kazemzadeh
platform_frameworks_base-old
Commits
0985eea3
Commit
0985eea3
authored
5 years ago
by
Treehugger Robot
Committed by
Gerrit Code Review
5 years ago
Browse files
Options
Downloads
Plain Diff
Merge "Fix a lock issue in AudioPortEventHandler"
parents
45402914
6dbaaf2d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
media/java/android/media/AudioPortEventHandler.java
+11
-6
11 additions, 6 deletions
media/java/android/media/AudioPortEventHandler.java
with
11 additions
and
6 deletions
media/java/android/media/AudioPortEventHandler.java
+
11
−
6
View file @
0985eea3
...
...
@@ -19,10 +19,12 @@ package android.media;
import
android.annotation.UnsupportedAppUsage
;
import
android.os.Handler
;
import
android.os.HandlerThread
;
import
android.os.Looper
;
import
android.os.Message
;
import
java.util.ArrayList
;
import
com.android.internal.annotations.GuardedBy
;
import
java.lang.ref.WeakReference
;
import
java.util.ArrayList
;
/**
* The AudioPortEventHandler handles AudioManager.OnAudioPortUpdateListener callbacks
...
...
@@ -33,6 +35,9 @@ import java.lang.ref.WeakReference;
class
AudioPortEventHandler
{
private
Handler
mHandler
;
private
HandlerThread
mHandlerThread
;
private
final
Object
mLock
=
new
Object
();
@GuardedBy
(
"mLock"
)
private
final
ArrayList
<
AudioManager
.
OnAudioPortUpdateListener
>
mListeners
=
new
ArrayList
<
AudioManager
.
OnAudioPortUpdateListener
>();
...
...
@@ -53,7 +58,7 @@ class AudioPortEventHandler {
private
long
mJniCallback
;
void
init
()
{
synchronized
(
this
)
{
synchronized
(
mLock
)
{
if
(
mHandler
!=
null
)
{
return
;
}
...
...
@@ -66,7 +71,7 @@ class AudioPortEventHandler {
@Override
public
void
handleMessage
(
Message
msg
)
{
ArrayList
<
AudioManager
.
OnAudioPortUpdateListener
>
listeners
;
synchronized
(
this
)
{
synchronized
(
mLock
)
{
if
(
msg
.
what
==
AUDIOPORT_EVENT_NEW_LISTENER
)
{
listeners
=
new
ArrayList
<
AudioManager
.
OnAudioPortUpdateListener
>();
if
(
mListeners
.
contains
(
msg
.
obj
))
{
...
...
@@ -152,7 +157,7 @@ class AudioPortEventHandler {
private
native
void
native_finalize
();
void
registerListener
(
AudioManager
.
OnAudioPortUpdateListener
l
)
{
synchronized
(
this
)
{
synchronized
(
mLock
)
{
mListeners
.
add
(
l
);
}
if
(
mHandler
!=
null
)
{
...
...
@@ -162,7 +167,7 @@ class AudioPortEventHandler {
}
void
unregisterListener
(
AudioManager
.
OnAudioPortUpdateListener
l
)
{
synchronized
(
this
)
{
synchronized
(
mLock
)
{
mListeners
.
remove
(
l
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment