Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2009-08-17 00:37:22 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-08-17 00:37:22 +0400
commit55edb016b198dbfbd94612348a70ea9bb26ef558 (patch)
tree01ec633273d5c92d42fcf1ba00e7546cba7d68fe /source/blender/editors/screen
parent19babf988d2e9e8cb9537161d5e331f35a05c2b5 (diff)
2.5: Sound
* Move sound_init to make sure it gets called everytime user preferences is reloaded. * Merged sound_reinit and sound_init. One used user preferences while the other did not, don't see the point of this, so just made it always use user preferences now. * Timeline header audio sync option now controls scene flag rather than timeline flag. Since it uses the same playback operator now, there is no distinction anymore. * Added boolean property sync to animation play operator, to sync with audio or not. Uses scene setting if property is not set. * Playback stop button in info header now calls operator, so sounds stop playing too.
Diffstat (limited to 'source/blender/editors/screen')
-rw-r--r--source/blender/editors/screen/screen_edit.c5
-rw-r--r--source/blender/editors/screen/screen_ops.c25
2 files changed, 22 insertions, 8 deletions
diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c
index b6c2ece1a02..6663dae1194 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -1516,7 +1516,7 @@ void ED_screen_full_prevspace(bContext *C)
/* redraws: uses defines from stime->redraws
* enable: 1 - forward on, -1 - backwards on, 0 - off
*/
-void ED_screen_animation_timer(bContext *C, int redraws, int enable)
+void ED_screen_animation_timer(bContext *C, int redraws, int sync, int enable)
{
bScreen *screen= CTX_wm_screen(C);
wmWindow *win= CTX_wm_window(C);
@@ -1532,7 +1532,8 @@ void ED_screen_animation_timer(bContext *C, int redraws, int enable)
screen->animtimer= WM_event_add_window_timer(win, TIMER0, (1.0/FPS));
sad->ar= CTX_wm_region(C);
sad->redraws= redraws;
- sad->flag= (enable < 0) ? ANIMPLAY_FLAG_REVERSE : 0;
+ sad->flag= (enable < 0)? ANIMPLAY_FLAG_REVERSE: 0;
+ sad->flag= (sync == 0)? ANIMPLAY_FLAG_NO_SYNC: (sync == 1)? ANIMPLAY_FLAG_SYNC: 0;
screen->animtimer->customdata= sad;
}
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index 9fcee99aa56..84e4fe1313f 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -2227,17 +2227,25 @@ static int screen_animation_step(bContext *C, wmOperator *op, wmEvent *event)
wmTimer *wt= screen->animtimer;
ScreenAnimData *sad= wt->customdata;
ScrArea *sa;
+ int sync;
+
+ /* sync, don't sync, or follow scene setting */
+ if(scene->audio.flag & ANIMPLAY_FLAG_SYNC) sync= 1;
+ else if(scene->audio.flag & ANIMPLAY_FLAG_NO_SYNC) sync= 0;
+ else sync= (scene->audio.flag & AUDIO_SYNC);
- if(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?
+ 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;
}
else {
- if (sad->flag & ANIMPLAY_FLAG_REVERSE)
+ /* one frame +/- */
+ if(sad->flag & ANIMPLAY_FLAG_REVERSE)
scene->r.cfra--;
else
scene->r.cfra++;
@@ -2325,18 +2333,22 @@ static int screen_animation_play(bContext *C, wmOperator *op, wmEvent *event)
bScreen *screen= CTX_wm_screen(C);
if(screen->animtimer) {
- ED_screen_animation_timer(C, 0, 0);
+ ED_screen_animation_timer(C, 0, 0, 0);
sound_stop_all(C);
}
else {
ScrArea *sa= CTX_wm_area(C);
int mode= (RNA_boolean_get(op->ptr, "reverse")) ? -1 : 1;
+ int sync= -1;
+
+ if(RNA_property_is_set(op->ptr, "sync"))
+ sync= (RNA_boolean_get(op->ptr, "sync"));
/* timeline gets special treatment since it has it's own menu for determining redraws */
if ((sa) && (sa->spacetype == SPACE_TIME)) {
SpaceTime *stime= (SpaceTime *)sa->spacedata.first;
- ED_screen_animation_timer(C, stime->redraws, mode);
+ ED_screen_animation_timer(C, stime->redraws, sync, mode);
/* update region if TIME_REGION was set, to leftmost 3d window */
if(screen->animtimer && (stime->redraws & TIME_REGION)) {
@@ -2347,7 +2359,7 @@ static int screen_animation_play(bContext *C, wmOperator *op, wmEvent *event)
}
}
else {
- ED_screen_animation_timer(C, TIME_REGION|TIME_ALL_3D_WIN, mode);
+ ED_screen_animation_timer(C, TIME_REGION|TIME_ALL_3D_WIN, sync, mode);
if(screen->animtimer) {
wmTimer *wt= screen->animtimer;
@@ -2373,6 +2385,7 @@ static void SCREEN_OT_animation_play(wmOperatorType *ot)
ot->poll= ED_operator_screenactive;
RNA_def_boolean(ot->srna, "reverse", 0, "Play in Reverse", "Animation is played backwards");
+ RNA_def_boolean(ot->srna, "sync", 0, "Sync", "Drop frames to maintain framerate and stay in sync with audio.");
}
/* ************** border select operator (template) ***************************** */