Better, cleaner state management of the scheduler by adding scheduler state flags.
[platform/upstream/gstreamer.git] / plugins / elements / gstqueue.c
1 /* GStreamer
2  * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3  *                    2000 Wim Taymans <wtay@chello.be>
4  *
5  * gstqueue.c:
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public
18  * License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22
23 /* #define DEBUG_ENABLED */
24 /* #define STATUS_ENABLED */
25 #ifdef STATUS_ENABLED
26 #define STATUS(A) GST_DEBUG(GST_CAT_DATAFLOW, A, GST_ELEMENT_NAME(queue))
27 #else
28 #define STATUS(A)
29 #endif
30
31 #include <pthread.h>
32
33 #include "config.h"
34 #include "gst_private.h"
35
36 #include "gstqueue.h"
37 #include "gstscheduler.h"
38 #include "gstevent.h"
39
40 GstElementDetails gst_queue_details = {
41   "Queue",
42   "Connection",
43   "Simple data queue",
44   VERSION,
45   "Erik Walthinsen <omega@cse.ogi.edu>",
46   "(C) 1999",
47 };
48
49
50 /* Queue signals and args */
51 enum {
52   LOW_WATERMARK,
53   HIGH_WATERMARK,
54   LAST_SIGNAL
55 };
56
57 enum {
58   ARG_0,
59   ARG_LEVEL_BUFFERS,
60   ARG_LEVEL_BYTES,
61   ARG_LEVEL_TIME,
62   ARG_SIZE_BUFFERS,
63   ARG_SIZE_BYTES,
64   ARG_SIZE_TIME,
65   ARG_LEAKY,
66   ARG_LEVEL,
67   ARG_MAX_LEVEL,
68   ARG_MAY_DEADLOCK,
69 };
70
71
72 static void                     gst_queue_class_init            (GstQueueClass *klass);
73 static void                     gst_queue_init                  (GstQueue *queue);
74 static void                     gst_queue_dispose               (GObject *object);
75
76 static void                     gst_queue_set_property          (GObject *object, guint prop_id, 
77                                                                  const GValue *value, GParamSpec *pspec);
78 static void                     gst_queue_get_property          (GObject *object, guint prop_id, 
79                                                                  GValue *value, GParamSpec *pspec);
80
81 static GstPadNegotiateReturn    gst_queue_handle_negotiate_src  (GstPad *pad, GstCaps **caps, gpointer *data);
82 static GstPadNegotiateReturn    gst_queue_handle_negotiate_sink (GstPad *pad, GstCaps **caps, gpointer *data);
83 static void                     gst_queue_chain                 (GstPad *pad, GstBuffer *buf);
84 static GstBuffer *              gst_queue_get                   (GstPad *pad);
85 static GstBufferPool*           gst_queue_get_bufferpool        (GstPad *pad);
86         
87 static void                     gst_queue_locked_flush                  (GstQueue *queue);
88 static void                     gst_queue_flush                 (GstQueue *queue);
89
90 static GstElementStateReturn    gst_queue_change_state          (GstElement *element);
91
92   
93 #define GST_TYPE_QUEUE_LEAKY (queue_leaky_get_type())
94 static GType
95 queue_leaky_get_type(void) {
96   static GType queue_leaky_type = 0;
97   static GEnumValue queue_leaky[] = {
98     { GST_QUEUE_NO_LEAK,                "0", "Not Leaky" },
99     { GST_QUEUE_LEAK_UPSTREAM,          "1", "Leaky on Upstream" },
100     { GST_QUEUE_LEAK_DOWNSTREAM,        "2", "Leaky on Downstream" },
101     { 0, NULL, NULL },
102   };
103   if (!queue_leaky_type) {
104     queue_leaky_type = g_enum_register_static("GstQueueLeaky", queue_leaky);
105   }
106   return queue_leaky_type;
107 }
108
109 static GstElementClass *parent_class = NULL;
110 /* static guint gst_queue_signals[LAST_SIGNAL] = { 0 }; */
111
112 GType
113 gst_queue_get_type(void) 
114 {
115   static GType queue_type = 0;
116
117   if (!queue_type) {
118     static const GTypeInfo queue_info = {
119       sizeof(GstQueueClass),
120       NULL,
121       NULL,
122       (GClassInitFunc)gst_queue_class_init,
123       NULL,
124       NULL,
125       sizeof(GstQueue),
126       4,
127       (GInstanceInitFunc)gst_queue_init,
128       NULL
129     };
130     queue_type = g_type_register_static (GST_TYPE_ELEMENT, "GstQueue", &queue_info, 0);
131   }
132   return queue_type;
133 }
134
135 static void
136 gst_queue_class_init (GstQueueClass *klass)
137 {
138   GObjectClass *gobject_class;
139   GstElementClass *gstelement_class;
140
141   gobject_class = (GObjectClass*)klass;
142   gstelement_class = (GstElementClass*)klass;
143
144   parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
145
146   g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LEAKY,
147     g_param_spec_enum ("leaky", "Leaky", "Where the queue leaks, if at all.",
148                        GST_TYPE_QUEUE_LEAKY, GST_QUEUE_NO_LEAK, G_PARAM_READWRITE));
149   g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LEVEL,
150     g_param_spec_int ("level", "Level", "How many buffers are in the queue.",
151                       0, G_MAXINT, 0, G_PARAM_READABLE));
152   g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MAX_LEVEL,
153     g_param_spec_int ("max_level", "Maximum Level", "How many buffers the queue holds.",
154                       0, G_MAXINT, 100, G_PARAM_READWRITE));
155   g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MAY_DEADLOCK,
156     g_param_spec_boolean ("may_deadlock", "May Deadlock", "The queue may deadlock if it's full and not PLAYING",
157                       TRUE, G_PARAM_READWRITE));
158
159   gobject_class->dispose                = GST_DEBUG_FUNCPTR (gst_queue_dispose);
160   gobject_class->set_property           = GST_DEBUG_FUNCPTR (gst_queue_set_property);
161   gobject_class->get_property           = GST_DEBUG_FUNCPTR (gst_queue_get_property);
162
163   gstelement_class->change_state = GST_DEBUG_FUNCPTR(gst_queue_change_state);
164 }
165
166 static void
167 gst_queue_init (GstQueue *queue)
168 {
169   /* scheduling on this kind of element is, well, interesting */
170   GST_FLAG_SET (queue, GST_ELEMENT_DECOUPLED);
171   GST_FLAG_SET (queue, GST_ELEMENT_EVENT_AWARE);
172
173   queue->sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
174   gst_pad_set_chain_function (queue->sinkpad, GST_DEBUG_FUNCPTR(gst_queue_chain));
175   gst_element_add_pad (GST_ELEMENT (queue), queue->sinkpad);
176   gst_pad_set_negotiate_function (queue->sinkpad, GST_DEBUG_FUNCPTR(gst_queue_handle_negotiate_sink));
177   gst_pad_set_bufferpool_function (queue->sinkpad, GST_DEBUG_FUNCPTR(gst_queue_get_bufferpool));
178
179   queue->srcpad = gst_pad_new ("src", GST_PAD_SRC);
180   gst_pad_set_get_function (queue->srcpad, GST_DEBUG_FUNCPTR(gst_queue_get));
181   gst_element_add_pad (GST_ELEMENT (queue), queue->srcpad);
182   gst_pad_set_negotiate_function (queue->srcpad, GST_DEBUG_FUNCPTR(gst_queue_handle_negotiate_src));
183
184   queue->queue = NULL;
185   queue->level_buffers = 0;
186   queue->level_bytes = 0;
187   queue->level_time = 0LL;
188   queue->size_buffers = 100;            /* 100 buffers */
189   queue->size_bytes = 100 * 1024;       /* 100KB */
190   queue->size_time = 1000000000LL;      /* 1sec */
191   queue->may_deadlock = TRUE;
192
193   queue->qlock = g_mutex_new ();
194   queue->reader = FALSE;
195   queue->writer = FALSE;
196   queue->not_empty = g_cond_new ();
197   queue->not_full = g_cond_new ();
198   GST_DEBUG_ELEMENT (GST_CAT_THREAD, queue, "initialized queue's not_empty & not_full conditions\n");
199 }
200
201 static void
202 gst_queue_dispose (GObject *object)
203 {
204   GstQueue *queue = GST_QUEUE (object);
205
206   g_mutex_free (queue->qlock);
207   g_cond_free (queue->not_empty);
208   g_cond_free (queue->not_full);
209
210   G_OBJECT_CLASS (parent_class)->dispose (object);
211 }
212
213 static GstBufferPool*
214 gst_queue_get_bufferpool (GstPad *pad)
215 {
216   GstQueue *queue;
217
218   queue = GST_QUEUE (GST_OBJECT_PARENT (pad));
219
220   return gst_pad_get_bufferpool (queue->srcpad);
221 }
222
223 static GstPadNegotiateReturn
224 gst_queue_handle_negotiate_src (GstPad *pad, GstCaps **caps, gpointer *data)
225 {
226   GstQueue *queue;
227
228   queue = GST_QUEUE (GST_OBJECT_PARENT (pad));
229
230   return gst_pad_negotiate_proxy (pad, queue->sinkpad, caps);
231 }
232
233 static GstPadNegotiateReturn
234 gst_queue_handle_negotiate_sink (GstPad *pad, GstCaps **caps, gpointer *data)
235 {
236   GstQueue *queue;
237
238   queue = GST_QUEUE (GST_OBJECT_PARENT (pad));
239
240   return gst_pad_negotiate_proxy (pad, queue->srcpad, caps);
241 }
242
243 static void
244 gst_queue_cleanup_buffers (gpointer data, const gpointer user_data)
245 {
246   GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, user_data, "cleaning buffer %p\n", data);
247
248   if (GST_IS_BUFFER (data)) {
249     gst_buffer_unref (GST_BUFFER (data));
250   }
251 }
252
253 static void
254 gst_queue_locked_flush (GstQueue *queue)
255 {
256   g_slist_foreach (queue->queue, gst_queue_cleanup_buffers,
257                   (gpointer) queue);
258   g_slist_free (queue->queue);
259
260   queue->queue = NULL;
261   queue->level_buffers = 0;
262   queue->timeval = NULL;
263 }
264
265 static void
266 gst_queue_flush (GstQueue *queue)
267 {
268   g_mutex_lock (queue->qlock);
269   gst_queue_locked_flush (queue);
270   g_mutex_unlock (queue->qlock);
271 }
272
273
274 static void
275 gst_queue_chain (GstPad *pad, GstBuffer *buf)
276 {
277   GstQueue *queue;
278   gboolean reader;
279
280   g_return_if_fail (pad != NULL);
281   g_return_if_fail (GST_IS_PAD (pad));
282   g_return_if_fail (buf != NULL);
283
284   queue = GST_QUEUE (GST_OBJECT_PARENT (pad));
285
286   reader = FALSE;
287
288 restart:
289   /* we have to lock the queue since we span threads */
290   GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, queue, "locking t:%ld\n", pthread_self ());
291   g_mutex_lock (queue->qlock);
292   GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, queue, "locked t:%ld\n", pthread_self ());
293
294   if (GST_IS_EVENT (buf)) {
295     switch (GST_EVENT_TYPE (buf)) {
296       case GST_EVENT_FLUSH:
297         GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, queue, "FLUSH event, flushing queue\n");
298         gst_queue_locked_flush (queue);
299         break;
300       case GST_EVENT_EOS:
301         GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, queue, "eos in on %s %d\n", 
302                            GST_ELEMENT_NAME (queue), queue->level_buffers);
303         break;
304       default:
305         gst_pad_event_default (pad, GST_EVENT (buf));
306         break;
307     }
308   }
309
310   GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, queue, "adding buffer %p of size %d\n",buf,GST_BUFFER_SIZE(buf));
311
312   if (queue->level_buffers == queue->size_buffers) {
313     /* if this is a leaky queue... */
314     if (queue->leaky) {
315       /* FIXME don't want to leak events! */
316       /* if we leak on the upstream side, drop the current buffer */
317       if (queue->leaky == GST_QUEUE_LEAK_UPSTREAM) {
318         GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, queue, "queue is full, leaking buffer on upstream end\n");
319         if (GST_IS_EVENT (buf))
320           fprintf(stderr, "Error: queue [%s] leaked an event, type:%d\n",
321               GST_ELEMENT_NAME(GST_ELEMENT(queue)),
322               GST_EVENT_TYPE(GST_EVENT(buf)));
323           GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, queue, "queue is full, leaking buffer on upstream end\n");
324         gst_buffer_unref(buf);
325         /* now we have to clean up and exit right away */
326         g_mutex_unlock (queue->qlock);
327         return;
328       }
329       /* otherwise we have to push a buffer off the other end */
330       else {
331         GSList *front;
332         GstBuffer *leakbuf;
333         GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, queue, "queue is full, leaking buffer on downstream end\n");
334         front = queue->queue;
335         leakbuf = (GstBuffer *)(front->data);
336         if (GST_IS_EVENT (leakbuf))
337           fprintf(stderr, "Error: queue [%s] leaked an event, type:%d\n",
338               GST_ELEMENT_NAME(GST_ELEMENT(queue)),
339               GST_EVENT_TYPE(GST_EVENT(leakbuf)));
340         queue->level_buffers--;
341         queue->level_bytes -= GST_BUFFER_SIZE(leakbuf);
342         gst_buffer_unref(leakbuf);
343         queue->queue = g_slist_remove_link (queue->queue, front);
344         g_slist_free (front);
345       }
346     }
347
348     GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, queue, "pre full wait, level:%d/%d\n",
349         queue->level_buffers, queue->size_buffers);
350     while (queue->level_buffers == queue->size_buffers) {
351       /* if there's a pending state change for this queue or its manager, switch */
352       /* back to iterator so bottom half of state change executes */
353       while (GST_STATE_PENDING (queue) != GST_STATE_VOID_PENDING) {
354         GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, queue, "interrupted!!\n");
355         g_mutex_unlock (queue->qlock);
356         gst_element_interrupt (GST_ELEMENT (queue));
357         goto restart;
358       }
359       if (GST_STATE (queue) != GST_STATE_PLAYING) {
360         /* this means the other end is shut down */
361         /* try to signal to resolve the error */
362         if (!queue->may_deadlock) {
363           if (GST_IS_BUFFER (buf)) gst_buffer_unref (buf);
364           else gst_event_free (GST_EVENT (buf));
365           g_mutex_unlock (queue->qlock);
366           gst_element_error (GST_ELEMENT (queue), "deadlock found, source pad elements are shut down");
367           return;
368         }
369         else {
370           gst_element_info (GST_ELEMENT (queue), "waiting for the app to restart source pad elements");
371         }
372       }
373
374       GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, queue, "waiting for not_full, level:%d/%d\n", queue->level_buffers, queue->size_buffers);
375       if (queue->writer)
376         GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, queue, "WARNING: multiple writers on queue!\n");
377       queue->writer = TRUE;
378       g_cond_wait (queue->not_full, queue->qlock);
379       queue->writer = FALSE;
380       GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, queue, "got not_full signal\n");
381     }
382     GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, queue, "post full wait, level:%d/%d\n",
383         queue->level_buffers, queue->size_buffers);
384   }
385
386   /* put the buffer on the tail of the list */
387   queue->queue = g_slist_append (queue->queue, buf);
388   queue->level_buffers++;
389   queue->level_bytes += GST_BUFFER_SIZE(buf);
390   GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, queue, "(%s:%s)+ level:%d/%d\n",
391       GST_DEBUG_PAD_NAME(pad),
392       queue->level_buffers, queue->size_buffers);
393
394   /* reader waiting on an empty queue */
395   reader = queue->reader;
396
397   g_mutex_unlock (queue->qlock);
398
399   if (reader)
400   {
401     GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, queue, "signalling not_empty\n");
402     g_cond_signal (queue->not_empty);
403   }
404 }
405
406 static GstBuffer *
407 gst_queue_get (GstPad *pad)
408 {
409   GstQueue *queue;
410   GstBuffer *buf = NULL;
411   GSList *front;
412   gboolean writer;
413
414   g_assert(pad != NULL);
415   g_assert(GST_IS_PAD(pad));
416   g_return_val_if_fail (pad != NULL, NULL);
417   g_return_val_if_fail (GST_IS_PAD (pad), NULL);
418
419   queue = GST_QUEUE (GST_OBJECT_PARENT (pad));
420
421   writer = FALSE;
422
423 restart:
424   /* have to lock for thread-safety */
425   GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, queue, "locking t:%ld\n", pthread_self ());
426   g_mutex_lock (queue->qlock);
427   GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, queue, "locked t:%ld %p\n", pthread_self (), queue->not_empty);
428
429   GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, queue, "pre empty wait, level:%d/%d\n", queue->level_buffers, queue->size_buffers);
430   while (queue->level_buffers == 0) {
431     /* if there's a pending state change for this queue or its manager, switch
432      * back to iterator so bottom half of state change executes
433      */ 
434     while (GST_STATE_PENDING (queue) != GST_STATE_VOID_PENDING) {
435       GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, queue, "interrupted!!\n");
436       g_mutex_unlock (queue->qlock);
437       gst_element_interrupt (GST_ELEMENT (queue));
438       goto restart;
439     }
440     if (GST_STATE (queue) != GST_STATE_PLAYING) {
441       /* this means the other end is shut down */
442       if (!queue->may_deadlock) {
443         g_mutex_unlock (queue->qlock);
444         gst_element_error (GST_ELEMENT (queue), "deadlock found, sink pad elements are shut down");
445         return NULL;
446       }
447       else {
448         gst_element_info (GST_ELEMENT (queue), "waiting for the app to restart sink pad elements");
449       }
450     }
451
452     GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, queue, "waiting for not_empty, level:%d/%d\n", queue->level_buffers, queue->size_buffers);
453     if (queue->reader)
454       GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, queue, "WARNING: multiple readers on queue!\n");
455     queue->reader = TRUE;
456     g_cond_wait (queue->not_empty, queue->qlock);
457     queue->reader = FALSE;
458     GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, queue, "got not_empty signal\n");
459   }
460   GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, queue, "post empty wait, level:%d/%d\n", queue->level_buffers, queue->size_buffers);
461
462   front = queue->queue;
463   buf = (GstBuffer *)(front->data);
464   GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, queue, "retrieved buffer %p from queue\n", buf);
465   queue->queue = g_slist_remove_link (queue->queue, front);
466   g_slist_free (front);
467
468   queue->level_buffers--;
469   queue->level_bytes -= GST_BUFFER_SIZE(buf);
470   GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, queue, "(%s:%s)- level:%d/%d\n",
471       GST_DEBUG_PAD_NAME(pad),
472       queue->level_buffers, queue->size_buffers);
473
474   /* writer waiting on a full queue */
475   writer = queue->writer;
476
477   g_mutex_unlock (queue->qlock);
478
479   if (writer)
480   {
481     GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, queue, "signalling not_full\n");
482     g_cond_signal (queue->not_full);
483   }
484
485   /* FIXME where should this be? locked? */
486   if (GST_IS_EVENT(buf)) {
487     GstEvent *event = GST_EVENT(buf);
488     switch (GST_EVENT_TYPE(event)) {
489       case GST_EVENT_EOS:
490         GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, queue, "queue \"%s\" eos\n", GST_ELEMENT_NAME (queue));
491         gst_element_set_state (GST_ELEMENT (queue), GST_STATE_PAUSED);
492         break;
493       default:
494         break;
495     }
496   }
497
498   return buf;
499 }
500
501 static GstElementStateReturn
502 gst_queue_change_state (GstElement *element)
503 {
504   GstQueue *queue;
505   GstElementStateReturn ret;
506   GstElementState new_state;
507   g_return_val_if_fail (GST_IS_QUEUE (element), GST_STATE_FAILURE);
508
509   queue = GST_QUEUE (element);
510
511   GST_DEBUG_ENTER("('%s')", GST_ELEMENT_NAME (element));
512
513   /* lock the queue so another thread (not in sync with this thread's state)
514    * can't call this queue's _get (or whatever)
515    */
516   g_mutex_lock (queue->qlock);
517
518   new_state = GST_STATE_PENDING (element);
519
520   if (new_state == GST_STATE_PAUSED) {
521     g_cond_signal (queue->not_full);
522     g_cond_signal (queue->not_empty);
523   }
524   else if (new_state == GST_STATE_READY) {
525     gst_queue_locked_flush (queue);
526   }
527   else if (new_state == GST_STATE_PLAYING) {
528     if (!GST_PAD_CONNECTED (queue->sinkpad)) {
529       /* FIXME can this be? */
530       if (queue->reader)
531         g_cond_signal (queue->not_empty);
532       g_mutex_unlock (queue->qlock);
533
534       return GST_STATE_FAILURE;
535     }
536   }
537
538   ret = GST_ELEMENT_CLASS (parent_class)->change_state (element);
539   g_mutex_unlock (queue->qlock);
540
541   GST_DEBUG_LEAVE("('%s')", GST_ELEMENT_NAME (element));
542   return ret;
543 }
544
545
546 static void
547 gst_queue_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
548 {
549   GstQueue *queue;
550
551   /* it's not null if we got it, but it might not be ours */
552   g_return_if_fail (GST_IS_QUEUE (object));
553
554   queue = GST_QUEUE (object);
555
556   switch (prop_id) {
557     case ARG_LEAKY:
558       queue->leaky = g_value_get_int (value);
559       break;
560     case ARG_MAX_LEVEL:
561       queue->size_buffers = g_value_get_int (value);
562       break;
563     case ARG_MAY_DEADLOCK:
564       queue->may_deadlock = g_value_get_boolean (value);
565       break;
566     default:
567       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
568       break;
569   }
570 }
571
572 static void
573 gst_queue_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
574 {
575   GstQueue *queue;
576
577   /* it's not null if we got it, but it might not be ours */
578   g_return_if_fail (GST_IS_QUEUE (object));
579
580   queue = GST_QUEUE (object);
581
582   switch (prop_id) {
583     case ARG_LEAKY:
584       g_value_set_int (value, queue->leaky);
585       break;
586     case ARG_LEVEL:
587       g_value_set_int (value, queue->level_buffers);
588       break;
589     case ARG_MAX_LEVEL:
590       g_value_set_int (value, queue->size_buffers);
591       break;
592     case ARG_MAY_DEADLOCK:
593       g_value_set_boolean (value, queue->may_deadlock);
594       break;
595     default:
596       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
597       break;
598   }
599 }