GST_DEBUG_CATEGORY_STATIC (splitmux_debug);
#define GST_CAT_DEFAULT splitmux_debug
+#define GST_SPLITMUX_STATE_LOCK(s) g_mutex_lock(&(s)->state_lock)
+#define GST_SPLITMUX_STATE_UNLOCK(s) g_mutex_unlock(&(s)->state_lock)
+
#define GST_SPLITMUX_LOCK(s) g_mutex_lock(&(s)->lock)
#define GST_SPLITMUX_UNLOCK(s) g_mutex_unlock(&(s)->lock)
#define GST_SPLITMUX_WAIT_INPUT(s) g_cond_wait (&(s)->input_cond, &(s)->lock)
gst_splitmux_sink_init (GstSplitMuxSink * splitmux)
{
g_mutex_init (&splitmux->lock);
+ g_mutex_init (&splitmux->state_lock);
g_cond_init (&splitmux->input_cond);
g_cond_init (&splitmux->output_cond);
g_queue_init (&splitmux->out_cmd_q);
g_cond_clear (&splitmux->input_cond);
g_cond_clear (&splitmux->output_cond);
g_mutex_clear (&splitmux->lock);
+ g_mutex_clear (&splitmux->state_lock);
g_queue_foreach (&splitmux->out_cmd_q, (GFunc) out_cmd_buf_free, NULL);
g_queue_clear (&splitmux->out_cmd_q);
sink = gst_object_ref (splitmux->active_sink);
GST_SPLITMUX_UNLOCK (splitmux);
- GST_STATE_LOCK (splitmux);
+ GST_SPLITMUX_STATE_LOCK (splitmux);
+
+ if (splitmux->shutdown) {
+ GST_DEBUG_OBJECT (splitmux,
+ "Shutdown requested. Aborting fragment switch.");
+ GST_SPLITMUX_STATE_UNLOCK (splitmux);
+ return;
+ }
if (splitmux->async_finalize) {
if (splitmux->muxed_out_bytes > 0
gst_object_unref (muxer);
GST_SPLITMUX_LOCK (splitmux);
- GST_STATE_UNLOCK (splitmux);
+ GST_SPLITMUX_STATE_UNLOCK (splitmux);
splitmux->switching_fragment = FALSE;
do_async_done (splitmux);
return;
fail:
- GST_STATE_UNLOCK (splitmux);
+ GST_SPLITMUX_STATE_UNLOCK (splitmux);
GST_ELEMENT_ERROR (splitmux, RESOURCE, SETTINGS,
("Could not create the new muxer/sink"), NULL);
}
splitmux->output_state = SPLITMUX_OUTPUT_STATE_START_NEXT_FILE;
GST_SPLITMUX_UNLOCK (splitmux);
+
+ GST_SPLITMUX_STATE_LOCK (splitmux);
+ splitmux->shutdown = FALSE;
+ GST_SPLITMUX_STATE_UNLOCK (splitmux);
break;
}
case GST_STATE_CHANGE_PAUSED_TO_READY:
g_atomic_int_set (&(splitmux->split_requested), FALSE);
g_atomic_int_set (&(splitmux->do_split_next_gop), FALSE);
+
case GST_STATE_CHANGE_READY_TO_NULL:
+ GST_SPLITMUX_STATE_LOCK (splitmux);
+ splitmux->shutdown = TRUE;
+ GST_SPLITMUX_STATE_UNLOCK (splitmux);
+
GST_SPLITMUX_LOCK (splitmux);
gst_splitmux_sink_reset (splitmux);
splitmux->output_state = SPLITMUX_OUTPUT_STATE_STOPPED;