omxvideodec: Use the frames storage of the base class instead of implementing our own
authorSebastian Dröge <sebastian.droege@collabora.co.uk>
Fri, 8 Jul 2011 11:16:45 +0000 (13:16 +0200)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Sat, 9 Jul 2011 09:06:06 +0000 (11:06 +0200)
They could get out of sync and we could store already destroyed frames.

omx/gstomxvideodec.c
omx/gstomxvideodec.h

index 22dd561..2378d94 100644 (file)
@@ -229,7 +229,7 @@ _find_nearest_frame (GstOMXVideoDec * self, GstOMXBuffer * buf)
   BufferIdentification *best_id = NULL;
 
   GST_OBJECT_LOCK (self);
-  for (l = self->pending_frames; l; l = l->next) {
+  for (l = GST_BASE_VIDEO_CODEC (self)->frames; l; l = l->next) {
     GstVideoFrame *tmp = l->data;
     BufferIdentification *id = tmp->coder_hook;
     guint64 timestamp, diff;
@@ -262,7 +262,7 @@ _find_nearest_frame (GstOMXVideoDec * self, GstOMXBuffer * buf)
   }
 
   if (best_id) {
-    for (l = self->pending_frames; l && l != best_l;) {
+    for (l = GST_BASE_VIDEO_CODEC (self)->frames; l && l != best_l;) {
       GstVideoFrame *tmp = l->data;
       BufferIdentification *id = tmp->coder_hook;
       guint64 diff_ticks, diff_frames;
@@ -281,16 +281,13 @@ _find_nearest_frame (GstOMXVideoDec * self, GstOMXBuffer * buf)
         g_warning ("Too old frame, bug in decoder -- please file a bug");
         gst_base_video_decoder_finish_frame (GST_BASE_VIDEO_DECODER (self),
             tmp);
-        self->pending_frames = g_list_delete_link (self->pending_frames, l);
-        l = self->pending_frames;
+        l = GST_BASE_VIDEO_CODEC (self)->frames;
       } else {
         l = l->next;
       }
     }
   }
 
-  if (best_l)
-    self->pending_frames = g_list_delete_link (self->pending_frames, best_l);
   GST_OBJECT_UNLOCK (self);
 
   return best;
@@ -479,9 +476,6 @@ gst_omx_video_dec_stop (GstBaseVideoDecoder * decoder)
 
   gst_omx_component_get_state (self->component, 5 * GST_SECOND);
 
-  g_list_free (self->pending_frames);
-  self->pending_frames = NULL;
-
   gst_buffer_replace (&self->codec_data, NULL);
 
   return ret;
@@ -610,9 +604,6 @@ gst_omx_video_dec_reset (GstBaseVideoDecoder * decoder)
   GST_PAD_STREAM_LOCK (GST_BASE_VIDEO_CODEC_SRC_PAD (self));
   GST_PAD_STREAM_UNLOCK (GST_BASE_VIDEO_CODEC_SRC_PAD (self));
 
-  g_list_free (self->pending_frames);
-  self->pending_frames = NULL;
-
   gst_omx_port_set_flushing (self->in_port, FALSE);
   gst_omx_port_set_flushing (self->out_port, FALSE);
 
@@ -644,10 +635,6 @@ gst_omx_video_dec_handle_frame (GstBaseVideoDecoder * decoder,
 
   GST_DEBUG_OBJECT (self, "Handling frame");
 
-  GST_OBJECT_LOCK (self);
-  self->pending_frames = g_list_append (self->pending_frames, frame);
-  GST_OBJECT_UNLOCK (self);
-
   timestamp = frame->presentation_timestamp;
   duration = frame->presentation_duration;
 
index a675e4e..fb7ea8a 100644 (file)
@@ -54,8 +54,6 @@ struct _GstOMXVideoDec
   GstOMXPort *in_port, *out_port;
 
   /* < private > */
-  GList *pending_frames;
-
   GstBuffer *codec_data;
 };