mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 14:15:38 +00:00
The VideoFFmpegComponent audio and video streams are now re-synchronized after resuming the appliction
This commit is contained in:
parent
2e5f56970a
commit
bd6c9646fc
|
@ -317,14 +317,19 @@ void VideoFFmpegComponent::updatePlayer()
|
||||||
1000000000.0l};
|
1000000000.0l};
|
||||||
|
|
||||||
// If there were more than 2 seconds since the last update then it's not a normal delay, for
|
// If there were more than 2 seconds since the last update then it's not a normal delay, for
|
||||||
// example the application may have been suspended or the computer was resumed from sleep.
|
// example the application may have been suspended or the computer may have been resumed from
|
||||||
// In this case don't proceed and instead wait for the next update. This avoids a massive
|
// sleep. In this case don't proceed and instead wait for the next update. This avoids a
|
||||||
// fast-forward as the frame processing would otherwise have tried to catch up. This may
|
// massive fast-forward as the frame processing would otherwise have tried to catch up.
|
||||||
// not result in perfect video and sound synchronization on some platforms, for example
|
// The frame queues are emptied as well and the audio stream is cleared in order to
|
||||||
// on Android the audio buffers are emptied before suspending the application after the
|
// re-synchronize the streams. This is neeeded as some platforms like Android keep processing
|
||||||
// video processing has already been halted.
|
// the audio buffers before suspending the application (i.e. after rendering has stopped).
|
||||||
if (deltaTime > 2.0) {
|
if (deltaTime > 2.0) {
|
||||||
|
AudioManager::getInstance().clearStream();
|
||||||
mTimeReference = std::chrono::high_resolution_clock::now();
|
mTimeReference = std::chrono::high_resolution_clock::now();
|
||||||
|
while (mAudioFrameQueue.size() > 1 && mVideoFrameQueue.size() > 1 &&
|
||||||
|
mAudioFrameQueue.front().pts > mVideoFrameQueue.front().pts) {
|
||||||
|
mVideoFrameQueue.pop();
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue