static void gf_cm_unit_del(GF_CMUnit *cb) { if (cb->next) gf_cm_unit_del(cb->next); cb->next = NULL; if (cb->data) { free(cb->data); cb->data = NULL; } free(cb); }
static void gf_cm_unit_del(GF_CMUnit *cb, Bool no_data_allocation) { if (!cb) return; if (cb->next) gf_cm_unit_del(cb->next, no_data_allocation); cb->next = NULL; if (cb->data) { if (!no_data_allocation) { my_large_gf_free(cb->data); } cb->data = NULL; } gf_free(cb); }
void gf_cm_del(GF_CompositionMemory *cb) { gf_odm_lock(cb->odm, 1); /*may happen when CB is destroyed right after creation in case*/ if (cb->Status == CB_BUFFER) { gf_clock_buffer_off(cb->odm->codec->ck); GF_LOG(GF_LOG_DEBUG, GF_LOG_SYNC, ("[SyncLayer] ODM%d: buffering off at %d (nb buffering on clock: %d)\n", cb->odm->OD->objectDescriptorID, gf_term_get_time(cb->odm->term), cb->odm->codec->ck->Buffering)); } /*break the loop and destroy*/ cb->input->prev->next = NULL; gf_cm_unit_del(cb->input); gf_odm_lock(cb->odm, 0); free(cb); }
/*resize buffers (blocking)*/ void gf_cm_reinit(GF_CompositionMemory *cb, u32 UnitSize, u32 Capacity) { GF_CMUnit *cu, *prev; u32 i; if (!Capacity || !UnitSize) return; gf_odm_lock(cb->odm, 1); if (cb->input){ /*break the loop and destroy*/ cb->input->prev->next = NULL; gf_cm_unit_del(cb->input, cb->no_allocation); cb->input = NULL; } cu = NULL; cb->Capacity = Capacity; cb->UnitSize = UnitSize; prev = NULL; i = 1; while (Capacity) { cu = gf_cm_unit_new(); if (!prev) { cb->input = cu; } else { prev->next = cu; cu->prev = prev; } cu->dataLength = 0; if (cb->no_allocation) { cu->data = NULL; } else { cu->data = (char*)my_large_alloc(UnitSize); } prev = cu; Capacity --; i++; } cu->next = cb->input; cb->input->prev = cu; cb->output = cb->input; gf_odm_lock(cb->odm, 0); }