Skip to content

Commit

Permalink
OpusOutputBuffer: instead of size field use data.limit
Browse files Browse the repository at this point in the history
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=115436131
  • Loading branch information
erdemguven authored and ojw28 committed Mar 10, 2016
1 parent 98f99dd commit b26c324
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ private void renderBuffer() throws OpusDecoderException, AudioTrack.Initializati

int handleBufferResult;
handleBufferResult = audioTrack.handleBuffer(outputBuffer.data, outputBuffer.data.position(),
outputBuffer.size, outputBuffer.timestampUs);
outputBuffer.data.remaining(), outputBuffer.timestampUs);

// If we are out of sync, allow currentPositionUs to jump backwards.
if ((handleBufferResult & AudioTrack.RESULT_POSITION_DISCONTINUITY) != 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,18 +167,17 @@ public boolean decode(InputBuffer inputBuffer, OpusOutputBuffer outputBuffer) {
exception = new OpusDecoderException("Decode error: " + opusGetErrorMessage(result));
return false;
}
outputBuffer.size = result;
outputBuffer.data.position(0);
outputBuffer.data.limit(result);
if (skipSamples > 0) {
int bytesPerSample = channelCount * 2;
int skipBytes = skipSamples * bytesPerSample;
if (outputBuffer.size <= skipBytes) {
skipSamples -= outputBuffer.size / bytesPerSample;
outputBuffer.size = 0;
if (result <= skipBytes) {
skipSamples -= result / bytesPerSample;
outputBuffer.setFlag(Buffer.FLAG_DECODE_ONLY);
outputBuffer.data.position(result);
} else {
skipSamples = 0;
outputBuffer.size -= skipBytes;
outputBuffer.data.position(skipBytes);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public final class OpusOutputBuffer extends OutputBuffer {
private final DecoderWrapper<?, OpusOutputBuffer, ?> owner;

public ByteBuffer data;
public int size;

/* package */ OpusOutputBuffer(DecoderWrapper<?, OpusOutputBuffer, ?> owner) {
this.owner = owner;
Expand Down

0 comments on commit b26c324

Please sign in to comment.