Skip to content

Potential bug in AudioTrack resulting in initial video frame drops #479

@srikieonline

Description

@srikieonline

I observe a typo error in AudioTrack.java code due to which initial video frames are being dropped.
Due to this typo, the startMediaTimeUs is incorrectly set as the start time of the 2nd audio frame buffer (because START_NOT_SET's value is 0 which matches with first audio frame's starting timestamp). This results in AudioTrack incorrectly reporting a currentTimestamp which is ahead by duration of a frame and results into initial video frames being dropped till it catches up.

Please clarify. Changing the code as Expected solves the initial frame drops.

Issue:
startMediaTimeUs is being incorrectly used as startMediaTimeState in several places as follows

For example:
Function: handleBuffer
Line number: 452
Actual: if (startMediaTimeUs == START_NOT_SET)
Expected: if (startMediaTimeState == START_NOT_SET)

Function: reset
Line number: 576
Actual: startMediaTimeUs = START_NOT_SET;
Expected: startMediaTimeState = START_NOT_SET; startMediaTimeUs = 0;

Function: hasCurrentPositionUs
Line number: 626
Actual: return isInitialized() && startMediaTimeUs != START_NOT_SET;
Expected: return isInitialized() && startMediaTimeState != START_NOT_SET;

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions