From 9cb1810551a257043f1f6db7e320b690ff4391f4 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 8 Jul 2019 15:57:33 +0200 Subject: Fix T66431: SE - Audio Caching crash Moved the caching code from direct calls in DNA to dependency graph. In fact, not much was needed to be done apart form removing the direct cache updates. The rest seemed to work fine. Possible to avoid full sound file re-load, but doesn't seem this is causing any issues. --- source/blender/blenkernel/intern/sequencer.c | 2 +- source/blender/blenkernel/intern/sound.c | 2 -- source/blender/editors/sound/sound_ops.c | 2 +- source/blender/makesrna/intern/rna_sound.c | 24 ++++-------------------- 4 files changed, 6 insertions(+), 24 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index f2e0ee0c7fa..ceb06c29f09 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -5400,7 +5400,7 @@ static void seq_load_apply(Main *bmain, Scene *scene, Sequence *seq, SeqLoadInfo if (seq_load->flag & SEQ_LOAD_SOUND_CACHE) { if (seq->sound) { - BKE_sound_cache(seq->sound); + seq->sound->flags |= SOUND_FLAGS_CACHING; } } diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 1722b888d28..6d782726e07 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -389,7 +389,6 @@ void BKE_sound_cache(bSound *sound) { sound_verify_evaluated_id(&sound->id); - sound->flags |= SOUND_FLAGS_CACHING; if (sound->cache) { AUD_Sound_free(sound->cache); } @@ -405,7 +404,6 @@ void BKE_sound_cache(bSound *sound) void BKE_sound_delete_cache(bSound *sound) { - sound->flags &= ~SOUND_FLAGS_CACHING; if (sound->cache) { AUD_Sound_free(sound->cache); sound->cache = NULL; diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c index f4191f87df6..0241a2fbe88 100644 --- a/source/blender/editors/sound/sound_ops.c +++ b/source/blender/editors/sound/sound_ops.c @@ -104,7 +104,7 @@ static int sound_open_exec(bContext *C, wmOperator *op) } if (RNA_boolean_get(op->ptr, "cache")) { - BKE_sound_cache(sound); + sound->flags |= SOUND_FLAGS_CACHING; } /* hook into UI */ diff --git a/source/blender/makesrna/intern/rna_sound.c b/source/blender/makesrna/intern/rna_sound.c index e4b120261c6..8402c4a8705 100644 --- a/source/blender/makesrna/intern/rna_sound.c +++ b/source/blender/makesrna/intern/rna_sound.c @@ -40,26 +40,10 @@ static void rna_Sound_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerR DEG_id_tag_update(&sound->id, ID_RECALC_AUDIO); } -static bool rna_Sound_caching_get(PointerRNA *ptr) +static void rna_Sound_caching_update(Main *bmain, Scene *scene, PointerRNA *ptr) { - bSound *sound = (bSound *)(ptr->data); - return (sound->flags & SOUND_FLAGS_CACHING) != 0; -} - -static void rna_Sound_caching_set(PointerRNA *ptr, const bool value) -{ - bSound *sound = (bSound *)(ptr->data); - if (value) { - BKE_sound_cache(sound); - } - else { - BKE_sound_delete_cache(sound); - } -} - -static void rna_Sound_caching_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr) -{ - BKE_sequencer_update_sound(scene, (bSound *)(ptr->data)); + rna_Sound_update(bmain, scene, ptr); + DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS); } #else @@ -87,7 +71,7 @@ static void rna_def_sound(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Packed File", ""); prop = RNA_def_property(srna, "use_memory_cache", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_funcs(prop, "rna_Sound_caching_get", "rna_Sound_caching_set"); + RNA_def_property_boolean_sdna(prop, NULL, "flags", SOUND_FLAGS_CACHING); RNA_def_property_ui_text(prop, "Caching", "The sound file is decoded and loaded into RAM"); RNA_def_property_update(prop, 0, "rna_Sound_caching_update"); -- cgit v1.2.3