Propagate sourceEnded to AudioGraphInputAudioSink

PiperOrigin-RevId: 702076933
This commit is contained in:
claincly 2024-12-02 13:56:44 -08:00 committed by Copybara-Service
parent 8908d82cac
commit ecdf7c5df7
2 changed files with 7 additions and 4 deletions

View file

@ -73,8 +73,11 @@ import java.util.Objects;
/** /**
* Returns the position (in microseconds) that should be {@linkplain * Returns the position (in microseconds) that should be {@linkplain
* AudioSink#getCurrentPositionUs returned} by this sink. * AudioSink#getCurrentPositionUs returned} by this sink.
*
* @param sourceEnded Specify {@code true} if no more input buffers will be provided.
* @return The playback position relative to the start of playback, in microseconds.
*/ */
long getCurrentPositionUs(); long getCurrentPositionUs(boolean sourceEnded);
/** Returns whether the controller is ended. */ /** Returns whether the controller is ended. */
boolean isEnded(); boolean isEnded();
@ -216,7 +219,7 @@ import java.util.Objects;
@Override @Override
public long getCurrentPositionUs(boolean sourceEnded) { public long getCurrentPositionUs(boolean sourceEnded) {
long currentPositionUs = controller.getCurrentPositionUs(); long currentPositionUs = controller.getCurrentPositionUs(sourceEnded);
if (currentPositionUs != CURRENT_POSITION_NOT_SET) { if (currentPositionUs != CURRENT_POSITION_NOT_SET) {
// Reset the position to the one expected by the player. // Reset the position to the one expected by the player.
currentPositionUs -= offsetToCompositionTimeUs; currentPositionUs -= offsetToCompositionTimeUs;

View file

@ -188,8 +188,8 @@ import java.util.Objects;
} }
@Override @Override
public long getCurrentPositionUs() { public long getCurrentPositionUs(boolean sourceEnded) {
return finalAudioSink.getCurrentPositionUs(/* sourceEnded= */ false); return finalAudioSink.getCurrentPositionUs(sourceEnded);
} }
@Override @Override