Basic AV Sync for forward playing.
authorJoerg Mueller <nexyon@gmail.com>
Thu, 18 Feb 2010 14:17:53 +0000 (14:17 +0000)
committerJoerg Mueller <nexyon@gmail.com>
Thu, 18 Feb 2010 14:17:53 +0000 (14:17 +0000)
source/blender/blenkernel/BKE_sound.h
source/blender/blenkernel/intern/sound.c
source/blender/editors/screen/screen_ops.c

index f44ce47ebccfe8ab7aebe7389881997e012db841..97a2adb6e6b28b9fca516dc80f47d4873695df79 100644 (file)
@@ -86,6 +86,8 @@ void sound_stop_scene(struct Scene *scene);
 
 void sound_seek_scene(struct bContext *C);
 
+float sound_sync_scene(struct Scene *scene);
+
 int sound_read_sound_buffer(struct bSound* sound, float* buffer, int length);
 
 #endif
index 35cedbd2d5337265a134e7392df5be342a2e2dab..4e08a52d992a0d3526a3ad8b1a528577e2b98a6d 100644 (file)
@@ -394,6 +394,11 @@ void sound_seek_scene(struct bContext *C)
        AUD_unlock();
 }
 
+float sound_sync_scene(struct Scene *scene)
+{
+       return AUD_getPosition(scene->sound_scene_handle);
+}
+
 int sound_read_sound_buffer(bSound* sound, float* buffer, int length)
 {
        return AUD_readSound(sound->cache, buffer, length);
index 728ce622d9b37b3e367365811a2fd3412fdba737..bbab671a889b13dd8590a98e2fe573a885bcb447 100644 (file)
@@ -2429,13 +2429,17 @@ static int screen_animation_step(bContext *C, wmOperator *op, wmEvent *event)
                else sync= (scene->audio.flag & AUDIO_SYNC);
                
                if(sync) {
-                       /* skip frames */
-                       int step = floor(wt->duration * FPS);
                        if(sad->flag & ANIMPLAY_FLAG_REVERSE) // XXX does this option work with audio?
+                       {                                     // XXX - no
+                               /* skip frames */
+                               int step = floor(wt->duration * FPS);
                                scene->r.cfra -= step;
+                               wt->duration -= ((float)step)/FPS;
+                       }
                        else
-                               scene->r.cfra += step;
-                       wt->duration -= ((float)step)/FPS;
+                       {
+                               scene->r.cfra = floor(sound_sync_scene(scene) * FPS);
+                       }
                }
                else {
                        /* one frame +/- */