diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2014-11-24 20:18:35 +0300 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2014-11-24 20:23:44 +0300 |
commit | 649a2bcc3d51cfc6f9fc237695015c87bcca7deb (patch) | |
tree | 4bea67033363027c40c3e78b2782d7df00e39558 /source/blender/blenkernel/intern/sound.c | |
parent | aa0b268acbf352bdf69644bb11ee3b893008cc40 (diff) |
Politically correct terrible consequencer changes
This patch includes the work done in the terrible consequencer branch
that hasn't been merged to master minus a few controversial and WIP
stuff, like strip parenting, new sequence data structs and cuddly
widgets.
What is included:
* Strip extensions only when slipping. It can very easily be made an
option but with a few strips with overlapping durations it makes view
too crowded and difficult to make out.
* Threaded waveform loading + code that restores waveforms on undo (not
used though, since sound_load recreates everything. There's a patch for
review D876)
* Toggle to enable backdrop in the strip sequence editor
* Toggle to easily turn on/off waveform display
* Snapping during transform on sequence boundaries. Snapping to start or
end of selection depends on position of mouse when invoking the operator
* Snapping of timeline indicator in sequencer to strip boundaries. To
use just press and hold ctrl while dragging.
Reviewers: campbellbarton
Differential Revision: https://developer.blender.org/D904
Diffstat (limited to 'source/blender/blenkernel/intern/sound.c')
-rw-r--r-- | source/blender/blenkernel/intern/sound.c | 49 |
1 files changed, 34 insertions, 15 deletions
diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index da6ead06d98..3c7b01f9052 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -36,6 +36,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_threads.h" #include "DNA_anim_types.h" #include "DNA_object_types.h" @@ -116,6 +117,12 @@ void BKE_sound_free(bSound *sound) } sound_free_waveform(sound); + + if (sound->mutex) { + BLI_mutex_free(sound->mutex); + sound->mutex = NULL; + } + #endif /* WITH_AUDASPACE */ } @@ -296,12 +303,6 @@ void sound_cache(bSound *sound) sound->playback_handle = sound->handle; } -void sound_cache_notifying(struct Main *main, bSound *sound) -{ - sound_cache(sound); - sound_update_sequencer(main, sound); -} - void sound_delete_cache(bSound *sound) { sound->flags &= ~SOUND_FLAGS_CACHING; @@ -680,22 +681,40 @@ void sound_free_waveform(bSound *sound) sound->waveform = NULL; } -void sound_read_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); - + 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); - sound->waveform = waveform; } + + 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) @@ -830,7 +849,7 @@ void sound_stop_scene(struct Scene *UNUSED(scene)) {} void sound_seek_scene(struct Main *UNUSED(bmain), struct Scene *UNUSED(scene)) {} float sound_sync_scene(struct Scene *UNUSED(scene)) { return NAN_FLT; } int sound_scene_playing(struct Scene *UNUSED(scene)) { return -1; } -void sound_read_waveform(struct bSound *UNUSED(sound)) {} +void sound_read_waveform(struct bSound *sound, bool locked, short *stop) { UNUSED_VARS(sound, locked, stop); } void sound_init_main(struct Main *UNUSED(bmain)) {} void sound_set_cfra(int UNUSED(cfra)) {} void sound_update_sequencer(struct Main *UNUSED(main), struct bSound *UNUSED(sound)) {} |