Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
f129812b
authored
Aug 11, 2015
by
Oliver Woodman
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Clean up AudioCapabilities.
parent
adf98b0f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
20 deletions
library/src/main/java/com/google/android/exoplayer/audio/AudioCapabilitiesReceiver.java
library/src/main/java/com/google/android/exoplayer/audio/AudioCapabilitiesReceiver.java
View file @
f129812b
...
@@ -18,6 +18,7 @@ package com.google.android.exoplayer.audio;
...
@@ -18,6 +18,7 @@ package com.google.android.exoplayer.audio;
import
com.google.android.exoplayer.util.Assertions
;
import
com.google.android.exoplayer.util.Assertions
;
import
com.google.android.exoplayer.util.Util
;
import
com.google.android.exoplayer.util.Util
;
import
android.annotation.SuppressLint
;
import
android.annotation.TargetApi
;
import
android.annotation.TargetApi
;
import
android.content.BroadcastReceiver
;
import
android.content.BroadcastReceiver
;
import
android.content.Context
;
import
android.content.Context
;
...
@@ -67,16 +68,9 @@ public final class AudioCapabilitiesReceiver {
...
@@ -67,16 +68,9 @@ public final class AudioCapabilitiesReceiver {
*/
*/
@TargetApi
(
21
)
@TargetApi
(
21
)
public
void
register
()
{
public
void
register
()
{
if
(
receiver
!=
null
)
{
Intent
stickyIntent
=
receiver
==
null
?
null
Intent
initialStickyIntent
=
:
context
.
registerReceiver
(
receiver
,
new
IntentFilter
(
AudioManager
.
ACTION_HDMI_AUDIO_PLUG
));
context
.
registerReceiver
(
receiver
,
new
IntentFilter
(
AudioManager
.
ACTION_HDMI_AUDIO_PLUG
));
listener
.
onAudioCapabilitiesChanged
(
getCapabilities
(
stickyIntent
));
if
(
initialStickyIntent
!=
null
)
{
receiver
.
onReceive
(
context
,
initialStickyIntent
);
return
;
}
}
listener
.
onAudioCapabilitiesChanged
(
DEFAULT_AUDIO_CAPABILITIES
);
}
}
/** Unregisters to stop notifying the listener when audio capabilities change. */
/** Unregisters to stop notifying the listener when audio capabilities change. */
...
@@ -86,7 +80,15 @@ public final class AudioCapabilitiesReceiver {
...
@@ -86,7 +80,15 @@ public final class AudioCapabilitiesReceiver {
}
}
}
}
@TargetApi
(
21
)
@SuppressLint
(
"InlinedApi"
)
/* package */
AudioCapabilities
getCapabilities
(
Intent
intent
)
{
if
(
intent
==
null
||
intent
.
getIntExtra
(
AudioManager
.
EXTRA_AUDIO_PLUG_STATE
,
0
)
==
0
)
{
return
DEFAULT_AUDIO_CAPABILITIES
;
}
return
new
AudioCapabilities
(
intent
.
getIntArrayExtra
(
AudioManager
.
EXTRA_ENCODINGS
),
intent
.
getIntExtra
(
AudioManager
.
EXTRA_MAX_CHANNEL_COUNT
,
0
));
}
private
final
class
HdmiAudioPlugBroadcastReceiver
extends
BroadcastReceiver
{
private
final
class
HdmiAudioPlugBroadcastReceiver
extends
BroadcastReceiver
{
@Override
@Override
...
@@ -94,15 +96,7 @@ public final class AudioCapabilitiesReceiver {
...
@@ -94,15 +96,7 @@ public final class AudioCapabilitiesReceiver {
if
(
isInitialStickyBroadcast
())
{
if
(
isInitialStickyBroadcast
())
{
return
;
return
;
}
}
listener
.
onAudioCapabilitiesChanged
(
getCapabilities
(
intent
));
String
action
=
intent
.
getAction
();
if
(!
action
.
equals
(
AudioManager
.
ACTION_HDMI_AUDIO_PLUG
))
{
return
;
}
listener
.
onAudioCapabilitiesChanged
(
new
AudioCapabilities
(
intent
.
getIntArrayExtra
(
AudioManager
.
EXTRA_ENCODINGS
),
intent
.
getIntExtra
(
AudioManager
.
EXTRA_MAX_CHANNEL_COUNT
,
0
)));
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment