avplayer: do not start the video multiple times (#3638)
Some checks failed
Build and Release / reuse (push) Has been cancelled
Build and Release / clang-format (push) Has been cancelled
Build and Release / get-info (push) Has been cancelled
Build and Release / windows-sdl (push) Has been cancelled
Build and Release / windows-qt (push) Has been cancelled
Build and Release / macos-sdl (push) Has been cancelled
Build and Release / macos-qt (push) Has been cancelled
Build and Release / linux-sdl (push) Has been cancelled
Build and Release / linux-qt (push) Has been cancelled
Build and Release / linux-sdl-gcc (push) Has been cancelled
Build and Release / linux-qt-gcc (push) Has been cancelled
Build and Release / pre-release (push) Has been cancelled

This commit is contained in:
Vladislav Mikhalin 2025-09-21 16:03:24 +03:00 committed by GitHub
parent 51c96b8ee6
commit 525d24a7fc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -176,13 +176,18 @@ bool AvPlayerState::GetStreamInfo(u32 stream_index, AvPlayerStreamInfo& info) {
// Called inside GAME thread
bool AvPlayerState::Start() {
std::shared_lock lock(m_source_mutex);
if (m_up_source == nullptr || !m_up_source->Start()) {
if (m_current_state == AvState::Ready || m_current_state == AvState::Stop || Stop()) {
if (!m_up_source->Start()) {
LOG_ERROR(Lib_AvPlayer, "Could not start playback.");
return false;
}
SetState(AvState::Play);
OnPlaybackStateChanged(AvState::Play);
return true;
}
LOG_ERROR(Lib_AvPlayer, "Could not start playback.");
return false;
}
// Called inside GAME thread