[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [22091] branches/soundsystem/source: Added sound caching.
Jörg Müller
nexyon at gmail.com
Fri Jul 31 21:48:29 CEST 2009
Revision: 22091
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22091
Author: nexyon
Date: 2009-07-31 21:48:28 +0200 (Fri, 31 Jul 2009)
Log Message:
-----------
Added sound caching.
Modified Paths:
--------------
branches/soundsystem/source/blender/blenkernel/BKE_sound.h
branches/soundsystem/source/blender/blenkernel/intern/sound.c
branches/soundsystem/source/blender/editors/space_sequencer/sequencer_add.c
branches/soundsystem/source/blender/makesdna/DNA_sound_types.h
branches/soundsystem/source/blender/makesrna/intern/rna_sound.c
branches/soundsystem/source/gameengine/Converter/KX_ConvertActuators.cpp
Modified: branches/soundsystem/source/blender/blenkernel/BKE_sound.h
===================================================================
--- branches/soundsystem/source/blender/blenkernel/BKE_sound.h 2009-07-31 16:19:26 UTC (rev 22090)
+++ branches/soundsystem/source/blender/blenkernel/BKE_sound.h 2009-07-31 19:48:28 UTC (rev 22091)
@@ -60,10 +60,17 @@
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);
Modified: branches/soundsystem/source/blender/blenkernel/intern/sound.c
===================================================================
--- branches/soundsystem/source/blender/blenkernel/intern/sound.c 2009-07-31 16:19:26 UTC (rev 22090)
+++ branches/soundsystem/source/blender/blenkernel/intern/sound.c 2009-07-31 19:48:28 UTC (rev 22091)
@@ -228,6 +228,8 @@
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 @@
return sound;
}
+#endif
void sound_delete(struct bContext *C, struct bSound* sound)
{
@@ -290,6 +293,14 @@
}
}
+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 @@
sound->snd_sound = AUD_limitSound(sound->child_sound, sound->start, sound->end);
break;
}
+
+ if(sound->cache)
+ {
+
+ }
}
}
@@ -488,7 +504,7 @@
{
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 @@
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);
}
Modified: branches/soundsystem/source/blender/editors/space_sequencer/sequencer_add.c
===================================================================
--- branches/soundsystem/source/blender/editors/space_sequencer/sequencer_add.c 2009-07-31 16:19:26 UTC (rev 22090)
+++ branches/soundsystem/source/blender/editors/space_sequencer/sequencer_add.c 2009-07-31 19:48:28 UTC (rev 22091)
@@ -258,8 +258,6 @@
return NULL;
}
- sound->flags |= SOUND_FLAGS_SEQUENCE;
-
seq = alloc_sequence(ed->seqbasep, start_frame, channel);
seq->type= SEQ_SOUND;
@@ -404,6 +402,10 @@
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 @@
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 */
Modified: branches/soundsystem/source/blender/makesdna/DNA_sound_types.h
===================================================================
--- branches/soundsystem/source/blender/makesdna/DNA_sound_types.h 2009-07-31 16:19:26 UTC (rev 22090)
+++ branches/soundsystem/source/blender/makesdna/DNA_sound_types.h 2009-07-31 19:48:28 UTC (rev 22091)
@@ -133,6 +133,7 @@
int type;
int changed;
struct bSound* child_sound;
+ void* cache;
// SOUND_TYPE_LIMITER
float start, end;
Modified: branches/soundsystem/source/blender/makesrna/intern/rna_sound.c
===================================================================
--- branches/soundsystem/source/blender/makesrna/intern/rna_sound.c 2009-07-31 16:19:26 UTC (rev 22090)
+++ branches/soundsystem/source/blender/makesrna/intern/rna_sound.c 2009-07-31 19:48:28 UTC (rev 22091)
@@ -151,6 +151,8 @@
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 @@
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)
Modified: branches/soundsystem/source/gameengine/Converter/KX_ConvertActuators.cpp
===================================================================
--- branches/soundsystem/source/gameengine/Converter/KX_ConvertActuators.cpp 2009-07-31 16:19:26 UTC (rev 22090)
+++ branches/soundsystem/source/gameengine/Converter/KX_ConvertActuators.cpp 2009-07-31 19:48:28 UTC (rev 22091)
@@ -501,7 +501,7 @@
"\" 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,
More information about the Bf-blender-cvs
mailing list