bo[i] = tbm_bo_import_fd(cb_info->bufmgr, recv_data->tfd[i]);
}
- tsurf_data = g_new(player_tsurf_info_s, 1);
- if (!tsurf_data) {
- LOGE("failed to alloc tsurf info");
- goto ERROR;
- }
- memset(tsurf_data->key, INVALID_DEFAULT_VALUE, sizeof(tsurf_data->key));
-
tsurf = tbm_surface_internal_create_with_bos(&sinfo, bo, bo_num);
if (!tsurf) {
LOGE("failed to create tbm surface");
- g_free(tsurf_data);
goto ERROR;
}
- memcpy(tsurf_data->key, key, sizeof(tsurf_data->key));
- tsurf_data->tsurf = tsurf;
+
if (cb_info->use_tsurf_pool) {
+ tsurf_data = g_try_new(player_tsurf_info_s, 1);
+ if (!tsurf_data) {
+ LOGE("failed to alloc tsurf info");
+ goto ERROR;
+ }
+ memset(tsurf_data->key, INVALID_DEFAULT_VALUE, sizeof(tsurf_data->key));
+
+ memcpy(tsurf_data->key, key, sizeof(tsurf_data->key));
+ tsurf_data->tsurf = tsurf;
+
g_mutex_lock(&cb_info->data_mutex);
cb_info->tsurf_list = g_list_append(cb_info->tsurf_list, tsurf_data);
LOGD("key %d is added to the pool", key[0]);
}
}
- fin_data = g_new0(_media_pkt_video_fin_data, 1);
+ fin_data = g_try_new0(_media_pkt_video_fin_data, 1);
if (!fin_data) {
LOGE("failed to alloc fin_data");
goto ERROR;
ERROR:
if (pkt)
media_packet_destroy(pkt);
+ else if (!tsurf_data && tsurf)
+ tbm_surface_destroy(tsurf);
if (fin_data)
g_free(fin_data);