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