diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2019-05-02 15:31:33 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2019-05-03 16:50:40 +0300 |
commit | c5fe16e121eefe5dd02cc9f9ba572053c383ccfa (patch) | |
tree | aa74a6fff290294220faf9c4a77aef4e17da250b /source/blender/depsgraph | |
parent | b4e1e0946bf124f95e1d9fa1a6ffa1cbc143c7d6 (diff) |
Sound: Make sound handles only be in evaluated datablocks
Quite straightforward change, which makes it so audio handles are
only created inside of evaluated datablocks.
Exception is adding sound strip to the sequencer, which needs an
audio handle to query length and number of channels. This is done
by temporarily loading sound file into an original datablock, and
then tossing it away.
There is an assert in sound.c which verifies that audio system is
used from an evaluated domain, which should help porting all the
cases which are likely missed by this commit.
Some annoying parts:
- `BKE_sound_update_scene()` is iterating over all bases, and does
special ID tags to see whether sound has been handled or not
already. This can not be done the old fashion now.
Ideally, this will be done as a speaker datablock evaluation,
but seems that would require a lock since audio API is not safe
for threading. So this is not a desired way i'd say.
Possible solution here would be to iterate over ID datablocks
using dependency graph query API.
- Frame jump needs to call `BKE_sound_seek_scene()` directly
because there might be some flags assigned to the scene which
could be clear after operator execution is over.
Need to verify if that's the case though. This is a bit hairy
code, so sticking to a safest and known to work approach for
now.
- Removed check for format when opening new sound file.
Maybe we can have some utility function which queries channel
and duration information, leaving the caller's code clean and
tidy.
Tested following cases:
- Adding/removing/moving sequencer's sound strips.
- Adding/moving speakers in viewport.
- Rendering audio.
Reviewers: brecht
Differential Revision: https://developer.blender.org/D4779
Diffstat (limited to 'source/blender/depsgraph')
3 files changed, 5 insertions, 8 deletions
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index 8fef35570fe..64772dcc64b 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -2391,6 +2391,10 @@ void DepsgraphRelationBuilder::build_copy_on_write_relations(IDNode *id_node) (id_type == ID_CF && comp_node->type == NodeType::CACHE)) { rel_flag &= ~RELATION_FLAG_NO_FLUSH; } + /* TODO(sergey): Needs better solution for this. */ + if (id_type == ID_SO) { + rel_flag &= ~RELATION_FLAG_NO_FLUSH; + } /* Notes on exceptions: * - Parameters component is where drivers are living. Changing any * of the (custom) properties in the original datablock (even the diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc index d8e895364ca..f7d7b76cb69 100644 --- a/source/blender/depsgraph/intern/depsgraph_tag.cc +++ b/source/blender/depsgraph/intern/depsgraph_tag.cc @@ -218,9 +218,6 @@ void depsgraph_tag_to_component_opcode(const ID *id, case ID_RECALC_SEQUENCER: *component_type = NodeType::SEQUENCER; break; - case ID_RECALC_AUDIO_JUMP: - *component_type = NodeType::AUDIO; - break; case ID_RECALC_ALL: case ID_RECALC_PSYS_ALL: BLI_assert(!"Should not happen"); @@ -623,8 +620,6 @@ const char *DEG_update_tag_as_string(IDRecalcFlag flag) return "EDITORS"; case ID_RECALC_SEQUENCER: return "SEQUENCER"; - case ID_RECALC_AUDIO_JUMP: - return "AUDIO_JUMP"; case ID_RECALC_ALL: return "ALL"; } diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc index 6d5714d5606..bb4300e5330 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc @@ -1516,9 +1516,7 @@ bool deg_copy_on_write_is_expanded(const ID *id_cow) bool deg_copy_on_write_is_needed(const ID *id_orig) { const ID_Type id_type = GS(id_orig->name); - /* TODO(sergey): Make Sound copyable. It is here only because the code for dependency graph is - * being work in progress. */ - return !ELEM(id_type, ID_IM, ID_SO); + return !ELEM(id_type, ID_IM); } } // namespace DEG |