mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-07 07:58:51 +00:00
transcoder: Base sync transcoding variant on a GMainLoop
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1151>
This commit is contained in:
parent
6d8133e41e
commit
7d1f5e951f
1 changed files with 13 additions and 26 deletions
|
@ -1065,33 +1065,23 @@ gst_transcoder_new_full (const gchar * source_uri,
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
GError **user_error;
|
GError *error;
|
||||||
GMutex m;
|
GMainLoop *loop;
|
||||||
GCond cond;
|
|
||||||
|
|
||||||
gboolean done;
|
|
||||||
|
|
||||||
} RunSyncData;
|
} RunSyncData;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_error_cb (GstTranscoder * self, GError * error, GstStructure * details,
|
_error_cb (GstTranscoder * self, GError * error, GstStructure * details,
|
||||||
RunSyncData * data)
|
RunSyncData * data)
|
||||||
{
|
{
|
||||||
g_mutex_lock (&data->m);
|
if (data->error == NULL)
|
||||||
data->done = TRUE;
|
g_propagate_error (&data->error, error);
|
||||||
if (data->user_error && (*data->user_error) == NULL)
|
g_main_loop_quit (data->loop);
|
||||||
g_propagate_error (data->user_error, error);
|
|
||||||
g_cond_broadcast (&data->cond);
|
|
||||||
g_mutex_unlock (&data->m);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_done_cb (GstTranscoder * self, RunSyncData * data)
|
_done_cb (GstTranscoder * self, RunSyncData * data)
|
||||||
{
|
{
|
||||||
g_mutex_lock (&data->m);
|
g_main_loop_quit (data->loop);
|
||||||
data->done = TRUE;
|
|
||||||
g_cond_broadcast (&data->cond);
|
|
||||||
g_mutex_unlock (&data->m);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1108,22 +1098,19 @@ gst_transcoder_run (GstTranscoder * self, GError ** error)
|
||||||
{
|
{
|
||||||
RunSyncData data = { 0, };
|
RunSyncData data = { 0, };
|
||||||
|
|
||||||
g_mutex_init (&data.m);
|
data.loop = g_main_loop_new (NULL, FALSE);
|
||||||
g_cond_init (&data.cond);
|
|
||||||
|
|
||||||
g_signal_connect (self, "error", G_CALLBACK (_error_cb), &data);
|
g_signal_connect (self, "error", G_CALLBACK (_error_cb), &data);
|
||||||
g_signal_connect (self, "done", G_CALLBACK (_done_cb), &data);
|
g_signal_connect (self, "done", G_CALLBACK (_done_cb), &data);
|
||||||
gst_transcoder_run_async (self);
|
gst_transcoder_run_async (self);
|
||||||
|
|
||||||
g_mutex_lock (&data.m);
|
if (!data.error)
|
||||||
while (!data.done) {
|
g_main_loop_run (data.loop);
|
||||||
g_cond_wait (&data.cond, &data.m);
|
|
||||||
}
|
|
||||||
g_mutex_unlock (&data.m);
|
|
||||||
|
|
||||||
if (data.user_error) {
|
if (data.error) {
|
||||||
g_propagate_error (error, *data.user_error);
|
if (error)
|
||||||
|
g_propagate_error (error, data.error);
|
||||||
|
|
||||||
|
g_clear_error (&data.error);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue