Commit 2e91628f authored by Youness Alaoui's avatar Youness Alaoui

Make the gst element unlock itself when requested by basesrc

darcs-hash:20080422214225-4f0f6-c0af607186626ef802acf8824089f41c30fcf53b.gz
parent 252a0b5a
...@@ -52,6 +52,14 @@ gst_nice_src_create ( ...@@ -52,6 +52,14 @@ gst_nice_src_create (
guint length, guint length,
GstBuffer **buffer); GstBuffer **buffer);
static gboolean
gst_nice_src_unlock (
GstBaseSrc *basesrc);
static gboolean
gst_nice_src_unlock_stop (
GstBaseSrc *basesrc);
static void static void
gst_nice_src_set_property ( gst_nice_src_set_property (
GObject *object, GObject *object,
...@@ -117,6 +125,8 @@ gst_nice_src_class_init (GstNiceSrcClass *klass) ...@@ -117,6 +125,8 @@ gst_nice_src_class_init (GstNiceSrcClass *klass)
gstbasesrc_class = (GstBaseSrcClass *) klass; gstbasesrc_class = (GstBaseSrcClass *) klass;
gstbasesrc_class->create = GST_DEBUG_FUNCPTR (gst_nice_src_create); gstbasesrc_class->create = GST_DEBUG_FUNCPTR (gst_nice_src_create);
gstbasesrc_class->unlock = GST_DEBUG_FUNCPTR (gst_nice_src_unlock);
gstbasesrc_class->unlock_stop = GST_DEBUG_FUNCPTR (gst_nice_src_unlock_stop);
gobject_class = (GObjectClass *) klass; gobject_class = (GObjectClass *) klass;
gobject_class->set_property = gst_nice_src_set_property; gobject_class->set_property = gst_nice_src_set_property;
...@@ -165,6 +175,7 @@ gst_nice_src_init (GstNiceSrc *src, GstNiceSrcClass *g_class) ...@@ -165,6 +175,7 @@ gst_nice_src_init (GstNiceSrc *src, GstNiceSrcClass *g_class)
src->stream_id = 0; src->stream_id = 0;
src->component_id = 0; src->component_id = 0;
src->mainloop = g_main_loop_new (g_main_context_new (), FALSE); src->mainloop = g_main_loop_new (g_main_context_new (), FALSE);
src->unlocked = FALSE;
} }
static void static void
...@@ -188,6 +199,33 @@ gst_nice_src_read_callback (NiceAgent *agent, ...@@ -188,6 +199,33 @@ gst_nice_src_read_callback (NiceAgent *agent,
g_main_loop_quit (nicesrc->mainloop); g_main_loop_quit (nicesrc->mainloop);
} }
static gboolean
gst_nice_src_unlock (GstBaseSrc *src)
{
GstNiceSrc *nicesrc = GST_NICE_SRC (src);
GST_OBJECT_LOCK (src);
nicesrc->unlocked = TRUE;
nicesrc->flow_ret = GST_FLOW_WRONG_STATE;
GST_OBJECT_UNLOCK (src);
g_main_loop_quit (nicesrc->mainloop);
return TRUE;
}
static gboolean
gst_nice_src_unlock_stop (GstBaseSrc *src)
{
GstNiceSrc *nicesrc = GST_NICE_SRC (src);
GST_OBJECT_LOCK (src);
nicesrc->unlocked = FALSE;
nicesrc->flow_ret = GST_FLOW_OK;
GST_OBJECT_UNLOCK (src);
return TRUE;
}
static GstFlowReturn static GstFlowReturn
gst_nice_src_create ( gst_nice_src_create (
...@@ -196,13 +234,18 @@ gst_nice_src_create ( ...@@ -196,13 +234,18 @@ gst_nice_src_create (
guint length, guint length,
GstBuffer **buffer) GstBuffer **buffer)
{ {
GstNiceSrc *nicesrc; GstNiceSrc *nicesrc = GST_NICE_SRC (basesrc);
nicesrc = GST_NICE_SRC (basesrc);
nicesrc->outbuf = NULL; nicesrc->outbuf = NULL;
nicesrc->offset = offset; nicesrc->offset = offset;
GST_OBJECT_LOCK (basesrc);
if (nicesrc->unlocked) {
GST_OBJECT_UNLOCK (basesrc);
return nicesrc->flow_ret;
}
GST_OBJECT_UNLOCK (basesrc);
g_main_loop_run (nicesrc->mainloop); g_main_loop_run (nicesrc->mainloop);
if (nicesrc->outbuf) { if (nicesrc->outbuf) {
......
...@@ -69,6 +69,7 @@ struct _GstNiceSrc ...@@ -69,6 +69,7 @@ struct _GstNiceSrc
guint64 offset; guint64 offset;
GstFlowReturn flow_ret; GstFlowReturn flow_ret;
GstBuffer *outbuf; GstBuffer *outbuf;
gboolean unlocked;
}; };
typedef struct _GstNiceSrcClass GstNiceSrcClass; typedef struct _GstNiceSrcClass GstNiceSrcClass;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment