#include <media_format.h>
#include <media_packet.h>
#include <media_packet_private.h>
+#include <tbm_surface_internal.h>
static int __pkt_init(media_buffer_type_e type, media_format_h fmt, void *cb, void *cb_data, bool is_from_new, media_packet_s **handle);
static void __pkt_deinit(media_packet_s *handle);
return ret;
}
+ tbm_surface_internal_ref(surface);
+
handle->surface_data = (void *)surface;
handle->data = surface_info.planes[0].ptr;
handle->size = (uint64_t)surface_info.size;
switch (handle->type) {
case MEDIA_BUFFER_TYPE_TBM_SURFACE:
- if (handle->surface_data) {
- tbm_surface_destroy((tbm_surface_h)handle->surface_data);
- handle->surface_data = NULL;
- }
+ /* fall through */
+ case MEDIA_BUFFER_TYPE_EXTERNAL_TBM_SURFACE:
+ tbm_surface_internal_unref((tbm_surface_h)handle->surface_data);
+ handle->surface_data = NULL;
break;
case MEDIA_BUFFER_TYPE_NORMAL:
if (handle->data) {
handle->data = NULL;
}
break;
- case MEDIA_BUFFER_TYPE_EXTERNAL_TBM_SURFACE:
- /* fall through */
case MEDIA_BUFFER_TYPE_EXTERNAL_MEMORY:
/* there is nothing to do, Do not free the buffer which is created by external module. */
break;