diff --git a/src/libs/avPlayer.cpp b/src/libs/avPlayer.cpp index a2d63bcf6..59948124c 100644 --- a/src/libs/avPlayer.cpp +++ b/src/libs/avPlayer.cpp @@ -1682,6 +1682,7 @@ struct AvPlayerInternal { AvPlayerPostInitData post_init {}; bool auto_start = false; int32_t video_buffers = 2; + uint32_t sync_mode = 0; uint32_t start_bandwidth = 0; uint32_t minimum_bandwidth = 0; uint32_t maximum_bandwidth = 0; @@ -1730,6 +1731,7 @@ static int add_source(AvPlayerInternal* h, const std::string& filename, AvPlayer if (auto rc = s->Init(filename, type); rc < 0) { return rc; } + s->SetSync(h->sync_mode); h->source = std::move(s); emit_event(h->event, AVPLAYER_EVENT_STATE_READY); if (h->auto_start) { @@ -1951,13 +1953,16 @@ int KYTY_SYSV_ABI AvPlayerSetTrickSpeed(AvPlayerInternal* h, int32_t trick_speed } int KYTY_SYSV_ABI AvPlayerSetAvSyncMode(AvPlayerInternal* h, uint32_t sync_mode) { PRINT_NAME(); - if (h == nullptr || h->source == nullptr) { + if (h == nullptr) { return AVPLAYER_ERROR_INVALID_PARAMS; } if (sync_mode > 1) { return AVPLAYER_ERROR_NOT_SUPPORTED; } - h->source->SetSync(sync_mode); + h->sync_mode = sync_mode; + if (h->source != nullptr) { + h->source->SetSync(sync_mode); + } return 0; } int KYTY_SYSV_ABI AvPlayerSetAvailableBandwidth(AvPlayerInternal* h, uint32_t start_bandwidth,