Miscellaneous cleanup related to recent changes

PiperOrigin-RevId: 300067561
This commit is contained in:
olly 2020-03-10 12:20:56 +00:00 committed by Oliver Woodman
parent b83041a6f5
commit 0d230d517a
3 changed files with 36 additions and 38 deletions

View File

@ -177,7 +177,7 @@ public class SampleChooserActivity extends AppCompatActivity
groupPosition = preferences.getInt(GROUP_POSITION_PREFERENCE_KEY, /* defValue= */ -1);
childPosition = preferences.getInt(CHILD_POSITION_PREFERENCE_KEY, /* defValue= */ -1);
} 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) {
sampleListView.expandGroup(groupPosition); // shouldExpandGroup does not work without this.

View File

@ -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(
boolean playWhenReady,
@AudioFocusManager.PlayerCommand int playerCommand,
@ -1717,17 +1731,6 @@ public class SimpleExoPlayer extends BasePlayer
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() {
@State int playbackState = getPlaybackState();
switch (playbackState) {
@ -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) {
return playWhenReady && playerCommand != AudioFocusManager.PLAYER_COMMAND_PLAY_WHEN_READY
? PLAY_WHEN_READY_CHANGE_REASON_AUDIO_FOCUS_LOSS
: 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
implements VideoRendererEventListener,
AudioRendererEventListener,

View File

@ -78,15 +78,15 @@ public final class Mp3Extractor implements Extractor {
*/
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.
* Therefore, it should only be used if:
* Therefore, it should only be used if one of the following is true:
*
* <ul>
* <li>the file is small, or
* <li>the bitrate is variable (or the type of bitrate is unknown) and the seeking metadata
* provided in the file is not precise enough (or is not present).
* <li>The file is small.
* <li>The bitrate is variable (or it's unknown whether it's variable) and the file does not
* provide precise enough seeking metadata.
* </ul>
*/
public static final int FLAG_ENABLE_INDEX_SEEKING = 1 << 1;
@ -135,9 +135,7 @@ public final class Mp3Extractor implements Extractor {
private @MonotonicNonNull ExtractorOutput extractorOutput;
private @MonotonicNonNull TrackOutput realTrackOutput;
// currentTrackOutput is set to skippingTrackOutput or to realTrackOutput, depending if the data
// read must be sent to the output.
private @MonotonicNonNull TrackOutput currentTrackOutput;
private TrackOutput currentTrackOutput; // skippingTrackOutput or realTrackOutput.
private int synchronizedHeaderData;
@ -177,6 +175,7 @@ public final class Mp3Extractor implements Extractor {
basisTimeUs = C.TIME_UNSET;
id3Peeker = new Id3Peeker();
skippingTrackOutput = new DummyTrackOutput();
currentTrackOutput = skippingTrackOutput;
}
// Extractor implementation.
@ -238,7 +237,7 @@ public final class Mp3Extractor implements Extractor {
// Internal methods.
@RequiresNonNull({"extractorOutput", "currentTrackOutput", "realTrackOutput"})
@RequiresNonNull({"extractorOutput", "realTrackOutput"})
private int readInternal(ExtractorInput input) throws IOException {
if (synchronizedHeaderData == 0) {
try {
@ -271,7 +270,7 @@ public final class Mp3Extractor implements Extractor {
return readSample(input);
}
@RequiresNonNull({"currentTrackOutput", "realTrackOutput", "seeker"})
@RequiresNonNull({"realTrackOutput", "seeker"})
private int readSample(ExtractorInput extractorInput) throws IOException {
if (sampleBytesRemaining == 0) {
extractorInput.resetPeekPosition();
@ -512,10 +511,9 @@ public final class Mp3Extractor implements Extractor {
return new ConstantBitrateSeeker(input.getLength(), input.getPosition(), synchronizedHeader);
}
@EnsuresNonNull({"extractorOutput", "currentTrackOutput", "realTrackOutput"})
@EnsuresNonNull({"extractorOutput", "realTrackOutput"})
private void assertInitialized() {
Assertions.checkStateNotNull(realTrackOutput);
Util.castNonNull(currentTrackOutput);
Util.castNonNull(extractorOutput);
}