dreamaudiosource: change to non-blocking read and poll. in case of timeout, create...
[gst-plugin-dreamsource.git] / src / gstdreamaudiosource.c
1 /*
2  * GStreamer dreamaudiosource
3  * Copyright 2014-2015 Andreas Frisch <fraxinas@opendreambox.org>
4  *
5  * This program is licensed under the Creative Commons
6  * Attribution-NonCommercial-ShareAlike 3.0 Unported
7  * License. To view a copy of this license, visit
8  * http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to
9  * Creative Commons,559 Nathan Abbott Way,Stanford,California 94305,USA.
10  *
11  * Alternatively, this program may be distributed and executed on
12  * hardware which is licensed by Dream Property GmbH.
13  *
14  * This program is NOT free software. It is open source, you are allowed
15  * to modify it (if you keep the license), but it may not be commercially
16  * distributed other than under the conditions noted above.
17  */
18
19 #ifdef HAVE_CONFIG_H
20 #include <config.h>
21 #endif
22
23 #include <gst/gst.h>
24 #include <sys/poll.h>
25 #include <sys/socket.h>
26 #include "gstdreamaudiosource.h"
27
28 #define CONTROL_STOP            'S'     /* stop the select call */
29 #define CONTROL_SOCKETS(src)   src->control_sock
30 #define WRITE_SOCKET(src)      src->control_sock[1]
31 #define READ_SOCKET(src)       src->control_sock[0]
32
33 #define SEND_COMMAND(src, command)          \
34 G_STMT_START {                              \
35   int G_GNUC_UNUSED _res; unsigned char c; c = command;   \
36   _res = write (WRITE_SOCKET(src), &c, 1);  \
37 } G_STMT_END
38
39 #define READ_COMMAND(src, command, res)        \
40 G_STMT_START {                                 \
41   res = read(READ_SOCKET(src), &command, 1);   \
42 } G_STMT_END
43
44
45 GST_DEBUG_CATEGORY_STATIC (dreamaudiosource_debug);
46 #define GST_CAT_DEFAULT dreamaudiosource_debug
47
48 enum
49 {
50         SIGNAL_GET_BASE_PTS,
51         LAST_SIGNAL
52 };
53 enum
54 {
55         ARG_0,
56         ARG_BITRATE,
57 };
58
59 static guint gst_dreamaudiosource_signals[LAST_SIGNAL] = { 0 };
60
61 #define DEFAULT_BITRATE 128
62
63 static GstStaticPadTemplate srctemplate =
64     GST_STATIC_PAD_TEMPLATE ("src",
65         GST_PAD_SRC,
66         GST_PAD_ALWAYS,
67         GST_STATIC_CAPS ("audio/mpeg, "
68         "mpegversion = 4,"
69         "stream-format = (string) adts")
70     );
71
72 #define gst_dreamaudiosource_parent_class parent_class
73 G_DEFINE_TYPE (GstDreamAudioSource, gst_dreamaudiosource, GST_TYPE_PUSH_SRC);
74
75 static GstCaps *gst_dreamaudiosource_getcaps (GstBaseSrc * psrc, GstCaps * filter);
76 static gboolean gst_dreamaudiosource_start (GstBaseSrc * bsrc);
77 static gboolean gst_dreamaudiosource_stop (GstBaseSrc * bsrc);
78 static gboolean gst_dreamaudiosource_unlock (GstBaseSrc * bsrc);
79 static void gst_dreamaudiosource_dispose (GObject * gobject);
80 static GstFlowReturn gst_dreamaudiosource_create (GstPushSrc * psrc, GstBuffer ** outbuf);
81
82 static void gst_dreamaudiosource_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec);
83 static void gst_dreamaudiosource_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec);
84
85 static GstStateChangeReturn gst_dreamaudiosource_change_state (GstElement * element, GstStateChange transition);
86 static gint64 gst_dreamaudiosource_get_base_pts (GstDreamAudioSource *self);
87
88 static void
89 gst_dreamaudiosource_class_init (GstDreamAudioSourceClass * klass)
90 {
91         GObjectClass *gobject_class;
92         GstElementClass *gstelement_class;
93         GstBaseSrcClass *gstbasesrc_class;
94         GstPushSrcClass *gstpush_src_class;
95
96         gobject_class = (GObjectClass *) klass;
97         gstelement_class = (GstElementClass *) klass;
98         gstbasesrc_class = (GstBaseSrcClass *) klass;
99         gstpush_src_class = (GstPushSrcClass *) klass;
100
101         gobject_class->set_property = gst_dreamaudiosource_set_property;
102         gobject_class->get_property = gst_dreamaudiosource_get_property;
103         gobject_class->dispose = gst_dreamaudiosource_dispose;
104
105         gst_element_class_add_pad_template (gstelement_class,
106                                             gst_static_pad_template_get (&srctemplate));
107
108         gst_element_class_set_static_metadata (gstelement_class,
109             "Dream Audio source", "Source/Audio",
110             "Provide an audio elementary stream from Dreambox encoder device",
111             "Andreas Frisch <fraxinas@opendreambox.org>");
112
113         gstelement_class->change_state = gst_dreamaudiosource_change_state;
114
115         gstbasesrc_class->get_caps = gst_dreamaudiosource_getcaps;
116         gstbasesrc_class->start = gst_dreamaudiosource_start;
117         gstbasesrc_class->stop = gst_dreamaudiosource_stop;
118         gstbasesrc_class->unlock = gst_dreamaudiosource_unlock;
119
120         gstpush_src_class->create = gst_dreamaudiosource_create;
121
122         g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BITRATE,
123           g_param_spec_int ("bitrate", "Bitrate (kb/s)",
124             "Bitrate in kbit/sec", 16, 320, DEFAULT_BITRATE,
125             G_PARAM_CONSTRUCT | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
126
127         gst_dreamaudiosource_signals[SIGNAL_GET_BASE_PTS] =
128                 g_signal_new ("get-base-pts",
129                 G_TYPE_FROM_CLASS (klass),
130                 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
131                 G_STRUCT_OFFSET (GstDreamAudioSourceClass, get_base_pts),
132                 NULL, NULL, gst_dreamsource_marshal_INT64__VOID, G_TYPE_INT64, 0);
133
134         klass->get_base_pts = gst_dreamaudiosource_get_base_pts;
135
136 }
137
138 static gint64
139 gst_dreamaudiosource_get_base_pts (GstDreamAudioSource *self)
140 {
141         GST_DEBUG_OBJECT (self, "gst_dreamaudiosource_get_base_pts %" GST_TIME_FORMAT"", GST_TIME_ARGS (self->base_pts) );
142         return self->base_pts;
143 }
144
145 static void gst_dreamaudiosource_set_bitrate (GstDreamAudioSource * self, uint32_t bitrate)
146 {
147         if (!self->encoder || !self->encoder->fd)
148                 return;
149         uint32_t abr = bitrate*1000;
150         int ret = ioctl(self->encoder->fd, AENC_SET_BITRATE, &abr);
151         if (ret != 0)
152         {
153                 GST_WARNING_OBJECT (self, "can't set audio bitrate to %i bytes/s!", abr);
154                 return;
155         }
156         GST_INFO_OBJECT (self, "set audio bitrate to %i kBytes/s", bitrate);
157         self->audio_info.bitrate = abr;
158 }
159
160 gboolean
161 gst_dreamaudiosource_plugin_init (GstPlugin *plugin)
162 {
163         GST_DEBUG_CATEGORY_INIT (dreamaudiosource_debug, "dreamaudiosource", 0, "dreamaudiosource");
164         return gst_element_register (plugin, "dreamaudiosource", GST_RANK_PRIMARY, GST_TYPE_DREAMAUDIOSOURCE);
165 }
166
167 static void
168 gst_dreamaudiosource_init (GstDreamAudioSource * self)
169 {
170         self->encoder = NULL;
171         self->descriptors_available = 0;
172
173         g_mutex_init (&self->mutex);
174         READ_SOCKET (self) = -1;
175         WRITE_SOCKET (self) = -1;
176
177         gst_base_src_set_format (GST_BASE_SRC (self), GST_FORMAT_TIME);
178         gst_base_src_set_live (GST_BASE_SRC (self), TRUE);
179
180         self->encoder = malloc(sizeof(EncoderInfo));
181
182         if(!self->encoder) {
183                 GST_ERROR_OBJECT(self,"out of space");
184                 return;
185         }
186
187         char fn_buf[32];
188         sprintf(fn_buf, "/dev/aenc%d", 0);
189         self->encoder->fd = open(fn_buf, O_RDWR | O_SYNC);
190         if(self->encoder->fd <= 0) {
191                 GST_ERROR_OBJECT(self,"cannot open device %s (%s)", fn_buf, strerror(errno));
192                 free(self->encoder);
193                 self->encoder = NULL;
194                 return;
195         }
196
197         int flags = fcntl(self->encoder->fd, F_GETFL, 0);
198         fcntl(self->encoder->fd, F_SETFL, flags | O_NONBLOCK);
199
200         self->encoder->buffer = malloc(ABUFSIZE);
201         if(!self->encoder->buffer) {
202                 GST_ERROR_OBJECT(self,"cannot alloc buffer");
203                 return;
204         }
205
206         self->encoder->cdb = (unsigned char *)mmap(0, AMMAPSIZE, PROT_READ, MAP_PRIVATE, self->encoder->fd, 0);
207         if(!self->encoder->cdb || self->encoder->cdb== MAP_FAILED) {
208                 GST_ERROR_OBJECT(self,"cannot mmap cdb: %s (%d)", strerror(errno));
209                 return;
210         }
211
212 #ifdef dump
213         self->dumpfd = open("/media/hdd/movie/dreamaudiosource.dump", O_WRONLY | O_CREAT | O_TRUNC);
214         GST_DEBUG_OBJECT (self, "dumpfd = %i (%s)", self->dumpfd, (self->dumpfd > 0) ? "OK" : strerror(errno));
215 #endif
216
217         gst_dreamaudiosource_set_bitrate(self, DEFAULT_BITRATE);
218 }
219
220 static void
221 gst_dreamaudiosource_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec)
222 {
223         GstDreamAudioSource *self = GST_DREAMAUDIOSOURCE (object);
224
225         switch (prop_id) {
226                 case ARG_BITRATE:
227                         gst_dreamaudiosource_set_bitrate(self, g_value_get_int (value));
228                         break;
229                 default:
230                         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
231                         break;
232         }
233 }
234
235 static void
236 gst_dreamaudiosource_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec)
237 {
238         GstDreamAudioSource *self = GST_DREAMAUDIOSOURCE (object);
239
240         switch (prop_id) {
241                 case ARG_BITRATE:
242                         g_value_set_int (value, self->audio_info.bitrate/1000);
243                         break;
244                 default:
245                         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
246                         break;
247         }
248 }
249
250 static GstCaps *
251 gst_dreamaudiosource_getcaps (GstBaseSrc * bsrc, GstCaps * filter)
252 {
253         GstDreamAudioSource *self = GST_DREAMAUDIOSOURCE (bsrc);
254         GstPadTemplate *pad_template;
255         GstCaps *caps;
256
257         pad_template = gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS(self), "src");
258         g_return_val_if_fail (pad_template != NULL, NULL);
259
260         if (self->encoder == NULL) {
261                 GST_DEBUG_OBJECT (self, "encoder not opened -> use template caps");
262                 caps = gst_pad_template_get_caps (pad_template);
263         }
264         else
265         {
266                 caps = gst_caps_make_writable(gst_pad_template_get_caps (pad_template));
267         }
268
269         GST_DEBUG_OBJECT (self, "return caps %" GST_PTR_FORMAT, caps);
270         return caps;
271 }
272
273 static gboolean gst_dreamaudiosource_unlock (GstBaseSrc * bsrc)
274 {
275         GstDreamAudioSource *self = GST_DREAMAUDIOSOURCE (bsrc);
276         GST_LOG_OBJECT (self, "stop creating buffers");
277         SEND_COMMAND (self, CONTROL_STOP);
278         return TRUE;
279 }
280
281 static void
282 gst_dreamaudiosource_free_buffer (struct _bufferdebug * bufferdebug)
283 {
284         GList *list = g_list_first (bufferdebug->self->buffers_list);
285         int count = 0;
286         while (list) {
287                 GST_TRACE_OBJECT (bufferdebug->self, "buffers_list[%i] = %" GST_PTR_FORMAT "", count, list->data);
288                 count++;
289                 list = g_list_next (list);
290         }
291         bufferdebug->self->buffers_list = g_list_remove(g_list_first (bufferdebug->self->buffers_list), bufferdebug->buffer);
292         GST_TRACE_OBJECT (bufferdebug->self, "removing %" GST_PTR_FORMAT " @ %" GST_TIME_FORMAT " from list -> new length=%i", bufferdebug->buffer, GST_TIME_ARGS (bufferdebug->buffer_pts), g_list_length(bufferdebug->self->buffers_list));
293 }
294
295 static GstFlowReturn
296 gst_dreamaudiosource_create (GstPushSrc * psrc, GstBuffer ** outbuf)
297 {
298         GstDreamAudioSource *self = GST_DREAMAUDIOSOURCE (psrc);
299         EncoderInfo *enc = self->encoder;
300
301         static int dumpoffset;
302
303         GST_LOG_OBJECT (self, "new buffer requested");
304
305         if (!enc) {
306                 GST_WARNING_OBJECT (self, "encoder device not opened!");
307                 return GST_FLOW_ERROR;
308         }
309
310         while (1)
311         {
312                 *outbuf = NULL;
313
314                 if (self->descriptors_available == 0)
315                 {
316                         self->descriptors_count = 0;
317                         struct pollfd rfd[2];
318
319                         rfd[0].fd = enc->fd;
320                         rfd[0].events = POLLIN;
321                         rfd[1].fd = READ_SOCKET (self);
322                         rfd[1].events = POLLIN | POLLERR | POLLHUP | POLLPRI;
323
324                         int ret = poll(rfd, 2, 200);
325
326                         if (G_UNLIKELY (ret == -1))
327                         {
328                                 GST_ERROR_OBJECT (self, "SELECT ERROR!");
329                                 return GST_FLOW_ERROR;
330                         }
331                         else if ( ret == 0 )
332                         {
333                                 GST_LOG_OBJECT (self, "SELECT TIMEOUT");
334                                 //!!! TODO generate dummy payload
335                                 *outbuf = gst_buffer_new();
336                         }
337                         else if ( G_UNLIKELY (rfd[1].revents) )
338                         {
339                                 char command;
340                                 READ_COMMAND (self, command, ret);
341                                 GST_LOG_OBJECT (self, "CONTROL_STOP!");
342                                 return GST_FLOW_FLUSHING;
343                         }
344                         else if ( G_LIKELY(rfd[0].revents & POLLIN) )
345                         {
346                                 int rlen = read(enc->fd, enc->buffer, ABUFSIZE);
347                                 if (rlen <= 0 || rlen % ABDSIZE ) {
348                                         if ( errno == 512 )
349                                                 return GST_FLOW_FLUSHING;
350                                         GST_WARNING_OBJECT (self, "read error %s (%i)", strerror(errno), errno);
351                                         return GST_FLOW_ERROR;
352                                 }
353                                 self->descriptors_available = rlen / ABDSIZE;
354                                 GST_LOG_OBJECT (self, "encoder buffer was empty, %d descriptors available", self->descriptors_available);
355                         }
356                 }
357
358                 while (self->descriptors_count < self->descriptors_available) {
359                         off_t offset = self->descriptors_count * ABDSIZE;
360                         AudioBufferDescriptor *desc = (AudioBufferDescriptor*)(&enc->buffer[offset]);
361
362                         uint32_t f = desc->stCommon.uiFlags;
363
364                         GST_LOG_OBJECT (self, "descriptors_count=%d, descriptors_available=%u\tuiOffset=%u, uiLength=%"G_GSIZE_FORMAT"", self->descriptors_count, self->descriptors_available, desc->stCommon.uiOffset, desc->stCommon.uiLength);
365
366                         if (f & CDB_FLAG_METADATA) {
367                                 GST_LOG_OBJECT (self, "CDB_FLAG_METADATA... skip outdated packet");
368                                 self->descriptors_count = self->descriptors_available;
369                                 continue;
370                         }
371
372                         struct _bufferdebug * bdg = malloc(sizeof(struct _bufferdebug));
373                         *outbuf = gst_buffer_new_wrapped_full (GST_MEMORY_FLAG_READONLY, enc->cdb, AMMAPSIZE, desc->stCommon.uiOffset, desc->stCommon.uiLength, bdg, (GDestroyNotify)gst_dreamaudiosource_free_buffer);
374                         bdg->self = self;
375                         bdg->buffer = *outbuf;
376                         self->buffers_list = g_list_append(self->buffers_list, *outbuf);
377
378                         if (f & CDB_FLAG_PTS_VALID)
379                         {
380                                 if (G_UNLIKELY (self->base_pts == GST_CLOCK_TIME_NONE))
381                                 {
382                                         if (self->dreamvideosrc)
383                                         {
384                                                 g_mutex_lock (&self->mutex);
385                                                 guint64 videosource_base_pts;
386                                                 g_signal_emit_by_name(self->dreamvideosrc, "get-base-pts", &videosource_base_pts);
387                                                 if (videosource_base_pts != GST_CLOCK_TIME_NONE)
388                                                 {
389                                                         GST_DEBUG_OBJECT (self, "use DREAMVIDEOSOURCE's base_pts=%" GST_TIME_FORMAT "", GST_TIME_ARGS (videosource_base_pts) );
390                                                         self->base_pts = videosource_base_pts;
391                                                 }
392                                                 g_mutex_unlock (&self->mutex);
393                                         }
394                                         else
395                                         {
396                                                 self->base_pts = MPEGTIME_TO_GSTTIME(desc->stCommon.uiPTS);
397                                                 GST_DEBUG_OBJECT (self, "use mpeg stream pts as base_pts=%" GST_TIME_FORMAT"", GST_TIME_ARGS (self->base_pts) );
398                                         }
399                                 }
400                                 GstClockTime buffer_time = MPEGTIME_TO_GSTTIME(desc->stCommon.uiPTS);
401                                 if (self->base_pts != GST_CLOCK_TIME_NONE && buffer_time > self->base_pts )
402                                 {
403                                         buffer_time -= self->base_pts;
404                                         GST_BUFFER_PTS(*outbuf) = buffer_time;
405                                         GST_BUFFER_DTS(*outbuf) = buffer_time;
406                                 }
407                                 bdg->buffer_pts = buffer_time;
408                         }
409
410 #ifdef dump
411                         int wret = write(self->dumpfd, (unsigned char*)(enc->cdb + desc->stCommon.uiOffset), desc->stCommon.uiLength);
412                         dumpoffset += wret;
413                         GST_LOG_OBJECT (self, "read %"G_GSIZE_FORMAT" dumped %i total 0x%08X", desc->stCommon.uiLength, wret, dumpoffset );
414 #endif
415                         self->descriptors_count++;
416
417                         break;
418                 }
419
420                 if (self->descriptors_count == self->descriptors_available) {
421                         GST_LOG_OBJECT (self, "self->descriptors_count == self->descriptors_available -> release %i consumed descriptors", self->descriptors_count);
422                         /* release consumed descs */
423                         if (write(enc->fd, &self->descriptors_count, 4) != 4) {
424                                 GST_WARNING_OBJECT (self, "release consumed descs write error!");
425                                 return GST_FLOW_ERROR;
426                         }
427                         self->descriptors_available = 0;
428                 }
429
430                 if (*outbuf)
431                 {
432                         GST_DEBUG_OBJECT (self, "pushing %" GST_PTR_FORMAT "", *outbuf );
433                         return GST_FLOW_OK;
434                 }
435         }
436
437         return GST_FLOW_ERROR;
438 }
439
440 static GstStateChangeReturn gst_dreamaudiosource_change_state (GstElement * element, GstStateChange transition)
441 {
442         GstDreamAudioSource *self = GST_DREAMAUDIOSOURCE (element);
443         int ret;
444         switch (transition) {
445                 case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
446                         GST_LOG_OBJECT (self, "GST_STATE_CHANGE_PAUSED_TO_PLAYING");
447                         self->base_pts = GST_CLOCK_TIME_NONE;
448                         ret = ioctl(self->encoder->fd, AENC_START);
449                         if ( ret != 0 )
450                         {
451                                 GST_ERROR_OBJECT(self,"can't start encoder ioctl!");
452                                 return GST_STATE_CHANGE_FAILURE;
453                         }
454                         self->descriptors_available = 0;
455                         GST_INFO_OBJECT (self, "started encoder!");
456                         break;
457                 case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
458                         GST_LOG_OBJECT (self, "GST_STATE_CHANGE_PLAYING_TO_PAUSED self->descriptors_count=%i self->descriptors_available=%i", self->descriptors_count, self->descriptors_available);
459                         GST_OBJECT_LOCK (self);
460                         while (self->descriptors_count < self->descriptors_available)
461                                 GST_LOG_OBJECT (self, "flushing self->descriptors_count=%i", self->descriptors_count++);
462                         if (self->descriptors_count)
463                                 write(self->encoder->fd, &self->descriptors_count, 4);
464                         ret = ioctl(self->encoder->fd, AENC_STOP);
465                         GST_OBJECT_UNLOCK (self);
466                         if ( ret != 0 )
467                         {
468                                 GST_ERROR_OBJECT(self,"can't stop encoder ioctl!");
469                                 return GST_STATE_CHANGE_FAILURE;
470                         }
471                         GST_INFO_OBJECT (self, "stopped encoder!");
472                         break;
473                 default:
474                         break;
475         }
476         if (GST_ELEMENT_CLASS (parent_class)->change_state)
477                 return GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
478         return GST_STATE_CHANGE_SUCCESS;
479 }
480
481 static gboolean
482 gst_dreamaudiosource_start (GstBaseSrc * bsrc)
483 {
484         GstDreamAudioSource *self = GST_DREAMAUDIOSOURCE (bsrc);
485         self->dreamvideosrc = gst_bin_get_by_name_recurse_up(GST_BIN(GST_ELEMENT_PARENT(self)), "dreamvideosource0");
486
487         int control_sock[2];
488         if (socketpair (PF_UNIX, SOCK_STREAM, 0, control_sock) < 0)
489         {
490                 GST_ELEMENT_ERROR (self, RESOURCE, OPEN_READ_WRITE, (NULL), GST_ERROR_SYSTEM);
491                 return FALSE;
492         }
493         READ_SOCKET (self) = control_sock[0];
494         WRITE_SOCKET (self) = control_sock[1];
495         fcntl (READ_SOCKET (self), F_SETFL, O_NONBLOCK);
496         fcntl (WRITE_SOCKET (self), F_SETFL, O_NONBLOCK);
497
498         GST_DEBUG_OBJECT (self, "started. reference to dreamvideosource=%" GST_PTR_FORMAT"", self->dreamvideosrc);
499         return TRUE;
500 }
501
502 static gboolean
503 gst_dreamaudiosource_stop (GstBaseSrc * bsrc)
504 {
505         GstDreamAudioSource *self = GST_DREAMAUDIOSOURCE (bsrc);
506         if (self->dreamvideosrc)
507                 gst_object_unref(self->dreamvideosrc);
508         GST_DEBUG_OBJECT (self, "stop");
509         return TRUE;
510 }
511
512 static void
513 gst_dreamaudiosource_dispose (GObject * gobject)
514 {
515         GstDreamAudioSource *self = GST_DREAMAUDIOSOURCE (gobject);
516         if (self->encoder) {
517                 if (self->encoder->buffer)
518                         free(self->encoder->buffer);
519                 if (self->encoder->cdb)
520                         munmap(self->encoder->cdb, AMMAPSIZE);
521                 if (self->encoder->fd)
522                         close(self->encoder->fd);
523                 free(self->encoder);
524         }
525 #ifdef dump
526         close(self->dumpfd);
527 #endif
528         g_list_free(self->buffers_list);
529         g_mutex_clear (&self->mutex);
530         GST_DEBUG_OBJECT (self, "disposed");
531         G_OBJECT_CLASS (parent_class)->dispose (gobject);
532 }