mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-25 01:30:38 +00:00
queue: avoid g_cond_signal when we can
Keep track of what cond we are waiting on and only signal when some other thread is waiting.
This commit is contained in:
parent
0dbb0f203e
commit
aa62c60a6c
2 changed files with 14 additions and 4 deletions
|
@ -142,7 +142,9 @@ enum
|
|||
|
||||
#define GST_QUEUE_WAIT_DEL_CHECK(q, label) G_STMT_START { \
|
||||
STATUS (q, q->sinkpad, "wait for DEL"); \
|
||||
q->waiting_del = TRUE; \
|
||||
g_cond_wait (q->item_del, q->qlock); \
|
||||
q->waiting_del = FALSE; \
|
||||
if (q->srcresult != GST_FLOW_OK) { \
|
||||
STATUS (q, q->srcpad, "received DEL wakeup"); \
|
||||
goto label; \
|
||||
|
@ -152,7 +154,9 @@ enum
|
|||
|
||||
#define GST_QUEUE_WAIT_ADD_CHECK(q, label) G_STMT_START { \
|
||||
STATUS (q, q->srcpad, "wait for ADD"); \
|
||||
q->waiting_add = TRUE; \
|
||||
g_cond_wait (q->item_add, q->qlock); \
|
||||
q->waiting_add = FALSE; \
|
||||
if (q->srcresult != GST_FLOW_OK) { \
|
||||
STATUS (q, q->srcpad, "received ADD wakeup"); \
|
||||
goto label; \
|
||||
|
@ -161,13 +165,17 @@ enum
|
|||
} G_STMT_END
|
||||
|
||||
#define GST_QUEUE_SIGNAL_DEL(q) G_STMT_START { \
|
||||
STATUS (q, q->srcpad, "signal DEL"); \
|
||||
g_cond_signal (q->item_del); \
|
||||
if (q->waiting_del) { \
|
||||
STATUS (q, q->srcpad, "signal DEL"); \
|
||||
g_cond_signal (q->item_del); \
|
||||
} \
|
||||
} G_STMT_END
|
||||
|
||||
#define GST_QUEUE_SIGNAL_ADD(q) G_STMT_START { \
|
||||
STATUS (q, q->sinkpad, "signal ADD"); \
|
||||
g_cond_signal (q->item_add); \
|
||||
if (q->waiting_add) { \
|
||||
STATUS (q, q->sinkpad, "signal ADD"); \
|
||||
g_cond_signal (q->item_add); \
|
||||
} \
|
||||
} G_STMT_END
|
||||
|
||||
#define _do_init(bla) \
|
||||
|
|
|
@ -108,7 +108,9 @@ struct _GstQueue {
|
|||
gint leaky;
|
||||
|
||||
GMutex *qlock; /* lock for queue (vs object lock) */
|
||||
gboolean waiting_add;
|
||||
GCond *item_add; /* signals buffers now available for reading */
|
||||
gboolean waiting_del;
|
||||
GCond *item_del; /* signals space now available for writing */
|
||||
|
||||
gboolean head_needs_discont, tail_needs_discont;
|
||||
|
|
Loading…
Reference in a new issue