[Bf-blender-cvs] [9ddbb03861f] master: Fix T74111: Animation Playback Delayed With Time Remapping And AV-Sync

Sebastian Parborg noreply at git.blender.org
Mon Apr 6 13:57:14 CEST 2020


Commit: 9ddbb03861fbfb36a83c1eb3fe2fb0feb455d0bd
Author: Sebastian Parborg
Date:   Mon Apr 6 13:53:07 2020 +0200
Branches: master
https://developer.blender.org/rB9ddbb03861fbfb36a83c1eb3fe2fb0feb455d0bd

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

===================================================================

M	source/blender/blenkernel/intern/sound.c

===================================================================

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);



More information about the Bf-blender-cvs mailing list