[Bf-blender-cvs] [c826566] master: Sound now returns even if file fails to load

Campbell Barton noreply at git.blender.org
Sat May 2 20:47:14 CEST 2015


Commit: c826566ce341cfa6bb02c733a5c70e26542bee9e
Author: Campbell Barton
Date:   Sun May 3 03:28:43 2015 +1000
Branches: master
https://developer.blender.org/rBc826566ce341cfa6bb02c733a5c70e26542bee9e

Sound now returns even if file fails to load

With various codecs its hard to ensure a sound will load or not.

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

M	source/blender/blenkernel/intern/sequencer.c
M	source/blender/blenkernel/intern/sound.c
M	source/blender/editors/sound/sound_ops.c
M	source/blender/makesrna/intern/rna_sequencer_api.c

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

diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c
index f370570..d189351 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 6a831d2..30c1777 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 bce9a37..8a3b481 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 8816882..44169fa 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;
 	}




More information about the Bf-blender-cvs mailing list