Skip to content

Instantly share code, notes, and snippets.

@tetkuz
Created May 25, 2016 02:48
Show Gist options
  • Save tetkuz/080a942a4947310d7cbddd10fc92c8e5 to your computer and use it in GitHub Desktop.
Save tetkuz/080a942a4947310d7cbddd10fc92c8e5 to your computer and use it in GitHub Desktop.
gst_memory and notify
#include <stdio.h>
#include <gst/gst.h>
void notify_func(gpointer data)
{
(void) data;
g_print ("from buffer_notify()\n");
}
int main (int argc, char *argv[])
{
GstMemory *mem;
GString *text;
gst_init (&argc, &argv);
text = g_string_new ("Hello");
mem = gst_memory_new_wrapped (GST_MEMORY_FLAG_NO_SHARE,
text->str, text->allocated_len, 0, text->len,
NULL, (GDestroyNotify)notify_func);
{
GstMapInfo info;
if (gst_memory_map (mem, &info, GST_MAP_READ)) {
g_print ("data: %s\n", info.data);
gst_memory_unmap (mem, &info);
}
}
gst_memory_unref(mem);
return 0;
}

gst_memory_unref() のタイミングでなんらかの処理を実行したい時には、 _new_wrapped() の notify に callback 関数を登録する。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment