diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2019-05-06 13:46:14 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2019-05-06 13:54:16 +0300 |
commit | 064273a4ae7101f937cf2e16b0e2f1efcd2f0e38 (patch) | |
tree | b10ee52c452decf2cd3ba760794609ee6795043b /source/blender/blenkernel | |
parent | 2c0da4a3db96d4aeeeec1cfba4a0a9f5bf0fa970 (diff) |
Sound: Port more cases to be a part of dependency graph
Mainly covers RNA callbacks which were still doing direct scene update,
which was causing crashes. Now corresponding ID_RECALC flags are used,
so all scenes can update accordingly.
Also tested animated volume/pitch on strips, which now works as well.
Fixes T64133: Assert after changing FPS
Fixes T64154: Immediate crash when changing the current frame on the timeline
Fixes T64185: Client Crashes when the frame position value is changed
Fixes T64190: Blender Crash using Timeline Editor
Fixes T64128: Click to close bug type on timeline
Fixes T64147: Crash when setting current frame from Python
Fixes T64152: Blender Auto-Close on timeline change
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_sound.h | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/scene.c | 25 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/sound.c | 22 |
3 files changed, 28 insertions, 23 deletions
diff --git a/source/blender/blenkernel/BKE_sound.h b/source/blender/blenkernel/BKE_sound.h index f526dd579ce..8d17380592e 100644 --- a/source/blender/blenkernel/BKE_sound.h +++ b/source/blender/blenkernel/BKE_sound.h @@ -144,10 +144,6 @@ void BKE_sound_stop_scene(struct Scene *scene); void BKE_sound_seek_scene(struct Main *bmain, struct Scene *scene); -/* Use this after original scene's frame has been changed. It will take care of doing all the - * updates required for BKE_sound_seek_scene(). */ -void BKE_sound_update_and_seek(struct Main *bmain, struct Depsgraph *depsgraph); - float BKE_sound_sync_scene(struct Scene *scene); int BKE_sound_scene_playing(struct Scene *scene); diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 1e43aee64eb..7cd89705a1e 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -1510,7 +1510,24 @@ static void prepare_mesh_for_viewport_render(Main *bmain, const ViewLayer *view_ static void scene_update_sound(Depsgraph *depsgraph, Main *bmain) { Scene *scene = DEG_get_evaluated_scene(depsgraph); + const int recalc = scene->id.recalc; BKE_sound_ensure_scene(scene); + if (recalc & ID_RECALC_AUDIO_SEEK) { + BKE_sound_seek_scene(bmain, scene); + } + if (recalc & ID_RECALC_AUDIO_FPS) { + BKE_sound_update_fps(scene); + } + if (recalc & ID_RECALC_AUDIO_VOLUME) { + BKE_sound_set_scene_volume(scene, scene->audio.volume); + } + if (recalc & ID_RECALC_AUDIO_MUTE) { + const bool is_mute = (scene->audio.flag & AUDIO_MUTE); + BKE_sound_mute_scene(scene, is_mute); + } + if (recalc & ID_RECALC_AUDIO_LISTENER) { + BKE_sound_update_scene_listener(scene); + } BKE_sound_update_scene(bmain, scene); } @@ -2407,6 +2424,14 @@ void BKE_scene_eval_sequencer_sequences(Depsgraph *depsgraph, Scene *scene) if (seq->sound != NULL && seq->scene_sound == NULL) { seq->scene_sound = BKE_sound_add_scene_sound_defaults(scene, seq); } + if (seq->scene_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( + seq->scene_sound, seq->pitch, (seq->flag & SEQ_AUDIO_PITCH_ANIMATED) != 0); + BKE_sound_set_scene_sound_pan( + seq->scene_sound, seq->pan, (seq->flag & SEQ_AUDIO_PAN_ANIMATED) != 0); + } } SEQ_END; BKE_sequencer_update_muting(scene->ed); diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 9ccb90b5cdc..f45c53426b9 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -57,7 +57,6 @@ #include "BKE_scene.h" #include "DEG_depsgraph.h" -#include "DEG_depsgraph_query.h" #ifdef WITH_AUDASPACE /* evil globals ;-) */ @@ -689,7 +688,6 @@ void BKE_sound_set_scene_sound_pitch(void *handle, float pitch, char animated) void BKE_sound_set_scene_sound_pan(void *handle, float pan, char animated) { - printf("%s\n", __func__); AUD_SequenceEntry_setAnimationData(handle, AUD_AP_PANNING, sound_cfra, &pan, animated); } @@ -798,10 +796,9 @@ void BKE_sound_seek_scene(Main *bmain, Scene *scene) } } - Scene *scene_orig = (Scene *)DEG_get_original_id(&scene->id); - if (scene_orig->audio.flag & AUDIO_SCRUB && !animation_playing) { + if (scene->audio.flag & AUDIO_SCRUB && !animation_playing) { AUD_Handle_setPosition(scene->playback_handle, cur_time); - if (scene_orig->audio.flag & AUDIO_SYNC) { + if (scene->audio.flag & AUDIO_SYNC) { AUD_seekSynchronizer(scene->playback_handle, cur_time); } AUD_Handle_resume(scene->playback_handle); @@ -817,7 +814,7 @@ void BKE_sound_seek_scene(Main *bmain, Scene *scene) } } else { - if (scene_orig->audio.flag & AUDIO_SYNC) { + if (scene->audio.flag & AUDIO_SYNC) { AUD_seekSynchronizer(scene->playback_handle, cur_time); } else { @@ -1227,19 +1224,6 @@ void BKE_sound_load_audio(Main *UNUSED(bmain), bSound *UNUSED(sound)) #endif /* WITH_AUDASPACE */ -void BKE_sound_update_and_seek(Main *bmain, Depsgraph *depsgraph) -{ - Scene *scene_orig = DEG_get_input_scene(depsgraph); - Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); - /* NOTE: We don't do copy-on-write or anything like that here because we need to know scene's - * flags like "scrubbing" in the BKE_sound_seek_scene(). So we simply update frame to which - * seek needs to happen. - * - * TODO(sergey): Might change API so the frame is passes explicitly. */ - scene_eval->r.cfra = scene_orig->r.cfra; - BKE_sound_seek_scene(bmain, scene_eval); -} - void BKE_sound_reset_scene_runtime(Scene *scene) { scene->sound_scene = NULL; |