Move SDL_GetTicks() to another place, maybe this will fix sound desync.
authorStepan777 <stepik-777@mail.ru>
Sun, 08 Jul 2012 13:21:12 +0400
changeset 7369 46921fbe76d3
parent 7367 ad3f5f2e6ea9
child 7371 911b53e8c00a
Move SDL_GetTicks() to another place, maybe this will fix sound desync. Also, ensure that thumbnail is aslways saved.
hedgewars/uVideoRec.pas
--- a/hedgewars/uVideoRec.pas	Sun Jul 08 13:18:52 2012 +0400
+++ b/hedgewars/uVideoRec.pas	Sun Jul 08 13:21:12 2012 +0400
@@ -248,12 +248,9 @@
     AddFileLog('BeginPreRecording');
 
     numFrames:= 0;
-    startTime:= SDL_GetTicks();
-
+    thumbnailSaved:= false;
     RecPrefix:= FormatDateTime('YYYY-MM-DD_HH-mm-ss', Now());
 
-    thumbnailSaved:= false;
-
     Mix_QuerySpec(@frequency, @format, @channels);
     AddFileLog('sound: frequency = ' + IntToStr(frequency) + ', format = ' + IntToStr(format) + ', channels = ' + IntToStr(channels));
     if format <> $8010 then
@@ -284,6 +281,7 @@
         exit;
     end;
 
+    // save audio parameters in sound file
     BlockWrite(audioFile, frequency, 4);
     BlockWrite(audioFile, channels, 4);
 {$IOCHECKS ON}
@@ -291,6 +289,7 @@
     // register callback for actual audio recording
     Mix_SetPostMix(@RecordPostMix, nil);
 
+    startTime:= SDL_GetTicks();
     flagPrerecording:= true;
 end;
 
@@ -305,6 +304,9 @@
     Close(cameraFile);
     Mix_SetPostMix(nil, nil);
     SDL_UnlockAudio();
+
+    if not thumbnailSaved then
+        SaveThumbnail();
 end;
 
 procedure SaveCameraPosition;