diff --git a/src/filters/analog-glitch.c b/src/filters/analog-glitch.c index 273701e..6a4b729 100644 --- a/src/filters/analog-glitch.c +++ b/src/filters/analog-glitch.c @@ -24,8 +24,13 @@ void analog_glitch_destroy(retro_effects_filter_data_t *filter) obs_leave_graphics(); - obs_data_t *settings = obs_source_get_settings(filter->base->context); - // obs_data_unset_user_value(settings, "analog_glitch_size"); + bfree(filter->active_filter_data); + filter->active_filter_data = NULL; +} + +void analog_glitch_unset_settings(retro_effects_filter_data_t* filter) +{ + obs_data_t* settings = obs_source_get_settings(filter->base->context); obs_data_unset_user_value(settings, "analog_glitch_primary_speed"); obs_data_unset_user_value(settings, "analog_glitch_primary_scale"); obs_data_unset_user_value(settings, "analog_glitch_secondary_speed"); @@ -40,9 +45,6 @@ void analog_glitch_destroy(retro_effects_filter_data_t *filter) obs_data_unset_user_value(settings, "analog_glitch_line_magnitude"); obs_data_unset_user_value(settings, "analog_glitch_interfence_alpha"); obs_data_release(settings); - - bfree(filter->active_filter_data); - filter->active_filter_data = NULL; } void analog_glitch_filter_update(retro_effects_filter_data_t *data, @@ -325,6 +327,7 @@ static void analog_glitch_set_functions(retro_effects_filter_data_t *filter) filter->filter_defaults = analog_glitch_filter_defaults; filter->filter_update = analog_glitch_filter_update; filter->filter_video_tick = analog_glitch_filter_video_tick; + filter->filter_unset_settings = analog_glitch_unset_settings; } void analog_glitch_filter_video_tick(retro_effects_filter_data_t *data, diff --git a/src/filters/analog-glitch.h b/src/filters/analog-glitch.h index f5ddb8e..aa16802 100644 --- a/src/filters/analog-glitch.h +++ b/src/filters/analog-glitch.h @@ -51,6 +51,7 @@ struct analog_glitch_filter_data { extern void analog_glitch_create(retro_effects_filter_data_t *filter); extern void analog_glitch_destroy(retro_effects_filter_data_t *filter); +extern void analog_glitch_unset_settings(retro_effects_filter_data_t* filter); extern void analog_glitch_filter_video_render(retro_effects_filter_data_t *data); extern void analog_glitch_filter_video_tick(retro_effects_filter_data_t *data, float seconds); diff --git a/src/filters/bloom-f.c b/src/filters/bloom-f.c index a88ed7f..2f15293 100644 --- a/src/filters/bloom-f.c +++ b/src/filters/bloom-f.c @@ -20,8 +20,13 @@ void bloom_f_destroy(retro_effects_filter_data_t *filter) obs_leave_graphics(); - obs_data_t *settings = obs_source_get_settings(filter->base->context); + bfree(filter->active_filter_data); + filter->active_filter_data = NULL; +} +void bloom_f_unset_settings(retro_effects_filter_data_t* filter) +{ + obs_data_t* settings = obs_source_get_settings(filter->base->context); obs_data_unset_user_value(settings, "bloom_intensity"); obs_data_unset_user_value(settings, "bloom_threshold"); obs_data_unset_user_value(settings, "bloom_size"); @@ -29,11 +34,7 @@ void bloom_f_destroy(retro_effects_filter_data_t *filter) obs_data_unset_user_value(settings, "bloom_red_level"); obs_data_unset_user_value(settings, "bloom_green_level"); obs_data_unset_user_value(settings, "bloom_blue_level"); - obs_data_release(settings); - - bfree(filter->active_filter_data); - filter->active_filter_data = NULL; } void bloom_f_filter_update(retro_effects_filter_data_t *data, @@ -183,6 +184,7 @@ static void bloom_f_set_functions(retro_effects_filter_data_t *filter) filter->filter_defaults = bloom_f_filter_defaults; filter->filter_update = bloom_f_filter_update; filter->filter_video_tick = NULL; + filter->filter_unset_settings = bloom_f_unset_settings; } static bool threshold_type_modified(void *data, obs_properties_t *props, diff --git a/src/filters/bloom-f.h b/src/filters/bloom-f.h index f1cd636..533286b 100644 --- a/src/filters/bloom-f.h +++ b/src/filters/bloom-f.h @@ -35,6 +35,8 @@ struct bloom_f_filter_data { extern void bloom_f_create(retro_effects_filter_data_t *filter); extern void bloom_f_destroy(retro_effects_filter_data_t *filter); +extern void bloom_f_unset_settings(retro_effects_filter_data_t* filter); + extern void bloom_f_filter_video_render(retro_effects_filter_data_t *data); extern void bloom_f_filter_properties(retro_effects_filter_data_t *data, obs_properties_t *props); diff --git a/src/filters/cathode-boot.c b/src/filters/cathode-boot.c index 6c55702..d676e0b 100644 --- a/src/filters/cathode-boot.c +++ b/src/filters/cathode-boot.c @@ -17,14 +17,20 @@ void cathode_boot_create(retro_effects_filter_data_t *filter) void cathode_boot_destroy(retro_effects_filter_data_t *filter) { cathode_boot_filter_data_t *data = filter->active_filter_data; + obs_enter_graphics(); if (data->effect_cathode_boot) { gs_effect_destroy(data->effect_cathode_boot); } - obs_leave_graphics(); - obs_data_t *settings = obs_source_get_settings(filter->base->context); + bfree(filter->active_filter_data); + filter->active_filter_data = NULL; +} + +void cathode_boot_unset_settings(retro_effects_filter_data_t* filter) +{ + obs_data_t* settings = obs_source_get_settings(filter->base->context); obs_data_unset_user_value(settings, "cathode_boot_progress"); obs_data_unset_user_value(settings, "cathode_boot_vert_thickness"); obs_data_unset_user_value(settings, "cathode_boot_vert_start"); @@ -36,9 +42,6 @@ void cathode_boot_destroy(retro_effects_filter_data_t *filter) obs_data_unset_user_value(settings, "cathode_boot_fade_end"); obs_data_unset_user_value(settings, "cathode_boot_glow_size"); obs_data_release(settings); - - bfree(filter->active_filter_data); - filter->active_filter_data = NULL; } void cathode_boot_filter_update(retro_effects_filter_data_t *data, @@ -72,7 +75,6 @@ void cathode_boot_filter_defaults(obs_data_t *settings) { obs_data_set_default_double(settings, "cathode_boot_vert_thickness", 1.0); obs_data_set_default_double(settings, "cathode_boot_horiz_thickness", 1.0); obs_data_set_default_double(settings, "cathode_boot_glow_size", 2.0); - } void cathode_boot_filter_properties(retro_effects_filter_data_t *data, @@ -239,6 +241,7 @@ static void cathode_boot_set_functions(retro_effects_filter_data_t *filter) filter->filter_defaults = cathode_boot_filter_defaults; filter->filter_update = cathode_boot_filter_update; filter->filter_video_tick = NULL; + filter->filter_unset_settings = cathode_boot_unset_settings; } static void cathode_boot_load_effect(cathode_boot_filter_data_t *filter) diff --git a/src/filters/cathode-boot.h b/src/filters/cathode-boot.h index 77417ed..1217d4f 100644 --- a/src/filters/cathode-boot.h +++ b/src/filters/cathode-boot.h @@ -29,6 +29,8 @@ struct cathode_boot_filter_data { extern void cathode_boot_create(retro_effects_filter_data_t *filter); extern void cathode_boot_destroy(retro_effects_filter_data_t *filter); +extern void cathode_boot_unset_settings(retro_effects_filter_data_t* filter); + extern void cathode_boot_filter_video_render(retro_effects_filter_data_t *data); extern void cathode_boot_filter_properties(retro_effects_filter_data_t *data, obs_properties_t *props); @@ -37,9 +39,3 @@ extern void cathode_boot_filter_update(retro_effects_filter_data_t *data, obs_data_t *settings); static void cathode_boot_set_functions(retro_effects_filter_data_t *filter); static void cathode_boot_load_effect(cathode_boot_filter_data_t *filter); -static bool cathode_boot_type_modified(obs_properties_t *props, - obs_property_t *p, obs_data_t *settings); -static bool cathode_boot_bayer_size_modified(void *data, - obs_properties_t *props, - obs_property_t *p, - obs_data_t *settings); diff --git a/src/filters/chromatic-aberration.c b/src/filters/chromatic-aberration.c index 56e3a74..6b7e392 100644 --- a/src/filters/chromatic-aberration.c +++ b/src/filters/chromatic-aberration.c @@ -20,7 +20,13 @@ void chromatic_aberration_destroy(retro_effects_filter_data_t *filter) obs_leave_graphics(); - obs_data_t *settings = obs_source_get_settings(filter->base->context); + bfree(filter->active_filter_data); + filter->active_filter_data = NULL; +} + +void chromatic_aberration_unset_settings(retro_effects_filter_data_t* filter) +{ + obs_data_t* settings = obs_source_get_settings(filter->base->context); obs_data_unset_user_value(settings, "ca_type"); obs_data_unset_user_value(settings, "ca_red_offset"); obs_data_unset_user_value(settings, "ca_red_offset_angle"); @@ -29,9 +35,6 @@ void chromatic_aberration_destroy(retro_effects_filter_data_t *filter) obs_data_unset_user_value(settings, "ca_blue_offset"); obs_data_unset_user_value(settings, "ca_blue_offset_angle"); obs_data_release(settings); - - bfree(filter->active_filter_data); - filter->active_filter_data = NULL; } void chromatic_aberration_filter_update(retro_effects_filter_data_t *data, @@ -227,6 +230,7 @@ chromatic_aberration_set_functions(retro_effects_filter_data_t *filter) filter->filter_defaults = chromatic_aberration_filter_defaults; filter->filter_update = chromatic_aberration_filter_update; filter->filter_video_tick = NULL; + filter->filter_unset_settings = chromatic_aberration_unset_settings; } static void diff --git a/src/filters/chromatic-aberration.h b/src/filters/chromatic-aberration.h index b2d3b5f..1503984 100644 --- a/src/filters/chromatic-aberration.h +++ b/src/filters/chromatic-aberration.h @@ -30,6 +30,8 @@ struct chromatic_aberration_filter_data { extern void chromatic_aberration_create(retro_effects_filter_data_t *filter); extern void chromatic_aberration_destroy(retro_effects_filter_data_t *filter); +extern void chromatic_aberration_unset_settings(retro_effects_filter_data_t* filter); + extern void chromatic_aberration_filter_video_render(retro_effects_filter_data_t *data); extern void chromatic_aberration_filter_properties(retro_effects_filter_data_t *data, obs_properties_t *props); diff --git a/src/filters/codec.c b/src/filters/codec.c index 3e415c4..56ec376 100644 --- a/src/filters/codec.c +++ b/src/filters/codec.c @@ -32,7 +32,13 @@ void codec_destroy(retro_effects_filter_data_t *filter) } obs_leave_graphics(); - obs_data_t *settings = obs_source_get_settings(filter->base->context); + bfree(filter->active_filter_data); + filter->active_filter_data = NULL; +} + +void codec_unset_settings(retro_effects_filter_data_t* filter) +{ + obs_data_t* settings = obs_source_get_settings(filter->base->context); obs_data_unset_user_value(settings, "codec_px_scale"); obs_data_unset_user_value(settings, "codec_colors_per_channel"); obs_data_unset_user_value(settings, "codec_quality"); @@ -42,9 +48,6 @@ void codec_destroy(retro_effects_filter_data_t *filter) obs_data_unset_user_value(settings, "codec_rpza_threshold_solid"); obs_data_unset_user_value(settings, "codec_rpza_threshold_gradient"); obs_data_release(settings); - - bfree(filter->active_filter_data); - filter->active_filter_data = NULL; } float lerp(float x, float y, float a) @@ -345,6 +348,7 @@ codec_set_functions(retro_effects_filter_data_t *filter) filter->filter_defaults = codec_filter_defaults; filter->filter_update = codec_filter_update; filter->filter_video_tick = codec_filter_video_tick; + filter->filter_unset_settings = codec_unset_settings; } static void codec_load_effect(codec_filter_data_t *filter) @@ -374,7 +378,7 @@ static void codec_load_effect(codec_filter_data_t *filter) } filter->effect_codec = gs_effect_create(shader_dstr.array, NULL, &errors); obs_leave_graphics(); - + dstr_free(&shader_dstr); bfree(shader_text); if (filter->effect_codec == NULL) { blog(LOG_WARNING, diff --git a/src/filters/codec.h b/src/filters/codec.h index ba37ee3..1b60cce 100644 --- a/src/filters/codec.h +++ b/src/filters/codec.h @@ -55,6 +55,8 @@ struct codec_filter_data { extern void codec_create(retro_effects_filter_data_t *filter); extern void codec_destroy(retro_effects_filter_data_t *filter); +extern void codec_unset_settings(retro_effects_filter_data_t* filter); + extern void codec_filter_video_tick(retro_effects_filter_data_t *data, float seconds); extern void codec_filter_video_render(retro_effects_filter_data_t *data); extern void codec_filter_properties(retro_effects_filter_data_t *data, diff --git a/src/filters/crt.c b/src/filters/crt.c index eb3ced3..69995df 100644 --- a/src/filters/crt.c +++ b/src/filters/crt.c @@ -15,9 +15,9 @@ void crt_create(retro_effects_filter_data_t *filter) obs_data_release(settings); } -void crt_destroy(retro_effects_filter_data_t *filter) +void crt_destroy(retro_effects_filter_data_t* filter) { - crt_filter_data_t *data = filter->active_filter_data; + crt_filter_data_t* data = filter->active_filter_data; obs_enter_graphics(); if (data->effect_crt) { gs_effect_destroy(data->effect_crt); @@ -30,7 +30,13 @@ void crt_destroy(retro_effects_filter_data_t *filter) } obs_leave_graphics(); - obs_data_t *settings = obs_source_get_settings(filter->base->context); + bfree(filter->active_filter_data); + filter->active_filter_data = NULL; +} + +void crt_unset_settings(retro_effects_filter_data_t* filter) +{ + obs_data_t* settings = obs_source_get_settings(filter->base->context); obs_data_unset_user_value(settings, "crt_phosphor_type"); obs_data_unset_user_value(settings, "crt_mask_intensity"); obs_data_unset_user_value(settings, "crt_bloom"); @@ -41,9 +47,6 @@ void crt_destroy(retro_effects_filter_data_t *filter) obs_data_unset_user_value(settings, "crt_black_level"); obs_data_unset_user_value(settings, "crt_white_level"); obs_data_release(settings); - - bfree(filter->active_filter_data); - filter->active_filter_data = NULL; } void crt_filter_update(retro_effects_filter_data_t *data, obs_data_t *settings) @@ -344,6 +347,7 @@ static void crt_set_functions(retro_effects_filter_data_t *filter) filter->filter_defaults = crt_filter_defaults; filter->filter_update = crt_filter_update; filter->filter_video_tick = NULL; + filter->filter_unset_settings = crt_unset_settings; } static void crt_load_effect(crt_filter_data_t *filter) diff --git a/src/filters/crt.h b/src/filters/crt.h index 3e77dd6..cc04565 100644 --- a/src/filters/crt.h +++ b/src/filters/crt.h @@ -46,6 +46,8 @@ struct crt_filter_data { extern void crt_create(retro_effects_filter_data_t *filter); extern void crt_destroy(retro_effects_filter_data_t *filter); +extern void crt_unset_settings(retro_effects_filter_data_t* filter); + extern void crt_filter_video_render(retro_effects_filter_data_t *data); extern void crt_filter_properties(retro_effects_filter_data_t *data, obs_properties_t *props); diff --git a/src/filters/digital-glitch.c b/src/filters/digital-glitch.c index 4ee70fc..157971c 100644 --- a/src/filters/digital-glitch.c +++ b/src/filters/digital-glitch.c @@ -39,8 +39,15 @@ void digital_glitch_destroy(retro_effects_filter_data_t *filter) da_free(data->horiz_grid); da_free(data->vert_grid); + da_free(data->rgb_drift_grid); - obs_data_t *settings = obs_source_get_settings(filter->base->context); + bfree(filter->active_filter_data); + filter->active_filter_data = NULL; +} + +void digital_glitch_unset_settings(retro_effects_filter_data_t* filter) +{ + obs_data_t* settings = obs_source_get_settings(filter->base->context); obs_data_unset_user_value(settings, "digital_glitch_amount"); obs_data_unset_user_value(settings, "digital_glitch_max_disp"); obs_data_unset_user_value(settings, "digital_glitch_min_block_width"); @@ -52,9 +59,6 @@ void digital_glitch_destroy(retro_effects_filter_data_t *filter) obs_data_unset_user_value(settings, "digital_glitch_min_rgb_interval"); obs_data_unset_user_value(settings, "digital_glitch_max_rgb_interval"); obs_data_release(settings); - - bfree(filter->active_filter_data); - filter->active_filter_data = NULL; } void digital_glitch_filter_update(retro_effects_filter_data_t *data, @@ -285,6 +289,7 @@ static void digital_glitch_set_functions(retro_effects_filter_data_t *filter) filter->filter_defaults = digital_glitch_filter_defaults; filter->filter_update = digital_glitch_filter_update; filter->filter_video_tick = digital_glitch_filter_video_tick; + filter->filter_unset_settings = digital_glitch_unset_settings; } void digital_glitch_filter_video_tick(retro_effects_filter_data_t *data, diff --git a/src/filters/digital-glitch.h b/src/filters/digital-glitch.h index 8faded5..3406f20 100644 --- a/src/filters/digital-glitch.h +++ b/src/filters/digital-glitch.h @@ -51,8 +51,9 @@ struct digital_glitch_filter_data { extern void digital_glitch_create(retro_effects_filter_data_t *filter); extern void digital_glitch_destroy(retro_effects_filter_data_t *filter); -extern void -digital_glitch_filter_video_render(retro_effects_filter_data_t *data); +extern void digital_glitch_unset_settings(retro_effects_filter_data_t* filter); + +extern void digital_glitch_filter_video_render(retro_effects_filter_data_t *data); extern void digital_glitch_filter_properties(retro_effects_filter_data_t *data, obs_properties_t *props); extern void digital_glitch_filter_defaults(obs_data_t *settings); diff --git a/src/filters/dither.c b/src/filters/dither.c index 764949f..3c4c0bc 100644 --- a/src/filters/dither.c +++ b/src/filters/dither.c @@ -23,7 +23,13 @@ void dither_destroy(retro_effects_filter_data_t *filter) obs_leave_graphics(); - obs_data_t *settings = obs_source_get_settings(filter->base->context); + bfree(filter->active_filter_data); + filter->active_filter_data = NULL; +} + +void dither_unset_settings(retro_effects_filter_data_t* filter) +{ + obs_data_t* settings = obs_source_get_settings(filter->base->context); obs_data_unset_user_value(settings, "dither_size"); obs_data_unset_user_value(settings, "dither_type"); obs_data_unset_user_value(settings, "dither_bayer_size"); @@ -35,9 +41,6 @@ void dither_destroy(retro_effects_filter_data_t *filter) obs_data_unset_user_value(settings, "dither_offset_x"); obs_data_unset_user_value(settings, "dither_offset_y"); obs_data_release(settings); - - bfree(filter->active_filter_data); - filter->active_filter_data = NULL; } void dither_filter_update(retro_effects_filter_data_t *data, @@ -228,6 +231,7 @@ dither_set_functions(retro_effects_filter_data_t *filter) filter->filter_defaults = dither_filter_defaults; filter->filter_update = dither_filter_update; filter->filter_video_tick = NULL; + filter->filter_unset_settings = dither_unset_settings; } static void dither_load_effect(dither_filter_data_t *filter) diff --git a/src/filters/dither.h b/src/filters/dither.h index c0487c8..26dce9f 100644 --- a/src/filters/dither.h +++ b/src/filters/dither.h @@ -35,6 +35,8 @@ struct dither_filter_data { extern void dither_create(retro_effects_filter_data_t *filter); extern void dither_destroy(retro_effects_filter_data_t *filter); +extern void dither_unset_settings(retro_effects_filter_data_t* filter); + extern void dither_filter_video_render(retro_effects_filter_data_t *data); extern void dither_filter_properties(retro_effects_filter_data_t *data, obs_properties_t *props); diff --git a/src/filters/frame-skip.c b/src/filters/frame-skip.c index 02729da..8c3cec8 100644 --- a/src/filters/frame-skip.c +++ b/src/filters/frame-skip.c @@ -12,13 +12,17 @@ void frame_skip_create(retro_effects_filter_data_t *filter) void frame_skip_destroy(retro_effects_filter_data_t *filter) { - obs_data_t *settings = obs_source_get_settings(filter->base->context); - obs_data_unset_user_value(settings, "skip_frames"); - obs_data_release(settings); bfree(filter->active_filter_data); filter->active_filter_data = NULL; } +void frame_skip_unset_settings(retro_effects_filter_data_t* filter) +{ + obs_data_t* settings = obs_source_get_settings(filter->base->context); + obs_data_unset_user_value(settings, "skip_frames"); + obs_data_release(settings); +} + void frame_skip_filter_update(retro_effects_filter_data_t *data, obs_data_t *settings) { @@ -74,4 +78,5 @@ static void frame_skip_set_functions(retro_effects_filter_data_t *filter) filter->filter_defaults = frame_skip_filter_defaults; filter->filter_update = frame_skip_filter_update; filter->filter_video_tick = NULL; + filter->filter_unset_settings = frame_skip_unset_settings; } diff --git a/src/filters/frame-skip.h b/src/filters/frame-skip.h index cffa7a7..6d81a04 100644 --- a/src/filters/frame-skip.h +++ b/src/filters/frame-skip.h @@ -11,6 +11,8 @@ struct frame_skip_filter_data { extern void frame_skip_create(retro_effects_filter_data_t *filter); extern void frame_skip_destroy(retro_effects_filter_data_t *filter); +extern void frame_skip_unset_settings(retro_effects_filter_data_t* filter); + extern void frame_skip_filter_video_render(retro_effects_filter_data_t *data); extern void frame_skip_filter_properties(retro_effects_filter_data_t *data, obs_properties_t *props); diff --git a/src/filters/interlace.c b/src/filters/interlace.c index f4ee53b..011adb5 100644 --- a/src/filters/interlace.c +++ b/src/filters/interlace.c @@ -25,14 +25,17 @@ void interlace_destroy(retro_effects_filter_data_t *filter) } obs_leave_graphics(); - obs_data_t *settings = obs_source_get_settings(filter->base->context); + bfree(filter->active_filter_data); + filter->active_filter_data = NULL; +} + +void interlace_unset_settings(retro_effects_filter_data_t* filter) +{ + obs_data_t* settings = obs_source_get_settings(filter->base->context); obs_data_unset_user_value(settings, "interlace_thickness"); obs_data_unset_user_value(settings, "interlace_brightness_reduction"); obs_data_unset_user_value(settings, "interlace_reduce_alpha"); obs_data_release(settings); - - bfree(filter->active_filter_data); - filter->active_filter_data = NULL; } void interlace_filter_update(retro_effects_filter_data_t *data, @@ -151,6 +154,7 @@ static void interlace_set_functions(retro_effects_filter_data_t *filter) filter->filter_defaults = interlace_filter_defaults; filter->filter_update = interlace_filter_update; filter->filter_video_tick = NULL; + filter->filter_unset_settings = interlace_unset_settings; } static void load_interlace_effect(interlace_filter_data_t *filter) diff --git a/src/filters/interlace.h b/src/filters/interlace.h index dfc9b89..1570f55 100644 --- a/src/filters/interlace.h +++ b/src/filters/interlace.h @@ -22,6 +22,8 @@ struct interlace_filter_data { extern void interlace_create(retro_effects_filter_data_t *filter); extern void interlace_destroy(retro_effects_filter_data_t *filter); +extern void interlace_unset_settings(retro_effects_filter_data_t* filter); + extern void interlace_filter_video_render(retro_effects_filter_data_t *data); extern void interlace_filter_properties(retro_effects_filter_data_t *data, obs_properties_t *props); diff --git a/src/filters/matrix-rain.c b/src/filters/matrix-rain.c index 3c48135..15351d7 100644 --- a/src/filters/matrix-rain.c +++ b/src/filters/matrix-rain.c @@ -40,9 +40,21 @@ void matrix_rain_destroy(retro_effects_filter_data_t *filter) obs_data_release(data->textures_data); } + if (data->matrix_rain_texrender) { + gs_texrender_destroy(data->matrix_rain_texrender); + } + obs_leave_graphics(); - obs_data_t *settings = obs_source_get_settings(filter->base->context); + dstr_free(&data->custom_texture_file); + + bfree(filter->active_filter_data); + filter->active_filter_data = NULL; +} + +void matrix_rain_unset_settings(retro_effects_filter_data_t* filter) +{ + obs_data_t* settings = obs_source_get_settings(filter->base->context); obs_data_unset_user_value(settings, "matrix_char_set"); obs_data_unset_user_value(settings, "matrix_rain_scale"); obs_data_unset_user_value(settings, "matrix_rain_noise_shift"); @@ -60,13 +72,7 @@ void matrix_rain_destroy(retro_effects_filter_data_t *filter) obs_data_unset_user_value(settings, "matrix_bloom_intensity"); obs_data_unset_user_value(settings, "matrix_rain_texture"); obs_data_unset_user_value(settings, "matrix_rain_texture_chars"); - obs_data_release(settings); - - dstr_free(&data->custom_texture_file); - - bfree(filter->active_filter_data); - filter->active_filter_data = NULL; } void matrix_rain_filter_update(retro_effects_filter_data_t *data, @@ -146,6 +152,8 @@ void matrix_rain_filter_update(retro_effects_filter_data_t *data, set_character_texture(filter, font_image_path.array, num_chars); dstr_free(&font_image_path); + obs_data_array_release(data_array); + obs_data_release(texture_dat); } } @@ -190,7 +198,6 @@ void set_character_texture(matrix_rain_filter_data_t *filter, void matrix_rain_filter_defaults(obs_data_t *settings) { - UNUSED_PARAMETER(settings); obs_data_set_default_int(settings, "matrix_char_set", 1); obs_data_set_default_double(settings, "matrix_rain_scale", 0.40); obs_data_set_default_double(settings, "matrix_rain_noise_shift", 0.0); @@ -479,6 +486,7 @@ static void matrix_rain_set_functions(retro_effects_filter_data_t *filter) filter->filter_defaults = matrix_rain_filter_defaults; filter->filter_update = matrix_rain_filter_update; filter->filter_video_tick = matrix_rain_filter_video_tick; + filter->filter_unset_settings = matrix_rain_unset_settings; } static void matrix_rain_load_effect(matrix_rain_filter_data_t *filter) diff --git a/src/filters/matrix-rain.h b/src/filters/matrix-rain.h index 86233cf..57ef27e 100644 --- a/src/filters/matrix-rain.h +++ b/src/filters/matrix-rain.h @@ -66,6 +66,9 @@ struct matrix_rain_filter_data { extern void matrix_rain_create(retro_effects_filter_data_t *filter); extern void matrix_rain_destroy(retro_effects_filter_data_t *filter); +extern void matrix_rain_unset_settings(retro_effects_filter_data_t* filter); + + extern void matrix_rain_filter_video_tick(retro_effects_filter_data_t *data, float seconds); extern void matrix_rain_filter_video_render(retro_effects_filter_data_t *data); diff --git a/src/filters/ntsc.c b/src/filters/ntsc.c index a9578ac..198d908 100644 --- a/src/filters/ntsc.c +++ b/src/filters/ntsc.c @@ -29,7 +29,13 @@ void ntsc_destroy(retro_effects_filter_data_t *filter) obs_leave_graphics(); - obs_data_t *settings = obs_source_get_settings(filter->base->context); + bfree(filter->active_filter_data); + filter->active_filter_data = NULL; +} + +void ntsc_unset_settings(retro_effects_filter_data_t* filter) +{ + obs_data_t* settings = obs_source_get_settings(filter->base->context); obs_data_unset_user_value(settings, "ntsc_tuning_offset"); obs_data_unset_user_value(settings, "ntsc_luma_noise"); obs_data_unset_user_value(settings, "ntsc_luma_band_size"); @@ -40,11 +46,7 @@ void ntsc_destroy(retro_effects_filter_data_t *filter) obs_data_unset_user_value(settings, "ntsc_chroma_bleed_steps"); obs_data_unset_user_value(settings, "ntsc_brightness"); obs_data_unset_user_value(settings, "ntsc_saturation"); - obs_data_release(settings); - - bfree(filter->active_filter_data); - filter->active_filter_data = NULL; } void ntsc_filter_update(retro_effects_filter_data_t *data, obs_data_t *settings) @@ -329,6 +331,7 @@ static void ntsc_set_functions(retro_effects_filter_data_t *filter) filter->filter_defaults = ntsc_filter_defaults; filter->filter_update = ntsc_filter_update; filter->filter_video_tick = ntsc_filter_video_tick; + filter->filter_unset_settings = ntsc_unset_settings; } static void ntsc_load_effects(ntsc_filter_data_t *filter) diff --git a/src/filters/ntsc.h b/src/filters/ntsc.h index c40db27..6a6f32f 100644 --- a/src/filters/ntsc.h +++ b/src/filters/ntsc.h @@ -46,6 +46,8 @@ struct ntsc_filter_data { extern void ntsc_create(retro_effects_filter_data_t *filter); extern void ntsc_destroy(retro_effects_filter_data_t *filter); +extern void ntsc_unset_settings(retro_effects_filter_data_t* filter); + extern void ntsc_filter_video_tick(retro_effects_filter_data_t *data, float seconds); extern void ntsc_filter_video_render(retro_effects_filter_data_t *data); diff --git a/src/filters/posterize.c b/src/filters/posterize.c index d6da9c1..af867eb 100644 --- a/src/filters/posterize.c +++ b/src/filters/posterize.c @@ -27,16 +27,19 @@ void posterize_destroy(retro_effects_filter_data_t *filter) obs_leave_graphics(); - obs_data_t *settings = obs_source_get_settings(filter->base->context); + bfree(filter->active_filter_data); + filter->active_filter_data = NULL; +} + +void posterize_unset_settings(retro_effects_filter_data_t* filter) +{ + obs_data_t* settings = obs_source_get_settings(filter->base->context); obs_data_unset_user_value(settings, "posterize_levels"); obs_data_unset_user_value(settings, "posterize_technique"); obs_data_unset_user_value(settings, "posterize_map_source"); obs_data_unset_user_value(settings, "posterize_color_1"); obs_data_unset_user_value(settings, "posterize_color_2"); obs_data_release(settings); - - bfree(filter->active_filter_data); - filter->active_filter_data = NULL; } void posterize_filter_update(retro_effects_filter_data_t *data, @@ -256,6 +259,7 @@ static void posterize_set_functions(retro_effects_filter_data_t *filter) filter->filter_defaults = posterize_filter_defaults; filter->filter_update = posterize_filter_update; filter->filter_video_tick = NULL; + filter->filter_unset_settings = posterize_unset_settings; } static void posterize_load_effect(posterize_filter_data_t *filter) diff --git a/src/filters/posterize.h b/src/filters/posterize.h index 416b358..a4d8bb9 100644 --- a/src/filters/posterize.h +++ b/src/filters/posterize.h @@ -31,6 +31,8 @@ struct posterize_filter_data { extern void posterize_create(retro_effects_filter_data_t *filter); extern void posterize_destroy(retro_effects_filter_data_t *filter); +extern void posterize_unset_settings(retro_effects_filter_data_t* filter); + extern void posterize_filter_video_render(retro_effects_filter_data_t *data); extern void posterize_filter_properties(retro_effects_filter_data_t *data, obs_properties_t *props); diff --git a/src/filters/scan-lines.c b/src/filters/scan-lines.c index 507a6d8..aad28a9 100644 --- a/src/filters/scan-lines.c +++ b/src/filters/scan-lines.c @@ -24,15 +24,18 @@ void scan_lines_destroy(retro_effects_filter_data_t *filter) obs_leave_graphics(); - obs_data_t *settings = obs_source_get_settings(filter->base->context); + bfree(filter->active_filter_data); + filter->active_filter_data = NULL; +} + +void scan_lines_unset_settings(retro_effects_filter_data_t* filter) +{ + obs_data_t* settings = obs_source_get_settings(filter->base->context); obs_data_unset_user_value(settings, "scanlines_period"); obs_data_unset_user_value(settings, "scanlines_offset"); obs_data_unset_user_value(settings, "scanlines_speed"); obs_data_unset_user_value(settings, "scanlines_profile"); obs_data_release(settings); - - bfree(filter->active_filter_data); - filter->active_filter_data = NULL; } void scan_lines_filter_update(retro_effects_filter_data_t *data, @@ -204,6 +207,7 @@ static void scan_lines_set_functions(retro_effects_filter_data_t *filter) filter->filter_defaults = scan_lines_filter_defaults; filter->filter_update = scan_lines_filter_update; filter->filter_video_tick = scan_lines_filter_video_tick; + filter->filter_unset_settings = scan_lines_unset_settings; } void scan_lines_filter_video_tick(retro_effects_filter_data_t *data, diff --git a/src/filters/scan-lines.h b/src/filters/scan-lines.h index 4fe5be9..8cb5a80 100644 --- a/src/filters/scan-lines.h +++ b/src/filters/scan-lines.h @@ -35,6 +35,8 @@ struct scan_lines_filter_data { extern void scan_lines_create(retro_effects_filter_data_t *filter); extern void scan_lines_destroy(retro_effects_filter_data_t *filter); +extern void scan_lines_unset_settings(retro_effects_filter_data_t* filter); + extern void scan_lines_filter_video_render(retro_effects_filter_data_t *data); extern void scan_lines_filter_properties(retro_effects_filter_data_t *data, obs_properties_t *props); diff --git a/src/filters/vhs.c b/src/filters/vhs.c index 5ec6709..fcbe898 100644 --- a/src/filters/vhs.c +++ b/src/filters/vhs.c @@ -23,7 +23,13 @@ void vhs_destroy(retro_effects_filter_data_t *filter) obs_leave_graphics(); - obs_data_t *settings = obs_source_get_settings(filter->base->context); + bfree(filter->active_filter_data); + filter->active_filter_data = NULL; +} + +void vhs_unset_settings(retro_effects_filter_data_t* filter) +{ + obs_data_t* settings = obs_source_get_settings(filter->base->context); //obs_data_unset_user_value(settings, "vhs_size"); obs_data_unset_user_value(settings, "vhs_wrinkle_occurrence_prob"); obs_data_unset_user_value(settings, "vhs_wrinkle_size"); @@ -41,9 +47,6 @@ void vhs_destroy(retro_effects_filter_data_t *filter) obs_data_unset_user_value(settings, "vhs_head_switch_secondary_horiz_offset"); obs_data_unset_user_value(settings, "vhs_head_switch_secondary_vert_amount"); obs_data_release(settings); - - bfree(filter->active_filter_data); - filter->active_filter_data = NULL; } void vhs_filter_update(retro_effects_filter_data_t *data, obs_data_t *settings) @@ -327,6 +330,7 @@ static void vhs_set_functions(retro_effects_filter_data_t *filter) filter->filter_defaults = vhs_filter_defaults; filter->filter_update = vhs_filter_update; filter->filter_video_tick = vhs_filter_video_tick; + filter->filter_unset_settings = vhs_unset_settings; } void vhs_filter_video_tick(retro_effects_filter_data_t *data, diff --git a/src/filters/vhs.h b/src/filters/vhs.h index fd57789..33d97fe 100644 --- a/src/filters/vhs.h +++ b/src/filters/vhs.h @@ -54,6 +54,8 @@ struct vhs_filter_data { extern void vhs_create(retro_effects_filter_data_t *filter); extern void vhs_destroy(retro_effects_filter_data_t *filter); +extern void vhs_unset_settings(retro_effects_filter_data_t* filter); + extern void vhs_filter_video_render(retro_effects_filter_data_t *data); extern void vhs_filter_properties(retro_effects_filter_data_t *data, obs_properties_t *props); diff --git a/src/obs-retro-effects-filter.c b/src/obs-retro-effects-filter.c index 89c0ba8..9b4f0d4 100644 --- a/src/obs-retro-effects-filter.c +++ b/src/obs-retro-effects-filter.c @@ -88,6 +88,7 @@ static void retro_effects_filter_destroy(void *data) filter->filter_destroy(filter); blur_destroy(filter); + bloom_destroy(filter); bfree(filter->base); bfree(filter); @@ -231,6 +232,9 @@ static void load_filter(retro_effects_filter_data_t *filter, int old_type) if (old_type != 0) { // Clear out old settings. // Destroy old type data object. + if (filter->filter_unset_settings) { + filter->filter_unset_settings(filter); + } if (filter->filter_destroy) { filter->filter_destroy(filter); } diff --git a/src/obs-retro-effects.h b/src/obs-retro-effects.h index 5f08c4e..3784022 100644 --- a/src/obs-retro-effects.h +++ b/src/obs-retro-effects.h @@ -61,6 +61,7 @@ struct retro_effects_filter_data { obs_data_t *); // update void (*filter_video_render)(retro_effects_filter_data_t *); // render void (*filter_destroy)(retro_effects_filter_data_t *); // destroy + void (*filter_unset_settings)(retro_effects_filter_data_t *); void (*filter_video_tick)(retro_effects_filter_data_t *, float); // Video Tick