mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-19 14:56:36 +00:00
queue2: pass item type enum to _enqueue instead of simple isbuffer boolean
Avoids some unnecessary GST_IS_EVENT()
This commit is contained in:
parent
52e3861e91
commit
c9df12754d
1 changed files with 23 additions and 15 deletions
|
@ -255,6 +255,12 @@ static gboolean gst_queue2_is_filled (GstQueue2 * queue);
|
||||||
|
|
||||||
static void update_cur_level (GstQueue2 * queue, GstQueue2Range * range);
|
static void update_cur_level (GstQueue2 * queue, GstQueue2Range * range);
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
GST_QUEUE2_ITEM_TYPE_UNKNOWN = 0,
|
||||||
|
GST_QUEUE2_ITEM_TYPE_BUFFER,
|
||||||
|
GST_QUEUE2_ITEM_TYPE_EVENT
|
||||||
|
} GstQueue2ItemType;
|
||||||
|
|
||||||
/* static guint gst_queue2_signals[LAST_SIGNAL] = { 0 }; */
|
/* static guint gst_queue2_signals[LAST_SIGNAL] = { 0 }; */
|
||||||
|
|
||||||
|
@ -1809,9 +1815,10 @@ handle_error:
|
||||||
|
|
||||||
/* enqueue an item an update the level stats */
|
/* enqueue an item an update the level stats */
|
||||||
static void
|
static void
|
||||||
gst_queue2_locked_enqueue (GstQueue2 * queue, gpointer item, gboolean isbuffer)
|
gst_queue2_locked_enqueue (GstQueue2 * queue, gpointer item,
|
||||||
|
GstQueue2ItemType item_type)
|
||||||
{
|
{
|
||||||
if (isbuffer) {
|
if (item_type == GST_QUEUE2_ITEM_TYPE_BUFFER) {
|
||||||
GstBuffer *buffer;
|
GstBuffer *buffer;
|
||||||
guint size;
|
guint size;
|
||||||
|
|
||||||
|
@ -1834,7 +1841,7 @@ gst_queue2_locked_enqueue (GstQueue2 * queue, gpointer item, gboolean isbuffer)
|
||||||
/* FIXME - check return value? */
|
/* FIXME - check return value? */
|
||||||
gst_queue2_create_write (queue, buffer);
|
gst_queue2_create_write (queue, buffer);
|
||||||
}
|
}
|
||||||
} else if (GST_IS_EVENT (item)) {
|
} else if (item_type == GST_QUEUE2_ITEM_TYPE_EVENT) {
|
||||||
GstEvent *event;
|
GstEvent *event;
|
||||||
|
|
||||||
event = GST_EVENT_CAST (item);
|
event = GST_EVENT_CAST (item);
|
||||||
|
@ -1906,7 +1913,7 @@ unexpected_event:
|
||||||
|
|
||||||
/* dequeue an item from the queue and update level stats */
|
/* dequeue an item from the queue and update level stats */
|
||||||
static GstMiniObject *
|
static GstMiniObject *
|
||||||
gst_queue2_locked_dequeue (GstQueue2 * queue, gboolean * is_buffer)
|
gst_queue2_locked_dequeue (GstQueue2 * queue, GstQueue2ItemType * item_type)
|
||||||
{
|
{
|
||||||
GstMiniObject *item;
|
GstMiniObject *item;
|
||||||
|
|
||||||
|
@ -1924,7 +1931,7 @@ gst_queue2_locked_dequeue (GstQueue2 * queue, gboolean * is_buffer)
|
||||||
|
|
||||||
buffer = GST_BUFFER_CAST (item);
|
buffer = GST_BUFFER_CAST (item);
|
||||||
size = GST_BUFFER_SIZE (buffer);
|
size = GST_BUFFER_SIZE (buffer);
|
||||||
*is_buffer = TRUE;
|
*item_type = GST_QUEUE2_ITEM_TYPE_BUFFER;
|
||||||
|
|
||||||
GST_CAT_LOG_OBJECT (queue_dataflow, queue,
|
GST_CAT_LOG_OBJECT (queue_dataflow, queue,
|
||||||
"retrieved buffer %p from queue", buffer);
|
"retrieved buffer %p from queue", buffer);
|
||||||
|
@ -1945,7 +1952,7 @@ gst_queue2_locked_dequeue (GstQueue2 * queue, gboolean * is_buffer)
|
||||||
} else if (GST_IS_EVENT (item)) {
|
} else if (GST_IS_EVENT (item)) {
|
||||||
GstEvent *event = GST_EVENT_CAST (item);
|
GstEvent *event = GST_EVENT_CAST (item);
|
||||||
|
|
||||||
*is_buffer = FALSE;
|
*item_type = GST_QUEUE2_ITEM_TYPE_EVENT;
|
||||||
|
|
||||||
GST_CAT_LOG_OBJECT (queue_dataflow, queue,
|
GST_CAT_LOG_OBJECT (queue_dataflow, queue,
|
||||||
"retrieved event %p from queue", event);
|
"retrieved event %p from queue", event);
|
||||||
|
@ -1966,6 +1973,7 @@ gst_queue2_locked_dequeue (GstQueue2 * queue, gboolean * is_buffer)
|
||||||
("Unexpected item %p dequeued from queue %s (refcounting problem?)",
|
("Unexpected item %p dequeued from queue %s (refcounting problem?)",
|
||||||
item, GST_OBJECT_NAME (queue));
|
item, GST_OBJECT_NAME (queue));
|
||||||
item = NULL;
|
item = NULL;
|
||||||
|
*item_type = GST_QUEUE2_ITEM_TYPE_UNKNOWN;
|
||||||
}
|
}
|
||||||
GST_QUEUE2_SIGNAL_DEL (queue);
|
GST_QUEUE2_SIGNAL_DEL (queue);
|
||||||
|
|
||||||
|
@ -2056,7 +2064,7 @@ gst_queue2_handle_sink_event (GstPad * pad, GstEvent * event)
|
||||||
/* refuse more events on EOS */
|
/* refuse more events on EOS */
|
||||||
if (queue->is_eos)
|
if (queue->is_eos)
|
||||||
goto out_eos;
|
goto out_eos;
|
||||||
gst_queue2_locked_enqueue (queue, event, FALSE);
|
gst_queue2_locked_enqueue (queue, event, GST_QUEUE2_ITEM_TYPE_EVENT);
|
||||||
GST_QUEUE2_MUTEX_UNLOCK (queue);
|
GST_QUEUE2_MUTEX_UNLOCK (queue);
|
||||||
} else {
|
} else {
|
||||||
/* non-serialized events are passed upstream. */
|
/* non-serialized events are passed upstream. */
|
||||||
|
@ -2171,7 +2179,7 @@ gst_queue2_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
goto out_flushing;
|
goto out_flushing;
|
||||||
|
|
||||||
/* put buffer in queue now */
|
/* put buffer in queue now */
|
||||||
gst_queue2_locked_enqueue (queue, buffer, TRUE);
|
gst_queue2_locked_enqueue (queue, buffer, GST_QUEUE2_ITEM_TYPE_BUFFER);
|
||||||
GST_QUEUE2_MUTEX_UNLOCK (queue);
|
GST_QUEUE2_MUTEX_UNLOCK (queue);
|
||||||
|
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
|
@ -2214,16 +2222,16 @@ gst_queue2_push_one (GstQueue2 * queue)
|
||||||
{
|
{
|
||||||
GstFlowReturn result = GST_FLOW_OK;
|
GstFlowReturn result = GST_FLOW_OK;
|
||||||
GstMiniObject *data;
|
GstMiniObject *data;
|
||||||
gboolean is_buffer = FALSE;
|
GstQueue2ItemType item_type;
|
||||||
|
|
||||||
data = gst_queue2_locked_dequeue (queue, &is_buffer);
|
data = gst_queue2_locked_dequeue (queue, &item_type);
|
||||||
if (data == NULL)
|
if (data == NULL)
|
||||||
goto no_item;
|
goto no_item;
|
||||||
|
|
||||||
next:
|
next:
|
||||||
GST_QUEUE2_MUTEX_UNLOCK (queue);
|
GST_QUEUE2_MUTEX_UNLOCK (queue);
|
||||||
|
|
||||||
if (is_buffer) {
|
if (item_type == GST_QUEUE2_ITEM_TYPE_BUFFER) {
|
||||||
GstBuffer *buffer;
|
GstBuffer *buffer;
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
|
|
||||||
|
@ -2247,12 +2255,12 @@ next:
|
||||||
* queue we can push, we set a flag to make the sinkpad refuse more
|
* queue we can push, we set a flag to make the sinkpad refuse more
|
||||||
* buffers with an UNEXPECTED return value until we receive something
|
* buffers with an UNEXPECTED return value until we receive something
|
||||||
* pushable again or we get flushed. */
|
* pushable again or we get flushed. */
|
||||||
while ((data = gst_queue2_locked_dequeue (queue, &is_buffer))) {
|
while ((data = gst_queue2_locked_dequeue (queue, &item_type))) {
|
||||||
if (is_buffer) {
|
if (item_type == GST_QUEUE2_ITEM_TYPE_BUFFER) {
|
||||||
GST_CAT_LOG_OBJECT (queue_dataflow, queue,
|
GST_CAT_LOG_OBJECT (queue_dataflow, queue,
|
||||||
"dropping UNEXPECTED buffer %p", data);
|
"dropping UNEXPECTED buffer %p", data);
|
||||||
gst_buffer_unref (GST_BUFFER_CAST (data));
|
gst_buffer_unref (GST_BUFFER_CAST (data));
|
||||||
} else if (GST_IS_EVENT (data)) {
|
} else if (item_type == GST_QUEUE2_ITEM_TYPE_EVENT) {
|
||||||
GstEvent *event = GST_EVENT_CAST (data);
|
GstEvent *event = GST_EVENT_CAST (data);
|
||||||
GstEventType type = GST_EVENT_TYPE (event);
|
GstEventType type = GST_EVENT_TYPE (event);
|
||||||
|
|
||||||
|
@ -2275,7 +2283,7 @@ next:
|
||||||
queue->unexpected = TRUE;
|
queue->unexpected = TRUE;
|
||||||
result = GST_FLOW_OK;
|
result = GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
} else if (GST_IS_EVENT (data)) {
|
} else if (item_type == GST_QUEUE2_ITEM_TYPE_EVENT) {
|
||||||
GstEvent *event = GST_EVENT_CAST (data);
|
GstEvent *event = GST_EVENT_CAST (data);
|
||||||
GstEventType type = GST_EVENT_TYPE (event);
|
GstEventType type = GST_EVENT_TYPE (event);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue