starboard: Fix integer overflow in AudioTrack sink#11549
Conversation
🤖 Gemini Suggested Commit Message💡 Pro Tips for a Better Commit Message:
|
Fix potential overflow and narrowing issues in AudioTrackAudioSink. Change accumulated_written_frames, last_playback_head_position, and playback_head_position to int64_t to prevent overflow after long playback times (~12.4 hours at 48kHz). Update GetFramesDurationUs to accept int64_t. Bug: 511356295 TAG=agy CONV=0d3a836a-08df-4860-a867-0f6affc85b25
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request updates frame-related variables and function parameters in AudioTrackAudioSink from int to int64_t to prevent potential integer overflow issues when handling large frame counts. Specifically, accumulated_written_frames, last_playback_head_position, playback_head_position, and the parameter for GetFramesDurationUs in audio_track_audio_sink_type.cc and audio_track_audio_sink_type.h have been updated to 64-bit integers. There are no review comments, so I have no feedback to provide.
There was a problem hiding this comment.
Code Review
This pull request updates the audio frame tracking variables (accumulated_written_frames, last_playback_head_position, and playback_head_position) and the helper function GetFramesDurationUs in AudioTrackAudioSink to use 64-bit integers (int64_t) instead of 32-bit integers (int). This prevents potential integer overflow issues during long-running audio playback. There are no review comments to address, and the changes look correct.
Update accumulated_written_frames, last_playback_head_position, and
playback_head_position to use 64-bit integers in AudioTrackAudioSink.
At a 48kHz sampling rate, 32-bit signed integers overflow after
approximately 12.4 hours of continuous playback, which can cause
incorrect playback head reporting and audio sync issues.
Also update GetFramesDurationUs to accept int64_t to maintain type
consistency and prevent narrowing.
Note that this doesn't resolve all integer size issues across the audio
pipeline as the Java AudioTrackBridge is still tracking the playback
position using 32 bits integer, which will be resolve in b/539224216.
Bug: 539224216