diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_nla.h | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_sequencer.h | 5 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_sound.h | 33 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/nla.c | 14 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/scene.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/sequencer.c | 30 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/sound.c | 120 | ||||
-rw-r--r-- | source/blender/editors/object/object_add.c | 3 | ||||
-rw-r--r-- | source/blender/editors/space_nla/nla_edit.c | 3 | ||||
-rw-r--r-- | source/blender/editors/space_sequencer/sequencer_edit.c | 34 | ||||
-rw-r--r-- | source/blender/editors/space_sequencer/sequencer_preview.c | 4 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_sequencer.c | 11 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_sequencer_api.c | 8 |
13 files changed, 164 insertions, 107 deletions
diff --git a/source/blender/blenkernel/BKE_nla.h b/source/blender/blenkernel/BKE_nla.h index 423f79a8049..0ba83516e91 100644 --- a/source/blender/blenkernel/BKE_nla.h +++ b/source/blender/blenkernel/BKE_nla.h @@ -55,7 +55,9 @@ void BKE_nla_tracks_copy(struct Main *bmain, ListBase *dst, ListBase *src, const struct NlaTrack *BKE_nlatrack_add(struct AnimData *adt, struct NlaTrack *prev); struct NlaStrip *BKE_nlastrip_new(struct bAction *act); struct NlaStrip *BKE_nlastack_add_strip(struct AnimData *adt, struct bAction *act); -struct NlaStrip *BKE_nla_add_soundstrip(struct Scene *scene, struct Speaker *spk); +struct NlaStrip *BKE_nla_add_soundstrip(struct Main *bmain, + struct Scene *scene, + struct Speaker *spk); /* ----------------------------- */ /* API */ diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h index 7eb08e6f770..a9e1dfb2392 100644 --- a/source/blender/blenkernel/BKE_sequencer.h +++ b/source/blender/blenkernel/BKE_sequencer.h @@ -266,7 +266,8 @@ const char *BKE_sequence_give_name(struct Sequence *seq); ListBase *BKE_sequence_seqbase_get(struct Sequence *seq, int *r_offset); void BKE_sequence_calc(struct Scene *scene, struct Sequence *seq); void BKE_sequence_calc_disp(struct Scene *scene, struct Sequence *seq); -void BKE_sequence_reload_new_file(struct Scene *scene, +void BKE_sequence_reload_new_file(struct Main *bmain, + struct Scene *scene, struct Sequence *seq, const bool lock_range); int BKE_sequencer_evaluate_frame(struct Scene *scene, int cfra); @@ -406,7 +407,7 @@ void BKE_sequencer_update_sound_bounds(struct Scene *scene, struct Sequence *seq void BKE_sequencer_update_muting(struct Editing *ed); void BKE_sequencer_update_sound(struct Scene *scene, struct bSound *sound); -void BKE_sequencer_refresh_sound_length(struct Scene *scene); +void BKE_sequencer_refresh_sound_length(struct Main *bmain, struct Scene *scene); void BKE_sequence_base_unique_name_recursive(ListBase *seqbasep, struct Sequence *seq); void BKE_sequence_base_dupli_recursive(const struct Scene *scene_src, diff --git a/source/blender/blenkernel/BKE_sound.h b/source/blender/blenkernel/BKE_sound.h index 07795e8438c..4694e86f4d6 100644 --- a/source/blender/blenkernel/BKE_sound.h +++ b/source/blender/blenkernel/BKE_sound.h @@ -78,10 +78,29 @@ void BKE_sound_ensure_loaded(struct Main *bmain, struct bSound *sound); void BKE_sound_free(struct bSound *sound); -/* Is used by sequencer to temporarily load audio to access information about channels and - * duration. */ -void BKE_sound_load_audio(struct Main *main, struct bSound *sound); -void BKE_sound_free_audio(struct bSound *sound); +/* Matches AUD_Channels. */ +typedef enum eSoundChannels { + SOUND_CHANNELS_INVALID = 0, + SOUND_CHANNELS_MONO = 1, + SOUND_CHANNELS_STEREO = 2, + SOUND_CHANNELS_STEREO_LFE = 3, + SOUND_CHANNELS_SURROUND4 = 4, + SOUND_CHANNELS_SURROUND5 = 5, + SOUND_CHANNELS_SURROUND51 = 6, + SOUND_CHANNELS_SURROUND61 = 7, + SOUND_CHANNELS_SURROUND71 = 8, +} eSoundChannels; + +typedef struct SoundInfo { + struct { + eSoundChannels channels; + } specs; + float length; +} SoundInfo; + +/* Get information about given sound. Returns truth on success., false if sound can not be loaded + * or if the codes is not supported. */ +bool BKE_sound_info_get(struct Main *main, struct bSound *sound, SoundInfo *sound_info); void BKE_sound_copy_data(struct Main *bmain, struct bSound *sound_dst, @@ -104,7 +123,7 @@ void BKE_sound_reset_scene_specs(struct Scene *scene); void BKE_sound_mute_scene(struct Scene *scene, int muted); -void BKE_sound_update_fps(struct Scene *scene); +void BKE_sound_update_fps(struct Main *bmain, struct Scene *scene); void BKE_sound_update_scene_listener(struct Scene *scene); @@ -150,13 +169,13 @@ int BKE_sound_scene_playing(struct Scene *scene); void BKE_sound_free_waveform(struct bSound *sound); -void BKE_sound_read_waveform(struct bSound *sound, short *stop); +void BKE_sound_read_waveform(struct Main *bmain, struct bSound *sound, short *stop); void BKE_sound_update_scene(struct Depsgraph *depsgraph, struct Scene *scene); void *BKE_sound_get_factory(void *sound); -float BKE_sound_get_length(struct bSound *sound); +float BKE_sound_get_length(struct Main *bmain, struct bSound *sound); char **BKE_sound_get_device_names(void); diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 15e53e12ece..d7546e5db0c 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -51,10 +51,7 @@ #include "BKE_library.h" #include "BKE_main.h" #include "BKE_nla.h" - -#ifdef WITH_AUDASPACE -# include <AUD_Special.h> -#endif +#include "BKE_sound.h" #include "RNA_access.h" #include "nla_private.h" @@ -392,7 +389,7 @@ NlaStrip *BKE_nlastack_add_strip(AnimData *adt, bAction *act) } /* Add a NLA Strip referencing the given speaker's sound */ -NlaStrip *BKE_nla_add_soundstrip(Scene *scene, Speaker *speaker) +NlaStrip *BKE_nla_add_soundstrip(Main *bmain, Scene *scene, Speaker *speaker) { NlaStrip *strip = MEM_callocN(sizeof(NlaStrip), "NlaSoundStrip"); @@ -401,9 +398,10 @@ NlaStrip *BKE_nla_add_soundstrip(Scene *scene, Speaker *speaker) */ #ifdef WITH_AUDASPACE if (speaker->sound) { - AUD_SoundInfo info = AUD_getInfo(speaker->sound->playback_handle); - - strip->end = (float)ceil((double)info.length * FPS); + SoundInfo info; + if (BKE_sound_info_get(bmain, speaker->sound, &info)) { + strip->end = (float)ceil((double)info.length * FPS); + } } else #endif diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index ef33cd7d137..7fb9b2f2281 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -1515,7 +1515,7 @@ static void scene_update_sound(Depsgraph *depsgraph, Main *bmain) BKE_sound_seek_scene(bmain, scene); } if (recalc & ID_RECALC_AUDIO_FPS) { - BKE_sound_update_fps(scene); + BKE_sound_update_fps(bmain, scene); } if (recalc & ID_RECALC_AUDIO_VOLUME) { BKE_sound_set_scene_volume(scene, scene->audio.volume); diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index ac242e35b03..215f651811c 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -909,7 +909,7 @@ static void seq_multiview_name(Scene *scene, } /* note: caller should run BKE_sequence_calc(scene, seq) after */ -void BKE_sequence_reload_new_file(Scene *scene, Sequence *seq, const bool lock_range) +void BKE_sequence_reload_new_file(Main *bmain, Scene *scene, Sequence *seq, const bool lock_range) { char path[FILE_MAX]; int prev_startdisp = 0, prev_enddisp = 0; @@ -1050,7 +1050,7 @@ void BKE_sequence_reload_new_file(Scene *scene, Sequence *seq, const bool lock_r if (!seq->sound) { return; } - seq->len = ceil((double)AUD_getInfo(seq->sound->playback_handle).length * FPS); + seq->len = ceil((double)BKE_sound_get_length(bmain, seq->sound) * FPS); seq->len -= seq->anim_startofs; seq->len -= seq->anim_endofs; if (seq->len < 0) { @@ -4923,24 +4923,24 @@ bool BKE_sequence_base_shuffle_time(ListBase *seqbasep, Scene *evil_scene) /* Unlike _update_sound_ funcs, these ones take info from audaspace to update sequence length! */ #ifdef WITH_AUDASPACE -static bool sequencer_refresh_sound_length_recursive(Scene *scene, ListBase *seqbase) +static bool sequencer_refresh_sound_length_recursive(Main *bmain, Scene *scene, ListBase *seqbase) { Sequence *seq; bool changed = false; for (seq = seqbase->first; seq; seq = seq->next) { if (seq->type == SEQ_TYPE_META) { - if (sequencer_refresh_sound_length_recursive(scene, &seq->seqbase)) { + if (sequencer_refresh_sound_length_recursive(bmain, scene, &seq->seqbase)) { BKE_sequence_calc(scene, seq); changed = true; } } else if (seq->type == SEQ_TYPE_SOUND_RAM) { - AUD_SoundInfo info = AUD_getInfo(seq->sound->playback_handle); + const float length = BKE_sound_get_length(bmain, seq->sound); int old = seq->len; float fac; - seq->len = (int)ceil((double)info.length * FPS); + seq->len = (int)ceil((double)length * FPS); fac = (float)seq->len / (float)old; old = seq->startofs; seq->startofs *= fac; @@ -4955,11 +4955,11 @@ static bool sequencer_refresh_sound_length_recursive(Scene *scene, ListBase *seq } #endif -void BKE_sequencer_refresh_sound_length(Scene *scene) +void BKE_sequencer_refresh_sound_length(Main *bmain, Scene *scene) { #ifdef WITH_AUDASPACE if (scene->ed) { - sequencer_refresh_sound_length_recursive(scene, &scene->ed->seqbase); + sequencer_refresh_sound_length_recursive(bmain, scene, &scene->ed->seqbase); } #else (void)scene; @@ -5562,17 +5562,13 @@ Sequence *BKE_sequencer_add_sound_strip(bContext *C, ListBase *seqbasep, SeqLoad sound = BKE_sound_new_file(bmain, seq_load->path); /* handles relative paths */ - /* Load the original sound, so we can access number of channels and length information. - * We free the sound handle on the original bSound datablock before existing this function, it is - * to be allocated on an evaluated version after this. */ - BKE_sound_load_audio(bmain, sound); - AUD_SoundInfo info = AUD_getInfo(sound->playback_handle); - if (sound->playback_handle == NULL) { + SoundInfo info; + if (!BKE_sound_info_get(bmain, sound, &info)) { BKE_id_free(bmain, sound); return NULL; } - if (info.specs.channels == AUD_CHANNELS_INVALID) { + if (info.specs.channels == SOUND_CHANNELS_INVALID) { BKE_id_free(bmain, sound); return NULL; } @@ -5602,9 +5598,7 @@ Sequence *BKE_sequencer_add_sound_strip(bContext *C, ListBase *seqbasep, SeqLoad seq_load_apply(bmain, scene, seq, seq_load); - BKE_sound_free_audio(sound); - - /* TODO(sergey): Shall we tag here or in the oeprator? */ + /* TODO(sergey): Shall we tag here or in the operator? */ DEG_relations_tag_update(bmain); return seq; diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 029fea5c300..927a45accca 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -145,6 +145,24 @@ bSound *BKE_sound_new_file_exists(Main *bmain, const char *filepath) return BKE_sound_new_file_exists_ex(bmain, filepath, NULL); } +static void sound_free_audio(bSound *sound) +{ +#ifdef WITH_AUDASPACE + if (sound->handle) { + AUD_Sound_free(sound->handle); + sound->handle = NULL; + sound->playback_handle = NULL; + } + + if (sound->cache) { + AUD_Sound_free(sound->cache); + sound->cache = NULL; + } +#else + UNUSED_VARS(sound); +#endif /* WITH_AUDASPACE */ +} + /** Free (or release) any data used by this sound (does not free the sound itself). */ void BKE_sound_free(bSound *sound) { @@ -155,7 +173,7 @@ void BKE_sound_free(bSound *sound) sound->packedfile = NULL; } - BKE_sound_free_audio(sound); + sound_free_audio(sound); BKE_sound_free_waveform(sound); if (sound->spinlock) { @@ -165,24 +183,6 @@ void BKE_sound_free(bSound *sound) } } -void BKE_sound_free_audio(bSound *sound) -{ -#ifdef WITH_AUDASPACE - if (sound->handle) { - AUD_Sound_free(sound->handle); - sound->handle = NULL; - sound->playback_handle = NULL; - } - - if (sound->cache) { - AUD_Sound_free(sound->cache); - sound->cache = NULL; - } -#else - UNUSED_VARS(sound); -#endif /* WITH_AUDASPACE */ -} - /** * Only copy internal data of Sound ID from source * to already allocated/initialized destination. @@ -412,13 +412,7 @@ void BKE_sound_delete_cache(bSound *sound) } } -void BKE_sound_load(Main *bmain, bSound *sound) -{ - sound_verify_evaluated_id(&sound->id); - BKE_sound_load_audio(bmain, sound); -} - -void BKE_sound_load_audio(Main *bmain, bSound *sound) +static void sound_load_audio(Main *bmain, bSound *sound) { if (sound->cache) { @@ -492,6 +486,12 @@ void BKE_sound_load_audio(Main *bmain, bSound *sound) } } +void BKE_sound_load(Main *bmain, bSound *sound) +{ + sound_verify_evaluated_id(&sound->id); + sound_load_audio(bmain, sound); +} + AUD_Device *BKE_sound_mixdown(Scene *scene, AUD_DeviceSpecs specs, int start, float volume) { sound_verify_evaluated_id(&scene->id); @@ -560,7 +560,7 @@ void BKE_sound_mute_scene(Scene *scene, int muted) } } -void BKE_sound_update_fps(Scene *scene) +void BKE_sound_update_fps(Main *bmain, Scene *scene) { sound_verify_evaluated_id(&scene->id); @@ -568,7 +568,7 @@ void BKE_sound_update_fps(Scene *scene) AUD_Sequence_setFPS(scene->sound_scene, FPS); } - BKE_sequencer_refresh_sound_length(scene); + BKE_sequencer_refresh_sound_length(bmain, scene); } void BKE_sound_update_scene_listener(Scene *scene) @@ -895,11 +895,15 @@ 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) +void BKE_sound_read_waveform(Main *bmain, bSound *sound, short *stop) { + bool need_close_audio_handles = false; + if (sound->playback_handle == NULL) { + /* TOOD(sergey): Make it fully independent audio handle. */ + sound_load_audio(bmain, sound); + need_close_audio_handles = true; + } + AUD_SoundInfo info = AUD_getInfo(sound->playback_handle); SoundWaveform *waveform = MEM_mallocN(sizeof(SoundWaveform), "SoundWaveform"); @@ -936,6 +940,10 @@ void BKE_sound_read_waveform(bSound *sound, short *stop) sound->waveform = waveform; sound->tags &= ~SOUND_TAGS_WAVEFORM_LOADING; BLI_spin_unlock(sound->spinlock); + + if (need_close_audio_handles) { + sound_free_audio(sound); + } } static void sound_update_base(Scene *scene, Object *object, void *new_set) @@ -1047,12 +1055,16 @@ void *BKE_sound_get_factory(void *sound) return ((bSound *)sound)->playback_handle; } -/* stupid wrapper because AUD_C-API.h includes Python.h which makesrna doesn't like */ -float BKE_sound_get_length(bSound *sound) +float BKE_sound_get_length(Main *bmain, bSound *sound) { - sound_verify_evaluated_id(&sound->id); - AUD_SoundInfo info = AUD_getInfo(sound->playback_handle); - + if (sound->playback_handle != NULL) { + AUD_SoundInfo info = AUD_getInfo(sound->playback_handle); + return info.length; + } + SoundInfo info; + if (!BKE_sound_info_get(bmain, sound, &info)) { + return 0.0f; + } return info.length; } @@ -1065,6 +1077,29 @@ char **BKE_sound_get_device_names(void) return audio_device_names; } +static bool sound_info_from_playback_handle(void *playback_handle, SoundInfo *sound_info) +{ + if (playback_handle == NULL) { + return false; + } + AUD_SoundInfo info = AUD_getInfo(playback_handle); + sound_info->specs.channels = (eSoundChannels)info.specs.channels; + sound_info->length = info.length; + return true; +} + +bool BKE_sound_info_get(struct Main *main, struct bSound *sound, SoundInfo *sound_info) +{ + if (sound->playback_handle != NULL) { + return sound_info_from_playback_handle(sound->playback_handle, sound_info); + } + /* TOOD(sergey): Make it fully independent audio handle. */ + sound_load_audio(main, sound); + const bool result = sound_info_from_playback_handle(sound->playback_handle, sound_info); + sound_free_audio(sound); + return result; +} + #else /* WITH_AUDASPACE */ # include "BLI_utildefines.h" @@ -1162,7 +1197,7 @@ int BKE_sound_scene_playing(Scene *UNUSED(scene)) { return -1; } -void BKE_sound_read_waveform(bSound *sound, short *stop) +void BKE_sound_read_waveform(Main *bmain, bSound *sound, short *stop) { UNUSED_VARS(sound, stop); } @@ -1184,7 +1219,7 @@ void BKE_sound_update_scene_sound(void *UNUSED(handle), bSound *UNUSED(sound)) void BKE_sound_update_scene_listener(Scene *UNUSED(scene)) { } -void BKE_sound_update_fps(Scene *UNUSED(scene)) +void BKE_sound_update_fps(Main *UNUSED(bmain), Scene *UNUSED(scene)) { } void BKE_sound_set_scene_sound_volume(void *UNUSED(handle), @@ -1203,7 +1238,7 @@ void BKE_sound_set_scene_sound_pitch(void *UNUSED(handle), char UNUSED(animated)) { } -float BKE_sound_get_length(bSound *UNUSED(sound)) +float BKE_sound_get_length(struct Main *UNUSED(bmain), bSound *UNUSED(sound)) { return 0; } @@ -1217,8 +1252,11 @@ void BKE_sound_free_waveform(bSound *UNUSED(sound)) { } -void BKE_sound_load_audio(Main *UNUSED(bmain), bSound *UNUSED(sound)) +bool BKE_sound_info_get(struct Main *UNUSED(main), + struct bSound *UNUSED(sound), + SoundInfo *UNUSED(sound_info)) { + return false; } #endif /* WITH_AUDASPACE */ diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 0b9ced84a59..99c3d7da2a2 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -1417,6 +1417,7 @@ void OBJECT_OT_collection_instance_add(wmOperatorType *ot) static int object_speaker_add_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); Object *ob; ushort local_view_bits; float loc[3], rot[3]; @@ -1434,7 +1435,7 @@ static int object_speaker_add_exec(bContext *C, wmOperator *op) /* create new data for NLA hierarchy */ AnimData *adt = BKE_animdata_add_id(&ob->id); NlaTrack *nlt = BKE_nlatrack_add(adt, NULL); - NlaStrip *strip = BKE_nla_add_soundstrip(scene, ob->data); + NlaStrip *strip = BKE_nla_add_soundstrip(bmain, scene, ob->data); strip->start = CFRA; strip->end += strip->start; diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c index acb3d913114..052f653ca7f 100644 --- a/source/blender/editors/space_nla/nla_edit.c +++ b/source/blender/editors/space_nla/nla_edit.c @@ -857,6 +857,7 @@ void NLA_OT_transition_add(wmOperatorType *ot) static int nlaedit_add_sound_exec(bContext *C, wmOperator *UNUSED(op)) { + Main *bmain = CTX_data_main(C); bAnimContext ac; ListBase anim_data = {NULL, NULL}; @@ -894,7 +895,7 @@ static int nlaedit_add_sound_exec(bContext *C, wmOperator *UNUSED(op)) } /* create a new strip, and offset it to start on the current frame */ - strip = BKE_nla_add_soundstrip(ac.scene, ob->data); + strip = BKE_nla_add_soundstrip(bmain, ac.scene, ob->data); strip->start += cfra; strip->end += cfra; diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index c214b84b611..b32f73323b2 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -726,7 +726,8 @@ static void recurs_del_seq_flag(Scene *scene, ListBase *lb, short flag, short de } } -static Sequence *cut_seq_hard(Scene *scene, Sequence *seq, ListBase *new_seq_list, int cutframe) +static Sequence *cut_seq_hard( + Main *bmain, Scene *scene, Sequence *seq, ListBase *new_seq_list, int cutframe) { TransSeq ts; Sequence *seqn = NULL; @@ -755,7 +756,7 @@ static Sequence *cut_seq_hard(Scene *scene, Sequence *seq, ListBase *new_seq_lis * blend file, or our code may have minor differences reading file length between versions. * This causes hard-cut to fail, see: T47862 */ if (seq->type != SEQ_TYPE_META) { - BKE_sequence_reload_new_file(scene, seq, true); + BKE_sequence_reload_new_file(bmain, scene, seq, true); BKE_sequence_calc(scene, seq); } @@ -790,7 +791,7 @@ static Sequence *cut_seq_hard(Scene *scene, Sequence *seq, ListBase *new_seq_lis } } - BKE_sequence_reload_new_file(scene, seq, false); + BKE_sequence_reload_new_file(bmain, scene, seq, false); BKE_sequence_calc(scene, seq); if (!skip_dup) { @@ -837,13 +838,14 @@ static Sequence *cut_seq_hard(Scene *scene, Sequence *seq, ListBase *new_seq_lis seqn->startstill = 0; } - BKE_sequence_reload_new_file(scene, seqn, false); + BKE_sequence_reload_new_file(bmain, scene, seqn, false); BKE_sequence_calc(scene, seqn); } return seqn; } -static Sequence *cut_seq_soft(Scene *scene, Sequence *seq, ListBase *new_seq_list, int cutframe) +static Sequence *cut_seq_soft( + Main *UNUSED(bmain), Scene *scene, Sequence *seq, ListBase *new_seq_list, int cutframe) { TransSeq ts; Sequence *seqn = NULL; @@ -949,10 +951,11 @@ static Sequence *cut_seq_soft(Scene *scene, Sequence *seq, ListBase *new_seq_lis * may generate strips with the same name (which will mess up animdata) */ -static bool cut_seq_list(Scene *scene, +static bool cut_seq_list(Main *bmain, + Scene *scene, ListBase *slist, int cutframe, - Sequence *(*cut_seq)(Scene *, Sequence *, ListBase *, int)) + Sequence *(*cut_seq)(Main *bmain, Scene *, Sequence *, ListBase *, int)) { Sequence *seq, *seq_next_iter; Sequence *seq_first_new = NULL; @@ -964,7 +967,7 @@ static bool cut_seq_list(Scene *scene, seq->tmp = NULL; if (seq->flag & SELECT) { if (cutframe > seq->startdisp && cutframe < seq->enddisp) { - Sequence *seqn = cut_seq(scene, seq, slist, cutframe); + Sequence *seqn = cut_seq(bmain, scene, seq, slist, cutframe); if (seqn) { if (seq_first_new == NULL) { seq_first_new = seqn; @@ -1040,7 +1043,7 @@ static void set_filter_seq(Scene *scene) if (seq->flag & SELECT) { if (seq->type == SEQ_TYPE_MOVIE) { seq->flag |= SEQ_FILTERY; - BKE_sequence_reload_new_file(scene, seq, false); + BKE_sequence_reload_new_file(bmain, scene, seq, false); BKE_sequence_calc(scene, seq); } } @@ -1622,6 +1625,7 @@ static void sequencer_slip_update_header(Scene *scene, ScrArea *sa, SlipData *da static int sequencer_slip_modal(bContext *C, wmOperator *op, const wmEvent *event) { + Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); SlipData *data = (SlipData *)op->customdata; ScrArea *sa = CTX_wm_area(C); @@ -1702,7 +1706,7 @@ static int sequencer_slip_modal(bContext *C, wmOperator *op, const wmEvent *even for (i = 0; i < data->num_seq; i++) { Sequence *seq = data->seq_array[i]; - BKE_sequence_reload_new_file(scene, seq, false); + BKE_sequence_reload_new_file(bmain, scene, seq, false); BKE_sequence_calc(scene, seq); } @@ -1956,6 +1960,7 @@ void SEQUENCER_OT_unlock(struct wmOperatorType *ot) /* reload operator */ static int sequencer_reload_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); Editing *ed = BKE_sequencer_editing_get(scene, false); Sequence *seq; @@ -1964,7 +1969,7 @@ static int sequencer_reload_exec(bContext *C, wmOperator *op) for (seq = ed->seqbasep->first; seq; seq = seq->next) { if (seq->flag & SELECT) { BKE_sequencer_update_changed_seq_and_deps(scene, seq, 0, 1); - BKE_sequence_reload_new_file(scene, seq, !adjust_length); + BKE_sequence_reload_new_file(bmain, scene, seq, !adjust_length); if (adjust_length) { if (BKE_sequence_test_overlap(ed->seqbasep, seq)) { @@ -2139,6 +2144,7 @@ static const EnumPropertyItem prop_cut_types[] = { static int sequencer_cut_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); Editing *ed = BKE_sequencer_editing_get(scene, false); int cut_side, cut_hard, cut_frame; @@ -2150,10 +2156,10 @@ static int sequencer_cut_exec(bContext *C, wmOperator *op) cut_side = RNA_enum_get(op->ptr, "side"); if (cut_hard == SEQ_CUT_HARD) { - changed = cut_seq_list(scene, ed->seqbasep, cut_frame, cut_seq_hard); + changed = cut_seq_list(bmain, scene, ed->seqbasep, cut_frame, cut_seq_hard); } else { - changed = cut_seq_list(scene, ed->seqbasep, cut_frame, cut_seq_soft); + changed = cut_seq_list(bmain, scene, ed->seqbasep, cut_frame, cut_seq_soft); } if (changed) { /* got new strips ? */ @@ -3948,7 +3954,7 @@ static int sequencer_change_path_exec(bContext *C, wmOperator *op) /* correct start/end frames so we don't move * important not to set seq->len = len; allow the function to handle it */ - BKE_sequence_reload_new_file(scene, seq, true); + BKE_sequence_reload_new_file(bmain, scene, seq, true); BKE_sequence_calc(scene, seq); diff --git a/source/blender/editors/space_sequencer/sequencer_preview.c b/source/blender/editors/space_sequencer/sequencer_preview.c index 8a4e8c007f7..81ddd0dd8cc 100644 --- a/source/blender/editors/space_sequencer/sequencer_preview.c +++ b/source/blender/editors/space_sequencer/sequencer_preview.c @@ -80,9 +80,7 @@ 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); + BKE_sound_read_waveform(previewjb->bmain, sound, stop); if (*stop || G.is_break) { BLI_mutex_lock(pj->mutex); diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index 4d7bc45308a..f5e4259c471 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -69,6 +69,7 @@ const EnumPropertyItem rna_enum_sequence_modifier_type_items[] = { #ifdef RNA_RUNTIME +# include "BKE_global.h" # include "BKE_report.h" # include "BKE_idprop.h" # include "BKE_movieclip.h" @@ -321,7 +322,7 @@ static void rna_Sequence_anim_startofs_final_set(PointerRNA *ptr, int value) seq->anim_startofs = MIN2(value, seq->len + seq->anim_startofs); - BKE_sequence_reload_new_file(scene, seq, false); + BKE_sequence_reload_new_file(G.main, scene, seq, false); do_sequence_frame_change_update(scene, seq); } @@ -332,7 +333,7 @@ static void rna_Sequence_anim_endofs_final_set(PointerRNA *ptr, int value) seq->anim_endofs = MIN2(value, seq->len + seq->anim_endofs); - BKE_sequence_reload_new_file(scene, seq, false); + BKE_sequence_reload_new_file(G.main, scene, seq, false); do_sequence_frame_change_update(scene, seq); } @@ -803,7 +804,7 @@ static void rna_Sequence_filepath_update(Main *bmain, Scene *UNUSED(scene), Poin { Scene *scene = (Scene *)ptr->id.data; Sequence *seq = (Sequence *)(ptr->data); - BKE_sequence_reload_new_file(scene, seq, true); + BKE_sequence_reload_new_file(bmain, scene, seq, true); BKE_sequence_calc(scene, seq); rna_Sequence_invalidate_raw_update(bmain, scene, ptr); } @@ -838,13 +839,13 @@ static Sequence *sequence_get_by_proxy(Editing *ed, StripProxy *proxy) return data.seq; } -static void rna_Sequence_tcindex_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +static void rna_Sequence_tcindex_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) { Scene *scene = (Scene *)ptr->id.data; Editing *ed = BKE_sequencer_editing_get(scene, false); Sequence *seq = sequence_get_by_proxy(ed, ptr->data); - BKE_sequence_reload_new_file(scene, seq, false); + BKE_sequence_reload_new_file(bmain, scene, seq, false); do_sequence_frame_change_update(scene, seq); } diff --git a/source/blender/makesrna/intern/rna_sequencer_api.c b/source/blender/makesrna/intern/rna_sequencer_api.c index b2afa81b29b..38bf1241b9c 100644 --- a/source/blender/makesrna/intern/rna_sequencer_api.c +++ b/source/blender/makesrna/intern/rna_sequencer_api.c @@ -259,17 +259,15 @@ static Sequence *rna_Sequences_new_sound(ID *id, bSound *sound = BKE_sound_new_file(bmain, file); - if (sound->playback_handle == NULL) { + SoundInfo info; + if (!BKE_sound_info_get(bmain, sound, &info)) { BKE_id_free(bmain, sound); BKE_report(reports, RPT_ERROR, "Sequences.new_sound: unable to open sound file"); return NULL; } - seq = alloc_generic_sequence(ed, name, frame_start, channel, SEQ_TYPE_SOUND_RAM, sound->name); seq->sound = sound; - seq->len = ceil((double)BKE_sound_get_length(sound) * FPS); - - seq->scene_sound = BKE_sound_add_scene_sound(scene, seq, frame_start, frame_start + seq->len, 0); + seq->len = ceil((double)info.length * FPS); BKE_sequence_calc_disp(scene, seq); |