androidmedia: Update to new GLib thread API

This commit is contained in:
Sebastian Dröge 2012-11-12 11:32:44 +01:00
parent 996da425a9
commit b2e5b9cb67
4 changed files with 36 additions and 36 deletions

View 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_needs_format (GST_AUDIO_DECODER (self), TRUE);
gst_audio_decoder_set_drainable (GST_AUDIO_DECODER (self), TRUE); gst_audio_decoder_set_drainable (GST_AUDIO_DECODER (self), TRUE);
self->drain_lock = g_mutex_new (); g_mutex_init (&self->drain_lock);
self->drain_cond = g_cond_new (); g_cond_init (&self->drain_cond);
} }
static gboolean static gboolean
@ -370,8 +370,8 @@ gst_amc_audio_dec_finalize (GObject * object)
{ {
GstAmcAudioDec *self = GST_AMC_AUDIO_DEC (object); GstAmcAudioDec *self = GST_AMC_AUDIO_DEC (object);
g_mutex_free (self->drain_lock); g_mutex_clear (&self->drain_lock);
g_cond_free (self->drain_cond); g_cond_clear (&self->drain_cond);
G_OBJECT_CLASS (parent_class)->finalize (object); 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: case GST_STATE_CHANGE_PAUSED_TO_READY:
self->flushing = TRUE; self->flushing = TRUE;
gst_amc_codec_flush (self->codec); gst_amc_codec_flush (self->codec);
g_mutex_lock (self->drain_lock); g_mutex_lock (&self->drain_lock);
self->draining = FALSE; self->draining = FALSE;
g_cond_broadcast (self->drain_cond); g_cond_broadcast (&self->drain_cond);
g_mutex_unlock (self->drain_lock); g_mutex_unlock (&self->drain_lock);
break; break;
default: default:
break; break;
@ -640,16 +640,16 @@ done:
if (is_eos || flow_ret == GST_FLOW_EOS) { if (is_eos || flow_ret == GST_FLOW_EOS) {
GST_AUDIO_DECODER_STREAM_UNLOCK (self); GST_AUDIO_DECODER_STREAM_UNLOCK (self);
g_mutex_lock (self->drain_lock); g_mutex_lock (&self->drain_lock);
if (self->draining) { if (self->draining) {
GST_DEBUG_OBJECT (self, "Drained"); GST_DEBUG_OBJECT (self, "Drained");
self->draining = FALSE; self->draining = FALSE;
g_cond_broadcast (self->drain_cond); g_cond_broadcast (&self->drain_cond);
} else if (flow_ret == GST_FLOW_OK) { } else if (flow_ret == GST_FLOW_OK) {
GST_DEBUG_OBJECT (self, "Component signalled EOS"); GST_DEBUG_OBJECT (self, "Component signalled EOS");
flow_ret = GST_FLOW_EOS; flow_ret = GST_FLOW_EOS;
} }
g_mutex_unlock (self->drain_lock); g_mutex_unlock (&self->drain_lock);
GST_AUDIO_DECODER_STREAM_LOCK (self); GST_AUDIO_DECODER_STREAM_LOCK (self);
} else { } else {
GST_DEBUG_OBJECT (self, "Finished frame: %s", gst_flow_get_name (flow_ret)); 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->downstream_flow_ret = GST_FLOW_FLUSHING;
self->eos = FALSE; self->eos = FALSE;
g_mutex_lock (self->drain_lock); g_mutex_lock (&self->drain_lock);
self->draining = FALSE; self->draining = FALSE;
g_cond_broadcast (self->drain_cond); g_cond_broadcast (&self->drain_cond);
g_mutex_unlock (self->drain_lock); g_mutex_unlock (&self->drain_lock);
GST_DEBUG_OBJECT (self, "Stopped decoder"); GST_DEBUG_OBJECT (self, "Stopped decoder");
return TRUE; return TRUE;
@ -1226,7 +1226,7 @@ gst_amc_audio_dec_drain (GstAmcAudioDec * self)
GstAmcBufferInfo buffer_info; GstAmcBufferInfo buffer_info;
GST_AUDIO_DECODER_STREAM_UNLOCK (self); GST_AUDIO_DECODER_STREAM_UNLOCK (self);
g_mutex_lock (self->drain_lock); g_mutex_lock (&self->drain_lock);
self->draining = TRUE; self->draining = TRUE;
memset (&buffer_info, 0, sizeof (buffer_info)); 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)) { if (gst_amc_codec_queue_input_buffer (self->codec, idx, &buffer_info)) {
GST_DEBUG_OBJECT (self, "Waiting until codec is drained"); 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"); GST_DEBUG_OBJECT (self, "Drained codec");
ret = GST_FLOW_OK; ret = GST_FLOW_OK;
} else { } else {
@ -1245,7 +1245,7 @@ gst_amc_audio_dec_drain (GstAmcAudioDec * self)
ret = GST_FLOW_ERROR; ret = GST_FLOW_ERROR;
} }
g_mutex_unlock (self->drain_lock); g_mutex_unlock (&self->drain_lock);
GST_AUDIO_DECODER_STREAM_LOCK (self); GST_AUDIO_DECODER_STREAM_LOCK (self);
} else if (idx >= self->n_input_buffers) { } else if (idx >= self->n_input_buffers) {
GST_ERROR_OBJECT (self, "Invalid input buffer index %d of %d", GST_ERROR_OBJECT (self, "Invalid input buffer index %d of %d",

View file

@ -73,8 +73,8 @@ struct _GstAmcAudioDec
GstClockTime last_upstream_ts; GstClockTime last_upstream_ts;
/* Draining state */ /* Draining state */
GMutex *drain_lock; GMutex drain_lock;
GCond *drain_cond; GCond drain_cond;
/* TRUE if EOS buffers shouldn't be forwarded */ /* TRUE if EOS buffers shouldn't be forwarded */
gboolean draining; gboolean draining;

View file

@ -454,8 +454,8 @@ gst_amc_video_dec_init (GstAmcVideoDec * self)
{ {
gst_video_decoder_set_packetized (GST_VIDEO_DECODER (self), TRUE); gst_video_decoder_set_packetized (GST_VIDEO_DECODER (self), TRUE);
self->drain_lock = g_mutex_new (); g_mutex_init (&self->drain_lock);
self->drain_cond = g_cond_new (); g_cond_init (&self->drain_cond);
} }
static gboolean static gboolean
@ -501,8 +501,8 @@ gst_amc_video_dec_finalize (GObject * object)
{ {
GstAmcVideoDec *self = GST_AMC_VIDEO_DEC (object); GstAmcVideoDec *self = GST_AMC_VIDEO_DEC (object);
g_mutex_free (self->drain_lock); g_mutex_clear (&self->drain_lock);
g_cond_free (self->drain_cond); g_cond_clear (&self->drain_cond);
G_OBJECT_CLASS (parent_class)->finalize (object); 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: case GST_STATE_CHANGE_PAUSED_TO_READY:
self->flushing = TRUE; self->flushing = TRUE;
gst_amc_codec_flush (self->codec); gst_amc_codec_flush (self->codec);
g_mutex_lock (self->drain_lock); g_mutex_lock (&self->drain_lock);
self->draining = FALSE; self->draining = FALSE;
g_cond_broadcast (self->drain_cond); g_cond_broadcast (&self->drain_cond);
g_mutex_unlock (self->drain_lock); g_mutex_unlock (&self->drain_lock);
break; break;
default: default:
break; break;
@ -1092,16 +1092,16 @@ retry:
if (is_eos || flow_ret == GST_FLOW_EOS) { if (is_eos || flow_ret == GST_FLOW_EOS) {
GST_VIDEO_DECODER_STREAM_UNLOCK (self); GST_VIDEO_DECODER_STREAM_UNLOCK (self);
g_mutex_lock (self->drain_lock); g_mutex_lock (&self->drain_lock);
if (self->draining) { if (self->draining) {
GST_DEBUG_OBJECT (self, "Drained"); GST_DEBUG_OBJECT (self, "Drained");
self->draining = FALSE; self->draining = FALSE;
g_cond_broadcast (self->drain_cond); g_cond_broadcast (&self->drain_cond);
} else if (flow_ret == GST_FLOW_OK) { } else if (flow_ret == GST_FLOW_OK) {
GST_DEBUG_OBJECT (self, "Component signalled EOS"); GST_DEBUG_OBJECT (self, "Component signalled EOS");
flow_ret = GST_FLOW_EOS; flow_ret = GST_FLOW_EOS;
} }
g_mutex_unlock (self->drain_lock); g_mutex_unlock (&self->drain_lock);
GST_VIDEO_DECODER_STREAM_LOCK (self); GST_VIDEO_DECODER_STREAM_LOCK (self);
} else { } else {
GST_DEBUG_OBJECT (self, "Finished frame: %s", gst_flow_get_name (flow_ret)); 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->downstream_flow_ret = GST_FLOW_FLUSHING;
self->eos = FALSE; self->eos = FALSE;
g_mutex_lock (self->drain_lock); g_mutex_lock (&self->drain_lock);
self->draining = FALSE; self->draining = FALSE;
g_cond_broadcast (self->drain_cond); g_cond_broadcast (&self->drain_cond);
g_mutex_unlock (self->drain_lock); g_mutex_unlock (&self->drain_lock);
g_free (self->codec_data); g_free (self->codec_data);
self->codec_data_size = 0; self->codec_data_size = 0;
if (self->input_state) if (self->input_state)
@ -1647,7 +1647,7 @@ gst_amc_video_dec_drain (GstAmcVideoDec * self, gboolean at_eos)
GstAmcBufferInfo buffer_info; GstAmcBufferInfo buffer_info;
GST_VIDEO_DECODER_STREAM_UNLOCK (self); GST_VIDEO_DECODER_STREAM_UNLOCK (self);
g_mutex_lock (self->drain_lock); g_mutex_lock (&self->drain_lock);
self->draining = TRUE; self->draining = TRUE;
memset (&buffer_info, 0, sizeof (buffer_info)); 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)) { if (gst_amc_codec_queue_input_buffer (self->codec, idx, &buffer_info)) {
GST_DEBUG_OBJECT (self, "Waiting until codec is drained"); 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"); GST_DEBUG_OBJECT (self, "Drained codec");
ret = GST_FLOW_OK; ret = GST_FLOW_OK;
} else { } else {
@ -1666,7 +1666,7 @@ gst_amc_video_dec_drain (GstAmcVideoDec * self, gboolean at_eos)
ret = GST_FLOW_ERROR; ret = GST_FLOW_ERROR;
} }
g_mutex_unlock (self->drain_lock); g_mutex_unlock (&self->drain_lock);
GST_VIDEO_DECODER_STREAM_LOCK (self); GST_VIDEO_DECODER_STREAM_LOCK (self);
} else if (idx >= self->n_input_buffers) { } else if (idx >= self->n_input_buffers) {
GST_ERROR_OBJECT (self, "Invalid input buffer index %d of %d", GST_ERROR_OBJECT (self, "Invalid input buffer index %d of %d",

View file

@ -74,8 +74,8 @@ struct _GstAmcVideoDec
GstClockTime last_upstream_ts; GstClockTime last_upstream_ts;
/* Draining state */ /* Draining state */
GMutex *drain_lock; GMutex drain_lock;
GCond *drain_cond; GCond drain_cond;
/* TRUE if EOS buffers shouldn't be forwarded */ /* TRUE if EOS buffers shouldn't be forwarded */
gboolean draining; gboolean draining;