Appsink buffer size

Hello everybody!

How can I dynamically set the size of the buffer that appsink passes to the host application?

I have the following pipeline:

GstElement *pipeline = gst_parse_launch("audiotestsrc wave=sine ! audio/x-raw,format=F64LE,channels=1,rate=%d ! appsink name=maxsink" NULL);

where rate can be set according to the settings of the host application, but the sample format MUST be double (hence F64LE).
As far as I understood there are different ways to set the number of samples/bytes that appsink can store. Let’s say that the application’s block_size=128, how do I pull 128 samples (1024 bytes …right?) from appsink.
I tried:

// directly modifying the pipeline
appsink name=maxsink max-byte=1024
// or after the pipeline's initialization
GstElement *appsink = GST_APP_SINK(gst_bin_get_by_name(GST_BIN(x->pipeline), "maxsink"));
g_object_set(appsink, "max-bytes",1024);
// or
gst_app_sink_set_max_bytes(x->appsink,1024)

But matter what I do, when I pull the sample from appsink (I am using gst_app_sink_try_pull_sample) the data size is always 8192.

For completeness these are the properties that I have been using for appsink:

g_object_set(sink,
    "emit-signals", FALSE,
    "max-buffers", 1,
    "drop", TRUE,
    "async", FALSE,
    "sync", FALSE,
    NULL
);

Thank you!

The producer decides how many samples go into a buffer.

In this case you have two options:

  1. audiotestsrc samplesperbuffer=128
  2. … ! audiobuffersplit output-buffer-duration=128/44100 ! …