Sound now returns even if file fails to load
With various codecs its hard to ensure a sound will load or not.
This commit is contained in:
@@ -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");
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user