diff options
author | Sebastian Parborg <darkdefende@gmail.com> | 2020-04-06 14:53:07 +0300 |
---|---|---|
committer | Sebastian Parborg <darkdefende@gmail.com> | 2020-04-06 14:57:03 +0300 |
commit | 9ddbb03861fbfb36a83c1eb3fe2fb0feb455d0bd (patch) | |
tree | 97b0c1667c358c6baf2ab232ca237f751e5cab54 /source/blender/blenkernel/intern/sound.c | |
parent | ded7af53b4f2fed41069dd52a9854fe1e904cad1 (diff) |
Fix T74111: Animation Playback Delayed With Time Remapping And AV-Sync
When setting the current playback time in BKE_sound_play_scene we didn't
account for the frame length. So the current frame/time would be wrong
when we asked the audio playback what time it was.
This would lead to playback being offset when using time remapping and
AV sync.
Reviewed By: Richard Antalik and Sybren A. Stüvel
Differential Revision: http://developer.blender.org/D7248
Diffstat (limited to 'source/blender/blenkernel/intern/sound.c')
-rw-r--r-- | source/blender/blenkernel/intern/sound.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 97a643e88b6..c26df027368 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -751,12 +751,20 @@ static void sound_start_play_scene(Scene *scene) } } +static float get_cur_time(Scene *scene) +{ + /* We divide by the current framelen to take into account time remapping. + * Otherwise we will get the wrong starting time which will break A/V sync. + * See T74111 for further details. */ + return FRA2TIME((CFRA + SUBFRA) / scene->r.framelen); +} + void BKE_sound_play_scene(Scene *scene) { sound_verify_evaluated_id(&scene->id); AUD_Status status; - const float cur_time = (float)((double)CFRA / FPS); + const float cur_time = get_cur_time(scene); AUD_Device_lock(sound_device); @@ -804,7 +812,7 @@ void BKE_sound_seek_scene(Main *bmain, Scene *scene) int animation_playing; const float one_frame = (float)(1.0 / FPS); - const float cur_time = (float)((double)CFRA / FPS); + const float cur_time = get_cur_time(scene); AUD_Device_lock(sound_device); |