Commit 13aaa5a5 by Oliver Woodman

Use C.MICROS_PER_SECOND more consistently.

parent daa58359
...@@ -22,7 +22,6 @@ import com.google.android.exoplayer.C; ...@@ -22,7 +22,6 @@ import com.google.android.exoplayer.C;
*/ */
/* package */ final class ConstantBitrateSeeker implements Mp3Extractor.Seeker { /* package */ final class ConstantBitrateSeeker implements Mp3Extractor.Seeker {
private static final int MICROSECONDS_PER_SECOND = 1000000;
private static final int BITS_PER_BYTE = 8; private static final int BITS_PER_BYTE = 8;
private final long firstFramePosition; private final long firstFramePosition;
...@@ -43,12 +42,12 @@ import com.google.android.exoplayer.C; ...@@ -43,12 +42,12 @@ import com.google.android.exoplayer.C;
@Override @Override
public long getPosition(long timeUs) { public long getPosition(long timeUs) {
return durationUs == C.UNKNOWN_TIME_US ? 0 return durationUs == C.UNKNOWN_TIME_US ? 0
: firstFramePosition + (timeUs * bitrate) / (MICROSECONDS_PER_SECOND * BITS_PER_BYTE); : firstFramePosition + (timeUs * bitrate) / (C.MICROS_PER_SECOND * BITS_PER_BYTE);
} }
@Override @Override
public long getTimeUs(long position) { public long getTimeUs(long position) {
return ((position - firstFramePosition) * MICROSECONDS_PER_SECOND * BITS_PER_BYTE) / bitrate; return ((position - firstFramePosition) * C.MICROS_PER_SECOND * BITS_PER_BYTE) / bitrate;
} }
@Override @Override
......
...@@ -187,7 +187,7 @@ public final class Mp3Extractor implements Extractor { ...@@ -187,7 +187,7 @@ public final class Mp3Extractor implements Extractor {
sampleBytesRemaining = synchronizedHeader.frameSize; sampleBytesRemaining = synchronizedHeader.frameSize;
} }
long timeUs = basisTimeUs + (samplesRead * 1000000L / synchronizedHeader.sampleRate); long timeUs = basisTimeUs + (samplesRead * C.MICROS_PER_SECOND / synchronizedHeader.sampleRate);
// Start by draining any buffered bytes, then read directly from the extractor input. // Start by draining any buffered bytes, then read directly from the extractor input.
sampleBytesRemaining -= inputBuffer.drainToOutput(trackOutput, sampleBytesRemaining); sampleBytesRemaining -= inputBuffer.drainToOutput(trackOutput, sampleBytesRemaining);
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
*/ */
package com.google.android.exoplayer.extractor.mp3; package com.google.android.exoplayer.extractor.mp3;
import com.google.android.exoplayer.C;
import com.google.android.exoplayer.util.MpegAudioHeader; import com.google.android.exoplayer.util.MpegAudioHeader;
import com.google.android.exoplayer.util.ParsableByteArray; import com.google.android.exoplayer.util.ParsableByteArray;
import com.google.android.exoplayer.util.Util; import com.google.android.exoplayer.util.Util;
...@@ -44,8 +45,8 @@ import com.google.android.exoplayer.util.Util; ...@@ -44,8 +45,8 @@ import com.google.android.exoplayer.util.Util;
return null; return null;
} }
int sampleRate = mpegAudioHeader.sampleRate; int sampleRate = mpegAudioHeader.sampleRate;
long durationUs = Util.scaleLargeTimestamp( long durationUs = Util.scaleLargeTimestamp(numFrames,
numFrames, 1000000L * (sampleRate >= 32000 ? 1152 : 576), sampleRate); C.MICROS_PER_SECOND * (sampleRate >= 32000 ? 1152 : 576), sampleRate);
int numEntries = frame.readUnsignedShort(); int numEntries = frame.readUnsignedShort();
int scale = frame.readUnsignedShort(); int scale = frame.readUnsignedShort();
int entrySize = frame.readUnsignedShort(); int entrySize = frame.readUnsignedShort();
......
...@@ -50,7 +50,8 @@ import com.google.android.exoplayer.util.Util; ...@@ -50,7 +50,8 @@ import com.google.android.exoplayer.util.Util;
// If the frame count is missing/invalid, the header can't be used to determine the duration. // If the frame count is missing/invalid, the header can't be used to determine the duration.
return null; return null;
} }
long durationUs = Util.scaleLargeTimestamp(frameCount, samplesPerFrame * 1000000L, sampleRate); long durationUs = Util.scaleLargeTimestamp(frameCount, samplesPerFrame * C.MICROS_PER_SECOND,
sampleRate);
if ((flags & 0x06) != 0x06) { if ((flags & 0x06) != 0x06) {
// If the size in bytes or table of contents is missing, the stream is not seekable. // If the size in bytes or table of contents is missing, the stream is not seekable.
return new XingSeeker(inputLength, firstFramePosition, durationUs); return new XingSeeker(inputLength, firstFramePosition, durationUs);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment