On Fri Sep 8 10:42:19 2023 +0000, Ziqing Hui wrote:
![muxer](/uploads/6dc24557dd2b9a4d02abb974d4d59281/muxer.png) I've dumped a pipeline image of wg_muxer, we can see that there is a "[T]" mark at the src pad of the muxer element. From the left-bottom coner of the image, we know that "[T]" stands for a started GstTask.
The condition variable is used here: https://gitlab.winehq.org/wine/wine/-/merge_requests/3303/diffs?commit_id=5f...
After we done muxing, we call finalize() in our PE side, then PE side call the corresponding finalize() function in wg_muxer backend. Our backend finalize() look like this:
``` sink_event_cb() /* sink cb of muxer my_sink. */ { [...] switch (event->type) { case GST_EVENT_EOS: pthread_mutex_lock(&muxer->mutex); muxer->eos = true; pthread_mutex_unlock(&muxer->mutex); pthread_cond_signal(&muxer->cond); break; [...] } [...] }
NTSTATUS wg_muxer_finalize(void *args) { struct wg_muxer *muxer = get_muxer(*(wg_muxer_t *)args); struct wg_muxer_stream *stream;
/* Notify each stream of EOS. */ LIST_FOR_EACH_ENTRY(stream, &muxer->streams, struct wg_muxer_stream, entry) { if (!push_event(stream->my_src, gst_event_new_segment_done(GST_FORMAT_BYTES, -1)) || !push_event(stream->my_src, gst_event_new_eos())) return E_FAIL; }
/* Wait for muxer EOS. */ pthread_mutex_lock(&muxer->mutex); while (!muxer->eos) pthread_cond_wait(&muxer->cond, &muxer->mutex); pthread_mutex_unlock(&muxer->mutex);
return S_OK; } ```
The sink_event_cb() will be called in GstTask thread of mp4muxer element, which is not the same thread with wg_muxer_finalize().
If we get rid of condition variable, how do we wait for the EOS, use a simple while() loop?