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 796476 - Appsink callback in tutorial is missing the return value
Appsink callback in tutorial is missing the return value
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: documentation
1.14.1
Other All
: Normal minor
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2018-05-31 22:33 UTC by Jacques de Broin
Modified: 2018-06-05 21:33 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gst-docs: add return value to appsink callback in tutorial (1.48 KB, patch)
2018-06-01 23:12 UTC, Jacques de Broin
committed Details | Review
gst-docs: add return value to appsink callback in example code (3.31 KB, patch)
2018-06-04 20:07 UTC, Jacques de Broin
committed Details | Review

Description Jacques de Broin 2018-05-31 22:33:23 UTC
In the "crude waveform generator" sample application in 
"Basic tutorial 8: Short-cutting the pipeline", https://gstreamer.freedesktop.org/documentation/tutorials/basic/short-cutting-the-pipeline.html, please update the new_sample function to return GstFlowReturn values.

static GstFlowReturn new_sample (GstElement *sink, CustomData *data) {
  GstSample *sample;

  /* Retrieve the buffer */
  g_signal_emit_by_name (sink, "pull-sample", &sample);
  if (sample) {
    /* The only thing we do in this example is print a * to indicate a received buffer */
    g_print ("*");
    gst_sample_unref (sample);
    return GST_FLOW_OK;
  }
  return GST_FLOW_ERROR;
}

I spent a while wondering why the callback was only invoked once!
Thanks
Comment 1 Sebastian Dröge (slomo) 2018-06-01 06:51:27 UTC
Thanks! Do you want to provide a patch against the gst-docs repository here or should I just go ahead and fix it?

https://cgit.freedesktop.org/gstreamer/gst-docs
Comment 2 Jacques de Broin 2018-06-01 23:12:02 UTC
Created attachment 372516 [details] [review]
gst-docs: add return value to appsink callback in tutorial
Comment 3 Jacques de Broin 2018-06-01 23:14:34 UTC
My first patch!!!
Comment 4 Sebastian Dröge (slomo) 2018-06-02 15:45:09 UTC
Comment on attachment 372516 [details] [review]
gst-docs: add return value to appsink callback in tutorial

The exactly same change is also needed in examples/tutorials/basic-tutorial-8.c, otherwise this looks great. Thanks! :)
Comment 5 Jacques de Broin 2018-06-04 15:55:40 UTC
Ah, I should have looked there!
It looks like the basic-tutorial-8.c code was fixed in a previous commit: 3be8a37124a9df30a4e3b36ab24956fdd9b052b9.
However, that example code always returns GST_FLOW_OK whether or not a sample was returned by pull_sample. Perhaps it's better that way, i.e. not receiving a sample is not an error condition that the callback needs to communicate back to GStreamer so I should do the same in my patch?
Comment 6 Sebastian Dröge (slomo) 2018-06-04 17:14:35 UTC
No, yours is better :)
Comment 7 Jacques de Broin 2018-06-04 20:07:04 UTC
Created attachment 372544 [details] [review]
gst-docs: add return value to appsink callback in example code
Comment 8 Sebastian Dröge (slomo) 2018-06-05 05:51:28 UTC
commit c25c2967602bce6d980303202b16b66068931665 (HEAD -> master)
Author: Jacques de Broin <jdebroin@yahoo.ca>
Date:   Mon Jun 4 15:55:08 2018 -0400

    gst-docs: add return value to appsink callback in tutorial and example code
    
    The "crude waveform generator" sample application in "Basic
    tutorial 8: Short-cutting the pipeline" was lacking the return value
    so it was only being invoked once.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=796476
Comment 9 Sebastian Dröge (slomo) 2018-06-05 05:51:56 UTC
Thanks :)
Comment 10 Jacques de Broin 2018-06-05 15:18:56 UTC
(In reply to Sebastian Dröge (slomo) from comment #9)
> Thanks :)

Oups, I did not include the first commit in the 2nd patch (I was thinking both patches would be applied).
So master is still missing the first change (in the Walkthrough section). Should I re-open the bug to add an additional patch or is it better to open another bug? Thanks and sorry for the confusion!
Comment 11 Sebastian Dröge (slomo) 2018-06-05 21:33:37 UTC
Comment on attachment 372516 [details] [review]
gst-docs: add return value to appsink callback in tutorial

Sorry for missing that :) This one is also merged now