From ebe209b8ecf11128a562ff595fa09425cf27eadc Mon Sep 17 00:00:00 2001 From: Richard Antalik Date: Tue, 12 Nov 2024 17:28:20 +0100 Subject: [PATCH] Fix #126461: Scene sound does not play Caused by removing scene sound from "main scene" when other strip using the same scene is not rendering sequencer strips. Only remove sound when all strips using particular scene are not rendering sequencer strips. Pull Request: https://projects.blender.org/blender/blender/pulls/129768 --- source/blender/sequencer/intern/sequencer.cc | 28 +++++++++++++++----- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/source/blender/sequencer/intern/sequencer.cc b/source/blender/sequencer/intern/sequencer.cc index eabc70fed97..cc198c25330 100644 --- a/source/blender/sequencer/intern/sequencer.cc +++ b/source/blender/sequencer/intern/sequencer.cc @@ -8,6 +8,7 @@ * \ingroup bke */ +#include "DNA_listBase.h" #define DNA_DEPRECATED_ALLOW #include "MEM_guardedalloc.h" @@ -1011,7 +1012,22 @@ static void seq_update_sound_strips(Scene *scene, Sequence *seq) seq_update_sound_modifiers(seq); } -static void seq_update_scene_strip_sound(Sequence *seq) +static bool scene_sequencer_is_used(const Scene *scene, ListBase *seqbase) +{ + bool sequencer_is_used = false; + LISTBASE_FOREACH (Sequence *, seq_iter, seqbase) { + if (seq_iter->scene == scene && (seq_iter->flag & SEQ_SCENE_STRIPS) != 0) { + sequencer_is_used = true; + } + if (seq_iter->type == SEQ_TYPE_META) { + sequencer_is_used |= scene_sequencer_is_used(scene, &seq_iter->seqbase); + } + } + + return sequencer_is_used; +} + +static void seq_update_scene_strip_sound(const Scene *scene, Sequence *seq) { if (seq->type != SEQ_TYPE_SCENE || seq->scene == nullptr) { return; @@ -1025,10 +1041,10 @@ static void seq_update_scene_strip_sound(Sequence *seq) * then it is no longer needed to do such manual forced updates. */ BKE_sound_set_scene_volume(seq->scene, seq->scene->audio.volume); - /* Mute nested strips of scene when not using sequencer as input. */ - if ((seq->flag & SEQ_SCENE_STRIPS) == 0 && seq->scene->sound_scene != nullptr && - seq->scene->ed != nullptr) - { + /* Mute sound when all scene strips using particular scene are not rendering sequencer strips. */ + bool sequencer_is_used = scene_sequencer_is_used(seq->scene, &scene->ed->seqbase); + + if (!sequencer_is_used && seq->scene->sound_scene != nullptr && seq->scene->ed != nullptr) { SEQ_for_each_callback(&seq->scene->ed->seqbase, seq_mute_sound_strips_cb, seq->scene); } } @@ -1044,7 +1060,7 @@ static bool seq_sound_update_cb(Sequence *seq, void *user_data) } seq_update_sound_strips(scene, seq); - seq_update_scene_strip_sound(seq); + seq_update_scene_strip_sound(scene, seq); seq_update_sound_properties(scene, seq); return true; }