[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12668] trunk/blender/source/blender: == Sequencer ==
Peter Schlaile
peter at schlaile.de
Sun Nov 25 17:35:33 CET 2007
Revision: 12668
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12668
Author: schlaile
Date: 2007-11-25 17:35:33 +0100 (Sun, 25 Nov 2007)
Log Message:
-----------
== Sequencer ==
Added malloc mutex handling. (Sorry, had to patch threads.c a bit,
since otherwise scene tracks will completely screw things up...)
Modified Paths:
--------------
trunk/blender/source/blender/blenlib/intern/threads.c
trunk/blender/source/blender/src/sequence.c
Modified: trunk/blender/source/blender/blenlib/intern/threads.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/threads.c 2007-11-25 13:43:14 UTC (rev 12667)
+++ trunk/blender/source/blender/blenlib/intern/threads.c 2007-11-25 16:35:33 UTC (rev 12668)
@@ -109,22 +109,26 @@
pthread_mutex_unlock(&_malloc_lock);
}
+/* tot = 0 only initializes malloc mutex in a safe way (see sequence.c)
+ problem otherwise: scene render will kill of the mutex!
+*/
+
void BLI_init_threads(ListBase *threadbase, void *(*do_thread)(void *), int tot)
{
int a;
- if(threadbase==NULL)
- return;
- threadbase->first= threadbase->last= NULL;
+ if(threadbase != NULL && tot > 0) {
+ threadbase->first= threadbase->last= NULL;
- if(tot>RE_MAX_THREAD) tot= RE_MAX_THREAD;
- else if(tot<1) tot= 1;
+ if(tot>RE_MAX_THREAD) tot= RE_MAX_THREAD;
+ else if(tot<1) tot= 1;
- for(a=0; a<tot; a++) {
- ThreadSlot *tslot= MEM_callocN(sizeof(ThreadSlot), "threadslot");
- BLI_addtail(threadbase, tslot);
- tslot->do_thread= do_thread;
- tslot->avail= 1;
+ for(a=0; a<tot; a++) {
+ ThreadSlot *tslot= MEM_callocN(sizeof(ThreadSlot), "threadslot");
+ BLI_addtail(threadbase, tslot);
+ tslot->do_thread= do_thread;
+ tslot->avail= 1;
+ }
}
MEM_set_lock_callback(BLI_lock_malloc_thread, BLI_unlock_malloc_thread);
@@ -190,12 +194,14 @@
{
ThreadSlot *tslot;
- for(tslot= threadbase->first; tslot; tslot= tslot->next) {
- if(tslot->avail==0) {
- pthread_join(tslot->pthread, NULL);
+ if (threadbase) {
+ for(tslot= threadbase->first; tslot; tslot= tslot->next) {
+ if(tslot->avail==0) {
+ pthread_join(tslot->pthread, NULL);
+ }
}
+ BLI_freelistN(threadbase);
}
- BLI_freelistN(threadbase);
thread_levels--;
if(thread_levels==0)
Modified: trunk/blender/source/blender/src/sequence.c
===================================================================
--- trunk/blender/source/blender/src/sequence.c 2007-11-25 13:43:14 UTC (rev 12667)
+++ trunk/blender/source/blender/src/sequence.c 2007-11-25 16:35:33 UTC (rev 12668)
@@ -71,6 +71,7 @@
#include "blendef.h"
+#include "BLI_threads.h"
#include <pthread.h>
int seqrectx, seqrecty;
@@ -1269,7 +1270,6 @@
struct ImBuf * ibuf;
} PrefetchQueueElem;
-
static void * seq_prefetch_thread(void * This_)
{
PrefetchThread * This = This_;
@@ -1370,6 +1370,9 @@
pthread_create(&t->pthread, NULL, seq_prefetch_thread, t);
}
+
+ /* init malloc mutex */
+ BLI_init_threads(0, 0, 0);
}
void seq_stop_threads()
@@ -1410,6 +1413,9 @@
}
BLI_freelistN(&running_threads);
+
+ /* deinit malloc mutex */
+ BLI_end_threads(0);
}
void give_ibuf_prefetch_request(int rectx, int recty, int cfra, int chanshown)
More information about the Bf-blender-cvs
mailing list