Fix T55414: waveforms are reprocessed when undoing
Add new tag to bSound (runtime flags), and make read code to set a 'no reload waveform' new tag, since it uses a mapping to get existing waveform in undo case...
This commit is contained in:
parent
0bf8096501
commit
f48e81e720
Notes:
blender-bot
2023-02-14 05:45:28 +01:00
Referenced by issue #55414, waveforms are reprocessed when undoing
|
@ -757,15 +757,19 @@ int BKE_sound_scene_playing(struct Scene *scene)
|
|||
|
||||
void BKE_sound_free_waveform(bSound *sound)
|
||||
{
|
||||
SoundWaveform *waveform = sound->waveform;
|
||||
if (waveform) {
|
||||
if (waveform->data) {
|
||||
MEM_freeN(waveform->data);
|
||||
if ((sound->tags & SOUND_TAGS_WAVEFORM_NO_RELOAD) == 0) {
|
||||
SoundWaveform *waveform = sound->waveform;
|
||||
if (waveform) {
|
||||
if (waveform->data) {
|
||||
MEM_freeN(waveform->data);
|
||||
}
|
||||
MEM_freeN(waveform);
|
||||
}
|
||||
MEM_freeN(waveform);
|
||||
}
|
||||
|
||||
sound->waveform = NULL;
|
||||
sound->waveform = NULL;
|
||||
}
|
||||
/* This tag is only valid once. */
|
||||
sound->tags &= ~SOUND_TAGS_WAVEFORM_NO_RELOAD;
|
||||
}
|
||||
|
||||
void BKE_sound_read_waveform(bSound *sound, short *stop)
|
||||
|
|
|
@ -7542,6 +7542,7 @@ static void direct_link_speaker(FileData *fd, Speaker *spk)
|
|||
|
||||
static void direct_link_sound(FileData *fd, bSound *sound)
|
||||
{
|
||||
sound->tags = 0;
|
||||
sound->handle = NULL;
|
||||
sound->playback_handle = NULL;
|
||||
|
||||
|
@ -7553,6 +7554,7 @@ static void direct_link_sound(FileData *fd, bSound *sound)
|
|||
|
||||
if (fd->soundmap) {
|
||||
sound->waveform = newsoundadr(fd, sound->waveform);
|
||||
sound->tags |= SOUND_TAGS_WAVEFORM_NO_RELOAD;
|
||||
}
|
||||
else {
|
||||
sound->waveform = NULL;
|
||||
|
|
|
@ -65,13 +65,15 @@ typedef struct bSound {
|
|||
*/
|
||||
struct PackedFile *newpackedfile;
|
||||
struct Ipo *ipo;
|
||||
|
||||
float volume;
|
||||
float attenuation;
|
||||
float pitch;
|
||||
float min_gain;
|
||||
float max_gain;
|
||||
float distance;
|
||||
int flags;
|
||||
short flags;
|
||||
short tags; /* Runtime only, always reset in readfile. */
|
||||
int pad;
|
||||
|
||||
/* unused currently
|
||||
|
@ -116,6 +118,7 @@ enum {
|
|||
SND_CFRA_NUM = 2,
|
||||
};
|
||||
|
||||
/* bSound->flags */
|
||||
enum {
|
||||
#ifdef DNA_DEPRECATED
|
||||
SOUND_FLAGS_3D = (1 << 3), /* deprecated! used for sound actuator loading */
|
||||
|
@ -125,6 +128,11 @@ enum {
|
|||
SOUND_FLAGS_WAVEFORM_LOADING = (1 << 6),
|
||||
};
|
||||
|
||||
/* bSound->tags */
|
||||
enum {
|
||||
SOUND_TAGS_WAVEFORM_NO_RELOAD = 1 << 0, /* Do not free/reset waveform on sound load, only used by undo code. */
|
||||
};
|
||||
|
||||
/* to DNA_sound_types.h*/
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue