mirror of
https://github.com/androidx/media.git
synced 2025-05-14 02:59:52 +08:00
Enable nullness checks for more easy files
PiperOrigin-RevId: 322586013
This commit is contained in:
parent
787cfb94c5
commit
bdadd572e2
@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.google.android.exoplayer2;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import com.google.android.exoplayer2.source.TrackGroupArray;
|
||||
import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
|
||||
import com.google.android.exoplayer2.upstream.Allocator;
|
||||
@ -94,7 +95,7 @@ public class DefaultLoadControl implements LoadControl {
|
||||
/** Builder for {@link DefaultLoadControl}. */
|
||||
public static final class Builder {
|
||||
|
||||
private DefaultAllocator allocator;
|
||||
@Nullable private DefaultAllocator allocator;
|
||||
private int minBufferMs;
|
||||
private int maxBufferMs;
|
||||
private int bufferForPlaybackMs;
|
||||
|
@ -328,7 +328,7 @@ public final class MediaCodecInfo {
|
||||
public boolean isSeamlessAdaptationSupported(
|
||||
Format oldFormat, Format newFormat, boolean isNewFormatComplete) {
|
||||
if (isVideo) {
|
||||
return oldFormat.sampleMimeType.equals(newFormat.sampleMimeType)
|
||||
return Assertions.checkNotNull(oldFormat.sampleMimeType).equals(newFormat.sampleMimeType)
|
||||
&& oldFormat.rotationDegrees == newFormat.rotationDegrees
|
||||
&& (adaptive
|
||||
|| (oldFormat.width == newFormat.width && oldFormat.height == newFormat.height))
|
||||
@ -336,14 +336,16 @@ public final class MediaCodecInfo {
|
||||
|| Util.areEqual(oldFormat.colorInfo, newFormat.colorInfo));
|
||||
} else {
|
||||
if (!MimeTypes.AUDIO_AAC.equals(mimeType)
|
||||
|| !oldFormat.sampleMimeType.equals(newFormat.sampleMimeType)
|
||||
|| !Assertions.checkNotNull(oldFormat.sampleMimeType).equals(newFormat.sampleMimeType)
|
||||
|| oldFormat.channelCount != newFormat.channelCount
|
||||
|| oldFormat.sampleRate != newFormat.sampleRate) {
|
||||
return false;
|
||||
}
|
||||
// Check the codec profile levels support adaptation.
|
||||
@Nullable
|
||||
Pair<Integer, Integer> oldCodecProfileLevel =
|
||||
MediaCodecUtil.getCodecProfileAndLevel(oldFormat);
|
||||
@Nullable
|
||||
Pair<Integer, Integer> newCodecProfileLevel =
|
||||
MediaCodecUtil.getCodecProfileAndLevel(newFormat);
|
||||
if (oldCodecProfileLevel == null || newCodecProfileLevel == null) {
|
||||
@ -402,6 +404,7 @@ public final class MediaCodecInfo {
|
||||
* the {@link MediaCodec}'s width and height alignment requirements, or null if not a video
|
||||
* codec.
|
||||
*/
|
||||
@Nullable
|
||||
@RequiresApi(21)
|
||||
public Point alignVideoSizeV21(int width, int height) {
|
||||
if (capabilities == null) {
|
||||
|
@ -19,6 +19,7 @@ import androidx.annotation.Nullable;
|
||||
import com.google.android.exoplayer2.util.Assertions;
|
||||
import com.google.android.exoplayer2.util.Util;
|
||||
import java.util.Arrays;
|
||||
import org.checkerframework.checker.nullness.compatqual.NullableType;
|
||||
|
||||
/**
|
||||
* Default implementation of {@link Allocator}.
|
||||
@ -35,7 +36,7 @@ public final class DefaultAllocator implements Allocator {
|
||||
private int targetBufferSize;
|
||||
private int allocatedCount;
|
||||
private int availableCount;
|
||||
private Allocation[] availableAllocations;
|
||||
@NullableType private Allocation[] availableAllocations;
|
||||
|
||||
/**
|
||||
* Constructs an instance without creating any {@link Allocation}s up front.
|
||||
@ -97,7 +98,7 @@ public final class DefaultAllocator implements Allocator {
|
||||
allocatedCount++;
|
||||
Allocation allocation;
|
||||
if (availableCount > 0) {
|
||||
allocation = availableAllocations[--availableCount];
|
||||
allocation = Assertions.checkNotNull(availableAllocations[--availableCount]);
|
||||
availableAllocations[availableCount] = null;
|
||||
} else {
|
||||
allocation = new Allocation(new byte[individualAllocationSize], 0);
|
||||
@ -141,11 +142,11 @@ public final class DefaultAllocator implements Allocator {
|
||||
int lowIndex = 0;
|
||||
int highIndex = availableCount - 1;
|
||||
while (lowIndex <= highIndex) {
|
||||
Allocation lowAllocation = availableAllocations[lowIndex];
|
||||
Allocation lowAllocation = Assertions.checkNotNull(availableAllocations[lowIndex]);
|
||||
if (lowAllocation.data == initialAllocationBlock) {
|
||||
lowIndex++;
|
||||
} else {
|
||||
Allocation highAllocation = availableAllocations[highIndex];
|
||||
Allocation highAllocation = Assertions.checkNotNull(availableAllocations[highIndex]);
|
||||
if (highAllocation.data != initialAllocationBlock) {
|
||||
highIndex--;
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user