|
Blender
V2.59
|
00001 /* 00002 * $Id: rna_sound.c 35238 2011-02-27 20:20:01Z jesterking $ 00003 * 00004 * ***** BEGIN GPL LICENSE BLOCK ***** 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software Foundation, 00018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 * 00020 * Contributor(s): Campbell Barton, Roland Hess 00021 * 00022 * ***** END GPL LICENSE BLOCK ***** 00023 */ 00024 00030 #include <stdlib.h> 00031 00032 #include "RNA_define.h" 00033 00034 #include "rna_internal.h" 00035 00036 #include "DNA_sound_types.h" 00037 #include "DNA_property_types.h" 00038 00039 #ifdef RNA_RUNTIME 00040 00041 #include "BKE_sound.h" 00042 #include "BKE_context.h" 00043 00044 static void rna_Sound_filepath_update(Main *bmain, Scene *scene, PointerRNA *ptr) 00045 { 00046 sound_load(bmain, (bSound*)ptr->data); 00047 } 00048 00049 static int rna_Sound_caching_get(PointerRNA *ptr) 00050 { 00051 bSound *sound = (bSound*)(ptr->data); 00052 return sound->cache != NULL; 00053 } 00054 00055 static void rna_Sound_caching_set(PointerRNA *ptr, const int value) 00056 { 00057 bSound *sound = (bSound*)(ptr->data); 00058 if(value) 00059 sound_cache(sound, 0); 00060 else 00061 sound_delete_cache(sound); 00062 } 00063 00064 #else 00065 00066 static void rna_def_sound(BlenderRNA *brna) 00067 { 00068 StructRNA *srna; 00069 PropertyRNA *prop; 00070 00071 srna= RNA_def_struct(brna, "Sound", "ID"); 00072 RNA_def_struct_sdna(srna, "bSound"); 00073 RNA_def_struct_ui_text(srna, "Sound", "Sound datablock referencing an external or packed sound file"); 00074 RNA_def_struct_ui_icon(srna, ICON_SOUND); 00075 00076 //rna_def_ipo_common(srna); 00077 00078 prop= RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH); 00079 RNA_def_property_string_sdna(prop, NULL, "name"); 00080 RNA_def_property_ui_text(prop, "File Path", "Sound sample file used by this Sound datablock"); 00081 RNA_def_property_update(prop, 0, "rna_Sound_filepath_update"); 00082 00083 prop= RNA_def_property(srna, "packed_file", PROP_POINTER, PROP_NONE); 00084 RNA_def_property_pointer_sdna(prop, NULL, "packedfile"); 00085 RNA_def_property_ui_text(prop, "Packed File", ""); 00086 00087 prop= RNA_def_property(srna, "use_memory_cache", PROP_BOOLEAN, PROP_NONE); 00088 RNA_def_property_boolean_funcs(prop, "rna_Sound_caching_get", "rna_Sound_caching_set"); 00089 RNA_def_property_ui_text(prop, "Caching", "The sound file is decoded and loaded into RAM"); 00090 RNA_def_property_update(prop, 0, "rna_Sound_filepath_update"); 00091 } 00092 00093 void RNA_def_sound(BlenderRNA *brna) 00094 { 00095 rna_def_sound(brna); 00096 } 00097 00098 #endif 00099 00100