Fix integer overflow for audio packet duration
The result is assigned to a long (64-bit signed integer), but the intermediate multiplication was stored in an int (32-bit signed integer). This value is only used as a fallback when no timestamp could be retrieved, that's why it did not cause too much harm so far. Fixes #4536 <https://github.com/Genymobile/scrcpy/issues/4536>
This commit is contained in:
parent
4cd61b5a90
commit
ec41896c85
@ -159,7 +159,7 @@ public final class AudioCapture {
|
||||
pts = nextPts;
|
||||
}
|
||||
|
||||
long durationUs = r * 1000000 / (CHANNELS * BYTES_PER_SAMPLE * SAMPLE_RATE);
|
||||
long durationUs = r * 1000000L / (CHANNELS * BYTES_PER_SAMPLE * SAMPLE_RATE);
|
||||
nextPts = pts + durationUs;
|
||||
|
||||
if (previousPts != 0 && pts < previousPts + ONE_SAMPLE_US) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user