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.
This commit is contained in:
Sebastian Parborg
2024-11-25 15:44:16 +01:00
committed by Sebastian Parborg
parent d7140a599d
commit 33af6d9c5b
+14 -1
View File
@@ -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 &&