node-mac-recorder 2.21.29 → 2.21.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/camera_recorder.mm +20 -10
package/package.json
CHANGED
package/src/camera_recorder.mm
CHANGED
|
@@ -754,31 +754,41 @@ static BOOL MRIsContinuityCamera(AVCaptureDevice *device) {
|
|
|
754
754
|
return YES; // Success - nothing to finish
|
|
755
755
|
}
|
|
756
756
|
|
|
757
|
-
|
|
758
|
-
|
|
757
|
+
AVAssetWriter *writer = self.assetWriter;
|
|
758
|
+
AVAssetWriterInput *writerInput = self.assetWriterInput;
|
|
759
|
+
|
|
760
|
+
if (writerInput) {
|
|
761
|
+
[writerInput markAsFinished];
|
|
759
762
|
}
|
|
760
763
|
|
|
761
764
|
__block BOOL finished = NO;
|
|
762
765
|
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
|
|
763
766
|
|
|
764
|
-
[
|
|
767
|
+
[writer finishWritingWithCompletionHandler:^{
|
|
765
768
|
finished = YES;
|
|
766
769
|
dispatch_semaphore_signal(semaphore);
|
|
767
770
|
}];
|
|
768
771
|
|
|
769
|
-
//
|
|
770
|
-
|
|
772
|
+
// Allow generous flush time so final frames are preserved.
|
|
773
|
+
const int64_t primaryWaitSeconds = 3;
|
|
774
|
+
dispatch_time_t timeout = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(primaryWaitSeconds * NSEC_PER_SEC));
|
|
771
775
|
long result = dispatch_semaphore_wait(semaphore, timeout);
|
|
772
776
|
|
|
773
777
|
if (result != 0 || !finished) {
|
|
774
|
-
MRLog(@"⚠️ CameraRecorder:
|
|
775
|
-
|
|
776
|
-
|
|
778
|
+
MRLog(@"⚠️ CameraRecorder: Writer still finishing after %ds – waiting longer", (int)primaryWaitSeconds);
|
|
779
|
+
const int64_t extendedWaitSeconds = 5;
|
|
780
|
+
dispatch_time_t extendedTimeout = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(extendedWaitSeconds * NSEC_PER_SEC));
|
|
781
|
+
result = dispatch_semaphore_wait(semaphore, extendedTimeout);
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
if (result != 0 || !finished) {
|
|
785
|
+
MRLog(@"⚠️ CameraRecorder: Writer did not finish after extended wait – forcing cancel");
|
|
786
|
+
[writer cancelWriting];
|
|
777
787
|
}
|
|
778
788
|
|
|
779
|
-
BOOL success = (
|
|
789
|
+
BOOL success = (writer.status == AVAssetWriterStatusCompleted);
|
|
780
790
|
if (!success) {
|
|
781
|
-
MRLog(@"⚠️ CameraRecorder: Writer finished with status %ld error %@", (long)
|
|
791
|
+
MRLog(@"⚠️ CameraRecorder: Writer finished with status %ld error %@", (long)writer.status, writer.error);
|
|
782
792
|
} else {
|
|
783
793
|
MRLog(@"✅ CameraRecorder writer finished successfully");
|
|
784
794
|
}
|