Disable enhanced Java 8 desugaring

This avoids that apps have to depend on this additional config

Issue: androidx/media#1312
PiperOrigin-RevId: 631447767
This commit is contained in:
tonihei 2024-05-07 09:23:49 -07:00 committed by Copybara-Service
parent 096904301f
commit 6ac60c6dff
17 changed files with 57 additions and 34 deletions

View File

@ -7,6 +7,8 @@
and `SimpleBasePlayer.handleSeek` methods instead of ignoring them. If and `SimpleBasePlayer.handleSeek` methods instead of ignoring them. If
you are implementing these methods in a custom player, you may need to you are implementing these methods in a custom player, you may need to
handle these additional calls with `mediaItemIndex == C.INDEX_UNSET`. handle these additional calls with `mediaItemIndex == C.INDEX_UNSET`.
* Remove compile dependency on enhanced Java 8 desugaring
([#1312](https://github.com/androidx/media/issues/1312)).
* ExoPlayer: * ExoPlayer:
* Add `reset` to `BasePreloadManager` to release all the holding sources * Add `reset` to `BasePreloadManager` to release all the holding sources
while keep the preload manager instance. while keep the preload manager instance.

View File

@ -29,7 +29,6 @@ android {
} }
compileOptions { compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8
} }
@ -44,5 +43,4 @@ android {
dependencies { dependencies {
androidTestImplementation 'androidx.multidex:multidex:' + androidxMultidexVersion androidTestImplementation 'androidx.multidex:multidex:' + androidxMultidexVersion
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
} }

View File

@ -20,7 +20,6 @@ android {
compileSdk project.ext.compileSdkVersion compileSdk project.ext.compileSdkVersion
compileOptions { compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8
} }
@ -66,7 +65,6 @@ dependencies {
implementation 'androidx.multidex:multidex:' + androidxMultidexVersion implementation 'androidx.multidex:multidex:' + androidxMultidexVersion
implementation 'androidx.recyclerview:recyclerview:' + androidxRecyclerViewVersion implementation 'androidx.recyclerview:recyclerview:' + androidxRecyclerViewVersion
implementation 'com.google.android.material:material:' + androidxMaterialVersion implementation 'com.google.android.material:material:' + androidxMaterialVersion
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
} }
apply plugin: 'com.google.android.gms.strict-version-matcher-plugin' apply plugin: 'com.google.android.gms.strict-version-matcher-plugin'

View File

@ -21,7 +21,6 @@ android {
compileSdk project.ext.compileSdkVersion compileSdk project.ext.compileSdkVersion
compileOptions { compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8
} }
@ -74,6 +73,4 @@ dependencies {
// For detecting and debugging leaks only. LeakCanary is not needed for demo app to work. // For detecting and debugging leaks only. LeakCanary is not needed for demo app to work.
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.10' debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.10'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
} }

View File

@ -20,7 +20,6 @@ android {
compileSdk project.ext.compileSdkVersion compileSdk project.ext.compileSdkVersion
compileOptions { compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8
} }
@ -58,5 +57,4 @@ dependencies {
implementation 'androidx.annotation:annotation:' + androidxAnnotationVersion implementation 'androidx.annotation:annotation:' + androidxAnnotationVersion
implementation 'androidx.multidex:multidex:' + androidxMultidexVersion implementation 'androidx.multidex:multidex:' + androidxMultidexVersion
compileOnly 'org.checkerframework:checker-qual:' + checkerframeworkVersion compileOnly 'org.checkerframework:checker-qual:' + checkerframeworkVersion
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
} }

View File

@ -22,7 +22,6 @@ android {
compileSdk project.ext.compileSdkVersion compileSdk project.ext.compileSdkVersion
compileOptions { compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8
} }
@ -91,7 +90,6 @@ dependencies {
withDecoderExtensionsImplementation project(modulePrefix + 'lib-decoder-vp9') withDecoderExtensionsImplementation project(modulePrefix + 'lib-decoder-vp9')
withDecoderExtensionsImplementation project(modulePrefix + 'lib-decoder-midi') withDecoderExtensionsImplementation project(modulePrefix + 'lib-decoder-midi')
withDecoderExtensionsImplementation project(modulePrefix + 'lib-datasource-rtmp') withDecoderExtensionsImplementation project(modulePrefix + 'lib-datasource-rtmp')
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
} }
apply plugin: 'com.google.android.gms.strict-version-matcher-plugin' apply plugin: 'com.google.android.gms.strict-version-matcher-plugin'

View File

@ -21,7 +21,6 @@ android {
compileSdk project.ext.compileSdkVersion compileSdk project.ext.compileSdkVersion
compileOptions { compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8
} }
@ -69,5 +68,4 @@ dependencies {
implementation project(modulePrefix + 'lib-ui') implementation project(modulePrefix + 'lib-ui')
implementation project(modulePrefix + 'lib-session') implementation project(modulePrefix + 'lib-session')
implementation project(modulePrefix + 'demo-session-service') implementation project(modulePrefix + 'demo-session-service')
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
} }

View File

