mirror of
https://github.com/blender/blender
synced 2026-09-28 04:04:20 +03:00
Fix: VSE: Can not cancel waveform reading job
When there are lot of sound strips in VSE timeline, waveform rendering
could not be stopped. This causes problems mainly when .blend file was
opened by accident and different one can not be opened until all
waveforms are read, which can take a minute.
This was caused by code, where value of `stop` boolean pointer was
stored in local variable and cast into short. Pointer to this local
variable was passed to `AUD_readSound()`. Then value of `stop` bool
pointer was set to that local variable again. Because the code runs in
multiple threads now, it is quite likely, that `stop` value gets
overwritten by older thread. Especially, because `AUD_readSound()` does
interrupt its process only when `stop` was true before its execution,
so it is done very quickly.
Pass boolean pointer directly to `AUD_readSound()`, so the waveform
reading process can be interrupted immediately. The change in Audaspace
is already merged in
9b1be5f7c9
Finally, while the waveform reading job now can be cancelled, new job
will be created immediately. This is technically correct behavior, even
though it can cause other problems described in #144082
Pull Request: https://projects.blender.org/blender/blender/pulls/149301
This commit is contained in:
parent
1a0cdb0d6d
commit
b27ba0fef1
3 changed files with 6 additions and 7 deletions
2
extern/audaspace/bindings/C/AUD_Special.cpp
vendored
2
extern/audaspace/bindings/C/AUD_Special.cpp
vendored
|
|
@ -200,7 +200,7 @@ AUD_API AUD_Handle* AUD_pauseAfter(AUD_Handle* handle, double seconds)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
AUD_API int AUD_readSound(AUD_Sound* sound, float* buffer, int length, int samples_per_second, short* interrupt)
|
||||
AUD_API int AUD_readSound(AUD_Sound* sound, float* buffer, int length, int samples_per_second, bool* interrupt)
|
||||
{
|
||||
DeviceSpecs specs;
|
||||
float* buf;
|
||||
|
|
|
|||
6
extern/audaspace/bindings/C/AUD_Special.h
vendored
6
extern/audaspace/bindings/C/AUD_Special.h
vendored
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
#include "AUD_Types.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
@ -53,10 +55,10 @@ extern AUD_API AUD_Handle* AUD_pauseAfter(AUD_Handle* handle, double seconds);
|
|||
* \param buffer The buffer to write to. Must have a size of 3*4*length.
|
||||
* \param length How many samples to read from the sound.
|
||||
* \param samples_per_second How many samples to read per second of the sound.
|
||||
* \param interrupt Must point to a short that equals 0. If it is set to a non-zero value, the method will be interrupted and return 0.
|
||||
* \param interrupt Must point to a bool that equals false. If it is set to true, the method will be interrupted and return 0.
|
||||
* \return How many samples really have been read. Always <= length.
|
||||
*/
|
||||
extern AUD_API int AUD_readSound(AUD_Sound* sound, float* buffer, int length, int samples_per_second, short* interrupt);
|
||||
extern AUD_API int AUD_readSound(AUD_Sound* sound, float* buffer, int length, int samples_per_second, bool* interrupt);
|
||||
|
||||
/**
|
||||
* Mixes a sound down into a file.
|
||||
|
|
|
|||
|
|
@ -1305,11 +1305,8 @@ void BKE_sound_read_waveform(Main *bmain, bSound *sound, bool *stop)
|
|||
int length = info.length * SOUND_WAVE_SAMPLES_PER_SECOND;
|
||||
|
||||
waveform->data = MEM_malloc_arrayN<float>(3 * size_t(length), "SoundWaveform.samples");
|
||||
/* Ideally this would take a boolean argument. */
|
||||
short stop_i16 = *stop;
|
||||
waveform->length = AUD_readSound(
|
||||
sound->playback_handle, waveform->data, length, SOUND_WAVE_SAMPLES_PER_SECOND, &stop_i16);
|
||||
*stop = stop_i16 != 0;
|
||||
sound->playback_handle, waveform->data, length, SOUND_WAVE_SAMPLES_PER_SECOND, stop);
|
||||
}
|
||||
else {
|
||||
/* Create an empty waveform here if the sound couldn't be
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue