mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-04-21 03:54:45 +00:00
avplayer: sync on video ts in default mode when audio ts is not available
This commit is contained in:
parent
78032d73dd
commit
f52c92e1a6
1 changed files with 6 additions and 5 deletions
|
@ -322,15 +322,16 @@ bool AvPlayerSource::GetVideoData(AvPlayerFrameInfoEx& video_info) {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (m_state.GetSyncMode() == AvPlayerAvSyncMode::Default && m_audio_stream_index.has_value()) {
|
||||
const auto audio_ts = m_last_audio_packet_time;
|
||||
if (audio_ts < frame->info.timestamp) {
|
||||
if (m_state.GetSyncMode() == AvPlayerAvSyncMode::Default) {
|
||||
const auto desired_time =
|
||||
m_audio_stream_index.has_value() ? m_last_audio_packet_time : CurrentTime();
|
||||
if (desired_time < frame->info.timestamp) {
|
||||
using namespace std::chrono;
|
||||
const auto start = high_resolution_clock::now();
|
||||
if (!m_stop_cv.WaitFor(milliseconds(frame->info.timestamp - audio_ts), [&] {
|
||||
if (!m_stop_cv.WaitFor(milliseconds(frame->info.timestamp - desired_time), [&] {
|
||||
const auto passed =
|
||||
duration_cast<milliseconds>(high_resolution_clock::now() - start).count();
|
||||
return (audio_ts + passed) >= frame->info.timestamp;
|
||||
return (desired_time + passed) >= frame->info.timestamp;
|
||||
})) {
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue