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
0d230d51
authored
Mar 10, 2020
by
olly
Committed by
Oliver Woodman
Mar 11, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Miscellaneous cleanup related to recent changes
PiperOrigin-RevId: 300067561
parent
b83041a6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
38 deletions
demos/main/src/main/java/com/google/android/exoplayer2/demo/SampleChooserActivity.java
library/core/src/main/java/com/google/android/exoplayer2/SimpleExoPlayer.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/Mp3Extractor.java
demos/main/src/main/java/com/google/android/exoplayer2/demo/SampleChooserActivity.java
View file @
0d230d51
...
@@ -177,7 +177,7 @@ public class SampleChooserActivity extends AppCompatActivity
...
@@ -177,7 +177,7 @@ public class SampleChooserActivity extends AppCompatActivity
groupPosition
=
preferences
.
getInt
(
GROUP_POSITION_PREFERENCE_KEY
,
/* defValue= */
-
1
);
groupPosition
=
preferences
.
getInt
(
GROUP_POSITION_PREFERENCE_KEY
,
/* defValue= */
-
1
);
childPosition
=
preferences
.
getInt
(
CHILD_POSITION_PREFERENCE_KEY
,
/* defValue= */
-
1
);
childPosition
=
preferences
.
getInt
(
CHILD_POSITION_PREFERENCE_KEY
,
/* defValue= */
-
1
);
}
catch
(
ClassCastException
e
)
{
}
catch
(
ClassCastException
e
)
{
android
.
util
.
Log
.
w
(
TAG
,
"Saved position is not an int. Will not restore position."
,
e
);
Log
.
w
(
TAG
,
"Saved position is not an int. Will not restore position."
,
e
);
}
}
if
(
groupPosition
!=
-
1
&&
childPosition
!=
-
1
)
{
if
(
groupPosition
!=
-
1
&&
childPosition
!=
-
1
)
{
sampleListView
.
expandGroup
(
groupPosition
);
// shouldExpandGroup does not work without this.
sampleListView
.
expandGroup
(
groupPosition
);
// shouldExpandGroup does not work without this.
...
...
library/core/src/main/java/com/google/android/exoplayer2/SimpleExoPlayer.java
View file @
0d230d51
...
@@ -1704,6 +1704,20 @@ public class SimpleExoPlayer extends BasePlayer
...
@@ -1704,6 +1704,20 @@ public class SimpleExoPlayer extends BasePlayer
}
}
}
}
@SuppressWarnings
(
"SuspiciousMethodCalls"
)
private
void
notifySkipSilenceEnabledChanged
()
{
for
(
AudioListener
listener
:
audioListeners
)
{
// Prevent duplicate notification if a listener is both a AudioRendererEventListener and
// a AudioListener, as they have the same method signature.
if
(!
audioDebugListeners
.
contains
(
listener
))
{
listener
.
onSkipSilenceEnabledChanged
(
skipSilenceEnabled
);
}
}
for
(
AudioRendererEventListener
listener
:
audioDebugListeners
)
{
listener
.
onSkipSilenceEnabledChanged
(
skipSilenceEnabled
);
}
}
private
void
updatePlayWhenReady
(
private
void
updatePlayWhenReady
(
boolean
playWhenReady
,
boolean
playWhenReady
,
@AudioFocusManager
.
PlayerCommand
int
playerCommand
,
@AudioFocusManager
.
PlayerCommand
int
playerCommand
,
...
@@ -1717,17 +1731,6 @@ public class SimpleExoPlayer extends BasePlayer
...
@@ -1717,17 +1731,6 @@ public class SimpleExoPlayer extends BasePlayer
player
.
setPlayWhenReady
(
playWhenReady
,
playbackSuppressionReason
,
playWhenReadyChangeReason
);
player
.
setPlayWhenReady
(
playWhenReady
,
playbackSuppressionReason
,
playWhenReadyChangeReason
);
}
}
private
void
verifyApplicationThread
()
{
if
(
Looper
.
myLooper
()
!=
getApplicationLooper
())
{
Log
.
w
(
TAG
,
"Player is accessed on the wrong thread. See "
+
"https://exoplayer.dev/issues/player-accessed-on-wrong-thread"
,
hasNotifiedFullWrongThreadWarning
?
null
:
new
IllegalStateException
());
hasNotifiedFullWrongThreadWarning
=
true
;
}
}
private
void
updateWakeAndWifiLock
()
{
private
void
updateWakeAndWifiLock
()
{
@State
int
playbackState
=
getPlaybackState
();
@State
int
playbackState
=
getPlaybackState
();
switch
(
playbackState
)
{
switch
(
playbackState
)
{
...
@@ -1746,26 +1749,23 @@ public class SimpleExoPlayer extends BasePlayer
...
@@ -1746,26 +1749,23 @@ public class SimpleExoPlayer extends BasePlayer
}
}
}
}
private
void
verifyApplicationThread
()
{
if
(
Looper
.
myLooper
()
!=
getApplicationLooper
())
{
Log
.
w
(
TAG
,
"Player is accessed on the wrong thread. See "
+
"https://exoplayer.dev/issues/player-accessed-on-wrong-thread"
,
hasNotifiedFullWrongThreadWarning
?
null
:
new
IllegalStateException
());
hasNotifiedFullWrongThreadWarning
=
true
;
}
}
private
static
int
getPlayWhenReadyChangeReason
(
boolean
playWhenReady
,
int
playerCommand
)
{
private
static
int
getPlayWhenReadyChangeReason
(
boolean
playWhenReady
,
int
playerCommand
)
{
return
playWhenReady
&&
playerCommand
!=
AudioFocusManager
.
PLAYER_COMMAND_PLAY_WHEN_READY
return
playWhenReady
&&
playerCommand
!=
AudioFocusManager
.
PLAYER_COMMAND_PLAY_WHEN_READY
?
PLAY_WHEN_READY_CHANGE_REASON_AUDIO_FOCUS_LOSS
?
PLAY_WHEN_READY_CHANGE_REASON_AUDIO_FOCUS_LOSS
:
PLAY_WHEN_READY_CHANGE_REASON_USER_REQUEST
;
:
PLAY_WHEN_READY_CHANGE_REASON_USER_REQUEST
;
}
}
@SuppressWarnings
(
"SuspiciousMethodCalls"
)
private
void
notifySkipSilenceEnabledChanged
()
{
for
(
AudioListener
listener
:
audioListeners
)
{
// Prevent duplicate notification if a listener is both a AudioRendererEventListener and
// a AudioListener, as they have the same method signature.
if
(!
audioDebugListeners
.
contains
(
listener
))
{
listener
.
onSkipSilenceEnabledChanged
(
skipSilenceEnabled
);
}
}
for
(
AudioRendererEventListener
listener
:
audioDebugListeners
)
{
listener
.
onSkipSilenceEnabledChanged
(
skipSilenceEnabled
);
}
}
private
final
class
ComponentListener
private
final
class
ComponentListener
implements
VideoRendererEventListener
,
implements
VideoRendererEventListener
,
AudioRendererEventListener
,
AudioRendererEventListener
,
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/Mp3Extractor.java
View file @
0d230d51
...
@@ -78,15 +78,15 @@ public final class Mp3Extractor implements Extractor {
...
@@ -78,15 +78,15 @@ public final class Mp3Extractor implements Extractor {
*/
*/
public
static
final
int
FLAG_ENABLE_CONSTANT_BITRATE_SEEKING
=
1
;
public
static
final
int
FLAG_ENABLE_CONSTANT_BITRATE_SEEKING
=
1
;
/**
/**
* Flag to force index seeking,
consisting in building a time-to-byte mapping
as the file is read.
* Flag to force index seeking,
in which a time-to-byte mapping is built
as the file is read.
*
*
* <p>This seeker may require to scan a significant portion of the file to compute a seek point.
* <p>This seeker may require to scan a significant portion of the file to compute a seek point.
* Therefore, it should only be used if:
* Therefore, it should only be used if
one of the following is true
:
*
*
* <ul>
* <ul>
* <li>
the file is small, or
* <li>
The file is small.
* <li>
the bitrate is variable (or the type of bitrate is unknown) and the seeking metadata
* <li>
The bitrate is variable (or it's unknown whether it's variable) and the file does not
* provide
d in the file is not precise enough (or is not present)
.
* provide
precise enough seeking metadata
.
* </ul>
* </ul>
*/
*/
public
static
final
int
FLAG_ENABLE_INDEX_SEEKING
=
1
<<
1
;
public
static
final
int
FLAG_ENABLE_INDEX_SEEKING
=
1
<<
1
;
...
@@ -135,9 +135,7 @@ public final class Mp3Extractor implements Extractor {
...
@@ -135,9 +135,7 @@ public final class Mp3Extractor implements Extractor {
private
@MonotonicNonNull
ExtractorOutput
extractorOutput
;
private
@MonotonicNonNull
ExtractorOutput
extractorOutput
;
private
@MonotonicNonNull
TrackOutput
realTrackOutput
;
private
@MonotonicNonNull
TrackOutput
realTrackOutput
;
// currentTrackOutput is set to skippingTrackOutput or to realTrackOutput, depending if the data
private
TrackOutput
currentTrackOutput
;
// skippingTrackOutput or realTrackOutput.
// read must be sent to the output.
private
@MonotonicNonNull
TrackOutput
currentTrackOutput
;
private
int
synchronizedHeaderData
;
private
int
synchronizedHeaderData
;
...
@@ -177,6 +175,7 @@ public final class Mp3Extractor implements Extractor {
...
@@ -177,6 +175,7 @@ public final class Mp3Extractor implements Extractor {
basisTimeUs
=
C
.
TIME_UNSET
;
basisTimeUs
=
C
.
TIME_UNSET
;
id3Peeker
=
new
Id3Peeker
();
id3Peeker
=
new
Id3Peeker
();
skippingTrackOutput
=
new
DummyTrackOutput
();
skippingTrackOutput
=
new
DummyTrackOutput
();
currentTrackOutput
=
skippingTrackOutput
;
}
}
// Extractor implementation.
// Extractor implementation.
...
@@ -238,7 +237,7 @@ public final class Mp3Extractor implements Extractor {
...
@@ -238,7 +237,7 @@ public final class Mp3Extractor implements Extractor {
// Internal methods.
// Internal methods.
@RequiresNonNull
({
"extractorOutput"
,
"
currentTrackOutput"
,
"
realTrackOutput"
})
@RequiresNonNull
({
"extractorOutput"
,
"realTrackOutput"
})
private
int
readInternal
(
ExtractorInput
input
)
throws
IOException
{
private
int
readInternal
(
ExtractorInput
input
)
throws
IOException
{
if
(
synchronizedHeaderData
==
0
)
{
if
(
synchronizedHeaderData
==
0
)
{
try
{
try
{
...
@@ -271,7 +270,7 @@ public final class Mp3Extractor implements Extractor {
...
@@ -271,7 +270,7 @@ public final class Mp3Extractor implements Extractor {
return
readSample
(
input
);
return
readSample
(
input
);
}
}
@RequiresNonNull
({
"
currentTrackOutput"
,
"
realTrackOutput"
,
"seeker"
})
@RequiresNonNull
({
"realTrackOutput"
,
"seeker"
})
private
int
readSample
(
ExtractorInput
extractorInput
)
throws
IOException
{
private
int
readSample
(
ExtractorInput
extractorInput
)
throws
IOException
{
if
(
sampleBytesRemaining
==
0
)
{
if
(
sampleBytesRemaining
==
0
)
{
extractorInput
.
resetPeekPosition
();
extractorInput
.
resetPeekPosition
();
...
@@ -512,10 +511,9 @@ public final class Mp3Extractor implements Extractor {
...
@@ -512,10 +511,9 @@ public final class Mp3Extractor implements Extractor {
return
new
ConstantBitrateSeeker
(
input
.
getLength
(),
input
.
getPosition
(),
synchronizedHeader
);
return
new
ConstantBitrateSeeker
(
input
.
getLength
(),
input
.
getPosition
(),
synchronizedHeader
);
}
}
@EnsuresNonNull
({
"extractorOutput"
,
"
currentTrackOutput"
,
"
realTrackOutput"
})
@EnsuresNonNull
({
"extractorOutput"
,
"realTrackOutput"
})
private
void
assertInitialized
()
{
private
void
assertInitialized
()
{
Assertions
.
checkStateNotNull
(
realTrackOutput
);
Assertions
.
checkStateNotNull
(
realTrackOutput
);
Util
.
castNonNull
(
currentTrackOutput
);
Util
.
castNonNull
(
extractorOutput
);
Util
.
castNonNull
(
extractorOutput
);
}
}
...
...
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