1
1

Loading pre 2.5 files now works flawlessly.

This commit is contained in:
2009-08-02 20:34:12 +00:00
parent 40c8585e84
commit 04d5344cae
6 changed files with 66 additions and 18 deletions

View File

@@ -36,6 +36,7 @@ struct bSound;
// AUD_XXX struct bSample;
struct bContext;
struct ListBase;
struct Main;
/* bad bad global... */
// AUD_XXX
@@ -58,7 +59,7 @@ void sound_reinit(struct bContext *C);
void sound_exit();
struct bSound* sound_new_file(struct bContext *C, char* filename);
struct bSound* sound_new_file(struct Main *main, char* filename);
// AUD_XXX unused currently
#if 0

View File

@@ -199,7 +199,7 @@ void sound_exit()
AUD_exit();
}
struct bSound* sound_new_file(struct bContext *C, char* filename)
struct bSound* sound_new_file(struct Main *main, char* filename)
{
bSound* sound = NULL;
@@ -213,7 +213,7 @@ struct bSound* sound_new_file(struct bContext *C, char* filename)
while(len > 0 && filename[len-1] != '/' && filename[len-1] != '\\')
len--;
sound = alloc_libblock(&CTX_data_main(C)->sound, ID_SO, filename+len);
sound = alloc_libblock(&main->sound, ID_SO, filename+len);
strcpy(sound->name, filename);
sound->type = SOUND_TYPE_FILE;
@@ -221,7 +221,7 @@ struct bSound* sound_new_file(struct bContext *C, char* filename)
if(!sound->snd_sound)
{
free_libblock(&CTX_data_main(C)->sound, sound);
free_libblock(&main->sound, sound);
sound = NULL;
}

View File

@@ -4042,7 +4042,10 @@ static void lib_link_scene(FileData *fd, Main *main)
if(seq->scene) seq->scene= newlibadr(fd, sce->id.lib, seq->scene);
// AUD_XXX
if(seq->sound) {
seq->sound= newlibadr(fd, sce->id.lib, seq->sound);
if(seq->type == SEQ_HD_SOUND)
seq->type = SEQ_SOUND;
else
seq->sound= newlibadr(fd, sce->id.lib, seq->sound);
if (seq->sound) {
seq->sound->id.us++;
seq->sound_handle= sound_new_handle(sce, seq->sound, seq->startdisp, seq->enddisp, seq->startofs);
@@ -5033,6 +5036,9 @@ static void lib_link_sound(FileData *fd, Main *main)
sound->id.flag -= LIB_NEEDLINK;
sound->ipo= newlibadr_us(fd, sound->id.lib, sound->ipo); // XXX depreceated - old animation system
sound->stream = 0;
// AUD_XXX
sound_load(sound);
}
sound= sound->id.next;
}
@@ -9173,6 +9179,8 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
// AUD_XXX
bSound *sound;
Sequence *seq;
bActuator *act;
for(sound = main->sound.first; sound; sound = sound->id.next)
{
@@ -9180,7 +9188,54 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
{
sound->packedfile = sound->newpackedfile;
sound->newpackedfile = NULL;
sound->type = SOUND_TYPE_FILE;
}
}
for(ob = main->object.first; ob; ob= ob->id.next) {
for(act= ob->actuators.first; act; act= act->next) {
if (act->type == ACT_SOUND) {
bSoundActuator *sAct = (bSoundActuator*) act->data;
/* that would only work if do_versions was called after the linking
if(sAct->sound)
{
sAct->flag = sAct->sound->flags | SOUND_FLAGS_3D ? ACT_SND_3D_SOUND : 0;
sAct->pitch = sAct->sound->pitch;
sAct->volume = sAct->sound->volume;
sAct->sound3D.reference_distance = sAct->sound->distance;
sAct->sound3D.max_gain = sAct->sound->max_gain;
sAct->sound3D.min_gain = sAct->sound->min_gain;
sAct->sound3D.rolloff_factor = sAct->sound->attenuation;
}
else*/
{
sAct->sound3D.reference_distance = 1.0f;
sAct->flag = ACT_SND_3D_SOUND;
sAct->volume = 1.0f;
sAct->sound3D.max_gain = 1.0f;
sAct->sound3D.rolloff_factor = 1.0f;
}
sAct->sound3D.cone_inner_angle = 360.0f;
sAct->sound3D.cone_outer_angle = 360.0f;
sAct->sound3D.max_distance = FLT_MAX;
}
}
}
for(scene = main->scene.first; scene; scene = scene->id.next)
{
if(scene->ed && scene->ed->seqbasep)
{
for(seq = scene->ed->seqbasep->first; seq; seq = seq->next)
{
if(seq->type == SEQ_HD_SOUND)
{
char str[FILE_MAX];
BLI_join_dirfile(str, seq->strip->dir, seq->strip->stripdata->name);
BLI_convertstringcode(str, G.sce);
BLI_convertstringframe(str, scene->r.cfra);
seq->sound = sound_new_file(main, str);
}
}
}
}
@@ -9278,14 +9333,6 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
Scene *sce;
ToolSettings *ts;
int i, a;
// AUD_XXX
bSound *sound;
for(sound = main->sound.first; sound; sound = sound->id.next)
{
sound->snd_sound = NULL;
sound_load(sound);
}
for(ob = main->object.first; ob; ob = ob->id.next) {

View File

@@ -241,7 +241,7 @@ static Sequence* sequencer_add_sound_strip(bContext *C, wmOperator *op, int star
AUD_SoundInfo info;
sound = sound_new_file(C, filename);
sound = sound_new_file(CTX_data_main(C), filename);
if (sound==NULL || sound->snd_sound == NULL) {
if(op)

View File

@@ -283,7 +283,7 @@ typedef struct SpeedControlVars {
#define SEQ_RAM_SOUND 4
#define SEQ_HD_SOUND 5
// AUD_XXX #define SEQ_MOVIE_AND_HD_SOUND 6 /* helper for add_sequence */
#define SEQ_SOUND 6
#define SEQ_SOUND 4
#define SEQ_EFFECT 8
#define SEQ_CROSS 8

View File

@@ -141,8 +141,8 @@ typedef struct bSound {
} bSound;
typedef enum eSound_Type {
SOUND_TYPE_INVALID = 0,
SOUND_TYPE_FILE,
SOUND_TYPE_INVALID = -1,
SOUND_TYPE_FILE = 0,
SOUND_TYPE_BUFFER,
SOUND_TYPE_LIMITER
} eSound_Type;