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:
-rw-r--r--source/blender/blenkernel/BKE_sound.h2
-rw-r--r--source/blender/blenkernel/intern/sound.c25
-rw-r--r--source/blender/editors/include/ED_screen.h2
-rw-r--r--source/blender/editors/include/ED_screen_types.h8
-rw-r--r--source/blender/editors/interface/interface_templates.c2
-rw-r--r--source/blender/editors/screen/screen_edit.c5
-rw-r--r--source/blender/editors/screen/screen_ops.c25
-rw-r--r--source/blender/editors/space_time/time_header.c5
-rw-r--r--source/blender/makesdna/DNA_space_types.h2
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c2
-rw-r--r--source/blender/windowmanager/intern/wm_files.c4
-rw-r--r--source/blender/windowmanager/intern/wm_init_exit.c2
12 files changed, 46 insertions, 38 deletions
diff --git a/source/blender/blenkernel/BKE_sound.h b/source/blender/blenkernel/BKE_sound.h
index ef66b29f112..1dd90b4dbda 100644
--- a/source/blender/blenkernel/BKE_sound.h
+++ b/source/blender/blenkernel/BKE_sound.h
@@ -39,8 +39,6 @@ struct Main;
void sound_init();
-void sound_reinit(struct bContext *C);
-
void sound_exit();
struct bSound* sound_new_file(struct Main *main, char* filename);
diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c
index 347837d1dd0..03123a4e577 100644
--- a/source/blender/blenkernel/intern/sound.c
+++ b/source/blender/blenkernel/intern/sound.c
@@ -34,19 +34,7 @@
void sound_init()
{
AUD_Specs specs;
- specs.channels = AUD_CHANNELS_STEREO;
- specs.format = AUD_FORMAT_S16;
- specs.rate = AUD_RATE_44100;
-
- if(!AUD_init(AUD_SDL_DEVICE, specs, AUD_DEFAULT_BUFFER_SIZE))
- if(!AUD_init(AUD_OPENAL_DEVICE, specs, AUD_DEFAULT_BUFFER_SIZE*4))
- AUD_init(AUD_NULL_DEVICE, specs, AUD_DEFAULT_BUFFER_SIZE);
-}
-
-void sound_reinit(struct bContext *C)
-{
- AUD_Specs specs;
- int device, buffersize;
+ int device, buffersize, success;
device = U.audiodevice;
buffersize = U.mixbufsize;
@@ -66,8 +54,15 @@ void sound_reinit(struct bContext *C)
if(specs.channels <= AUD_CHANNELS_INVALID)
specs.channels = AUD_CHANNELS_STEREO;
- if(!AUD_init(device, specs, buffersize))
- AUD_init(AUD_NULL_DEVICE, specs, buffersize);
+ if(!AUD_init(device, specs, buffersize)) {
+ if(device == AUD_SDL_DEVICE)
+ success= AUD_init(AUD_OPENAL_DEVICE, specs, AUD_DEFAULT_BUFFER_SIZE*4);
+ else
+ success= AUD_init(AUD_SDL_DEVICE, specs, AUD_DEFAULT_BUFFER_SIZE*4);
+
+ if(!success)
+ AUD_init(AUD_NULL_DEVICE, specs, buffersize);
+ }
}
void sound_exit()
diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h
index 1c504f84eae..0430a8cecac 100644
--- a/source/blender/editors/include/ED_screen.h
+++ b/source/blender/editors/include/ED_screen.h
@@ -94,7 +94,7 @@ void ED_screen_set_scene(struct bContext *C, struct Scene *scene);
void ED_screen_delete_scene(struct bContext *C, struct Scene *scene);
void ED_screen_set_subwinactive(struct wmWindow *win, struct wmEvent *event);
void ED_screen_exit(struct bContext *C, struct wmWindow *window, struct bScreen *screen);
-void ED_screen_animation_timer(struct bContext *C, int redraws, int enable);
+void ED_screen_animation_timer(struct bContext *C, int redraws, int sync, int enable);
int ED_screen_full_newspace(struct bContext *C, ScrArea *sa, int type);
void ED_screen_full_prevspace(struct bContext *C);
diff --git a/source/blender/editors/include/ED_screen_types.h b/source/blender/editors/include/ED_screen_types.h
index 76a2a55c29e..72afe7704b4 100644
--- a/source/blender/editors/include/ED_screen_types.h
+++ b/source/blender/editors/include/ED_screen_types.h
@@ -31,9 +31,9 @@
/* for animplayer */
typedef struct ScreenAnimData {
- ARegion *ar; /* do not read from this, only for comparing if region exists */
+ ARegion *ar; /* do not read from this, only for comparing if region exists */
int redraws;
- int flag; /* flags for playback */
+ int flag; /* flags for playback */
} ScreenAnimData;
/* for animplayer */
@@ -42,6 +42,10 @@ enum {
ANIMPLAY_FLAG_REVERSE = (1<<0),
/* temporary - playback just jumped to the start/end */
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) */
+ ANIMPLAY_FLAG_NO_SYNC = (1<<3),
};
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 948203eaa24..d5df03e151a 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -1579,7 +1579,7 @@ static void do_running_jobs(bContext *C, void *arg, int event)
WM_jobs_stop(CTX_wm_manager(C), CTX_wm_screen(C));
break;
case B_STOPANIM:
- ED_screen_animation_timer(C, 0, 0);
+ WM_operator_name_call(C, "SCREEN_OT_animation_play", WM_OP_INVOKE_SCREEN, NULL);
break;
}
}
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) ***************************** */
diff --git a/source/blender/editors/space_time/time_header.c b/source/blender/editors/space_time/time_header.c
index ea391e0cca7..412a1e81d49 100644
--- a/source/blender/editors/space_time/time_header.c
+++ b/source/blender/editors/space_time/time_header.c
@@ -397,7 +397,6 @@ void do_time_buttons(bContext *C, void *arg, int event)
void time_header_buttons(const bContext *C, ARegion *ar)
{
ScrArea *sa= CTX_wm_area(C);
- SpaceTime *stime= CTX_wm_space_time(C);
Scene *scene= CTX_data_scene(C);
wmTimer *animtimer= CTX_wm_screen(C)->animtimer;
uiBlock *block;
@@ -568,8 +567,8 @@ void time_header_buttons(const bContext *C, ARegion *ar)
xco+= XIC;
- uiDefIconButBitI(block, TOG, TIME_WITH_SEQ_AUDIO, B_DIFF, ICON_SPEAKER,
- xco, yco, XIC, YIC, &(stime->redraws), 0, 0, 0, 0, "Play back and sync with audio from Sequence Editor");
+ uiDefIconButBitS(block, TOG, AUDIO_SYNC, B_DIFF, ICON_SPEAKER,
+ xco, yco, XIC, YIC, &(scene->audio.flag), 0, 0, 0, 0, "Play back and sync with audio from Sequence Editor");
/* always as last */
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index d24d9af4177..6eb5afbd6ac 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -821,7 +821,7 @@ enum {
#define TIME_ALL_3D_WIN 2
#define TIME_ALL_ANIM_WIN 4
#define TIME_ALL_BUTS_WIN 8
-#define TIME_WITH_SEQ_AUDIO 16
+#define TIME_WITH_SEQ_AUDIO 16 // deprecated
#define TIME_SEQ 32
#define TIME_ALL_IMAGE_WIN 64
#define TIME_CONTINUE_PHYSICS 128
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index 2179b10e47e..59333f1191d 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -120,7 +120,7 @@ static PointerRNA rna_UserDef_system_get(PointerRNA *ptr)
static void rna_UserDef_audio_update(bContext *C, PointerRNA *ptr)
{
- sound_reinit(C);
+ sound_init(C);
}
#else
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index ffaa315f04e..9c30c99bbdd 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -68,6 +68,7 @@
#include "BKE_main.h"
#include "BKE_packedFile.h"
#include "BKE_report.h"
+#include "BKE_sound.h"
#include "BKE_texture.h"
#include "BKE_utildefines.h"
@@ -224,7 +225,7 @@ static void wm_init_userdef()
{
UI_init_userdef();
MEM_CacheLimiter_set_maximum(U.memcachelimit * 1024 * 1024);
-
+ sound_init();
}
void WM_read_file(bContext *C, char *name, ReportList *reports)
@@ -252,7 +253,6 @@ void WM_read_file(bContext *C, char *name, ReportList *reports)
wm_check(C); /* opens window(s), checks keymaps */
// XXX mainwindow_set_filename_to_title(G.main->name);
-// XXX sound_initialize_sounds();
if(retval==2) wm_init_userdef(); // in case a userdef is read from regular .blend
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index c679cbcab53..ee826d5f57e 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -144,8 +144,6 @@ void WM_init(bContext *C)
read_Blog();
BLI_strncpy(G.lib, G.sce, FILE_MAX);
-
- sound_init();
}
/* free strings of open recent files */