[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [27021] trunk/blender: Enabling AV-sync again.
Joerg Mueller
nexyon at gmail.com
Fri Feb 19 13:20:29 CET 2010
Revision: 27021
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=27021
Author: nexyon
Date: 2010-02-19 13:20:29 +0100 (Fri, 19 Feb 2010)
Log Message:
-----------
Enabling AV-sync again. You can now choose between No sync, Frame Dropping or AV-sync.
Modified Paths:
--------------
trunk/blender/release/scripts/ui/space_time.py
trunk/blender/source/blender/blenkernel/BKE_sound.h
trunk/blender/source/blender/blenkernel/intern/sound.c
trunk/blender/source/blender/editors/include/ED_screen_types.h
trunk/blender/source/blender/editors/screen/screen_ops.c
trunk/blender/source/blender/makesdna/DNA_scene_types.h
trunk/blender/source/blender/makesrna/intern/rna_scene.c
Modified: trunk/blender/release/scripts/ui/space_time.py
===================================================================
--- trunk/blender/release/scripts/ui/space_time.py 2010-02-19 11:42:21 UTC (rev 27020)
+++ trunk/blender/release/scripts/ui/space_time.py 2010-02-19 12:20:29 UTC (rev 27021)
@@ -72,7 +72,7 @@
subsub = row.row()
subsub.prop(tools, "record_with_nla", toggle=True)
- layout.prop(scene, "sync_audio", text="AV-sync", toggle=True, icon='SPEAKER')
+ layout.prop(scene, "sync_mode", text="")
layout.separator()
@@ -152,6 +152,7 @@
layout.separator()
+ layout.prop(scene, "frame_drop", text="Frame Dropping")
layout.prop(scene, "sync_audio", text="AV-sync", icon='SPEAKER')
layout.prop(scene, "mute_audio")
layout.prop(scene, "scrub_audio")
Modified: trunk/blender/source/blender/blenkernel/BKE_sound.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_sound.h 2010-02-19 11:42:21 UTC (rev 27020)
+++ trunk/blender/source/blender/blenkernel/BKE_sound.h 2010-02-19 12:20:29 UTC (rev 27021)
@@ -86,6 +86,8 @@
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
Modified: trunk/blender/source/blender/blenkernel/intern/sound.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/sound.c 2010-02-19 11:42:21 UTC (rev 27020)
+++ trunk/blender/source/blender/blenkernel/intern/sound.c 2010-02-19 12:20:29 UTC (rev 27021)
@@ -394,6 +394,11 @@
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);
Modified: trunk/blender/source/blender/editors/include/ED_screen_types.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_screen_types.h 2010-02-19 11:42:21 UTC (rev 27020)
+++ trunk/blender/source/blender/editors/include/ED_screen_types.h 2010-02-19 12:20:29 UTC (rev 27021)
@@ -47,7 +47,7 @@
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),
};
Modified: trunk/blender/source/blender/editors/screen/screen_ops.c
===================================================================
--- trunk/blender/source/blender/editors/screen/screen_ops.c 2010-02-19 11:42:21 UTC (rev 27020)
+++ trunk/blender/source/blender/editors/screen/screen_ops.c 2010-02-19 12:20:29 UTC (rev 27021)
@@ -2426,23 +2426,30 @@
/* 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... */
Modified: trunk/blender/source/blender/makesdna/DNA_scene_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_scene_types.h 2010-02-19 11:42:21 UTC (rev 27020)
+++ trunk/blender/source/blender/makesdna/DNA_scene_types.h 2010-02-19 12:20:29 UTC (rev 27021)
@@ -1067,6 +1067,7 @@
#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 */
Modified: trunk/blender/source/blender/makesrna/intern/rna_scene.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_scene.c 2010-02-19 11:42:21 UTC (rev 27020)
+++ trunk/blender/source/blender/makesrna/intern/rna_scene.c 2010-02-19 12:20:29 UTC (rev 27021)
@@ -704,6 +704,32 @@
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 @@
{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 @@
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");
More information about the Bf-blender-cvs
mailing list