deps/media-playback: Check if frame can be played before using it

It's possible that frame_ready is false when this function is called,
which implies that the mp_decode frame field is not valid. However we
dereference the frame by counting the number of audio channels before
checking the value of frame_ready, causing a crash.
This commit is contained in:
Richard Stanway
2023-04-30 16:23:16 -07:00
committed by Jim
parent 2ac3767e7a
commit b9ef64d4eb
+4 -3
View File
@@ -356,15 +356,16 @@ void mp_media_next_audio(mp_media_t *m)
struct obs_source_audio audio = {0};
AVFrame *f = d->frame;
int channels;
if (!mp_media_can_play_frame(m, d))
return;
#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(59, 19, 100)
channels = f->channels;
#else
channels = f->ch_layout.nb_channels;
#endif
if (!mp_media_can_play_frame(m, d))
return;
d->frame_ready = false;
if (!m->a_cb)
return;