<div dir="ltr">Sorry for a simple question, I could do it by using mutexes, of course, but maybe there is a canonical way of doing it using the GStreamer APIs?<div><br></div><div>The problem is this.</div><div><br></div><div>
1. In one thread, periodically, in the loop, I am waiting for a message on the bus:</div><div><br></div><div><div>msg = gst_bus_timed_pop_filtered (bus, duration,</div><div> (GstMessageType)(GST_MESSAGE_EOS | </div>
<div> GST_MESSAGE_SEGMENT_DONE | </div><div> GST_MESSAGE_ERROR | </div><div> GST_MESSAGE_APPLICATION));</div>
</div><div><br></div><div>and this waiting occupies only part of the whole loop:</div><div><br></div><div>for(;;) {</div><div> // do smth else...</div><div><br></div><div> msg = gst_bus_timed_pop_filtered...</div><div><br>
</div><div> // do smth else ...</div><div>}</div><div><br></div><div>In the other thread I am posting (using the GStreamer's gift):</div><div><br></div><div>gst_bus_post (bus, gst_message_new_application (NULL, NULL));<br>
</div><div><br></div><div>But how can I make sure, before posting, that it is being expected (and received) by the blocking</div><div><br></div><div>msg = gst_bus_timed_pop_filtered... in the other thread,<br></div><div><br>
</div><div>and not consumed by the loop doing smth else?</div><div><br></div><div>Actually, the boolean TRUE returned by gst_bus_post does not guarantee that the posting was expected and received.</div><div><br></div><div>
One might naively think that the following is a solution (simply surround with gst_bus_set_flushing):</div><div><br></div><div><div>for(;;) {</div><div> // do smth else...</div><div><br></div><div> gst_bus_set_flushing (bus, FALSE);</div>
<div> msg = gst_bus_timed_pop_filtered...</div><div> gst_bus_set_flushing (bus, TRUE);</div><div><br></div><div> // do smth else ...</div><div>}</div></div><div><br></div><div>However, it isn't. Imagine gst_bus_timed_pop_filtered returns because duration expired, but before the next gst_bus_set_flushing (bus, TRUE) the other thread makes gst_bus_post (bus, gst_message_new_application (NULL, NULL)). Then this posting is acknowledged (returns TRUE) but the message is actually flushed.</div>
<div><br></div><div>Some real acknowledge mechanism is desired. Does it exist in the GStreamer API?</div><div><br></div><div>Any suggestions?</div></div>