video: port to the new GLib thread API

This commit is contained in:
Thibault Saunier 2012-09-09 20:34:56 -03:00
parent dc5bb008a3
commit 39a907d04d

View file

@ -367,7 +367,7 @@ no_pipeline:
typedef struct typedef struct
{ {
GMutex *mutex; GMutex mutex;
GstElement *pipeline; GstElement *pipeline;
GstVideoConvertSampleCallback callback; GstVideoConvertSampleCallback callback;
gpointer user_data; gpointer user_data;
@ -395,9 +395,9 @@ static void
gst_video_convert_frame_context_free (GstVideoConvertSampleContext * ctx) gst_video_convert_frame_context_free (GstVideoConvertSampleContext * ctx)
{ {
/* Wait until all users of the mutex are done */ /* Wait until all users of the mutex are done */
g_mutex_lock (ctx->mutex); g_mutex_lock (&ctx->mutex);
g_mutex_unlock (ctx->mutex); g_mutex_unlock (&ctx->mutex);
g_mutex_free (ctx->mutex); g_mutex_clear (&ctx->mutex);
if (ctx->timeout_id) if (ctx->timeout_id)
g_source_remove (ctx->timeout_id); g_source_remove (ctx->timeout_id);
//if (ctx->buffer) //if (ctx->buffer)
@ -467,7 +467,7 @@ convert_frame_timeout_callback (GstVideoConvertSampleContext * context)
{ {
GError *error; GError *error;
g_mutex_lock (context->mutex); g_mutex_lock (&context->mutex);
if (context->finished) if (context->finished)
goto done; goto done;
@ -480,7 +480,7 @@ convert_frame_timeout_callback (GstVideoConvertSampleContext * context)
convert_frame_finish (context, NULL, error); convert_frame_finish (context, NULL, error);
done: done:
g_mutex_unlock (context->mutex); g_mutex_unlock (&context->mutex);
return FALSE; return FALSE;
} }
@ -488,7 +488,7 @@ static gboolean
convert_frame_bus_callback (GstBus * bus, GstMessage * message, convert_frame_bus_callback (GstBus * bus, GstMessage * message,
GstVideoConvertSampleContext * context) GstVideoConvertSampleContext * context)
{ {
g_mutex_lock (context->mutex); g_mutex_lock (&context->mutex);
if (context->finished) if (context->finished)
goto done; goto done;
@ -513,7 +513,7 @@ convert_frame_bus_callback (GstBus * bus, GstMessage * message,
} }
done: done:
g_mutex_unlock (context->mutex); g_mutex_unlock (&context->mutex);
return FALSE; return FALSE;
} }
@ -526,7 +526,7 @@ convert_frame_need_data_callback (GstElement * src, guint size,
GError *error; GError *error;
GstBuffer *buffer; GstBuffer *buffer;
g_mutex_lock (context->mutex); g_mutex_lock (&context->mutex);
if (context->finished) if (context->finished)
goto done; goto done;
@ -549,7 +549,7 @@ convert_frame_need_data_callback (GstElement * src, guint size,
context); context);
done: done:
g_mutex_unlock (context->mutex); g_mutex_unlock (&context->mutex);
} }
static void static void
@ -559,7 +559,7 @@ convert_frame_new_preroll_callback (GstElement * sink,
GstSample *sample = NULL; GstSample *sample = NULL;
GError *error = NULL; GError *error = NULL;
g_mutex_lock (context->mutex); g_mutex_lock (&context->mutex);
if (context->finished) if (context->finished)
goto done; goto done;
@ -576,7 +576,7 @@ convert_frame_new_preroll_callback (GstElement * sink,
context); context);
done: done:
g_mutex_unlock (context->mutex); g_mutex_unlock (&context->mutex);
} }
/** /**
@ -652,7 +652,7 @@ gst_video_convert_sample_async (GstSample * sample,
bus = gst_element_get_bus (pipeline); bus = gst_element_get_bus (pipeline);
ctx = g_slice_new0 (GstVideoConvertSampleContext); ctx = g_slice_new0 (GstVideoConvertSampleContext);
ctx->mutex = g_mutex_new (); g_mutex_init (&ctx->mutex);
//ctx->buffer = gst_buffer_ref (buf); //ctx->buffer = gst_buffer_ref (buf);
ctx->sample = gst_sample_ref (sample); ctx->sample = gst_sample_ref (sample);
ctx->callback = callback; ctx->callback = callback;