From b50de0f8b75b9f7af62e09528635f6a9fdbb07cd Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 17 Jun 2019 12:54:56 +0200 Subject: [PATCH] Fix T65651: Crash when changing audio strip source file --- source/blender/blenkernel/intern/scene.c | 7 ++++++- source/blender/blenkernel/intern/sound.c | 4 ++++ source/blender/depsgraph/intern/depsgraph_tag.cc | 3 +++ source/blender/makesdna/DNA_ID.h | 2 ++ source/blender/makesrna/intern/rna_sequencer.c | 7 ++----- source/blender/makesrna/intern/rna_sound.c | 7 +++++-- 6 files changed, 22 insertions(+), 8 deletions(-) diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 6300d48c700..a250b005bad 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -2456,7 +2456,9 @@ void BKE_scene_eval_sequencer_sequences(Depsgraph *depsgraph, Scene *scene) SEQ_BEGIN (scene->ed, seq) { if (seq->scene_sound == NULL) { if (seq->sound != NULL) { - seq->scene_sound = BKE_sound_add_scene_sound_defaults(scene, seq); + if (seq->scene_sound == NULL) { + seq->scene_sound = BKE_sound_add_scene_sound_defaults(scene, seq); + } } else if (seq->type == SEQ_TYPE_SCENE) { if (seq->scene != NULL) { @@ -2466,6 +2468,9 @@ void BKE_scene_eval_sequencer_sequences(Depsgraph *depsgraph, Scene *scene) } } if (seq->scene_sound) { + if (scene->id.recalc & ID_RECALC_AUDIO || seq->sound->id.recalc & ID_RECALC_AUDIO) { + BKE_sound_update_scene_sound(seq->scene_sound, seq->sound); + } BKE_sound_set_scene_sound_volume( seq->scene_sound, seq->volume, (seq->flag & SEQ_AUDIO_VOLUME_ANIMATED) != 0); BKE_sound_set_scene_sound_pitch( diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 007614b4b95..ad26314e877 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -1328,5 +1328,9 @@ void BKE_sound_jack_scene_update(Scene *scene, int mode, float time) void BKE_sound_evaluate(Depsgraph *depsgraph, Main *bmain, bSound *sound) { DEG_debug_print_eval(depsgraph, __func__, sound->id.name, sound); + if (sound->id.recalc & ID_RECALC_AUDIO) { + BKE_sound_load(bmain, sound); + return; + } BKE_sound_ensure_loaded(bmain, sound); } diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc index c5743e77d9a..1c26e6fecd5 100644 --- a/source/blender/depsgraph/intern/depsgraph_tag.cc +++ b/source/blender/depsgraph/intern/depsgraph_tag.cc @@ -223,6 +223,7 @@ void depsgraph_tag_to_component_opcode(const ID *id, case ID_RECALC_AUDIO_VOLUME: case ID_RECALC_AUDIO_MUTE: case ID_RECALC_AUDIO_LISTENER: + case ID_RECALC_AUDIO: *component_type = NodeType::AUDIO; break; case ID_RECALC_ALL: @@ -656,6 +657,8 @@ const char *DEG_update_tag_as_string(IDRecalcFlag flag) return "AUDIO_MUTE"; case ID_RECALC_AUDIO_LISTENER: return "AUDIO_LISTENER"; + case ID_RECALC_AUDIO: + return "AUDIO"; case ID_RECALC_ALL: return "ALL"; } diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h index 2eace6d07d5..2a6800c55b6 100644 --- a/source/blender/makesdna/DNA_ID.h +++ b/source/blender/makesdna/DNA_ID.h @@ -612,6 +612,8 @@ typedef enum IDRecalcFlag { ID_RECALC_AUDIO_MUTE = (1 << 18), ID_RECALC_AUDIO_LISTENER = (1 << 19), + ID_RECALC_AUDIO = (1 << 20), + /*************************************************************************** * Pseudonyms, to have more semantic meaning in the actual code without * using too much low-level and implementation specific tags. */ diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index f5e4259c471..4e7f9f51d12 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -809,12 +809,9 @@ static void rna_Sequence_filepath_update(Main *bmain, Scene *UNUSED(scene), Poin rna_Sequence_invalidate_raw_update(bmain, scene, ptr); } -static void rna_Sequence_sound_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +static void rna_Sequence_sound_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) { - Sequence *seq = (Sequence *)ptr->data; - if (seq->sound != NULL) { - BKE_sound_update_scene_sound(seq->scene_sound, seq->sound); - } + DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS | ID_RECALC_AUDIO); } static int seqproxy_seq_cmp_cb(Sequence *seq, void *arg_pt) diff --git a/source/blender/makesrna/intern/rna_sound.c b/source/blender/makesrna/intern/rna_sound.c index 7437a24f65e..e4b120261c6 100644 --- a/source/blender/makesrna/intern/rna_sound.c +++ b/source/blender/makesrna/intern/rna_sound.c @@ -32,9 +32,12 @@ # include "BKE_context.h" # include "BKE_sequencer.h" -static void rna_Sound_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) +# include "DEG_depsgraph.h" + +static void rna_Sound_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { - BKE_sound_load(bmain, (bSound *)ptr->data); + bSound *sound = (bSound *)ptr->data; + DEG_id_tag_update(&sound->id, ID_RECALC_AUDIO); } static bool rna_Sound_caching_get(PointerRNA *ptr)