@ -21,7 +21,6 @@ android {
compileSdk project.ext.compileSdkVersion compileSdk project.ext.compileSdkVersion
compileOptions { compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8
} }
@ -65,5 +64,4 @@ dependencies {
implementation 'com.google.android.material:material:' + androidxMaterialVersion implementation 'com.google.android.material:material:' + androidxMaterialVersion
implementation project(modulePrefix + 'lib-session') implementation project(modulePrefix + 'lib-session')
implementation project(modulePrefix + 'demo-session-service') implementation project(modulePrefix + 'demo-session-service')
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
} }

View File

@ -21,7 +21,6 @@ android {
compileSdk project.ext.compileSdkVersion compileSdk project.ext.compileSdkVersion
compileOptions { compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8
} }
@ -94,5 +93,4 @@ dependencies {
testImplementation 'com.google.truth:truth:' + truthVersion testImplementation 'com.google.truth:truth:' + truthVersion
testImplementation 'org.robolectric:robolectric:' + robolectricVersion testImplementation 'org.robolectric:robolectric:' + robolectricVersion
testImplementation 'org.robolectric:robolectric:' + robolectricVersion testImplementation 'org.robolectric:robolectric:' + robolectricVersion
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
} }

View File

@ -20,7 +20,6 @@ android {
compileSdk project.ext.compileSdkVersion compileSdk project.ext.compileSdkVersion
compileOptions { compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8
} }
@ -55,5 +54,4 @@ dependencies {
implementation project(modulePrefix + 'lib-exoplayer-smoothstreaming') implementation project(modulePrefix + 'lib-exoplayer-smoothstreaming')
implementation project(modulePrefix + 'lib-ui') implementation project(modulePrefix + 'lib-ui')
implementation 'androidx.annotation:annotation:' + androidxAnnotationVersion implementation 'androidx.annotation:annotation:' + androidxAnnotationVersion
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
} }

View File

@ -22,7 +22,6 @@ android {
compileSdk project.ext.compileSdkVersion compileSdk project.ext.compileSdkVersion
compileOptions { compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8
} }
@ -86,8 +85,6 @@ dependencies {
implementation project(modulePrefix + 'lib-transformer') implementation project(modulePrefix + 'lib-transformer')
implementation project(modulePrefix + 'lib-ui') implementation project(modulePrefix + 'lib-ui')
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
// For MediaPipe and its dependencies: // For MediaPipe and its dependencies:
withMediaPipeImplementation fileTree(dir: 'libs', include: ['*.aar']) withMediaPipeImplementation fileTree(dir: 'libs', include: ['*.aar'])
withMediaPipeImplementation 'com.google.flogger:flogger:latest.release' withMediaPipeImplementation 'com.google.flogger:flogger:latest.release'

View File

@ -967,6 +967,18 @@ public final class Format implements Bundleable {
// Lazily initialized hashcode. // Lazily initialized hashcode.
private int hashCode; private int hashCode;
private static boolean isLabelPartOfLabels(Builder builder) {
if (builder.labels.isEmpty() && builder.label == null) {
return true;
}
for (int i = 0; i < builder.labels.size(); i++) {
if (builder.labels.get(i).value.equals(builder.label)) {
return true;
}
}
return false;
}
private Format(Builder builder) { private Format(Builder builder) {
id = builder.id; id = builder.id;
language = Util.normalizeLanguageCode(builder.language); language = Util.normalizeLanguageCode(builder.language);
@ -977,9 +989,7 @@ public final class Format implements Bundleable {
labels = builder.labels; labels = builder.labels;
label = getDefaultLabel(builder.labels, language); label = getDefaultLabel(builder.labels, language);
} else { } else {
checkState( checkState(isLabelPartOfLabels(builder));
(builder.labels.isEmpty() && builder.label == null)
|| (builder.labels.stream().anyMatch(l -> l.value.equals(builder.label))));
labels = builder.labels; labels = builder.labels;
label = builder.label; label = builder.label;
} }

View File

@ -24,6 +24,7 @@ import androidx.media3.common.C;
import androidx.media3.common.util.LongArray; import androidx.media3.common.util.LongArray;
import androidx.media3.common.util.LongArrayQueue; import androidx.media3.common.util.LongArrayQueue;
import androidx.media3.common.util.SpeedProviderUtil; import androidx.media3.common.util.SpeedProviderUtil;
import androidx.media3.common.util.TimestampConsumer;
import androidx.media3.common.util.UnstableApi; import androidx.media3.common.util.UnstableApi;
import androidx.media3.common.util.Util; import androidx.media3.common.util.Util;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
@ -53,7 +54,7 @@ public final class SpeedChangingAudioProcessor extends BaseAudioProcessor {
// Elements in the same positions in the queues are associated. // Elements in the same positions in the queues are associated.
private final LongArrayQueue pendingCallbackInputTimesUs; private final LongArrayQueue pendingCallbackInputTimesUs;
private final Queue<LongConsumer> pendingCallbacks; private final Queue<TimestampConsumer> pendingCallbacks;
// Elements in the same positions in the arrays are associated. // Elements in the same positions in the arrays are associated.
private final LongArray inputSegmentStartTimesUs; private final LongArray inputSegmentStartTimesUs;
@ -204,13 +205,13 @@ public final class SpeedChangingAudioProcessor extends BaseAudioProcessor {
* @param callback The callback called with the output time. May be called on a different thread * @param callback The callback called with the output time. May be called on a different thread
* from the caller of this method. * from the caller of this method.
*/ */
public void getSpeedAdjustedTimeAsync(long inputTimeUs, LongConsumer callback) { public void getSpeedAdjustedTimeAsync(long inputTimeUs, TimestampConsumer callback) {
checkArgument(speedAdjustedTimeAsyncInputTimeUs < inputTimeUs); checkArgument(speedAdjustedTimeAsyncInputTimeUs < inputTimeUs);
speedAdjustedTimeAsyncInputTimeUs = inputTimeUs; speedAdjustedTimeAsyncInputTimeUs = inputTimeUs;
synchronized (pendingCallbacksLock) { synchronized (pendingCallbacksLock) {
if ((inputTimeUs <= lastProcessedInputTimeUs && pendingCallbackInputTimesUs.isEmpty()) if ((inputTimeUs <= lastProcessedInputTimeUs && pendingCallbackInputTimesUs.isEmpty())
|| isEnded()) { || isEnded()) {
callback.accept(calculateSpeedAdjustedTime(inputTimeUs)); callback.onTimestamp(calculateSpeedAdjustedTime(inputTimeUs));
return; return;
} }
pendingCallbackInputTimesUs.add(inputTimeUs); pendingCallbackInputTimesUs.add(inputTimeUs);
@ -261,7 +262,7 @@ public final class SpeedChangingAudioProcessor extends BaseAudioProcessor {
&& (pendingCallbackInputTimesUs.element() <= lastProcessedInputTimeUs || isEnded())) { && (pendingCallbackInputTimesUs.element() <= lastProcessedInputTimeUs || isEnded())) {
pendingCallbacks pendingCallbacks
.remove() .remove()
.accept(calculateSpeedAdjustedTime(pendingCallbackInputTimesUs.remove())); .onTimestamp(calculateSpeedAdjustedTime(pendingCallbackInputTimesUs.remove()));
} }
} }
} }

View File

@ -0,0 +1,28 @@
/*
* Copyright 2024 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package androidx.media3.common.util;
/** A consumer for long timestamp values. */
@UnstableApi
public interface TimestampConsumer {
/**
* Consumes a timestamp.
*
* @param timestampUs The timestamp, in microseconds.
*/
public void onTimestamp(long timestampUs);
}

View File

@ -66,7 +66,7 @@ public class TimestampAdjustmentTest {
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
throw new IllegalStateException(e); throw new IllegalStateException(e);
} }
callback.accept(inputTimeUs / 2); callback.onTimestamp(inputTimeUs / 2);
}); });
ImmutableList<Long> actualPresentationTimesUs = ImmutableList<Long> actualPresentationTimesUs =

