1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-03-01 19:39:41 +00:00

Merge branch 'videostate_lock' into 'master'

Avoid possible race in videoplayer

See merge request OpenMW/openmw!3791
This commit is contained in:
psi29a 2024-01-21 13:37:06 +00:00
commit c45c2355ae

View file

@ -598,8 +598,17 @@ public:
if(av_read_frame(pFormatCtx, packet.get()) < 0) if(av_read_frame(pFormatCtx, packet.get()) < 0)
{ {
if (self->audioq.nb_packets == 0 && self->videoq.nb_packets == 0 && self->pictq_size == 0) if (self->audioq.nb_packets == 0 && self->videoq.nb_packets == 0)
self->mVideoEnded = true; {
self->pictq_mutex.lock();
bool videoEnded = self->pictq_size == 0;
self->pictq_mutex.unlock();
if (videoEnded)
self->mVideoEnded = true;
else
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
continue; continue;
} }
else else