Skip to content

Replace Audio prepare hack by nicer, asynchronous solution

Bart De Vries requested to merge work/improve-audio-hack into master

The main bits of this implementation are:

  • Start a new track in paused state. We don't care about the actual media state or player state that QMediaPlayer is reporting. We will deal with that when the audio actually starts playing.
  • If a player position needs to be restored, we set d->m_pendingSeek to the position that needs to be seeked. We don't actually seek because we have no idea what state the player is in yet.
  • On the positionChanged signal of QMP, and if the media is buffered, we check if there is pendingSeek value set which is set to a different value than the current player position. If so, we call d->m_player.setPosition(). If we have arrived at the correct position, then we reset d->m_pendingSeek to -1.
  • In the position(), duration() and seek() methods, we return sensible values, even QMP is not. So, we report the duration from the enclosure, the position from d->m_pendingSeek, and let seek() change the value of d->m_PendingSeek (if it's not -1) to the new seek position.
  • When there's a pending seek, we set the notifyInterval to shorter interval to reduce the startup audio glitch as much as possible. We then reset it to the default of 1000 msec.

This was tested on linux and android.

Edited by Bart De Vries

Merge request reports