diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-05-02 20:28:43 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-05-02 21:41:39 +0300 |
commit | c826566ce341cfa6bb02c733a5c70e26542bee9e (patch) | |
tree | 2420f32fb1ed7ee2342d7e1ea657e38c6a6298c2 | |
parent | 8e4ac2d229fff53ed7bd7dee638fc0f004c1e12c (diff) |
Sound now returns even if file fails to load
With various codecs its hard to ensure a sound will load or not.
-rw-r--r-- | source/blender/blenkernel/intern/sequencer.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/sound.c | 19 | ||||
-rw-r--r-- | source/blender/editors/sound/sound_ops.c | 4 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_sequencer_api.c | 3 |
4 files changed, 7 insertions, 21 deletions
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index f370570750f..d1893513a4f 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -4974,7 +4974,7 @@ Sequence *BKE_sequencer_add_sound_strip(bContext *C, ListBase *seqbasep, SeqLoad sound = BKE_sound_new_file(bmain, seq_load->path); /* handles relative paths */ - if (sound == NULL || sound->playback_handle == NULL) { + if (sound->playback_handle == NULL) { #if 0 if (op) BKE_report(op->reports, RPT_ERROR, "Unsupported audio format"); diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 6a831d23aea..30c17773f7d 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -66,7 +66,7 @@ static int sound_cfra; bSound *BKE_sound_new_file(struct Main *bmain, const char *filename) { - bSound *sound = NULL; + bSound *sound; char str[FILE_MAX]; const char *path; @@ -89,11 +89,6 @@ bSound *BKE_sound_new_file(struct Main *bmain, const char *filename) BKE_sound_load(bmain, sound); - if (!sound->playback_handle) { - BKE_libblock_free(bmain, sound); - sound = NULL; - } - return sound; } @@ -246,12 +241,6 @@ bSound *BKE_sound_new_buffer(struct Main *bmain, bSound *source) sound_load(bmain, sound); - if (!sound->playback_handle) - { - BKE_libblock_free(bmain, sound); - sound = NULL; - } - return sound; } @@ -272,12 +261,6 @@ bSound *BKE_sound_new_limiter(struct Main *bmain, bSound *source, float start, f sound_load(bmain, sound); - if (!sound->playback_handle) - { - BKE_libblock_free(bmain, sound); - sound = NULL; - } - return sound; } #endif diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c index bce9a375091..8a3b48125d0 100644 --- a/source/blender/editors/sound/sound_ops.c +++ b/source/blender/editors/sound/sound_ops.c @@ -51,6 +51,7 @@ #include "BKE_global.h" #include "BKE_main.h" #include "BKE_report.h" +#include "BKE_library.h" #include "BKE_packedFile.h" #include "BKE_scene.h" #include "BKE_sound.h" @@ -105,8 +106,9 @@ static int sound_open_exec(bContext *C, wmOperator *op) if (!op->customdata) sound_open_init(C, op); - if (sound == NULL || sound->playback_handle == NULL) { + if (sound->playback_handle == NULL) { if (op->customdata) MEM_freeN(op->customdata); + BKE_libblock_free(bmain, sound); BKE_report(op->reports, RPT_ERROR, "Unsupported audio format"); return OPERATOR_CANCELLED; } diff --git a/source/blender/makesrna/intern/rna_sequencer_api.c b/source/blender/makesrna/intern/rna_sequencer_api.c index 881688281f3..44169fa641e 100644 --- a/source/blender/makesrna/intern/rna_sequencer_api.c +++ b/source/blender/makesrna/intern/rna_sequencer_api.c @@ -232,7 +232,8 @@ static Sequence *rna_Sequences_new_sound(ID *id, Editing *ed, Main *bmain, Repor bSound *sound = BKE_sound_new_file(bmain, file); - if (sound == NULL || sound->playback_handle == NULL) { + if (sound->playback_handle == NULL) { + BKE_libblock_free(bmain, sound); BKE_report(reports, RPT_ERROR, "Sequences.new_sound: unable to open sound file"); return NULL; } |