From 33af6d9c5bc7f78206e8aec55c7bc4815bc9d042 Mon Sep 17 00:00:00 2001 From: Sebastian Parborg Date: Mon, 25 Nov 2024 15:44:16 +0100 Subject: [PATCH] Fix: Make sure that sound scrubbing doesn't interfere with regular playback When "sound scrubbing" was turned on, it would stop audio playback if you managed to start the timeline before the "sound scrubbing" audio preview had finished. --- source/blender/blenkernel/intern/sound.cc | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/sound.cc b/source/blender/blenkernel/intern/sound.cc index 261c6a3b006..6a9d4a09fee 100644 --- a/source/blender/blenkernel/intern/sound.cc +++ b/source/blender/blenkernel/intern/sound.cc @@ -917,6 +917,20 @@ void BKE_sound_play_scene(Scene *scene) AUD_Device_lock(sound_device); + if (scene->sound_scrub_handle && + AUD_Handle_getStatus(scene->sound_scrub_handle) != AUD_STATUS_INVALID) + { + /* If the audio scrub handle is playbing back, stop to make sure it is not active. + * Otherwise, it will trigger a callback that will stop audio playback. + */ + AUD_Handle_stop(scene->sound_scrub_handle); + scene->sound_scrub_handle = nullptr; + /* The scrub_handle started playback with playback_handle, stop it so we can + * properly restart it. + */ + AUD_Handle_pause(scene->playback_handle); + } + status = scene->playback_handle ? AUD_Handle_getStatus(scene->playback_handle) : AUD_STATUS_INVALID; @@ -996,7 +1010,6 @@ void BKE_sound_seek_scene(Main *bmain, Scene *scene) if (scene->audio.flag & AUDIO_SCRUB && !animation_playing) { /* Playback one frame of audio without advancing the timeline. */ - // TODO bug when starting playback before "pauseAfter has finished. AUD_Handle_setPosition(scene->playback_handle, cur_time); AUD_Handle_resume(scene->playback_handle); if (scene->sound_scrub_handle &&