diff options
author | Thibault Saunier <tsaunier@igalia.com> | 2020-12-10 16:29:31 -0300 |
---|---|---|
committer | GStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org> | 2020-12-14 12:30:14 +0000 |
commit | 76bc578bae093944fbf86335a99bff2d2927a58f (patch) | |
tree | 577f57c31c81bd22ad497fe3f0beeae82e39b1c8 | |
parent | 3ce1086b14d63a7915f6de7149f5bcc8e509e4d5 (diff) | |
download | gstreamer-plugins-bad-76bc578bae093944fbf86335a99bff2d2927a58f.tar.gz |
player/transcoder: Use bus signal watch
Instead of implementing exactly the same thing ourself but making
`GstBus` not know that it is the case.
Since we are *sure* that the bus can't have been access at the point
where we add the watch we are guaranteed that the current thread
maincontext is going to be used.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1870>
-rw-r--r-- | gst-libs/gst/player/gstplayer.c | 9 | ||||
-rw-r--r-- | gst-libs/gst/transcoder/gsttranscoder.c | 9 |
2 files changed, 4 insertions, 14 deletions
diff --git a/gst-libs/gst/player/gstplayer.c b/gst-libs/gst/player/gstplayer.c index b72c8deff..07b7ae2ba 100644 --- a/gst-libs/gst/player/gstplayer.c +++ b/gst-libs/gst/player/gstplayer.c @@ -2877,7 +2877,6 @@ gst_player_main (gpointer data) GstPlayer *self = GST_PLAYER (data); GstBus *bus; GSource *source; - GSource *bus_source; GstElement *scaletempo; const gchar *env; @@ -2927,10 +2926,7 @@ gst_player_main (gpointer data) } self->bus = bus = gst_element_get_bus (self->playbin); - bus_source = gst_bus_create_watch (bus); - g_source_set_callback (bus_source, (GSourceFunc) gst_bus_async_signal_func, - NULL, NULL); - g_source_attach (bus_source, self->context); + gst_bus_add_signal_watch (bus); g_signal_connect (G_OBJECT (bus), "message::error", G_CALLBACK (error_cb), self); @@ -2993,8 +2989,7 @@ gst_player_main (gpointer data) g_main_loop_run (self->loop); GST_TRACE_OBJECT (self, "Stopped main loop"); - g_source_destroy (bus_source); - g_source_unref (bus_source); + gst_bus_remove_signal_watch (bus); gst_object_unref (bus); remove_tick_source (self); diff --git a/gst-libs/gst/transcoder/gsttranscoder.c b/gst-libs/gst/transcoder/gsttranscoder.c index ec2eacbdd..1083616a1 100644 --- a/gst-libs/gst/transcoder/gsttranscoder.c +++ b/gst-libs/gst/transcoder/gsttranscoder.c @@ -920,7 +920,6 @@ gst_transcoder_main (gpointer data) GstTranscoder *self = GST_TRANSCODER (data); GstBus *bus; GSource *source; - GSource *bus_source; GST_TRACE_OBJECT (self, "Starting main thread"); @@ -933,10 +932,7 @@ gst_transcoder_main (gpointer data) g_source_unref (source); self->bus = bus = gst_element_get_bus (self->transcodebin); - bus_source = gst_bus_create_watch (bus); - g_source_set_callback (bus_source, (GSourceFunc) gst_bus_async_signal_func, - NULL, NULL); - g_source_attach (bus_source, self->context); + gst_bus_add_signal_watch (bus); g_signal_connect (G_OBJECT (bus), "message::error", G_CALLBACK (error_cb), self); @@ -965,8 +961,7 @@ gst_transcoder_main (gpointer data) g_main_loop_run (self->loop); GST_TRACE_OBJECT (self, "Stopped main loop"); - g_source_destroy (bus_source); - g_source_unref (bus_source); + gst_bus_remove_signal_watch (bus); gst_object_unref (bus); remove_tick_source (self); |