[Bf-blender-cvs] [9f681bea68f] master: Fix T64144: Crash when displaying audio waveforms in VSE

Sergey Sharybin noreply at git.blender.org
Sat May 4 19:16:03 CEST 2019


Commit: 9f681bea68fc1aebc41d43d5bd3b5e73c91f6f45
Author: Sergey Sharybin
Date:   Sat May 4 19:15:15 2019 +0200
Branches: master
https://developer.blender.org/rB9f681bea68fc1aebc41d43d5bd3b5e73c91f6f45

Fix T64144: Crash when displaying audio waveforms in VSE

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

M	source/blender/blenkernel/intern/sound.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/editors/space_sequencer/sequencer_draw.c
M	source/blender/editors/space_sequencer/sequencer_preview.c

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

diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c
index 6ea384abdd6..7d335ab1347 100644
--- a/source/blender/blenkernel/intern/sound.c
+++ b/source/blender/blenkernel/intern/sound.c
@@ -152,6 +152,7 @@ void BKE_sound_free(bSound *sound)
   }
 
   BKE_sound_free_audio(sound);
+  BKE_sound_free_waveform(sound);
 
   if (sound->spinlock) {
     BLI_spin_end(sound->spinlock);
@@ -173,8 +174,6 @@ void BKE_sound_free_audio(bSound *sound)
     AUD_Sound_free(sound->cache);
     sound->cache = NULL;
   }
-
-  BKE_sound_free_waveform(sound);
 #else
   UNUSED_VARS(sound);
 #endif /* WITH_AUDASPACE */
@@ -199,8 +198,8 @@ void BKE_sound_copy_data(Main *UNUSED(bmain),
   sound_dst->cache = NULL;
   sound_dst->waveform = NULL;
   sound_dst->playback_handle = NULL;
-  sound_dst->spinlock =
-      NULL; /* Think this is OK? Otherwise, easy to create new spinlock here... */
+  sound_dst->spinlock = MEM_mallocN(sizeof(SpinLock), "sound_spinlock");
+  BLI_spin_init(sound_dst->spinlock);
 
   /* Just to be sure, should not have any value actually after reading time. */
   sound_dst->ipo = NULL;
@@ -882,10 +881,11 @@ void BKE_sound_free_waveform(bSound *sound)
   sound->tags &= ~SOUND_TAGS_WAVEFORM_NO_RELOAD;
 }
 
+/* TODO(sergey): Consider mamakinging this function fully autonomous, as in, not require having
+ * an existing playback handle. That would make it easy to read waveforms, which doesn't seem to
+ * be affected by evaluated scene (waveworm comes from file). */
 void BKE_sound_read_waveform(bSound *sound, short *stop)
 {
-  sound_verify_evaluated_id(&sound->id);
-
   AUD_SoundInfo info = AUD_getInfo(sound->playback_handle);
   SoundWaveform *waveform = MEM_mallocN(sizeof(SoundWaveform), "SoundWaveform");
 
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 9661fd0bc61..3d9497ae6b8 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -8403,10 +8403,9 @@ static void direct_link_sound(FileData *fd, bSound *sound)
     sound->waveform = NULL;
   }
 
-  if (sound->spinlock) {
-    sound->spinlock = MEM_mallocN(sizeof(SpinLock), "sound_spinlock");
-    BLI_spin_init(sound->spinlock);
-  }
+  sound->spinlock = MEM_mallocN(sizeof(SpinLock), "sound_spinlock");
+  BLI_spin_init(sound->spinlock);
+
   /* clear waveform loading flag */
   sound->tags &= ~SOUND_TAGS_WAVEFORM_LOADING;
 
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index a3b02407a9e..72f186d4c1a 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -259,11 +259,6 @@ static void drawseqwave(View2D *v2d,
       return;
     }
 
-    if (!sound->spinlock) {
-      sound->spinlock = MEM_mallocN(sizeof(SpinLock), "sound_spinlock");
-      BLI_spin_init(sound->spinlock);
-    }
-
     BLI_spin_lock(sound->spinlock);
     if (!sound->waveform) {
       if (!(sound->tags & SOUND_TAGS_WAVEFORM_LOADING)) {
diff --git a/source/blender/editors/space_sequencer/sequencer_preview.c b/source/blender/editors/space_sequencer/sequencer_preview.c
index 546c2a8a9f0..8a4e8c007f7 100644
--- a/source/blender/editors/space_sequencer/sequencer_preview.c
+++ b/source/blender/editors/space_sequencer/sequencer_preview.c
@@ -50,6 +50,7 @@ typedef struct PreviewJob {
 
 typedef struct PreviewJobAudio {
   struct PreviewJobAudio *next, *prev;
+  struct Main *bmain;
   bSound *sound;
   int lr; /* sample left or right */
   int startframe;
@@ -79,7 +80,9 @@ static void preview_startjob(void *data, short *stop, short *do_update, float *p
     PreviewJobAudio *preview_next;
     bSound *sound = previewjb->sound;
 
+    BKE_sound_load_audio(previewjb->bmain, sound);
     BKE_sound_read_waveform(sound, stop);
+    BKE_sound_free_audio(sound);
 
     if (*stop || G.is_break) {
       BLI_mutex_lock(pj->mutex);
@@ -153,6 +156,7 @@ void sequencer_preview_add_sound(const bContext *C, Sequence *seq)
 
   /* attempt to lock mutex of job here */
 
+  audiojob->bmain = CTX_data_main(C);
   audiojob->sound = seq->sound;
 
   BLI_mutex_lock(pj->mutex);



More information about the Bf-blender-cvs mailing list