+ /* Handle expected async-done before waiting on next async-done.
+ *
+ * Since the seek further down in code will cause a preroll and
+ * a async-done will be generated it's important to wait on async-done
+ * if that is expected. Otherwise there is the risk that the waiting
+ * for async-done after the seek is detecting the expected async-done
+ * instead of the one that corresponds to the seek. Then execution
+ * continue and act as if the pipeline is prerolled, but it's not.
+ *
+ * During wait_preroll message GST_MESSAGE_ASYNC_DONE will come
+ * and then the state will change from preparing to prepared */
+ if (priv->expected_async_done) {
+ GST_DEBUG (" expected to get async-done, waiting ");
+ gst_rtsp_media_set_status (media, GST_RTSP_MEDIA_STATUS_PREPARING);
+ g_rec_mutex_unlock (&priv->state_lock);
+
+ /* wait until pipeline is prerolled */
+ if (!wait_preroll (media))
+ goto preroll_failed_expected_async_done;
+
+ g_rec_mutex_lock (&priv->state_lock);
+ GST_DEBUG (" got expected async-done");
+ }
+