Skip to content

Commit 797191d

Browse files
committed
avplayer: do not start the video multiple times
1 parent 51c96b8 commit 797191d

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/core/libraries/avplayer/avplayer_state.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,18 @@ bool AvPlayerState::GetStreamInfo(u32 stream_index, AvPlayerStreamInfo& info) {
176176
// Called inside GAME thread
177177
bool AvPlayerState::Start() {
178178
std::shared_lock lock(m_source_mutex);
179-
if (m_up_source == nullptr || !m_up_source->Start()) {
180-
LOG_ERROR(Lib_AvPlayer, "Could not start playback.");
181-
return false;
179+
if (m_current_state == AvState::Ready || m_current_state == AvState::Stop || Stop()) {
180+
if (!m_up_source->Start()) {
181+
LOG_ERROR(Lib_AvPlayer, "Could not start playback.");
182+
return false;
183+
}
184+
SetState(AvState::Play);
185+
OnPlaybackStateChanged(AvState::Play);
186+
return true;
182187
}
183-
SetState(AvState::Play);
184-
OnPlaybackStateChanged(AvState::Play);
185-
return true;
188+
189+
LOG_ERROR(Lib_AvPlayer, "Could not start playback.");
190+
return false;
186191
}
187192

188193
// Called inside GAME thread

0 commit comments

Comments
 (0)