diff options
author | Peter Schlaile <peter@schlaile.de> | 2007-12-23 20:01:44 +0300 |
---|---|---|
committer | Peter Schlaile <peter@schlaile.de> | 2007-12-23 20:01:44 +0300 |
commit | 74ebc7754729add77fa2b7dc9e74798a407bffed (patch) | |
tree | 9a1769d9620cd35ec838a399ca2446e53a0e0984 | |
parent | 9efe5e5b2327cf22bd187a3d17371f5d156ef9fa (diff) |
== Sequencer (Peach request) ==
Make the "Sync" button work when sound is disabled, Animators use this as a way to play animations at the right speed, could be renamed to "Drop Frames" and work even when blender built without audio enabled.
(do not forget to give credit to me :)
-rw-r--r-- | source/blender/src/drawview.c | 4 | ||||
-rw-r--r-- | source/blender/src/editscreen.c | 2 | ||||
-rw-r--r-- | source/blender/src/seqaudio.c | 19 |
3 files changed, 15 insertions, 10 deletions
diff --git a/source/blender/src/drawview.c b/source/blender/src/drawview.c index 5df1448ebc1..5568cc17231 100644 --- a/source/blender/src/drawview.c +++ b/source/blender/src/drawview.c @@ -3274,8 +3274,7 @@ int update_time(void) static double ltime; double time; - if ((U.mixbufsize) - && (audiostream_pos() != CFRA) + if ((audiostream_pos() != CFRA) && (G.scene->audio.flag & AUDIO_SYNC)) { return 0; } @@ -3507,7 +3506,6 @@ void inner_play_anim_loop(int init, int mode) cached = cached_dynamics(PSFRA,PEFRA); } else { if (cached - && U.mixbufsize && (G.scene->audio.flag & AUDIO_SYNC)) { CFRA = audiostream_pos(); } else { diff --git a/source/blender/src/editscreen.c b/source/blender/src/editscreen.c index 741b6ab6d13..35c0692510d 100644 --- a/source/blender/src/editscreen.c +++ b/source/blender/src/editscreen.c @@ -1086,7 +1086,7 @@ int has_screenhandler(bScreen *sc, short eventcode) static void animated_screen(bScreen *sc, short val) { - if (U.mixbufsize && (val & TIME_WITH_SEQ_AUDIO)) { + if ((val & TIME_WITH_SEQ_AUDIO)) { if(CFRA>=PEFRA) { CFRA= PSFRA; audiostream_stop(); diff --git a/source/blender/src/seqaudio.c b/source/blender/src/seqaudio.c index de8cc488a85..b4d4f190f91 100644 --- a/source/blender/src/seqaudio.c +++ b/source/blender/src/seqaudio.c @@ -96,6 +96,7 @@ static int audio_scrub=0; static int audio_playing=0; static int audio_initialised=0; static int audio_startframe=0; +static double audio_starttime = 0.0; ///// // /* local protos ------------------- */ @@ -494,7 +495,7 @@ void audiostream_play(Uint32 startframe, Uint32 duration, int mixdown) sound_init_audio(); } - if (!audio_initialised && !(duration + mixdown)) { + if (U.mixbufsize && !audio_initialised && !(duration + mixdown)) { desired.freq=G.scene->audio.mixrate; desired.format=AUDIO_S16SYS; desired.channels=2; @@ -508,7 +509,8 @@ void audiostream_play(Uint32 startframe, Uint32 duration, int mixdown) audio_startframe = startframe; audio_pos = ( ((int)( FRA2TIME(startframe) *(G.scene->audio.mixrate)*4 )) & (~3) ); - + audio_starttime = PIL_check_seconds_timer(); + audio_scrub = duration; if (!mixdown) { SDL_PauseAudio(0); @@ -535,10 +537,15 @@ void audiostream_stop(void) int audiostream_pos(void) { int pos; - - pos = (int) (((double)(audio_pos-U.mixbufsize) - / ( G.scene->audio.mixrate*4 )) - * FPS ); + + if (U.mixbufsize) { + pos = (int) (((double)(audio_pos-U.mixbufsize) + / ( G.scene->audio.mixrate*4 )) + * FPS ); + } else { /* fallback to seconds_timer when no audio available */ + pos = (int) ((PIL_check_seconds_timer() - audio_starttime) + * FPS); + } if (pos < audio_startframe) pos = audio_startframe; return ( pos ); |