return MEDIA_PACKET_ERROR_OUT_OF_MEMORY;
}
+ g_atomic_int_set(&new_handle->ref_count, 1);
new_handle->type = type;
new_handle->format = MEDIA_FORMAT_CAST(fmt);
new_handle->finalizecb_func = fcb;
new_handle->userdata = fcb_data;
-
media_format_ref((media_format_h)new_handle->format);
*handle = new_handle;
handle = (media_packet_s *)packet;
+ if (!g_atomic_int_dec_and_test(&handle->ref_count)) {
+ LOGD("ref count %d", g_atomic_int_get(&handle->ref_count));
+ return MEDIA_PACKET_ERROR_NONE;
+ }
+
/* finalize callback */
if (handle->finalizecb_func) {
int finalize_cb_ret;
/* creator do not want to destroy media packet handle */
if (finalize_cb_ret == MEDIA_PACKET_REUSE) {
LOGI("the media packet handle will be reused."); //LCOV_EXCL_LINE
+ g_atomic_int_set(&handle->ref_count, 1);
return MEDIA_PACKET_ERROR_NONE;
}
}