fix position go backward after resume
When audio played with MediaPlayer without offloaded, if we pause the player,
then call start. It may be occured that the position get from getCurrentPosition
increase first, and then decrease after a while. We found that, when call
getCurrentPosition after start() was called, mAudioSink->getPlayedOutDurationUs
retrun 0, and MediaClock was update with mAudioFirstAnchorTimeMediaUs. In this case,
audiosink has not start to play actually, but the pts will be caculated refered to
mAudioFirstAnchorTimeMediaUs. After audiosink start successfully, onNewAudioMediaTime
will be called, which will call updateAnchor to set pts. As a result, the position get
by calling getCurrentPosition get descreased, which will be observed from our UI.
Return mAudioFirstAnchorTimeMediaUs without updateAnchor before valid value obtain from
getPlayedOutDurationUs will fix this issue.
Signed-off-by: zengjing <firstname.lastname@example.org>
1 file changed