Added sound caching.
This commit is contained in:
@@ -60,10 +60,17 @@ void sound_exit();
|
||||
|
||||
struct bSound* sound_new_file(struct bContext *C, char* filename);
|
||||
|
||||
// AUD_XXX unused currently
|
||||
#if 0
|
||||
struct bSound* sound_new_buffer(struct bContext *C, struct bSound *source);
|
||||
|
||||
struct bSound* sound_new_limiter(struct bContext *C, struct bSound *source, float start, float end);
|
||||
#endif
|
||||
|
||||
void sound_delete(struct bContext *C, struct bSound* sound);
|
||||
|
||||
void sound_cache(struct bSound* sound, int ignore);
|
||||
|
||||
void sound_load(struct bSound* sound);
|
||||
|
||||
void sound_free(struct bSound* sound);
|
||||
|
@@ -228,6 +228,8 @@ struct bSound* sound_new_file(struct bContext *C, char* filename)
|
||||
return sound;
|
||||
}
|
||||
|
||||
// AUD_XXX unused currently
|
||||
#if 0
|
||||
struct bSound* sound_new_buffer(struct bContext *C, struct bSound *source)
|
||||
{
|
||||
bSound* sound = NULL;
|
||||
@@ -277,6 +279,7 @@ struct bSound* sound_new_limiter(struct bContext *C, struct bSound *source, floa
|
||||
|
||||
return sound;
|
||||
}
|
||||
#endif
|
||||
|
||||
void sound_delete(struct bContext *C, struct bSound* sound)
|
||||
{
|
||||
@@ -290,6 +293,14 @@ void sound_delete(struct bContext *C, struct bSound* sound)
|
||||
}
|
||||
}
|
||||
|
||||
void sound_cache(struct bSound* sound, int ignore)
|
||||
{
|
||||
if(sound->cache && !ignore)
|
||||
AUD_unload(sound->cache);
|
||||
|
||||
sound->cache = AUD_bufferSound(sound->snd_sound);
|
||||
}
|
||||
|
||||
void sound_load(struct bSound* sound)
|
||||
{
|
||||
if(sound)
|
||||
@@ -330,6 +341,11 @@ void sound_load(struct bSound* sound)
|
||||
sound->snd_sound = AUD_limitSound(sound->child_sound, sound->start, sound->end);
|
||||
break;
|
||||
}
|
||||
|
||||
if(sound->cache)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -488,7 +504,7 @@ void sound_update_playing(struct bContext *C)
|
||||
{
|
||||
if(handle->source && handle->source->snd_sound)
|
||||
{
|
||||
AUD_Sound* limiter = AUD_limitSound(handle->source->snd_sound, handle->frameskip / fps, (handle->frameskip + handle->endframe - handle->startframe)/fps);
|
||||
AUD_Sound* limiter = AUD_limitSound(handle->source->cache ? handle->source->cache : handle->source->snd_sound, handle->frameskip / fps, (handle->frameskip + handle->endframe - handle->startframe)/fps);
|
||||
handle->handle = AUD_play(limiter, 1);
|
||||
AUD_unload(limiter);
|
||||
if(handle->handle)
|
||||
@@ -530,7 +546,7 @@ void sound_scrub(struct bContext *C)
|
||||
if(handle->source && handle->source->snd_sound)
|
||||
{
|
||||
int frameskip = handle->frameskip + cfra - handle->startframe;
|
||||
AUD_Sound* limiter = AUD_limitSound(handle->source->snd_sound, frameskip / fps, (frameskip + 1)/fps);
|
||||
AUD_Sound* limiter = AUD_limitSound(handle->source->cache ? handle->source->cache : handle->source->snd_sound, frameskip / fps, (frameskip + 1)/fps);
|
||||
AUD_play(limiter, 0);
|
||||
AUD_unload(limiter);
|
||||
}
|
||||
|
@@ -258,8 +258,6 @@ static Sequence* sequencer_add_sound_strip(bContext *C, wmOperator *op, int star
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sound->flags |= SOUND_FLAGS_SEQUENCE;
|
||||
|
||||
seq = alloc_sequence(ed->seqbasep, start_frame, channel);
|
||||
|
||||
seq->type= SEQ_SOUND;
|
||||
@@ -404,6 +402,10 @@ static int sequencer_add_sound_strip_exec(bContext *C, wmOperator *op)
|
||||
|
||||
RNA_string_get(op->ptr, "name", seq->name);
|
||||
|
||||
if (RNA_boolean_get(op->ptr, "cache")) {
|
||||
sound_cache(seq->sound, 0);
|
||||
}
|
||||
|
||||
if (RNA_boolean_get(op->ptr, "replace_sel")) {
|
||||
deselect_all_seq(scene);
|
||||
set_last_seq(scene, seq);
|
||||
@@ -443,7 +445,7 @@ void SEQUENCER_OT_sound_strip_add(struct wmOperatorType *ot)
|
||||
|
||||
WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE);
|
||||
sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME);
|
||||
RNA_def_boolean(ot->srna, "cache", FALSE, "Cache", "Load the sound as streaming audio"); // XXX need to impliment this
|
||||
RNA_def_boolean(ot->srna, "cache", FALSE, "Cache", "Cache the sound in memory.");
|
||||
}
|
||||
|
||||
/* add image operator */
|
||||
|
@@ -133,6 +133,7 @@ typedef struct bSound {
|
||||
int type;
|
||||
int changed;
|
||||
struct bSound* child_sound;
|
||||
void* cache;
|
||||
|
||||
// SOUND_TYPE_LIMITER
|
||||
float start, end;
|
||||
|
@@ -151,6 +151,8 @@ static void rna_def_sound(BlenderRNA *brna)
|
||||
RNA_def_property_ui_text(prop, "Packed File", "");
|
||||
|
||||
/* game engine settings */
|
||||
// AUD_XXX DEPRECATED!
|
||||
#if 0
|
||||
prop= RNA_def_property(srna, "volume", PROP_FLOAT, PROP_UNSIGNED);
|
||||
RNA_def_property_float_sdna(prop, NULL, "volume");
|
||||
RNA_def_property_ui_range(prop, 0.0, 1.0, 10, 4);
|
||||
@@ -214,6 +216,7 @@ static void rna_def_sound(BlenderRNA *brna)
|
||||
prop= RNA_def_property(srna, "priority", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "flags", SOUND_FLAGS_PRIORITY);
|
||||
RNA_def_property_ui_text(prop, "Priority", "Make sound higher priority."); */
|
||||
#endif
|
||||
}
|
||||
|
||||
void RNA_def_sound(BlenderRNA *brna)
|
||||
|
@@ -501,7 +501,7 @@ void BL_ConvertActuators(char* maggiename,
|
||||
"\" has no sound datablock." << std::endl;
|
||||
}
|
||||
else
|
||||
snd_sound = sound->snd_sound;
|
||||
snd_sound = sound->cache ? sound->cache : sound->snd_sound;
|
||||
#endif
|
||||
KX_SoundActuator* tmpsoundact =
|
||||
new KX_SoundActuator(gameobj,
|
||||
|
Reference in New Issue
Block a user