void obs_source_destroy(struct obs_source *source) { size_t i; if (!source) return; obs_context_data_remove(&source->context); obs_source_dosignal(source, "source_destroy", "destroy"); if (source->context.data) source->info.destroy(source->context.data); if (source->filter_parent) obs_source_filter_remove(source->filter_parent, source); for (i = 0; i < source->filters.num; i++) obs_source_release(source->filters.array[i]); for (i = 0; i < source->video_frames.num; i++) source_frame_destroy(source->video_frames.array[i]); gs_entercontext(obs->video.graphics); texrender_destroy(source->async_convert_texrender); texture_destroy(source->async_texture); gs_leavecontext(); for (i = 0; i < MAX_AV_PLANES; i++) bfree(source->audio_data.data[i]); audio_line_destroy(source->audio_line); audio_resampler_destroy(source->resampler); texrender_destroy(source->filter_texrender); da_free(source->video_frames); da_free(source->filters); pthread_mutex_destroy(&source->filter_mutex); pthread_mutex_destroy(&source->audio_mutex); pthread_mutex_destroy(&source->video_mutex); obs_context_data_free(&source->context); bfree(source); }
void test_destroy(struct test_filter *tf) { if (tf) { gs_entercontext(obs_graphics()); effect_destroy(tf->whatever); texrender_destroy(tf->texrender); bfree(tf); gs_leavecontext(); } }
static inline bool set_async_texture_size(struct obs_source *source, struct source_frame *frame) { enum convert_type prev, cur; prev = get_convert_type(source->async_format); cur = get_convert_type(frame->format); if (source->async_texture) { if (source->async_width == frame->width && source->async_height == frame->height && prev == cur) return true; } texture_destroy(source->async_texture); texrender_destroy(source->async_convert_texrender); source->async_convert_texrender = NULL; if (cur != CONVERT_NONE && init_gpu_conversion(source, frame)) { source->async_gpu_conversion = true; source->async_convert_texrender = texrender_create(GS_RGBA, GS_ZS_NONE); source->async_texture = gs_create_texture( source->async_convert_width, source->async_convert_height, GS_RGBA, 1, NULL, GS_DYNAMIC); } else { source->async_gpu_conversion = false; source->async_texture = gs_create_texture( frame->width, frame->height, GS_RGBA, 1, NULL, GS_DYNAMIC); } if (!source->async_texture) return false; source->async_width = frame->width; source->async_height = frame->height; return true; }