[Bf-blender-cvs] [aab41401f9e] master: Move bSound cache handling during undo to new system.

Bastien Montagne noreply at git.blender.org
Fri Jul 3 12:56:36 CEST 2020


Commit: aab41401f9e911f417039c06a28e948d75cbcdaf
Author: Bastien Montagne
Date:   Fri Jul 3 12:55:50 2020 +0200
Branches: master
https://developer.blender.org/rBaab41401f9e911f417039c06a28e948d75cbcdaf

Move bSound cache handling during undo to new system.

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

M	source/blender/blenkernel/intern/sound.c
M	source/blender/blenloader/intern/readblenentry.c
M	source/blender/blenloader/intern/readfile.c

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

diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c
index a293bc55073..18fd8a10cc1 100644
--- a/source/blender/blenkernel/intern/sound.c
+++ b/source/blender/blenkernel/intern/sound.c
@@ -112,6 +112,20 @@ static void sound_free_data(ID *id)
   }
 }
 
+static void sound_foreach_cache(ID *id,
+                                IDTypeForeachCacheFunctionCallback function_callback,
+                                void *user_data)
+{
+  bSound *sound = (bSound *)id;
+  IDCacheKey key = {
+      .id_session_uuid = id->session_uuid,
+      .offset_in_ID = offsetof(bSound, waveform),
+      .cache_v = sound->waveform,
+  };
+
+  function_callback(id, &key, &sound->waveform, user_data);
+}
+
 IDTypeInfo IDType_ID_SO = {
     .id_code = ID_SO,
     .id_filter = FILTER_ID_SO,
@@ -128,6 +142,7 @@ IDTypeInfo IDType_ID_SO = {
     .free_data = sound_free_data,
     .make_local = NULL,
     .foreach_id = NULL,
+    .foreach_cache = sound_foreach_cache,
 };
 
 #ifdef WITH_AUDASPACE
diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c
index a6fe99b2974..4af9399573a 100644
--- a/source/blender/blenloader/intern/readblenentry.c
+++ b/source/blender/blenloader/intern/readblenentry.c
@@ -399,9 +399,6 @@ BlendFileData *BLO_read_from_memfile(Main *oldmain,
     /* makes lookup of existing video clips in old main */
     blo_make_movieclip_pointer_map(fd, oldmain);
 
-    /* make lookups of existing sound data in old main */
-    blo_make_sound_pointer_map(fd, oldmain);
-
     /* make lookups of existing volume data in old main */
     blo_make_volume_pointer_map(fd, oldmain);
 
@@ -422,9 +419,6 @@ BlendFileData *BLO_read_from_memfile(Main *oldmain,
     /* ensures relinked movie clips are not freed */
     blo_end_movieclip_pointer_map(fd, oldmain);
 
-    /* ensures relinked sounds are not freed */
-    blo_end_sound_pointer_map(fd, oldmain);
-
     /* ensures relinked volumes are not freed */
     blo_end_volume_pointer_map(fd, oldmain);
 
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index a24ccdc2dc1..31843efaaf8 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -8408,13 +8408,9 @@ static void direct_link_sound(BlendDataReader *reader, bSound *sound)
     sound->cache = NULL;
   }
 
-  if (reader->fd->soundmap) {
-    sound->waveform = newsoundadr(reader->fd, sound->waveform);
+  if (reader->fd->memfile != NULL) {
     sound->tags |= SOUND_TAGS_WAVEFORM_NO_RELOAD;
   }
-  else {
-    sound->waveform = NULL;
-  }
 
   sound->spinlock = MEM_mallocN(sizeof(SpinLock), "sound_spinlock");
   BLI_spin_init(sound->spinlock);



More information about the Bf-blender-cvs mailing list