qtkit : improve thread safety, enforce build on OSX 10.5+
authorDamien Plisson <damien.plisson@yahoo.fr>
Sat, 28 Nov 2009 18:16:27 +0000 (18:16 +0000)
committerDamien Plisson <damien.plisson@yahoo.fr>
Sat, 28 Nov 2009 18:16:27 +0000 (18:16 +0000)
qtkit movie creation functions can be started in a worker thread only from OSX 10.5

source/blender/quicktime/apple/qtkit_export.m

index 9f2a97dee237bd7775750e4a5674522156ee4499..6788c22d9a13100fd322264d5cf0172ece541ef3 100644 (file)
 #endif
 #import <Cocoa/Cocoa.h>
 #import <QTKit/QTKit.h>
+
+#if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4
+#error OSX 10.5 minimum is needed for QTKit
+#endif
+
 #endif /* __APPLE__ */
 
 typedef struct QuicktimeExport {
@@ -127,9 +132,12 @@ void start_qt(struct Scene *scene, struct RenderData *rd, int rectx, int recty)
        char name[2048];
 
        
-       if(qtexport == NULL) qtexport = MEM_callocN(sizeof(QuicktimeExport), "QuicktimeExport");
-
        if (G.afbreek != 1) {
+               
+               if(qtexport == NULL) qtexport = MEM_callocN(sizeof(QuicktimeExport), "QuicktimeExport");
+               
+               [QTMovie enterQTKitOnThread];           
+               
                /* Check first if the QuickTime 7.2.1 initToWritableFile: method is available */
                if ([[[[QTMovie alloc] init] autorelease] respondsToSelector:@selector(initToWritableFile:error:)] != YES) {
                        G.afbreek = 1;
@@ -144,6 +152,7 @@ void start_qt(struct Scene *scene, struct RenderData *rd, int rectx, int recty)
                        if(qtexport->movie == nil) {
                                G.afbreek = 1;
                                NSLog(@"Unable to create quicktime movie : %@",[error localizedDescription]);
+                               [QTMovie exitQTKitOnThread];
                        } else {
                                [qtexport->movie retain];
                                [qtexport->filename retain];
@@ -235,6 +244,8 @@ void end_qt(void)
                [qtexport->frameAttributes release];
                [qtexport->movie release];
                }
+       
+       [QTMovie exitQTKitOnThread];
 
        if(qtexport) {
                MEM_freeN(qtexport);