diff options
author | Joerg Mueller <nexyon@gmail.com> | 2010-02-19 15:20:29 +0300 |
---|---|---|
committer | Joerg Mueller <nexyon@gmail.com> | 2010-02-19 15:20:29 +0300 |
commit | f09dc08523e5f5f995e8bb163ddd7e6b86f9cd60 (patch) | |
tree | 855dc2d4f38b3a8852d02c4e8b431135e11c1c83 /source/blender | |
parent | 92927e5f7d094fa1e7262fee95682fb2d588682a (diff) |
Enabling AV-sync again. You can now choose between No sync, Frame Dropping or AV-sync.
Diffstat (limited to 'source/blender')
-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/include/ED_screen_types.h | 2 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_ops.c | 37 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_scene_types.h | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_scene.c | 46 |
6 files changed, 76 insertions, 17 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/include/ED_screen_types.h b/source/blender/editors/include/ED_screen_types.h index cff454d5bff..8580dcc33c9 100644 --- a/source/blender/editors/include/ED_screen_types.h +++ b/source/blender/editors/include/ED_screen_types.h @@ -47,7 +47,7 @@ enum { ANIMPLAY_FLAG_JUMPED = (1<<1), /* drop frames as needed to maintain framerate */ ANIMPLAY_FLAG_SYNC = (1<<2), - /* don't drop frames (and ignore AUDIO_SYNC flag) */ + /* don't drop frames (and ignore SCE_FRAME_DROP flag) */ ANIMPLAY_FLAG_NO_SYNC = (1<<3), }; diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 728ce622d9b..fae7e7b6c40 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -2426,23 +2426,30 @@ static int screen_animation_step(bContext *C, wmOperator *op, wmEvent *event) /* sync, don't sync, or follow scene setting */ if(sad->flag & ANIMPLAY_FLAG_SYNC) sync= 1; else if(sad->flag & ANIMPLAY_FLAG_NO_SYNC) sync= 0; - else sync= (scene->audio.flag & AUDIO_SYNC); + else sync= (scene->flag & SCE_FRAME_DROP); - if(sync) { - /* skip frames */ - int step = floor(wt->duration * FPS); - if(sad->flag & ANIMPLAY_FLAG_REVERSE) // XXX does this option work with audio? - scene->r.cfra -= step; - else - scene->r.cfra += step; - wt->duration -= ((float)step)/FPS; + if((scene->audio.flag & AUDIO_SYNC) && !(sad->flag & ANIMPLAY_FLAG_REVERSE)) + { + scene->r.cfra = floor(sound_sync_scene(scene) * FPS); } - else { - /* one frame +/- */ - if(sad->flag & ANIMPLAY_FLAG_REVERSE) - scene->r.cfra--; - else - scene->r.cfra++; + else + { + if(sync) { + int step = floor(wt->duration * FPS); + /* skip frames */ + if(sad->flag & ANIMPLAY_FLAG_REVERSE) + scene->r.cfra -= step; + else + scene->r.cfra += step; + wt->duration -= ((float)step)/FPS; + } + else { + /* one frame +/- */ + if(sad->flag & ANIMPLAY_FLAG_REVERSE) + scene->r.cfra--; + else + scene->r.cfra++; + } } /* reset 'jumped' flag before checking if we need to jump... */ diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index c408fd69f4f..2bea683b392 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -1067,6 +1067,7 @@ typedef struct Scene { #define SCE_DS_SELECTED (1<<0) #define SCE_DS_COLLAPSED (1<<1) #define SCE_NLA_EDIT_ON (1<<2) +#define SCE_FRAME_DROP (1<<3) /* return flag next_object function */ diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 2d5310971db..c947edd7d6d 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -704,6 +704,32 @@ static void rna_Scene_simplify_update(Main *bmain, Scene *scene, PointerRNA *ptr WM_main_add_notifier(NC_GEOM|ND_DATA, NULL); } +static int rna_Scene_sync_mode_get(PointerRNA *ptr) +{ + Scene *scene= (Scene*)ptr->data; + if(scene->audio.flag & AUDIO_SYNC) + return AUDIO_SYNC; + return scene->flag & SCE_FRAME_DROP; +} + +static void rna_Scene_sync_mode_set(PointerRNA *ptr, int value) +{ + Scene *scene= (Scene*)ptr->data; + + if(value == AUDIO_SYNC) + scene->audio.flag |= AUDIO_SYNC; + else if(value == SCE_FRAME_DROP) + { + scene->audio.flag &= ~AUDIO_SYNC; + scene->flag |= SCE_FRAME_DROP; + } + else + { + scene->audio.flag &= ~AUDIO_SYNC; + scene->flag &= ~SCE_FRAME_DROP; + } +} + #else static void rna_def_transform_orientation(BlenderRNA *brna) @@ -2600,6 +2626,12 @@ void RNA_def_scene(BlenderRNA *brna) {6, "EXPONENT_CLAMPED", 0, "Exponent Clamped", "Exponent distance model with clamping"}, {0, NULL, 0, NULL, NULL}}; + static EnumPropertyItem sync_mode_items[] = { + {0, "NONE", 0, "No Sync", "Do not sync, play every frame"}, + {SCE_FRAME_DROP, "FRAME_DROP", 0, "Frame Dropping", "Drop frames if playback is too slow"}, + {AUDIO_SYNC, "AUDIO_SYNC", 0, "AV-sync", "Sync to audio playback, dropping frames"}, + {0, NULL, 0, NULL, NULL}}; + /* Struct definition */ srna= RNA_def_struct(brna, "Scene", "ID"); RNA_def_struct_ui_text(srna, "Scene", "Scene consisting objects and defining time and render related settings"); @@ -2725,7 +2757,19 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_ui_text(prop, "NLA TweakMode", "Indicates whether there is any action referenced by NLA being edited. Strictly read-only"); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_GRAPH, NULL); - + /* Frame dropping flag for playback and sync enum */ + prop= RNA_def_property(srna, "frame_drop", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_FRAME_DROP); + RNA_def_property_ui_text(prop, "Frame Dropping", "Play back dropping frames if frame display is too slow"); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop= RNA_def_property(srna, "sync_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_funcs(prop, "rna_Scene_sync_mode_get", "rna_Scene_sync_mode_set", NULL); + RNA_def_property_enum_items(prop, sync_mode_items); + RNA_def_property_ui_text(prop, "Sync Mode", "How to sync playback"); + RNA_def_property_update(prop, NC_SCENE, NULL); + + /* Nodes (Compositing) */ prop= RNA_def_property(srna, "nodetree", PROP_POINTER, PROP_NONE); RNA_def_property_ui_text(prop, "Node Tree", "Compositing node tree"); |