mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-12 20:55:56 +00:00
avplayer: sync on video ts in default mode when audio ts is not available
This commit is contained in:
parent
5a57c924ba
commit
3cd370d587
1 changed files with 6 additions and 5 deletions
|
@ -322,15 +322,16 @@ bool AvPlayerSource::GetVideoData(AvPlayerFrameInfoEx& video_info) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_state.GetSyncMode() == AvPlayerAvSyncMode::Default && m_audio_stream_index.has_value()) {
|
if (m_state.GetSyncMode() == AvPlayerAvSyncMode::Default) {
|
||||||
const auto audio_ts = m_last_audio_packet_time;
|
const auto desired_time =
|
||||||
if (audio_ts < frame->info.timestamp) {
|
m_audio_stream_index.has_value() ? m_last_audio_packet_time : CurrentTime();
|
||||||
|
if (desired_time < frame->info.timestamp) {
|
||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
const auto start = high_resolution_clock::now();
|
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 =
|
const auto passed =
|
||||||
duration_cast<milliseconds>(high_resolution_clock::now() - start).count();
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue