[Bf-blender-cvs] [f48e81e720c] master: Fix T55414: waveforms are reprocessed when undoing

Bastien Montagne noreply at git.blender.org
Fri Jul 20 12:13:26 CEST 2018


Commit: f48e81e720c1e5fcc93ba6da11f862263da9cadc
Author: Bastien Montagne
Date:   Fri Jul 20 12:01:38 2018 +0200
Branches: master
https://developer.blender.org/rBf48e81e720c1e5fcc93ba6da11f862263da9cadc

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...

===================================================================

M	source/blender/blenkernel/intern/sound.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/makesdna/DNA_sound_types.h

===================================================================

diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c
index 6aa44cde0e0..709a0022767 100644
--- a/source/blender/blenkernel/intern/sound.c
+++ b/source/blender/blenkernel/intern/sound.c
@@ -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)
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 1def462b1ca..1d772a15efd 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -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;
diff --git a/source/blender/makesdna/DNA_sound_types.h b/source/blender/makesdna/DNA_sound_types.h
index aefe1a7d5a3..7778582b82d 100644
--- a/source/blender/makesdna/DNA_sound_types.h
+++ b/source/blender/makesdna/DNA_sound_types.h
@@ -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



More information about the Bf-blender-cvs mailing list