From 37d781b8687ea242c6d185f4c9e58518a62eec32 Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Thu, 18 Feb 2010 14:17:53 +0000 Subject: Basic AV Sync for forward playing. --- source/blender/blenkernel/BKE_sound.h | 2 ++ source/blender/blenkernel/intern/sound.c | 5 +++++ source/blender/editors/screen/screen_ops.c | 12 ++++++++---- 3 files changed, 15 insertions(+), 4 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/BKE_sound.h b/source/blender/blenkernel/BKE_sound.h index f44ce47ebcc..97a2adb6e6b 100644 --- a/source/blender/blenkernel/BKE_sound.h +++ b/source/blender/blenkernel/BKE_sound.h @@ -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 diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 35cedbd2d53..4e08a52d992 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -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); diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 728ce622d9b..bbab671a889 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -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 +/- */ -- cgit v1.2.3