+INTERN void
+tdm_pp_destroy_internal(tdm_private_pp *private_pp)
+{
+ tdm_private_display *private_display;
+ tdm_private_module *private_module;
+ tdm_func_pp *func_pp;
+ tdm_pp_private_buffer *b = NULL, *bb = NULL;
+ struct list_head clone_list;
+
+ TDM_RETURN_IF_FAIL(TDM_MUTEX_IS_LOCKED());
+
+ if (!private_pp)
+ return;
+
+ tdm_thread_cb_remove(private_pp, TDM_THREAD_CB_PP_DONE, NULL, _tdm_pp_thread_cb_done, NULL);
+
+ private_display = private_pp->private_display;
+ private_module = private_pp->private_module;
+ func_pp = &private_module->func_pp;
+
+ LIST_DEL(&private_pp->link);
+
+ func_pp->pp_destroy(private_pp->pp_module);
+
+ if (!LIST_IS_EMPTY(&private_pp->pending_buffer_list)) {
+ TDM_WRN("pp(%p) not finished:", private_pp);
+ _tdm_pp_print_list(&private_pp->pending_buffer_list);
+
+ LIST_INITHEAD(&clone_list);
+ LIST_FOR_EACH_ENTRY_SAFE(b, bb, &private_pp->pending_buffer_list, link) {
+ LIST_DEL(&b->link);
+ LIST_ADDTAIL(&b->link, &clone_list);
+ }
+
+ _pthread_mutex_unlock(&private_display->lock);
+ LIST_FOR_EACH_ENTRY_SAFE(b, bb, &clone_list, link) {
+ LIST_DEL(&b->link);
+
+ if (tdm_ttrace_module & TDM_TTRACE_PP) {
+ tbm_bo bo = tbm_surface_internal_get_bo(b->dst, 0);
+ TDM_TRACE_ASYNC_END((intptr_t)private_pp, "[PP] %d", tbm_bo_export(bo));
+ }
+
+ tdm_buffer_unref_backend(b->src);
+ tdm_buffer_unref_backend(b->dst);
+ free(b);
+ }
+ _pthread_mutex_lock(&private_display->lock);
+ }
+
+ if (!LIST_IS_EMPTY(&private_pp->buffer_list)) {
+ TDM_WRN("pp(%p) not finished:", private_pp);
+ _tdm_pp_print_list(&private_pp->buffer_list);
+
+ LIST_INITHEAD(&clone_list);
+ LIST_FOR_EACH_ENTRY_SAFE(b, bb, &private_pp->buffer_list, link) {
+ LIST_DEL(&b->link);
+ LIST_ADDTAIL(&b->link, &clone_list);
+ }
+
+ _pthread_mutex_unlock(&private_display->lock);
+ LIST_FOR_EACH_ENTRY_SAFE(b, bb, &clone_list, link) {
+ LIST_DEL(&b->link);
+
+ if (tdm_ttrace_module & TDM_TTRACE_PP) {
+ tbm_bo bo = tbm_surface_internal_get_bo(b->dst, 0);
+ TDM_TRACE_ASYNC_END((intptr_t)private_pp, "[PP] %d", tbm_bo_export(bo));
+ }
+
+ tdm_buffer_unref_backend(b->src);
+ tdm_buffer_unref_backend(b->dst);
+ free(b);
+ }
+ _pthread_mutex_lock(&private_display->lock);
+ }
+
+ private_pp->stamp = 0;
+ free(private_pp);
+}