After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 779453 - gst-player: fix gst-player failed to load external subtitle uri
gst-player: fix gst-player failed to load external subtitle uri
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
git master
Other Linux
: Normal normal
: 1.11.90
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2017-03-02 06:41 UTC by Haihua Hu
Modified: 2017-03-09 08:32 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gst-player: fix gst-player failed to load external subtitle uri (1.10 KB, patch)
2017-03-02 06:42 UTC, Haihua Hu
none Details | Review
gst-player: fix gst-player failed to load external subtitle uri (1.32 KB, patch)
2017-03-07 06:26 UTC, Haihua Hu
none Details | Review
gst-player: fix gst-player failed to load external subtitle uri (1.13 KB, patch)
2017-03-08 07:43 UTC, Haihua Hu
none Details | Review
gst-player: fix gst-player failed to load external subtitle uri (1.48 KB, patch)
2017-03-09 05:31 UTC, Haihua Hu
committed Details | Review

Description Haihua Hu 2017-03-02 06:41:43 UTC
set_uri_internal will free subtitle uri but this uri has not been set to playbin by set_suburi_internal
Comment 1 Haihua Hu 2017-03-02 06:42:45 UTC
Created attachment 347027 [details] [review]
gst-player: fix gst-player failed to load external subtitle uri
Comment 2 Sebastian Dröge (slomo) 2017-03-06 09:32:52 UTC
Review of attachment 347027 [details] [review]:

::: gst-libs/gst/player/gstplayer.c
@@ +585,2 @@
   /* if have suburi from previous playback then free it */
+  gchar *suburi = NULL;

Don't put new variable declarations into the middle of a block

