Fix for [#23912]: Replace by integer comparison a float comparison whose precision...
authorDamien Plisson <damien.plisson@yahoo.fr>
Sun, 26 Sep 2010 16:11:53 +0000 (16:11 +0000)
committerDamien Plisson <damien.plisson@yahoo.fr>
Sun, 26 Sep 2010 16:11:53 +0000 (16:11 +0000)
source/blender/quicktime/apple/qtkit_export.m

index 35f3629cb619bf1f0ca66bf1bdf9312a2da4bf56..73e23ea8abd56727b68d0076be09460e5e5534ef 100644 (file)
@@ -587,6 +587,7 @@ int append_qt(struct RenderData *rd, int frame, int *pixels, int rectx, int rect
        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
        NSBitmapImageRep *blBitmapFormatImage;
        NSImage *frameImage;
+       OSStatus err = noErr;
        unsigned char *from_Ptr,*to_Ptr;
        int y,from_i,to_i;
        
@@ -628,8 +629,7 @@ int append_qt(struct RenderData *rd, int frame, int *pixels, int rectx, int rect
        if (qtexport->audioFile) {
                UInt32 audioPacketsConverted;
                /* Append audio */
-               while (((double)qtexport->audioTotalExportedFrames / (double) qtexport->audioInputFormat.mSampleRate)
-                          < ((double)(frame - rd->sfra)) / (((double)rd->frs_sec) / rd->frs_sec_base)) {       
+               while (qtexport->audioTotalExportedFrames < qtexport->audioLastFrame) { 
 
                        qtexport->audioBufferList.mNumberBuffers = 1;
                        qtexport->audioBufferList.mBuffers[0].mNumberChannels = qtexport->audioOutputFormat.mChannelsPerFrame;
@@ -637,7 +637,7 @@ int append_qt(struct RenderData *rd, int frame, int *pixels, int rectx, int rect
                        qtexport->audioBufferList.mBuffers[0].mData = qtexport->audioOutputBuffer;
                        audioPacketsConverted = AUDIOOUTPUTBUFFERSIZE / qtexport->audioCodecMaxOutputPacketSize;
                        
-                       AudioConverterFillComplexBuffer(qtexport->audioConverter, AudioConverterInputCallback,
+                       err = AudioConverterFillComplexBuffer(qtexport->audioConverter, AudioConverterInputCallback,
                                                                                        NULL, &audioPacketsConverted, &qtexport->audioBufferList, qtexport->audioOutputPktDesc);
                        if (audioPacketsConverted) {
                                AudioFileWritePackets(qtexport->audioFile, false, qtexport->audioBufferList.mBuffers[0].mDataByteSize,
@@ -656,6 +656,12 @@ int append_qt(struct RenderData *rd, int frame, int *pixels, int rectx, int rect
                                
                                
                        }
+                       else {
+                               //Error getting audio packets
+                               BKE_reportf(reports, RPT_ERROR, "Unable to get further audio packets from frame %i, error = 0x%x",qtexport->audioTotalExportedFrames,err);
+                               break;
+                       }
+
                }
        }
        [pool drain];