diff options
author | Joerg Mueller <nexyon@gmail.com> | 2010-02-18 17:17:53 +0300 |
---|---|---|
committer | Joerg Mueller <nexyon@gmail.com> | 2010-02-18 17:17:53 +0300 |
commit | 37d781b8687ea242c6d185f4c9e58518a62eec32 (patch) | |
tree | 8a11e42b32878bd2d824fbd45714edc341aff288 | |
parent | 8a3be9840315412e344bbd8554b3888399b72e6b (diff) |
Basic AV Sync for forward playing.
-rw-r--r-- | source/blender/blenkernel/BKE_sound.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/sound.c | 5 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_ops.c | 12 |
3 files changed, 15 insertions, 4 deletions
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 +/- */ |