mirror of
https://github.com/samsonjs/media.git
synced 2026-04-16 13:05:46 +00:00
Remove deprecated AudioSink methods
Also do some minor cleanup in DefaultAudioSink. PiperOrigin-RevId: 326012441
This commit is contained in:
parent
82b26357c9
commit
607e11718b
4 changed files with 9 additions and 81 deletions
|
|
@ -20,7 +20,6 @@ import androidx.annotation.IntDef;
|
|||
import androidx.annotation.Nullable;
|
||||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.Format;
|
||||
import com.google.android.exoplayer2.PlaybackParameters;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
|
@ -298,19 +297,6 @@ public interface AudioSink {
|
|||
*/
|
||||
boolean hasPendingData();
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #setPlaybackSpeed(float)} and {@link #setSkipSilenceEnabled(boolean)}
|
||||
* instead.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Deprecated
|
||||
void setPlaybackParameters(PlaybackParameters playbackParameters);
|
||||
|
||||
/** @deprecated Use {@link #getPlaybackSpeed()} and {@link #getSkipSilenceEnabled()} instead. */
|
||||
@SuppressWarnings("deprecation")
|
||||
@Deprecated
|
||||
PlaybackParameters getPlaybackParameters();
|
||||
|
||||
/** Sets the playback speed. */
|
||||
void setPlaybackSpeed(float playbackSpeed);
|
||||
|
||||
|
|
|
|||
|
|
@ -318,7 +318,7 @@ import java.lang.reflect.Method;
|
|||
|
||||
boolean hadData = hasData;
|
||||
hasData = hasPendingData(writtenFrames);
|
||||
if (hadData && !hasData && playState != PLAYSTATE_STOPPED && listener != null) {
|
||||
if (hadData && !hasData && playState != PLAYSTATE_STOPPED) {
|
||||
listener.onUnderrun(bufferSize, C.usToMs(bufferSizeUs));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ import androidx.annotation.Nullable;
|
|||
import androidx.annotation.RequiresApi;
|
||||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.Format;
|
||||
import com.google.android.exoplayer2.PlaybackParameters;
|
||||
import com.google.android.exoplayer2.audio.AudioProcessor.UnhandledAudioFormatException;
|
||||
import com.google.android.exoplayer2.util.Assertions;
|
||||
import com.google.android.exoplayer2.util.Log;
|
||||
|
|
@ -91,14 +90,6 @@ public final class DefaultAudioSink implements AudioSink {
|
|||
*/
|
||||
AudioProcessor[] getAudioProcessors();
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #applyPlaybackSpeed(float)} and {@link
|
||||
* #applySkipSilenceEnabled(boolean)} instead.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Deprecated
|
||||
PlaybackParameters applyPlaybackParameters(PlaybackParameters playbackParameters);
|
||||
|
||||
/**
|
||||
* Configures audio processors to apply the specified playback speed immediately, returning the
|
||||
* new playback speed, which may differ from the speed passed in. Only called when processors
|
||||
|
|
@ -177,17 +168,6 @@ public final class DefaultAudioSink implements AudioSink {
|
|||
return audioProcessors;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #applyPlaybackSpeed(float)} and {@link
|
||||
* #applySkipSilenceEnabled(boolean)} instead.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Deprecated
|
||||
@Override
|
||||
public PlaybackParameters applyPlaybackParameters(PlaybackParameters playbackParameters) {
|
||||
return new PlaybackParameters(applyPlaybackSpeed(playbackParameters.speed));
|
||||
}
|
||||
|
||||
@Override
|
||||
public float applyPlaybackSpeed(float playbackSpeed) {
|
||||
return sonicAudioProcessor.setSpeed(playbackSpeed);
|
||||
|
|
@ -259,7 +239,7 @@ public final class DefaultAudioSink implements AudioSink {
|
|||
@SuppressLint("InlinedApi")
|
||||
private static final int WRITE_NON_BLOCKING = AudioTrack.WRITE_NON_BLOCKING;
|
||||
/** The default playback speed. */
|
||||
private static final float DEFAULT_PLAYBACK_SPEED = 1.0f;
|
||||
private static final float DEFAULT_PLAYBACK_SPEED = 1f;
|
||||
/** The default skip silence flag. */
|
||||
private static final boolean DEFAULT_SKIP_SILENCE = false;
|
||||
|
||||
|
|
@ -424,7 +404,7 @@ public final class DefaultAudioSink implements AudioSink {
|
|||
Collections.addAll(toIntPcmAudioProcessors, audioProcessorChain.getAudioProcessors());
|
||||
toIntPcmAvailableAudioProcessors = toIntPcmAudioProcessors.toArray(new AudioProcessor[0]);
|
||||
toFloatPcmAvailableAudioProcessors = new AudioProcessor[] {new FloatResamplingAudioProcessor()};
|
||||
volume = 1.0f;
|
||||
volume = 1f;
|
||||
audioAttributes = AudioAttributes.DEFAULT;
|
||||
audioSessionId = C.AUDIO_SESSION_ID_UNSET;
|
||||
auxEffectInfo = new AuxEffectInfo(AuxEffectInfo.NO_AUX_EFFECT_ID, 0f);
|
||||
|
|
@ -1004,26 +984,6 @@ public final class DefaultAudioSink implements AudioSink {
|
|||
return isInitialized() && audioTrackPositionTracker.hasPendingData(getWrittenFrames());
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #setPlaybackSpeed(float)} and {@link #setSkipSilenceEnabled(boolean)}
|
||||
* instead.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Deprecated
|
||||
@Override
|
||||
public void setPlaybackParameters(PlaybackParameters playbackParameters) {
|
||||
setPlaybackSpeedAndSkipSilence(playbackParameters.speed, getSkipSilenceEnabled());
|
||||
}
|
||||
|
||||
/** @deprecated Use {@link #getPlaybackSpeed()} and {@link #getSkipSilenceEnabled()} instead. */
|
||||
@SuppressWarnings("deprecation")
|
||||
@Deprecated
|
||||
@Override
|
||||
public PlaybackParameters getPlaybackParameters() {
|
||||
MediaPositionParameters mediaPositionParameters = getMediaPositionParameters();
|
||||
return new PlaybackParameters(mediaPositionParameters.playbackSpeed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlaybackSpeed(float playbackSpeed) {
|
||||
setPlaybackSpeedAndSkipSilence(playbackSpeed, getSkipSilenceEnabled());
|
||||
|
|
@ -1435,6 +1395,10 @@ public final class DefaultAudioSink implements AudioSink {
|
|||
return notGapless || isOffloadedGaplessPlaybackSupported();
|
||||
}
|
||||
|
||||
private static boolean isOffloadedPlayback(AudioTrack audioTrack) {
|
||||
return Util.SDK_INT >= 29 && audioTrack.isOffloadedPlayback();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the device supports gapless in offload playback.
|
||||
*
|
||||
|
|
@ -1446,10 +1410,6 @@ public final class DefaultAudioSink implements AudioSink {
|
|||
return Util.SDK_INT >= 30 && Util.MODEL.startsWith("Pixel");
|
||||
}
|
||||
|
||||
private static boolean isOffloadedPlayback(AudioTrack audioTrack) {
|
||||
return Util.SDK_INT >= 29 && audioTrack.isOffloadedPlayback();
|
||||
}
|
||||
|
||||
private static AudioTrack initializeKeepSessionIdAudioTrack(int audioSessionId) {
|
||||
int sampleRate = 4000; // Equal to private AudioTrack.MIN_SAMPLE_RATE.
|
||||
int channelConfig = AudioFormat.CHANNEL_OUT_MONO;
|
||||
|
|
@ -1498,6 +1458,7 @@ public final class DefaultAudioSink implements AudioSink {
|
|||
case C.ENCODING_PCM_32BIT:
|
||||
case C.ENCODING_PCM_8BIT:
|
||||
case C.ENCODING_PCM_FLOAT:
|
||||
case C.ENCODING_AAC_ER_BSAC:
|
||||
case C.ENCODING_INVALID:
|
||||
case Format.NO_VALUE:
|
||||
default:
|
||||
|
|
@ -1544,6 +1505,7 @@ public final class DefaultAudioSink implements AudioSink {
|
|||
case C.ENCODING_PCM_32BIT:
|
||||
case C.ENCODING_PCM_8BIT:
|
||||
case C.ENCODING_PCM_FLOAT:
|
||||
case C.ENCODING_AAC_ER_BSAC:
|
||||
case C.ENCODING_INVALID:
|
||||
case Format.NO_VALUE:
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ package com.google.android.exoplayer2.audio;
|
|||
|
||||
import androidx.annotation.Nullable;
|
||||
import com.google.android.exoplayer2.Format;
|
||||
import com.google.android.exoplayer2.PlaybackParameters;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/** An overridable {@link AudioSink} implementation forwarding all methods to another sink. */
|
||||
|
|
@ -88,25 +87,6 @@ public class ForwardingAudioSink implements AudioSink {
|
|||
return sink.hasPendingData();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #setPlaybackSpeed(float)} and {@link #setSkipSilenceEnabled(boolean)}
|
||||
* instead.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Deprecated
|
||||
@Override
|
||||
public void setPlaybackParameters(PlaybackParameters playbackParameters) {
|
||||
sink.setPlaybackParameters(playbackParameters);
|
||||
}
|
||||
|
||||
/** @deprecated Use {@link #getPlaybackSpeed()} and {@link #getSkipSilenceEnabled()} instead. */
|
||||
@SuppressWarnings("deprecation")
|
||||
@Deprecated
|
||||
@Override
|
||||
public PlaybackParameters getPlaybackParameters() {
|
||||
return sink.getPlaybackParameters();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlaybackSpeed(float playbackSpeed) {
|
||||
sink.setPlaybackSpeed(playbackSpeed);
|
||||
|
|
|
|||
Loading…
Reference in a new issue