Commit f67849af by kimvde Committed by Marc Baechinger

Add IntRange annotation to onTrackCount

PiperOrigin-RevId: 496942702
parent 5c4d85c2
......@@ -18,6 +18,7 @@ package androidx.media3.transformer;
import android.content.Context;
import android.os.Looper;
import androidx.annotation.IntRange;
import androidx.media3.common.Format;
import androidx.media3.common.MediaItem;
import androidx.media3.common.util.Clock;
......@@ -131,7 +132,7 @@ public interface AssetLoader {
void onDurationUs(long durationUs);
/** Called when the number of tracks output by the asset loader is known. */
void onTrackCount(int trackCount);
void onTrackCount(@IntRange(from = 1) int trackCount);
/**
* Called when the information on a track is known.
......
......@@ -16,6 +16,7 @@
package androidx.media3.transformer;
import static androidx.media3.common.PlaybackException.ERROR_CODE_FAILED_RUNTIME_CHECK;
import static androidx.media3.common.util.Assertions.checkStateNotNull;
import static androidx.media3.exoplayer.DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS;
import static androidx.media3.exoplayer.DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_MS;
......@@ -350,7 +351,15 @@ public final class ExoPlayerAssetLoader implements AssetLoader {
if (tracks.isTypeSelected(C.TRACK_TYPE_VIDEO)) {
trackCount++;
}
assetLoaderListener.onTrackCount(trackCount);
if (trackCount == 0) {
assetLoaderListener.onError(
new PlaybackException(
"The asset loader has no track to output.",
/* cause= */ null,
ERROR_CODE_FAILED_RUNTIME_CHECK));
} else {
assetLoaderListener.onTrackCount(trackCount);
}
}
@Override
......
......@@ -401,8 +401,9 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
@Override
public void onTrackCount(int trackCount) {
if (trackCount == 0) {
onError(new IllegalStateException("The output does not contain any tracks."));
if (trackCount <= 0) {
onError(new IllegalStateException("AssetLoader instances must provide at least 1 track."));
return;
}
this.trackCount.set(trackCount);
if (forceSilentAudio) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment