androidmedia: Update to new GLib thread API
authorSebastian Dröge <sebastian.droege@collabora.co.uk>
Mon, 12 Nov 2012 10:32:44 +0000 (11:32 +0100)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Tue, 16 Apr 2013 10:57:25 +0000 (12:57 +0200)
sys/androidmedia/gstamcaudiodec.c
sys/androidmedia/gstamcaudiodec.h
sys/androidmedia/gstamcvideodec.c
sys/androidmedia/gstamcvideodec.h

index 886556ae20a21ae8cf9280623890ccc48fc19e94..e34a0574c5c5f096115d869d706fe4a87ad05b8e 100644 (file)
@@ -323,8 +323,8 @@ gst_amc_audio_dec_init (GstAmcAudioDec * self)
   gst_audio_decoder_set_needs_format (GST_AUDIO_DECODER (self), TRUE);
   gst_audio_decoder_set_drainable (GST_AUDIO_DECODER (self), TRUE);
 
-  self->drain_lock = g_mutex_new ();
-  self->drain_cond = g_cond_new ();
+  g_mutex_init (&self->drain_lock);
+  g_cond_init (&self->drain_cond);
 }
 
 static gboolean
@@ -370,8 +370,8 @@ gst_amc_audio_dec_finalize (GObject * object)
 {
   GstAmcAudioDec *self = GST_AMC_AUDIO_DEC (object);
 
-  g_mutex_free (self->drain_lock);
-  g_cond_free (self->drain_cond);
+  g_mutex_clear (&self->drain_lock);
+  g_cond_clear (&self->drain_cond);
 
   G_OBJECT_CLASS (parent_class)->finalize (object);
 }
@@ -399,10 +399,10 @@ gst_amc_audio_dec_change_state (GstElement * element, GstStateChange transition)
     case GST_STATE_CHANGE_PAUSED_TO_READY:
       self->flushing = TRUE;
       gst_amc_codec_flush (self->codec);
-      g_mutex_lock (self->drain_lock);
+      g_mutex_lock (&self->drain_lock);
       self->draining = FALSE;
-      g_cond_broadcast (self->drain_cond);
-      g_mutex_unlock (self->drain_lock);
+      g_cond_broadcast (&self->drain_cond);
+      g_mutex_unlock (&self->drain_lock);
       break;
     default:
       break;