View File

@ -16,8 +16,8 @@
package androidx.media3.effect; package androidx.media3.effect;
import android.content.Context; import android.content.Context;
import androidx.media3.common.util.TimestampConsumer;
import androidx.media3.common.util.UnstableApi; import androidx.media3.common.util.UnstableApi;
import java.util.function.LongConsumer;
/** /**
* Changes the frame timestamps using the {@link TimestampMap}. * Changes the frame timestamps using the {@link TimestampMap}.
@ -43,7 +43,7 @@ public final class TimestampAdjustment implements GlEffect {
* <p>The implementation should invoke the {@code outputTimeConsumer} with the output timestamp, * <p>The implementation should invoke the {@code outputTimeConsumer} with the output timestamp,
* on any thread. * on any thread.
*/ */
void calculateOutputTimeUs(long inputTimeUs, LongConsumer outputTimeConsumer); void calculateOutputTimeUs(long inputTimeUs, TimestampConsumer outputTimeConsumer);
} }
private final TimestampMap timestampMap; private final TimestampMap timestampMap;

View File

@ -149,11 +149,15 @@ import java.util.Map;
} }
long presentationTimeOffsetUs = long presentationTimeOffsetUs =
trackTokenToPresentationTimeOffsetUs.getOrDefault(trackToken, 0L); trackTokenToPresentationTimeOffsetUs.containsKey(trackToken)
? trackTokenToPresentationTimeOffsetUs.get(trackToken)
: 0;
presentationTimeUs += presentationTimeOffsetUs; presentationTimeUs += presentationTimeOffsetUs;
long lastSamplePresentationTimeUs = long lastSamplePresentationTimeUs =
trackTokenToLastPresentationTimeUs.getOrDefault(trackToken, 0L); trackTokenToLastPresentationTimeUs.containsKey(trackToken)
? trackTokenToLastPresentationTimeUs.get(trackToken)
: 0;
// writeSampleData blocks on old API versions, so check here to avoid calling the method. // writeSampleData blocks on old API versions, so check here to avoid calling the method.
checkState( checkState(
Util.SDK_INT > 24 || presentationTimeUs >= lastSamplePresentationTimeUs, Util.SDK_INT > 24 || presentationTimeUs >= lastSamplePresentationTimeUs,