diff --git a/demos/main/src/main/java/com/google/android/exoplayer2/demo/SampleChooserActivity.java b/demos/main/src/main/java/com/google/android/exoplayer2/demo/SampleChooserActivity.java index 2aa134b114..1458d1a6b2 100644 --- a/demos/main/src/main/java/com/google/android/exoplayer2/demo/SampleChooserActivity.java +++ b/demos/main/src/main/java/com/google/android/exoplayer2/demo/SampleChooserActivity.java @@ -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. diff --git a/library/core/src/main/java/com/google/android/exoplayer2/SimpleExoPlayer.java b/library/core/src/main/java/com/google/android/exoplayer2/SimpleExoPlayer.java index dd306c69d0..6e183ba811 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/SimpleExoPlayer.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/SimpleExoPlayer.java @@ -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, diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/Mp3Extractor.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/Mp3Extractor.java index 8967e0a230..b9613f38f5 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/Mp3Extractor.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/Mp3Extractor.java @@ -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. * *

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: * *

*/ 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); }