@@ -640,16 +640,16 @@ done:
 
   if (is_eos || flow_ret == GST_FLOW_EOS) {
     GST_AUDIO_DECODER_STREAM_UNLOCK (self);
-    g_mutex_lock (self->drain_lock);
+    g_mutex_lock (&self->drain_lock);
     if (self->draining) {
       GST_DEBUG_OBJECT (self, "Drained");
       self->draining = FALSE;
-      g_cond_broadcast (self->drain_cond);
+      g_cond_broadcast (&self->drain_cond);
     } else if (flow_ret == GST_FLOW_OK) {
       GST_DEBUG_OBJECT (self, "Component signalled EOS");
       flow_ret = GST_FLOW_EOS;
     }
-    g_mutex_unlock (self->drain_lock);
+    g_mutex_unlock (&self->drain_lock);
     GST_AUDIO_DECODER_STREAM_LOCK (self);
   } else {
     GST_DEBUG_OBJECT (self, "Finished frame: %s", gst_flow_get_name (flow_ret));
@@ -801,10 +801,10 @@ gst_amc_audio_dec_stop (GstAudioDecoder * decoder)
 
   self->downstream_flow_ret = GST_FLOW_FLUSHING;
   self->eos = FALSE;
-  g_mutex_lock (self->drain_lock);
+  g_mutex_lock (&self->drain_lock);
   self->draining = FALSE;
-  g_cond_broadcast (self->drain_cond);
-  g_mutex_unlock (self->drain_lock);
+  g_cond_broadcast (&self->drain_cond);
+  g_mutex_unlock (&self->drain_lock);
 
   GST_DEBUG_OBJECT (self, "Stopped decoder");
   return TRUE;
@@ -1226,7 +1226,7 @@ gst_amc_audio_dec_drain (GstAmcAudioDec * self)
     GstAmcBufferInfo buffer_info;
 
     GST_AUDIO_DECODER_STREAM_UNLOCK (self);
-    g_mutex_lock (self->drain_lock);
+    g_mutex_lock (&self->drain_lock);
     self->draining = TRUE;
 
     memset (&buffer_info, 0, sizeof (buffer_info));
@@ -1237,7 +1237,7 @@ gst_amc_audio_dec_drain (GstAmcAudioDec * self)
 
     if (gst_amc_codec_queue_input_buffer (self->codec, idx, &buffer_info)) {
       GST_DEBUG_OBJECT (self, "Waiting until codec is drained");
-      g_cond_wait (self->drain_cond, self->drain_lock);
+      g_cond_wait (&self->drain_cond, &self->drain_lock);
       GST_DEBUG_OBJECT (self, "Drained codec");
       ret = GST_FLOW_OK;
     } else {
@@ -1245,7 +1245,7 @@ gst_amc_audio_dec_drain (GstAmcAudioDec * self)
       ret = GST_FLOW_ERROR;
     }
 
-    g_mutex_unlock (self->drain_lock);
+    g_mutex_unlock (&self->drain_lock);
     GST_AUDIO_DECODER_STREAM_LOCK (self);
   } else if (idx >= self->n_input_buffers) {
     GST_ERROR_OBJECT (self, "Invalid input buffer index %d of %d",
index 0e0c6e10bd789437cae4014777e8c16471c839bb..ee52181900862fd34b1b05bb8ba1734df6c34c51 100644 (file)
@@ -73,8 +73,8 @@ struct _GstAmcAudioDec
   GstClockTime last_upstream_ts;
 
   /* Draining state */
-  GMutex *drain_lock;
-  GCond *drain_cond;
+  GMutex drain_lock;
+  GCond drain_cond;
   /* TRUE if EOS buffers shouldn't be forwarded */
   gboolean draining;
 
index 5e702ee75eea6177e725cfdfe039aee924868fcf..22568287287e4885875b1670cd5279aad833a1be 100644 (file)
@@ -454,8 +454,8 @@ gst_amc_video_dec_init (GstAmcVideoDec * self)
 {
   gst_video_decoder_set_packetized (GST_VIDEO_DECODER (self), TRUE);
 
-  self->drain_lock = g_mutex_new ();
-  self->drain_cond = g_cond_new ();
+  g_mutex_init (&self->drain_lock);
+  g_cond_init (&self->drain_cond);
 }
 
 static gboolean
@@ -501,8 +501,8 @@ gst_amc_video_dec_finalize (GObject * object)
 {
   GstAmcVideoDec *self = GST_AMC_VIDEO_DEC (object);
 
-  g_mutex_free (self->drain_lock);
-  g_cond_free (self->drain_cond);
+  g_mutex_clear (&self->drain_lock);
+  g_cond_clear (&self->drain_cond);
 
   G_OBJECT_CLASS (parent_class)->finalize (object);
 }
@@ -530,10 +530,10 @@ gst_amc_video_dec_change_state (GstElement * element, GstStateChange transition)
     case GST_STATE_CHANGE_PAUSED_TO_READY:
       self->flushing = TRUE;
       gst_amc_codec_flush (self->codec);
-      g_mutex_lock (self->drain_lock);
+      g_mutex_lock (&self->drain_lock);
       self->draining = FALSE;
-      g_cond_broadcast (self->drain_cond);
-      g_mutex_unlock (self->drain_lock);
+      g_cond_broadcast (&self->drain_cond);
+      g_mutex_unlock (&self->drain_lock);
       break;
     default:
       break;
@@ -1092,16 +1092,16 @@ retry:
 
   if (is_eos || flow_ret == GST_FLOW_EOS) {
     GST_VIDEO_DECODER_STREAM_UNLOCK (self);
-    g_mutex_lock (self->drain_lock);
+    g_mutex_lock (&self->drain_lock);
     if (self->draining) {
       GST_DEBUG_OBJECT (self, "Drained");
       self->draining = FALSE;
-      g_cond_broadcast (self->drain_cond);
+      g_cond_broadcast (&self->drain_cond);
     } else if (flow_ret == GST_FLOW_OK) {
       GST_DEBUG_OBJECT (self, "Component signalled EOS");
       flow_ret = GST_FLOW_EOS;
     }
-    g_mutex_unlock (self->drain_lock);
+    g_mutex_unlock (&self->drain_lock);
     GST_VIDEO_DECODER_STREAM_LOCK (self);
   } else {
     GST_DEBUG_OBJECT (self, "Finished frame: %s", gst_flow_get_name (flow_ret));
@@ -1236,10 +1236,10 @@ gst_amc_video_dec_stop (GstVideoDecoder * decoder)
 
   self->downstream_flow_ret = GST_FLOW_FLUSHING;
   self->eos = FALSE;
-  g_mutex_lock (self->drain_lock);
+  g_mutex_lock (&self->drain_lock);
   self->draining = FALSE;
-  g_cond_broadcast (self->drain_cond);
-  g_mutex_unlock (self->drain_lock);
+  g_cond_broadcast (&self->drain_cond);
+  g_mutex_unlock (&self->drain_lock);
   g_free (self->codec_data);
   self->codec_data_size = 0;
   if (self->input_state)
@@ -1647,7 +1647,7 @@ gst_amc_video_dec_drain (GstAmcVideoDec * self, gboolean at_eos)
     GstAmcBufferInfo buffer_info;
 
     GST_VIDEO_DECODER_STREAM_UNLOCK (self);
-    g_mutex_lock (self->drain_lock);
+    g_mutex_lock (&self->drain_lock);
     self->draining = TRUE;
 
     memset (&buffer_info, 0, sizeof (buffer_info));
@@ -1658,7 +1658,7 @@ gst_amc_video_dec_drain (GstAmcVideoDec * self, gboolean at_eos)
 
     if (gst_amc_codec_queue_input_buffer (self->codec, idx, &buffer_info)) {
       GST_DEBUG_OBJECT (self, "Waiting until codec is drained");
-      g_cond_wait (self->drain_cond, self->drain_lock);
+      g_cond_wait (&self->drain_cond, &self->drain_lock);
       GST_DEBUG_OBJECT (self, "Drained codec");
       ret = GST_FLOW_OK;
     } else {
@@ -1666,7 +1666,7 @@ gst_amc_video_dec_drain (GstAmcVideoDec * self, gboolean at_eos)
       ret = GST_FLOW_ERROR;
     }
 
-    g_mutex_unlock (self->drain_lock);
+    g_mutex_unlock (&self->drain_lock);
     GST_VIDEO_DECODER_STREAM_LOCK (self);
   } else if (idx >= self->n_input_buffers) {
     GST_ERROR_OBJECT (self, "Invalid input buffer index %d of %d",
index 8709d11697e9104e8ee3f8ac599f8902983c7901..3353dc68ea63b32c88254b3789ffb0beee672353 100644 (file)
@@ -74,8 +74,8 @@ struct _GstAmcVideoDec
   GstClockTime last_upstream_ts;
 
   /* Draining state */
-  GMutex *drain_lock;
-  GCond *drain_cond;
+  GMutex drain_lock;
+  GCond drain_cond;
   /* TRUE if EOS buffers shouldn't be forwarded */
   gboolean draining;