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:
Bastien Montagne
2018-07-20 12:01:38 +02:00
parent 0bf8096501
commit f48e81e720
3 changed files with 22 additions and 8 deletions

View File

@@ -757,15 +757,19 @@ int BKE_sound_scene_playing(struct Scene *scene)
void BKE_sound_free_waveform(bSound *sound) void BKE_sound_free_waveform(bSound *sound)
{ {
SoundWaveform *waveform = sound->waveform; if ((sound->tags & SOUND_TAGS_WAVEFORM_NO_RELOAD) == 0) {
if (waveform) { SoundWaveform *waveform = sound->waveform;
if (waveform->data) { if (waveform) {
MEM_freeN(waveform->data); 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) void BKE_sound_read_waveform(bSound *sound, short *stop)

View File

@@ -7542,6 +7542,7 @@ static void direct_link_speaker(FileData *fd, Speaker *spk)
static void direct_link_sound(FileData *fd, bSound *sound) static void direct_link_sound(FileData *fd, bSound *sound)
{ {
sound->tags = 0;
sound->handle = NULL; sound->handle = NULL;
sound->playback_handle = NULL; sound->playback_handle = NULL;
@@ -7553,6 +7554,7 @@ static void direct_link_sound(FileData *fd, bSound *sound)
if (fd->soundmap) { if (fd->soundmap) {
sound->waveform = newsoundadr(fd, sound->waveform); sound->waveform = newsoundadr(fd, sound->waveform);
sound->tags |= SOUND_TAGS_WAVEFORM_NO_RELOAD;
} }
else { else {
sound->waveform = NULL; sound->waveform = NULL;

View File

@@ -65,13 +65,15 @@ typedef struct bSound {
*/ */
struct PackedFile *newpackedfile; struct PackedFile *newpackedfile;
struct Ipo *ipo; struct Ipo *ipo;
float volume; float volume;
float attenuation; float attenuation;
float pitch; float pitch;
float min_gain; float min_gain;
float max_gain; float max_gain;
float distance; float distance;
int flags; short flags;
short tags; /* Runtime only, always reset in readfile. */
int pad; int pad;
/* unused currently /* unused currently
@@ -116,6 +118,7 @@ enum {
SND_CFRA_NUM = 2, SND_CFRA_NUM = 2,
}; };
/* bSound->flags */
enum { enum {
#ifdef DNA_DEPRECATED #ifdef DNA_DEPRECATED
SOUND_FLAGS_3D = (1 << 3), /* deprecated! used for sound actuator loading */ SOUND_FLAGS_3D = (1 << 3), /* deprecated! used for sound actuator loading */
@@ -125,6 +128,11 @@ enum {
SOUND_FLAGS_WAVEFORM_LOADING = (1 << 6), 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*/ /* to DNA_sound_types.h*/
#endif #endif