From dea77cc39f848664f0bee7212613ae45292ceddd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Thu, 28 Jan 2021 17:39:52 +0100 Subject: [PATCH] API: notify about speed value reset on STOP --- lib/gst/clapper/gstclapper.c | 25 ++++++++++++++++++++++++- src/player.js | 5 ----- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/lib/gst/clapper/gstclapper.c b/lib/gst/clapper/gstclapper.c index c8c2cf63..47d7a74f 100644 --- a/lib/gst/clapper/gstclapper.c +++ b/lib/gst/clapper/gstclapper.c @@ -850,6 +850,25 @@ state_changed_signal_data_free (StateChangedSignalData * data) g_free (data); } +static void +rate_notify_dispatch (gpointer user_data) +{ + GstClapper *clapper = user_data; + + if (clapper->inhibit_sigs) + return; + + g_object_notify_by_pspec (G_OBJECT (clapper), param_specs[PROP_RATE]); +} + +static void +emit_rate_notify (GstClapper * self) +{ + gst_clapper_signal_dispatcher_dispatch (self->signal_dispatcher, self, + rate_notify_dispatch, g_object_ref (self), + (GDestroyNotify) g_object_unref); +} + static void change_state (GstClapper * self, GstClapperState state) { @@ -861,6 +880,11 @@ change_state (GstClapper * self, GstClapperState state) gst_clapper_state_get_name (state)); self->app_state = state; + if (state == GST_CLAPPER_STATE_STOPPED && self->rate != 1.0) { + self->rate = 1.0; + emit_rate_notify (self); + } + if (g_signal_handler_find (self, G_SIGNAL_MATCH_ID, signals[SIGNAL_STATE_CHANGED], 0, NULL, NULL, NULL) != 0) { StateChangedSignalData *data = g_new (StateChangedSignalData, 1); @@ -3127,7 +3151,6 @@ gst_clapper_stop_internal (GstClapper * self, gboolean transient) remove_seek_source (self); self->seek_position = GST_CLOCK_TIME_NONE; self->last_seek_time = GST_CLOCK_TIME_NONE; - self->rate = 1.0; if (self->collection) { if (self->stream_notify_id) g_signal_handler_disconnect (self->collection, self->stream_notify_id); diff --git a/src/player.js b/src/player.js index 21f31bd0..9f8e85d2 100644 --- a/src/player.js +++ b/src/player.js @@ -78,11 +78,6 @@ class ClapperPlayer extends PlayerBase set_uri(uri) { - /* FIXME: Player does not notify about - * rate change after file load */ - if(this.rate !== 1) - this.set_rate(1); - if(Gst.Uri.get_protocol(uri) !== 'file') return super.set_uri(uri);