2001-01-07 02:30:50 +00:00
|
|
|
thread 1 thread2
|
|
|
|
|
|
|
|
// the queue is empty
|
|
|
|
while (!queue->level_buffers) {
|
|
|
|
STATUS("queue: %s U released lock\n");
|
2005-11-21 16:34:26 +00:00
|
|
|
GST_OBJECT_UNLOCK (queue);
|
2001-01-07 02:30:50 +00:00
|
|
|
|
|
|
|
// thread1 is scheduled and puts a lot of buffers
|
|
|
|
// in the queue
|
|
|
|
|
|
|
|
// thread1 has put the last buffer on the queue
|
2018-04-27 16:40:31 +00:00
|
|
|
// here. A signal is going to be emitted
|
2001-01-07 02:30:50 +00:00
|
|
|
|
|
|
|
tosignal = (queue->level_buffers >= 0);
|
|
|
|
queue->level_buffers++;
|
|
|
|
|
|
|
|
/* we can unlock now */
|
2005-11-21 16:34:26 +00:00
|
|
|
GST_OBJECT_UNLOCK (queue);
|
2001-01-07 02:30:50 +00:00
|
|
|
|
|
|
|
if (tosignal) {
|
|
|
|
g_mutex_lock (queue->emptylock);
|
|
|
|
g_cond_signal (queue->emptycond);
|
|
|
|
g_mutex_unlock (queue->emptylock);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_mutex_lock (queue->emptylock);
|
|
|
|
// wait forever
|
|
|
|
g_cond_wait (queue->emptycond, queue->emptylock);
|
|
|
|
g_mutex_unlock (queue->emptylock);
|
2005-11-21 16:34:26 +00:00
|
|
|
GST_OBJECT_LOCK (queue);
|
2001-01-07 02:30:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// thread 1 will also wait forever because the
|
|
|
|
// queue is filled....
|
|
|
|
|
|
|
|
|
|
|
|
|