@@ +586,3 @@
+  gchar *suburi = NULL;
+  g_object_get(self->playbin, "suburi", &suburi, NULL);
+  if (self->suburi && suburi && strcmp(self->suburi, suburi)==0) {

Shouldn't self->suburi always be the same as playbin's suburi? When is it not?
Comment 3 Haihua Hu 2017-03-06 09:36:35 UTC
(In reply to Sebastian Dröge (slomo) from comment #2)
> Review of attachment 347027 [details] [review] [review]:
> 
> ::: gst-libs/gst/player/gstplayer.c
> @@ +585,2 @@
>    /* if have suburi from previous playback then free it */
> +  gchar *suburi = NULL;
> 
> Don't put new variable declarations into the middle of a block
> 
> @@ +586,3 @@
> +  gchar *suburi = NULL;
> +  g_object_get(self->playbin, "suburi", &suburi, NULL);
> +  if (self->suburi && suburi && strcmp(self->suburi, suburi)==0) {
> 
> Shouldn't self->suburi always be the same as playbin's suburi? When is it
> not?

When there is a suburi from previous playback.
Comment 4 Sebastian Dröge (slomo) 2017-03-06 09:44:30 UTC
Comment on attachment 347027 [details] [review]
gst-player: fix gst-player failed to load external subtitle uri

Ah I see. Then please just update the patch and I'll merge it
Comment 5 Haihua Hu 2017-03-07 06:26:11 UTC
Created attachment 347364 [details] [review]
gst-player: fix gst-player failed to load external subtitle uri
Comment 6 Sebastian Dröge (slomo) 2017-03-07 10:55:45 UTC
Review of attachment 347364 [details] [review]:

Please explain in more detail what this fixes in the commit message. Also we don't use "Signed-off-by: ..."

::: gst-libs/gst/player/gstplayer.c
@@ +586,3 @@
   /* if have suburi from previous playback then free it */
+  g_object_get(self->playbin, "suburi", &suburi, NULL);
+  if (self->suburi && suburi && strcmp(self->suburi, suburi)==0) {

So we reset the suburi here if there was a previous one and it was the same as the current one? Why? Shouldn't we just always reset it to NULL, no matter if playbin or GstPlayer thought there was a previous one or not?


Please also run "gst-indent" over your changes before sending patches.

@@ +590,3 @@
     self->suburi = NULL;
     g_object_set (self->playbin, "suburi", NULL, NULL);
+    g_free (suburi);

You're leaking suburi here if suburi!=NULL but any of the other conditions is false.
Comment 7 Haihua Hu 2017-03-08 07:23:55 UTC
(In reply to Sebastian Dröge (slomo) from comment #6)
> Review of attachment 347364 [details] [review] [review]:
> 
> Please explain in more detail what this fixes in the commit message. Also we
> don't use "Signed-off-by: ..."

Ok.

> 
> ::: gst-libs/gst/player/gstplayer.c
> @@ +586,3 @@
>    /* if have suburi from previous playback then free it */
> +  g_object_get(self->playbin, "suburi", &suburi, NULL);
> +  if (self->suburi && suburi && strcmp(self->suburi, suburi)==0) {
> 
> So we reset the suburi here if there was a previous one and it was the same
> as the current one? Why? Shouldn't we just always reset it to NULL, no
> matter if playbin or GstPlayer thought there was a previous one or not?

Yes, you are right, we just need always reset playbin's suburi to NULL when change uri. Let the application to handle the suburi change and call gst_player_set_suburi() to load new subtitle

> 
> 
> Please also run "gst-indent" over your changes before sending patches.
> 
> @@ +590,3 @@
>      self->suburi = NULL;
>      g_object_set (self->playbin, "suburi", NULL, NULL);
> +    g_free (suburi);
> 
> You're leaking suburi here if suburi!=NULL but any of the other conditions
> is false.
Comment 8 Haihua Hu 2017-03-08 07:43:20 UTC
Created attachment 347444 [details] [review]
gst-player: fix gst-player failed to load external subtitle uri
Comment 9 Sebastian Dröge (slomo) 2017-03-08 07:52:38 UTC
Review of attachment 347444 [details] [review]:

::: gst-libs/gst/player/gstplayer.c
@@ -586,3 @@
-  if (self->suburi) {
-    g_free (self->suburi);
-    self->suburi = NULL;

You're now not freeing self->suburi and not setting it to NULL. Apart from that this looks good now
Comment 10 Haihua Hu 2017-03-08 08:24:48 UTC
(In reply to Sebastian Dröge (slomo) from comment #9)
> Review of attachment 347444 [details] [review] [review]:
> 
> ::: gst-libs/gst/player/gstplayer.c
> @@ -586,3 @@
> -  if (self->suburi) {
> -    g_free (self->suburi);
> -    self->suburi = NULL;
> 
> You're now not freeing self->suburi and not setting it to NULL. Apart from
> that this looks good now

We cannot free and set self->suburi to NULL. Before start play, user may set uri and suburi. After user call set_uri and set_suburi, the two operations will not be conducted immediately. As a result, set_uri_internal will free suburi which is user set at beginning and set_suburi_internal will set NULL to suburi property.
Comment 11 Sebastian Dröge (slomo) 2017-03-08 11:21:35 UTC
Then set_uri() (not set_uri_internal() should probably get rid of the suburi). Or overall the way how uri/suburi setting is done should be refactored.
Comment 12 Haihua Hu 2017-03-09 05:31:57 UTC
Created attachment 347523 [details] [review]
gst-player: fix gst-player failed to load external subtitle uri
Comment 13 Sebastian Dröge (slomo) 2017-03-09 08:32:20 UTC
commit 79be2e8b7b153bb0389fb09951b197a92b493357
Author: Haihua Hu <jared.hu@nxp.com>
Date:   Thu Mar 2 14:36:56 2017 +0800

    player: Fix setting of external subtitle URI
    
    gst_player_set_uri_internal shouldn't free suburi which maybe set
    by user to load external subtitle before start play. It just need
    reset playbin's subutri property to NULL no matter if there was a
    previous one or not.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=779453