[Bf-blender-cvs] [d366d8e] terrible_consequencer: Attempt to fix OSX issues (again): cleanup the loading flag for files that are loading when interrupted.
Antony Riakiotakis
noreply at git.blender.org
Thu Sep 25 16:27:04 CEST 2014
Commit: d366d8e028c72538d3f55ad5fcc7ef0a87ab33d7
Author: Antony Riakiotakis
Date: Thu Sep 25 16:26:52 2014 +0200
Branches: terrible_consequencer
https://developer.blender.org/rBd366d8e028c72538d3f55ad5fcc7ef0a87ab33d7
Attempt to fix OSX issues (again): cleanup the loading flag for files
that are loading when interrupted.
===================================================================
M source/blender/blenkernel/intern/sound.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 1b9f258..aa52c86 100644
--- a/source/blender/blenkernel/intern/sound.c
+++ b/source/blender/blenkernel/intern/sound.c
@@ -680,30 +680,37 @@ void sound_free_waveform(bSound *sound)
void sound_read_waveform(bSound *sound, bool locked, short *stop)
{
AUD_SoundInfo info;
-
+ SoundWaveform *waveform = NULL;
+
info = AUD_getInfo(sound->playback_handle);
-
+
if (info.length > 0) {
- SoundWaveform *waveform = MEM_mallocN(sizeof(SoundWaveform), "SoundWaveform");
int length = info.length * SOUND_WAVE_SAMPLES_PER_SECOND;
-
+
+ waveform = MEM_mallocN(sizeof(SoundWaveform), "SoundWaveform");
waveform->data = MEM_mallocN(length * sizeof(float) * 3, "SoundWaveform.samples");
waveform->length = AUD_readSound(sound->playback_handle, waveform->data, length, SOUND_WAVE_SAMPLES_PER_SECOND, stop);
-
+
if (*stop) {
MEM_freeN(waveform->data);
MEM_freeN(waveform);
+ if (locked)
+ BLI_mutex_lock(sound->mutex);
+ sound->flags &= ~SOUND_FLAGS_WAVEFORM_LOADING;
+ if (locked)
+ BLI_mutex_unlock(sound->mutex);
return;
}
sound_free_waveform(sound);
-
- if (locked)
- BLI_mutex_lock(sound->mutex);
- sound->waveform = waveform;
- if (locked)
- BLI_mutex_unlock(sound->mutex);
}
+
+ if (locked)
+ BLI_mutex_lock(sound->mutex);
+ sound->waveform = waveform;
+ sound->flags &= ~SOUND_FLAGS_WAVEFORM_LOADING;
+ if (locked)
+ BLI_mutex_unlock(sound->mutex);
}
void sound_update_scene(Main *bmain, struct Scene *scene)
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index b1a267c..396f5c9 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -195,16 +195,17 @@ static void drawseqwave(const bContext *C, SpaceSeq *sseq, Scene *scene, Sequenc
float startsample, endsample;
float value;
bSound *sound = seq->sound;
-
+
SoundWaveform *waveform;
-
+
if (!sound->mutex)
sound->mutex = BLI_mutex_alloc();
BLI_mutex_lock(sound->mutex);
- waveform = seq->sound->waveform;
- if (!waveform) {
+ if (!seq->sound->waveform) {
if(!(sound->flags & SOUND_FLAGS_WAVEFORM_LOADING)) {
+ /* prevent sounds from reloading */
+ seq->sound->flags |= SOUND_FLAGS_WAVEFORM_LOADING;
BLI_mutex_unlock(sound->mutex);
sequencer_preview_add_sound(C, seq);
}
@@ -215,7 +216,8 @@ static void drawseqwave(const bContext *C, SpaceSeq *sseq, Scene *scene, Sequenc
}
BLI_mutex_unlock(sound->mutex);
-
+ waveform = seq->sound->waveform;
+
startsample = floor((seq->startofs + seq->anim_startofs) / FPS * SOUND_WAVE_SAMPLES_PER_SECOND);
endsample = ceil((seq->startofs + seq->anim_startofs + seq->enddisp - seq->startdisp) / FPS * SOUND_WAVE_SAMPLES_PER_SECOND);
samplestep = (endsample - startsample) * stepsize / (x2 - x1);
diff --git a/source/blender/editors/space_sequencer/sequencer_preview.c b/source/blender/editors/space_sequencer/sequencer_preview.c
index 4950003..4d76901 100644
--- a/source/blender/editors/space_sequencer/sequencer_preview.c
+++ b/source/blender/editors/space_sequencer/sequencer_preview.c
@@ -91,16 +91,29 @@ static void preview_startjob(void *data, short *stop, short *do_update, float *p
if (*stop || G.is_break) {
BLI_mutex_lock(pj->mutex);
+ previewjb = previewjb->next;
+ BLI_mutex_unlock(pj->mutex);
+ while (previewjb) {
+ sound = previewjb->sound;
+
+ /* make sure we cleanup the loading flag! */
+ BLI_mutex_lock(sound->mutex);
+ sound->flags &= ~SOUND_FLAGS_WAVEFORM_LOADING;
+ BLI_mutex_unlock(sound->mutex);
+
+ BLI_mutex_lock(pj->mutex);
+ previewjb = previewjb->next;
+ BLI_mutex_unlock(pj->mutex);
+ }
+
+ BLI_mutex_lock(pj->mutex);
BLI_freelistN(&pj->previews);
pj->total = 0;
pj->processed = 0;
BLI_mutex_unlock(pj->mutex);
- sound->flags &= ~SOUND_FLAGS_WAVEFORM_LOADING;
break;
}
- sound->flags &= ~SOUND_FLAGS_WAVEFORM_LOADING;
-
BLI_mutex_lock(pj->mutex);
preview_next = previewjb->next;
BLI_freelinkN(&pj->previews, previewjb);
@@ -144,9 +157,7 @@ void sequencer_preview_add_sound(const bContext *C, Sequence *seq)
}
/* attempt to lock mutex of job here */
-
- seq->sound->flags |= SOUND_FLAGS_WAVEFORM_LOADING;
-
+
audiojob->sound = seq->sound;
BLI_mutex_lock(pj->mutex);
More information about the Bf-blender-cvs
mailing list