Skip to content

Commit

Permalink
mfvideosrc: attempt to unlock ReadSample() in gst_mf_source_reader_un…
Browse files Browse the repository at this point in the history
…lock()

by calling Flush() on the reader

This change allows us to unblock the source thread that could be locked
for a long time waiting for ReadSample() to finish.
  • Loading branch information
tbeloqui committed Feb 24, 2025
1 parent 35c3589 commit 02cd866
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,13 @@ gst_mf_source_reader_read_sample (GstMFSourceReader * self)
hr = self->reader->ReadSample (type->stream_index, 0, nullptr, &stream_flags,
nullptr, &sample);

if (hr == MF_E_NOTACCEPTING) {
/* unlock() called Flush() on the reader */
g_assert (!sample);
GST_DEBUG_OBJECT (self, "ReadSample returned MF_E_NOTACCEPTING, flushing");
return GST_FLOW_FLUSHING;
}

if (!gst_mf_result (hr)) {
GST_ERROR_OBJECT (self, "Failed to read sample");
return GST_FLOW_ERROR;
Expand Down Expand Up @@ -730,6 +737,13 @@ gst_mf_source_reader_unlock (GstMFSourceObject * object)
GstMFSourceReader *self = GST_MF_SOURCE_READER (object);

g_mutex_lock (&self->lock);

GstMFStreamMediaType *type = self->cur_type;
if (self->reader) {
HRESULT hr = self->reader->Flush (type->stream_index);
GST_LOG_OBJECT (self, "Flush() returned: %u", hr);
}

self->flushing = TRUE;
g_mutex_unlock (&self->lock);

Expand Down

0 comments on commit 02cd866

Please sign in to comment.