GNOME Bugzilla – Bug 796476
Appsink callback in tutorial is missing the return value
Last modified: 2018-06-05 21:33:37 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
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
Created attachment 372516 [details] [review] gst-docs: add return value to appsink callback in tutorial
My first patch!!!
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! :)
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?
No, yours is better :)
Created attachment 372544 [details] [review] gst-docs: add return value to appsink callback in example code
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
Thanks :)
(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 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