mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Double the buffer duration for AC3
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=219765107
This commit is contained in:
parent
76688589d2
commit
3b1d0e270b
1 changed files with 6 additions and 0 deletions
|
|
@ -172,6 +172,9 @@ public final class DefaultAudioSink implements AudioSink {
|
||||||
*/
|
*/
|
||||||
private static final int BUFFER_MULTIPLICATION_FACTOR = 4;
|
private static final int BUFFER_MULTIPLICATION_FACTOR = 4;
|
||||||
|
|
||||||
|
/** To avoid underruns on some devices (e.g., Broadcom 7271), scale up the AC3 buffer duration. */
|
||||||
|
private static final int AC3_BUFFER_MULTIPLICATION_FACTOR = 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see AudioTrack#ERROR_BAD_VALUE
|
* @see AudioTrack#ERROR_BAD_VALUE
|
||||||
*/
|
*/
|
||||||
|
|
@ -483,6 +486,9 @@ public final class DefaultAudioSink implements AudioSink {
|
||||||
return Util.constrainValue(multipliedBufferSize, minAppBufferSize, maxAppBufferSize);
|
return Util.constrainValue(multipliedBufferSize, minAppBufferSize, maxAppBufferSize);
|
||||||
} else {
|
} else {
|
||||||
int rate = getMaximumEncodedRateBytesPerSecond(outputEncoding);
|
int rate = getMaximumEncodedRateBytesPerSecond(outputEncoding);
|
||||||
|
if (outputEncoding == C.ENCODING_AC3) {
|
||||||
|
rate *= AC3_BUFFER_MULTIPLICATION_FACTOR;
|
||||||
|
}
|
||||||
return (int) (PASSTHROUGH_BUFFER_DURATION_US * rate / C.MICROS_PER_SECOND);
|
return (int) (PASSTHROUGH_BUFFER_DURATION_US * rate / C.MICROS_PER_SECOND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue