Original commit message from CVS:
put upstream events in an async queue and resend them at the start of the chain. not working as expected yet but a start
queue->writer = FALSE;
queue->not_empty = g_cond_new ();
queue->not_full = g_cond_new ();
queue->writer = FALSE;
queue->not_empty = g_cond_new ();
queue->not_full = g_cond_new ();
+ queue->events = g_async_queue_new();
GST_DEBUG_ELEMENT (GST_CAT_THREAD, queue, "initialized queue's not_empty & not_full conditions");
}
GST_DEBUG_ELEMENT (GST_CAT_THREAD, queue, "initialized queue's not_empty & not_full conditions");
}
g_cond_free (queue->not_empty);
g_cond_free (queue->not_full);
g_cond_free (queue->not_empty);
g_cond_free (queue->not_full);
+ g_async_queue_unref(queue->events);
+
G_OBJECT_CLASS (parent_class)->dispose (object);
}
G_OBJECT_CLASS (parent_class)->dispose (object);
}
g_return_if_fail (buf != NULL);
queue = GST_QUEUE (GST_OBJECT_PARENT (pad));
g_return_if_fail (buf != NULL);
queue = GST_QUEUE (GST_OBJECT_PARENT (pad));
+
+ /* check for events to send upstream */
+ g_async_queue_lock(queue->events);
+ while (g_async_queue_length_unlocked(queue->events) > 0){
+ GstEvent *event = (GstEvent*)g_async_queue_pop_unlocked(queue->events);
+ g_print("sending event upstream\n");
+ gst_pad_event_default (pad, event);
+ g_print("event sent\n");
+ }
+ g_async_queue_unlock(queue->events);
restart:
/* we have to lock the queue since we span threads */
restart:
/* we have to lock the queue since we span threads */
queue = GST_QUEUE (GST_OBJECT_PARENT (pad));
queue = GST_QUEUE (GST_OBJECT_PARENT (pad));
restart:
/* have to lock for thread-safety */
GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, queue, "locking t:%ld", pthread_self ());
restart:
/* have to lock for thread-safety */
GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, queue, "locking t:%ld", pthread_self ());
gst_queue_handle_src_event (GstPad *pad, GstEvent *event)
{
GstQueue *queue;
gst_queue_handle_src_event (GstPad *pad, GstEvent *event)
{
GstQueue *queue;
queue = GST_QUEUE (GST_OBJECT_PARENT (pad));
queue = GST_QUEUE (GST_OBJECT_PARENT (pad));
- g_mutex_lock (queue->qlock);
-
- if (gst_element_get_state (GST_ELEMENT (queue)) == GST_STATE_PLAYING) {
- g_mutex_unlock (queue->qlock);
- g_warning ("queue event in playing state");
- return FALSE;
- }
+ /* push the event to the queue for upstream consumption */
+ g_async_queue_push(queue->events, event);
- res = gst_pad_event_default (pad, event);
- if (res) {
- switch (GST_EVENT_TYPE (event)) {
- case GST_EVENT_FLUSH:
- GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, queue, "FLUSH event, flushing queue\n");
+ g_mutex_lock (queue->qlock);
+ switch (GST_EVENT_TYPE (event)) {
+ case GST_EVENT_FLUSH:
+ GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, queue, "FLUSH event, flushing queue\n");
+ gst_queue_locked_flush (queue);
+ break;
+ case GST_EVENT_SEEK:
+ if (GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH)
gst_queue_locked_flush (queue);
gst_queue_locked_flush (queue);
- break;
- case GST_EVENT_SEEK:
- if (GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH)
- gst_queue_locked_flush (queue);
- default:
- break;
- }
}
g_mutex_unlock (queue->qlock);
}
g_mutex_unlock (queue->qlock);
+ /* we have to claim success, but we don't really know */
+ return TRUE;
GCond *not_full; /* signals space now available for writing */
GTimeVal *timeval; /* the timeout for the queue locking */
GCond *not_full; /* signals space now available for writing */
GTimeVal *timeval; /* the timeout for the queue locking */
+ GAsyncQueue *events; /* upstream events get decoupled here */
};
struct _GstQueueClass {
};
struct _GstQueueClass {
queue->writer = FALSE;
queue->not_empty = g_cond_new ();
queue->not_full = g_cond_new ();
queue->writer = FALSE;
queue->not_empty = g_cond_new ();
queue->not_full = g_cond_new ();
+ queue->events = g_async_queue_new();
GST_DEBUG_ELEMENT (GST_CAT_THREAD, queue, "initialized queue's not_empty & not_full conditions");
}
GST_DEBUG_ELEMENT (GST_CAT_THREAD, queue, "initialized queue's not_empty & not_full conditions");
}
g_cond_free (queue->not_empty);
g_cond_free (queue->not_full);
g_cond_free (queue->not_empty);
g_cond_free (queue->not_full);
+ g_async_queue_unref(queue->events);
+
G_OBJECT_CLASS (parent_class)->dispose (object);
}
G_OBJECT_CLASS (parent_class)->dispose (object);
}
g_return_if_fail (buf != NULL);
queue = GST_QUEUE (GST_OBJECT_PARENT (pad));
g_return_if_fail (buf != NULL);
queue = GST_QUEUE (GST_OBJECT_PARENT (pad));
+
+ /* check for events to send upstream */
+ g_async_queue_lock(queue->events);
+ while (g_async_queue_length_unlocked(queue->events) > 0){
+ GstEvent *event = (GstEvent*)g_async_queue_pop_unlocked(queue->events);
+ g_print("sending event upstream\n");
+ gst_pad_event_default (pad, event);
+ g_print("event sent\n");
+ }
+ g_async_queue_unlock(queue->events);
restart:
/* we have to lock the queue since we span threads */
restart:
/* we have to lock the queue since we span threads */
queue = GST_QUEUE (GST_OBJECT_PARENT (pad));
queue = GST_QUEUE (GST_OBJECT_PARENT (pad));
restart:
/* have to lock for thread-safety */
GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, queue, "locking t:%ld", pthread_self ());
restart:
/* have to lock for thread-safety */
GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, queue, "locking t:%ld", pthread_self ());
gst_queue_handle_src_event (GstPad *pad, GstEvent *event)
{
GstQueue *queue;
gst_queue_handle_src_event (GstPad *pad, GstEvent *event)
{
GstQueue *queue;
queue = GST_QUEUE (GST_OBJECT_PARENT (pad));
queue = GST_QUEUE (GST_OBJECT_PARENT (pad));
- g_mutex_lock (queue->qlock);
-
- if (gst_element_get_state (GST_ELEMENT (queue)) == GST_STATE_PLAYING) {
- g_mutex_unlock (queue->qlock);
- g_warning ("queue event in playing state");
- return FALSE;
- }
+ /* push the event to the queue for upstream consumption */
+ g_async_queue_push(queue->events, event);
- res = gst_pad_event_default (pad, event);
- if (res) {
- switch (GST_EVENT_TYPE (event)) {
- case GST_EVENT_FLUSH:
- GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, queue, "FLUSH event, flushing queue\n");
+ g_mutex_lock (queue->qlock);
+ switch (GST_EVENT_TYPE (event)) {
+ case GST_EVENT_FLUSH:
+ GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, queue, "FLUSH event, flushing queue\n");
+ gst_queue_locked_flush (queue);
+ break;
+ case GST_EVENT_SEEK:
+ if (GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH)
gst_queue_locked_flush (queue);
gst_queue_locked_flush (queue);
- break;
- case GST_EVENT_SEEK:
- if (GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH)
- gst_queue_locked_flush (queue);
- default:
- break;
- }
}
g_mutex_unlock (queue->qlock);
}
g_mutex_unlock (queue->qlock);
+ /* we have to claim success, but we don't really know */
+ return TRUE;
GCond *not_full; /* signals space now available for writing */
GTimeVal *timeval; /* the timeout for the queue locking */
GCond *not_full; /* signals space now available for writing */
GTimeVal *timeval; /* the timeout for the queue locking */
+ GAsyncQueue *events; /* upstream events get decoupled here */
};
struct _GstQueueClass {
};
struct _GstQueueClass {