diff options
author | Ton Roosendaal <ton@blender.org> | 2006-11-25 16:07:28 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2006-11-25 16:07:28 +0300 |
commit | 604b4230325aa012efb063e0a3fd2ac23809e393 (patch) | |
tree | 10d0b42f972550484bde3d9d47a72bbbd68a956e /source/blender/blenkernel | |
parent | b78b3a4761849bd7e2b368884e05c40ef58d12d0 (diff) |
- Library linking feature: global undo/redo now doesn't read the linked
library .blend files anymore, making it a load faster to use.
- Fixed ancient annoyance; samples were not properly freed, giving a lot
"Error Totblock" when using sound.
This fix also involves removing an ancient NaN hack, which treated the
samples as fake Library data in the Main database.
But still, the Blender Sound and Sample code is horrible... :/
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_sound.h | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/blender.c | 11 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/library.c | 19 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/sound.c | 20 |
4 files changed, 36 insertions, 17 deletions
diff --git a/source/blender/blenkernel/BKE_sound.h b/source/blender/blenkernel/BKE_sound.h index e6634bc4a6a..0a747847b11 100644 --- a/source/blender/blenkernel/BKE_sound.h +++ b/source/blender/blenkernel/BKE_sound.h @@ -39,8 +39,11 @@ struct bSound; struct bSample; struct ListBase; +/* bad bad global... */ extern struct ListBase *samples; +void sound_free_all_samples(void); + /* void *sound_get_listener(void); implemented in src!also declared there now */ void sound_set_packedfile(struct bSample* sample, struct PackedFile* pf); diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 570f993f542..bb5f25c6907 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -73,6 +73,7 @@ #include "BKE_main.h" #include "BKE_object.h" #include "BKE_scene.h" +#include "BKE_sound.h" #include "BLI_editVert.h" @@ -166,10 +167,14 @@ void pushpop_test() void free_blender(void) { + /* samples are in a global list..., also sets G.main->sound->sample NULL */ + sound_free_all_samples(); + free_main(G.main); G.main= NULL; IMB_freeImBufdata(); /* imbuf lib */ + } void duplicatelist(ListBase *list1, ListBase *list2) /* copy from 2 to 1 */ @@ -336,7 +341,7 @@ static void setup_app_data(BlendFileData *bfd, char *filename) lib_link_screen_restore(bfd->main, curscene); } - clear_global(); + clear_global(); /* free Main database */ if(mode!='u') G.save_over = 1; @@ -351,6 +356,9 @@ static void setup_app_data(BlendFileData *bfd, char *filename) } + /* samples is a global list... */ + sound_free_all_samples(); + /* case G_FILE_NO_UI or no screens in file */ if(mode) { G.curscreen= curscreen; @@ -459,6 +467,7 @@ int BKE_read_file_from_memory(char* filebuf, int filelength, void *type_r) return (bfd?1:0); } +/* memfile is the undo buffer */ int BKE_read_file_from_memfile(MemFile *memfile) { BlendReadError bre; diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index e6aa0208a5e..6038e70f6f2 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -184,9 +184,6 @@ ListBase *wich_libbase(Main *mainlib, short type) return &(mainlib->script); case ID_SO: return &(mainlib->sound); - case ID_SAMPLE: - /* declared as an external in sound.h !!! */ - return (samples); case ID_GR: return &(mainlib->group); case ID_AR: @@ -239,12 +236,10 @@ int set_listbasepointers(Main *main, ListBase **lb) lb[22]= &(main->group); lb[23]= &(main->nodetree); lb[24]= &(main->brush); + lb[25]= &(main->script); + lb[26]= NULL; - lb[25]= samples; - lb[26]= &(main->script); - lb[27]= NULL; - - return 27; + return 26; } /* *********** ALLOC AND FREE ***************** @@ -325,11 +320,8 @@ static ID *alloc_libblock_notest(short type) case ID_SO: id= MEM_callocN(sizeof(bSound), "sound"); break; - case ID_SAMPLE: - id = MEM_callocN(sizeof(bSample), "sound"); - break; case ID_GR: - id= MEM_callocN(sizeof(Group), "sound"); + id= MEM_callocN(sizeof(Group), "group"); break; case ID_AR: id = MEM_callocN(sizeof(bArmature), "armature"); @@ -471,9 +463,6 @@ void free_libblock(ListBase *lb, void *idv) case ID_SO: sound_free_sound((bSound *)id); break; - case ID_SAMPLE: - sound_free_sample((bSample *)id); - break; case ID_GR: free_group((Group *)id); break; diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 2f31dbcaa80..3b14cb8adac 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -62,7 +62,25 @@ void sound_free_sample(bSample *sample) } } - +/* this is called after file reading or undos */ +void sound_free_all_samples(void) +{ + bSample *sample; + bSound *sound; + + /* ensure no sample pointers exist, and check packedfile */ + for(sound= G.main->sound.first; sound; sound= sound->id.next) { + if(sound->sample && sound->sample->packedfile==sound->newpackedfile) + sound->newpackedfile= NULL; + sound->sample= NULL; + } + + /* now free samples */ + for(sample= samples->first; sample; sample= sample->id.next) + sound_free_sample(sample); + BLI_freelistN(samples); + +} void sound_set_packedfile(bSample *sample, PackedFile *pf) { |