I:
- Create
android::MediaBufferGroup
; - Fill it up with multiple
buf_group.add_buffer(new android::MediaBuffer(bufsize));
on initialisation; - Do
buf_group->acquire_buffer(&buffer)
when I need a buffer to send somewhere; - Use
buffer->data()
to get actual memory location to store the data at, useset_range
and set up metadata, then feed the buffer into other component; - That other component
release
s the buffer, retuning them back to the MediaBufferGroup.
It works, but not reliably. Sometimes acquired buffer's data()
returns NULL, sometimes the program crashes on release()
...
How to use MediaBufferGroup properly? Should I use some synchronization?