mirror of
https://github.com/androidx/media.git
synced 2025-05-17 20:49:53 +08:00
Remove unused logic in SonicAudioProcessor
PiperOrigin-RevId: 343882631
This commit is contained in:
parent
05f6d24821
commit
3ec5ad1d1e
@ -112,8 +112,11 @@ public final class DefaultAudioSink implements AudioSink {
|
|||||||
boolean applySkipSilenceEnabled(boolean skipSilenceEnabled);
|
boolean applySkipSilenceEnabled(boolean skipSilenceEnabled);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scales the specified playout duration to take into account speedup due to audio processing,
|
* Returns the media duration corresponding to the specified playout duration, taking speed
|
||||||
* returning an input media duration, in arbitrary units.
|
* adjustment due to audio processing into account.
|
||||||
|
*
|
||||||
|
* @param playoutDuration The playout duration to scale.
|
||||||
|
* @return The corresponding media duration, in the same units as {@code duration}.
|
||||||
*/
|
*/
|
||||||
long getMediaDuration(long playoutDuration);
|
long getMediaDuration(long playoutDuration);
|
||||||
|
|
||||||
@ -172,9 +175,9 @@ public final class DefaultAudioSink implements AudioSink {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PlaybackParameters applyPlaybackParameters(PlaybackParameters playbackParameters) {
|
public PlaybackParameters applyPlaybackParameters(PlaybackParameters playbackParameters) {
|
||||||
float speed = sonicAudioProcessor.setSpeed(playbackParameters.speed);
|
sonicAudioProcessor.setSpeed(playbackParameters.speed);
|
||||||
float pitch = sonicAudioProcessor.setPitch(playbackParameters.pitch);
|
sonicAudioProcessor.setPitch(playbackParameters.pitch);
|
||||||
return new PlaybackParameters(speed, pitch);
|
return playbackParameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -185,7 +188,7 @@ public final class DefaultAudioSink implements AudioSink {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getMediaDuration(long playoutDuration) {
|
public long getMediaDuration(long playoutDuration) {
|
||||||
return sonicAudioProcessor.scaleDurationForSpeedup(playoutDuration);
|
return sonicAudioProcessor.getMediaDuration(playoutDuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -36,10 +36,10 @@ public final class SonicAudioProcessor implements AudioProcessor {
|
|||||||
private static final float CLOSE_THRESHOLD = 0.0001f;
|
private static final float CLOSE_THRESHOLD = 0.0001f;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The minimum number of output bytes at which the speedup is calculated using the input/output
|
* The minimum number of output bytes required for duration scaling to be calculated using the
|
||||||
* byte counts, rather than using the current playback parameters speed.
|
* input and output byte counts, rather than using the current playback speed.
|
||||||
*/
|
*/
|
||||||
private static final int MIN_BYTES_FOR_SPEEDUP_CALCULATION = 1024;
|
private static final int MIN_BYTES_FOR_DURATION_SCALING_CALCULATION = 1024;
|
||||||
|
|
||||||
private int pendingOutputSampleRate;
|
private int pendingOutputSampleRate;
|
||||||
private float speed;
|
private float speed;
|
||||||
@ -74,35 +74,31 @@ public final class SonicAudioProcessor implements AudioProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the playback speed. This method may only be called after draining data through the
|
* Sets the target playback speed. This method may only be called after draining data through the
|
||||||
* processor. The value returned by {@link #isActive()} may change, and the processor must be
|
* processor. The value returned by {@link #isActive()} may change, and the processor must be
|
||||||
* {@link #flush() flushed} before queueing more data.
|
* {@link #flush() flushed} before queueing more data.
|
||||||
*
|
*
|
||||||
* @param speed The requested new playback speed.
|
* @param speed The target playback speed.
|
||||||
* @return The actual new playback speed.
|
|
||||||
*/
|
*/
|
||||||
public float setSpeed(float speed) {
|
public void setSpeed(float speed) {
|
||||||
if (this.speed != speed) {
|
if (this.speed != speed) {
|
||||||
this.speed = speed;
|
this.speed = speed;
|
||||||
pendingSonicRecreation = true;
|
pendingSonicRecreation = true;
|
||||||
}
|
}
|
||||||
return speed;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the playback pitch. This method may only be called after draining data through the
|
* Sets the target playback pitch. This method may only be called after draining data through the
|
||||||
* processor. The value returned by {@link #isActive()} may change, and the processor must be
|
* processor. The value returned by {@link #isActive()} may change, and the processor must be
|
||||||
* {@link #flush() flushed} before queueing more data.
|
* {@link #flush() flushed} before queueing more data.
|
||||||
*
|
*
|
||||||
* @param pitch The requested new pitch.
|
* @param pitch The target pitch.
|
||||||
* @return The actual new pitch.
|
|
||||||
*/
|
*/
|
||||||
public float setPitch(float pitch) {
|
public void setPitch(float pitch) {
|
||||||
if (this.pitch != pitch) {
|
if (this.pitch != pitch) {
|
||||||
this.pitch = pitch;
|
this.pitch = pitch;
|
||||||
pendingSonicRecreation = true;
|
pendingSonicRecreation = true;
|
||||||
}
|
}
|
||||||
return pitch;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -118,23 +114,22 @@ public final class SonicAudioProcessor implements AudioProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the specified duration scaled to take into account the speedup factor of this instance,
|
* Returns the media duration corresponding to the specified playout duration, taking speed
|
||||||
* in the same units as {@code duration}.
|
* adjustment into account.
|
||||||
*
|
*
|
||||||
* @param duration The duration to scale taking into account speedup.
|
* @param playoutDuration The playout duration to scale.
|
||||||
* @return The specified duration scaled to take into account speedup, in the same units as
|
* @return The corresponding media duration, in the same units as {@code duration}.
|
||||||
* {@code duration}.
|
|
||||||
*/
|
*/
|
||||||
public long scaleDurationForSpeedup(long duration) {
|
public long getMediaDuration(long playoutDuration) {
|
||||||
if (outputBytes >= MIN_BYTES_FOR_SPEEDUP_CALCULATION) {
|
if (outputBytes >= MIN_BYTES_FOR_DURATION_SCALING_CALCULATION) {
|
||||||
return outputAudioFormat.sampleRate == inputAudioFormat.sampleRate
|
return outputAudioFormat.sampleRate == inputAudioFormat.sampleRate
|
||||||
? Util.scaleLargeTimestamp(duration, inputBytes, outputBytes)
|
? Util.scaleLargeTimestamp(playoutDuration, inputBytes, outputBytes)
|
||||||
: Util.scaleLargeTimestamp(
|
: Util.scaleLargeTimestamp(
|
||||||
duration,
|
playoutDuration,
|
||||||
inputBytes * outputAudioFormat.sampleRate,
|
inputBytes * outputAudioFormat.sampleRate,
|
||||||
outputBytes * inputAudioFormat.sampleRate);
|
outputBytes * inputAudioFormat.sampleRate);
|
||||||
} else {
|
} else {
|
||||||
return (long) ((double) speed * duration);
|
return (long) ((double) speed * playoutDuration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user