diff options
author | Julian Eisel <julian@blender.org> | 2020-06-05 14:09:31 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2020-06-05 14:09:31 +0300 |
commit | 920a58d9b6d667894cf166cbbd25e4c2fbd238ea (patch) | |
tree | 7ca5a9da640753b5e070c439ac3bdd14dfad92cf /source/blender/blenkernel/intern/sound.c | |
parent | c94b6209861ca7cc3985b53474feed7d94c0221a (diff) | |
parent | a1d55bdd530390e58c51abe9707b8d3b0ae3e861 (diff) |
Merge branch 'master' into wm-drag-drop-rewritewm-drag-drop-rewrite
Diffstat (limited to 'source/blender/blenkernel/intern/sound.c')
-rw-r--r-- | source/blender/blenkernel/intern/sound.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 3bb95eaeff0..e8f31594cc0 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -127,6 +127,7 @@ IDTypeInfo IDType_ID_SO = { .copy_data = sound_copy_data, .free_data = sound_free_data, .make_local = NULL, + .foreach_id = NULL, }; #ifdef WITH_AUDASPACE @@ -550,12 +551,12 @@ void BKE_sound_destroy_scene(Scene *scene) } } -void BKE_sound_lock_scene(struct Scene *scene) +void BKE_sound_lock() { AUD_Device_lock(sound_device); } -void BKE_sound_unlock_scene(struct Scene *scene) +void BKE_sound_unlock() { AUD_Device_unlock(sound_device); } @@ -751,12 +752,20 @@ static void sound_start_play_scene(Scene *scene) } } +static double get_cur_time(Scene *scene) +{ + /* We divide by the current framelen to take into account time remapping. + * Otherwise we will get the wrong starting time which will break A/V sync. + * See T74111 for further details. */ + return FRA2TIME((CFRA + SUBFRA) / (double)scene->r.framelen); +} + void BKE_sound_play_scene(Scene *scene) { sound_verify_evaluated_id(&scene->id); AUD_Status status; - const float cur_time = (float)((double)CFRA / FPS); + const double cur_time = get_cur_time(scene); AUD_Device_lock(sound_device); @@ -803,8 +812,8 @@ void BKE_sound_seek_scene(Main *bmain, Scene *scene) bScreen *screen; int animation_playing; - const float one_frame = (float)(1.0 / FPS); - const float cur_time = (float)((double)CFRA / FPS); + const double one_frame = 1.0 / FPS; + const double cur_time = FRA2TIME(CFRA); AUD_Device_lock(sound_device); @@ -861,7 +870,7 @@ void BKE_sound_seek_scene(Main *bmain, Scene *scene) AUD_Device_unlock(sound_device); } -float BKE_sound_sync_scene(Scene *scene) +double BKE_sound_sync_scene(Scene *scene) { sound_verify_evaluated_id(&scene->id); @@ -1161,10 +1170,10 @@ void BKE_sound_create_scene(Scene *UNUSED(scene)) void BKE_sound_destroy_scene(Scene *UNUSED(scene)) { } -void BKE_sound_lock_scene(Scene *UNUSED(scene)) +void BKE_sound_lock(void) { } -void BKE_sound_unlock_scene(Scene *UNUSED(scene)) +void BKE_sound_unlock(void) { } void BKE_sound_reset_scene_specs(Scene *UNUSED(scene)) @@ -1222,7 +1231,7 @@ void BKE_sound_stop_scene(Scene *UNUSED(scene)) void BKE_sound_seek_scene(Main *UNUSED(bmain), Scene *UNUSED(scene)) { } -float BKE_sound_sync_scene(Scene *UNUSED(scene)) +double BKE_sound_sync_scene(Scene *UNUSED(scene)) { return NAN_FLT; } @@ -1333,7 +1342,7 @@ void BKE_sound_jack_sync_callback_set(SoundJackSyncCallback callback) #endif } -void BKE_sound_jack_scene_update(Scene *scene, int mode, float time) +void BKE_sound_jack_scene_update(Scene *scene, int mode, double time) { sound_verify_evaluated_id(&scene->id); |