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/blenkernel/BKE_sound.h | |
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/blenkernel/BKE_sound.h')
-rw-r--r-- | source/blender/blenkernel/BKE_sound.h | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/source/blender/blenkernel/BKE_sound.h b/source/blender/blenkernel/BKE_sound.h index d95be9fde97..0c1ab2cc4c3 100644 --- a/source/blender/blenkernel/BKE_sound.h +++ b/source/blender/blenkernel/BKE_sound.h @@ -71,12 +71,17 @@ void BKE_sound_cache(struct bSound *sound); void BKE_sound_delete_cache(struct bSound *sound); -void BKE_sound_reset_pointers(struct bSound *sound); +void BKE_sound_reset_runtime(struct bSound *sound); void BKE_sound_load(struct Main *main, struct bSound *sound); void BKE_sound_ensure_loaded(struct Main *bmain, struct bSound *sound); void BKE_sound_free(struct bSound *sound); +/* Is used by sequencer to temporarily load audio to access information about channels and + * duration. */ +void BKE_sound_load_audio(struct Main *main, struct bSound *sound); +void BKE_sound_free_audio(struct bSound *sound); + void BKE_sound_copy_data(struct Main *bmain, struct bSound *sound_dst, const struct bSound *sound_src, @@ -88,7 +93,7 @@ void BKE_sound_make_local(struct Main *bmain, struct bSound *sound, const bool l AUD_Device *BKE_sound_mixdown(struct Scene *scene, AUD_DeviceSpecs specs, int start, float volume); #endif -void BKE_sound_reset_scene_pointers(struct Scene *scene); +void BKE_sound_reset_scene_runtime(struct Scene *scene); void BKE_sound_create_scene(struct Scene *scene); void BKE_sound_ensure_scene(struct Scene *scene); @@ -154,6 +159,11 @@ float BKE_sound_get_length(struct bSound *sound); char **BKE_sound_get_device_names(void); +typedef void (*SoundJackSyncCallback)(struct Main *bmain, int mode, float time); + +void BKE_sound_jack_sync_callback_set(SoundJackSyncCallback callback); +void BKE_sound_jack_scene_update(struct Scene *scene, int mode, float time); + /* Evaluation. */ struct Depsgraph; |