Sound: Fix for being unable to jump to a frame during playback with A/V sync
This commit is contained in:
@@ -32,6 +32,7 @@
|
|||||||
struct Main;
|
struct Main;
|
||||||
struct Sequence;
|
struct Sequence;
|
||||||
struct bSound;
|
struct bSound;
|
||||||
|
struct Depsgraph;
|
||||||
|
|
||||||
typedef struct SoundWaveform {
|
typedef struct SoundWaveform {
|
||||||
int length;
|
int length;
|
||||||
@@ -143,6 +144,10 @@ void BKE_sound_stop_scene(struct Scene *scene);
|
|||||||
|
|
||||||
void BKE_sound_seek_scene(struct Main *bmain, struct Scene *scene);
|
void BKE_sound_seek_scene(struct Main *bmain, struct Scene *scene);
|
||||||
|
|
||||||
|
/* Use this after original scene's frame has been changed. It will take care of doing all the
|
||||||
|
* updates required for BKE_sound_seek_scene(). */
|
||||||
|
void BKE_sound_update_and_seek(struct Main *bmain, struct Depsgraph *depsgraph);
|
||||||
|
|
||||||
float BKE_sound_sync_scene(struct Scene *scene);
|
float BKE_sound_sync_scene(struct Scene *scene);
|
||||||
|
|
||||||
int BKE_sound_scene_playing(struct Scene *scene);
|
int BKE_sound_scene_playing(struct Scene *scene);
|
||||||
|
@@ -1213,6 +1213,19 @@ char **BKE_sound_get_device_names(void)
|
|||||||
|
|
||||||
#endif /* WITH_AUDASPACE */
|
#endif /* WITH_AUDASPACE */
|
||||||
|
|
||||||
|
void BKE_sound_update_and_seek(Main *bmain, Depsgraph *depsgraph)
|
||||||
|
{
|
||||||
|
Scene *scene_orig = DEG_get_input_scene(depsgraph);
|
||||||
|
Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
|
||||||
|
/* NOTE: We don't do copy-on-write or anything like that here because we need to know scene's
|
||||||
|
* flags like "scrubbing" in the BKE_sound_seek_scene(). So we simply update frame to which
|
||||||
|
* seek needs to happen.
|
||||||
|
*
|
||||||
|
* TODO(sergey): Might change API so the frame is passes explicitly. */
|
||||||
|
scene_eval->r.cfra = scene_orig->r.cfra;
|
||||||
|
BKE_sound_seek_scene(bmain, scene_eval);
|
||||||
|
}
|
||||||
|
|
||||||
void BKE_sound_reset_scene_runtime(Scene *scene)
|
void BKE_sound_reset_scene_runtime(Scene *scene)
|
||||||
{
|
{
|
||||||
scene->sound_scene = NULL;
|
scene->sound_scene = NULL;
|
||||||
|
@@ -116,7 +116,7 @@ static void change_frame_apply(bContext *C, wmOperator *op)
|
|||||||
FRAMENUMBER_MIN_CLAMP(CFRA);
|
FRAMENUMBER_MIN_CLAMP(CFRA);
|
||||||
|
|
||||||
/* do updates */
|
/* do updates */
|
||||||
BKE_sound_seek_scene(CTX_data_main(C), DEG_get_evaluated_scene(CTX_data_depsgraph(C)));
|
BKE_sound_update_and_seek(CTX_data_main(C), CTX_data_depsgraph(C));
|
||||||
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
|
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2771,7 +2771,7 @@ static int frame_offset_exec(bContext *C, wmOperator *op)
|
|||||||
|
|
||||||
areas_do_frame_follow(C, false);
|
areas_do_frame_follow(C, false);
|
||||||
|
|
||||||
BKE_sound_seek_scene(bmain, scene);
|
BKE_sound_update_and_seek(bmain, CTX_data_depsgraph(C));
|
||||||
|
|
||||||
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
|
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
|
||||||
|
|
||||||
@@ -2833,8 +2833,7 @@ static int frame_jump_exec(bContext *C, wmOperator *op)
|
|||||||
|
|
||||||
areas_do_frame_follow(C, true);
|
areas_do_frame_follow(C, true);
|
||||||
|
|
||||||
/* TODO(sergey): Make more reusable. */
|
BKE_sound_update_and_seek(bmain, CTX_data_depsgraph(C));
|
||||||
BKE_sound_seek_scene(bmain, DEG_get_evaluated_scene(CTX_data_depsgraph(C)));
|
|
||||||
|
|
||||||
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
|
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
|
||||||
}
|
}
|
||||||
@@ -2950,7 +2949,7 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op)
|
|||||||
else {
|
else {
|
||||||
areas_do_frame_follow(C, true);
|
areas_do_frame_follow(C, true);
|
||||||
|
|
||||||
BKE_sound_seek_scene(bmain, scene);
|
BKE_sound_update_and_seek(bmain, CTX_data_depsgraph(C));
|
||||||
|
|
||||||
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
|
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
|
||||||
|
|
||||||
@@ -3017,7 +3016,7 @@ static int marker_jump_exec(bContext *C, wmOperator *op)
|
|||||||
|
|
||||||
areas_do_frame_follow(C, true);
|
areas_do_frame_follow(C, true);
|
||||||
|
|
||||||
BKE_sound_seek_scene(bmain, scene);
|
BKE_sound_update_and_seek(bmain, CTX_data_depsgraph(C));
|
||||||
|
|
||||||
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
|
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
|
||||||
|
|
||||||
@@ -4404,7 +4403,7 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEv
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (sad->flag & ANIMPLAY_FLAG_JUMPED) {
|
if (sad->flag & ANIMPLAY_FLAG_JUMPED) {
|
||||||
BKE_sound_seek_scene(bmain, scene_eval);
|
BKE_sound_update_and_seek(bmain, depsgraph);
|
||||||
#ifdef PROFILE_AUDIO_SYNCH
|
#ifdef PROFILE_AUDIO_SYNCH
|
||||||
old_frame = CFRA;
|
old_frame = CFRA;
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user