node-mac-recorder 2.21.30 → 2.21.32
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 +33 -17
- package/src/sync_timeline.mm +3 -3
package/package.json
CHANGED
package/src/camera_recorder.mm
CHANGED
|
@@ -724,27 +724,43 @@ static BOOL MRIsContinuityCamera(AVCaptureDevice *device) {
|
|
|
724
724
|
MRLog(@"🛑 CameraRecorder: Stopping session (external device safe)...");
|
|
725
725
|
|
|
726
726
|
self.isShuttingDown = YES;
|
|
727
|
-
self.isRecording = NO;
|
|
728
|
-
|
|
729
|
-
// Stop delegate FIRST to prevent new frames
|
|
730
|
-
[self.videoOutput setSampleBufferDelegate:nil queue:nil];
|
|
731
727
|
|
|
732
|
-
// Stop session on background thread to avoid blocking
|
|
728
|
+
// Stop session on background thread to avoid blocking, but wait briefly so we capture trailing frames.
|
|
733
729
|
AVCaptureSession *sessionToStop = self.session;
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
730
|
+
|
|
731
|
+
dispatch_group_t sessionStopGroup = NULL;
|
|
732
|
+
if (sessionToStop) {
|
|
733
|
+
sessionStopGroup = dispatch_group_create();
|
|
734
|
+
dispatch_group_enter(sessionStopGroup);
|
|
735
|
+
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
|
|
736
|
+
@autoreleasepool {
|
|
737
|
+
@try {
|
|
738
|
+
if ([sessionToStop isRunning]) {
|
|
739
|
+
MRLog(@"🛑 Stopping AVCaptureSession (camera)...");
|
|
740
|
+
[sessionToStop stopRunning];
|
|
741
|
+
MRLog(@"✅ AVCaptureSession stopped (camera)");
|
|
742
|
+
}
|
|
743
|
+
} @catch (NSException *exception) {
|
|
744
|
+
MRLog(@"⚠️ CameraRecorder: Exception while stopping session: %@", exception.reason);
|
|
741
745
|
}
|
|
742
|
-
|
|
743
|
-
MRLog(@"⚠️ CameraRecorder: Exception while stopping session: %@", exception.reason);
|
|
746
|
+
dispatch_group_leave(sessionStopGroup);
|
|
744
747
|
}
|
|
745
|
-
|
|
748
|
+
});
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
if (sessionStopGroup) {
|
|
752
|
+
dispatch_time_t sessionTimeout = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC));
|
|
753
|
+
long waitResult = dispatch_group_wait(sessionStopGroup, sessionTimeout);
|
|
754
|
+
if (waitResult != 0) {
|
|
755
|
+
MRLog(@"⚠️ CameraRecorder: AVCaptureSession stop timed out after 2s (continuing shutdown)");
|
|
746
756
|
}
|
|
747
|
-
}
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
// Now detach delegate to prevent further callbacks
|
|
760
|
+
if (self.videoOutput) {
|
|
761
|
+
[self.videoOutput setSampleBufferDelegate:nil queue:nil];
|
|
762
|
+
}
|
|
763
|
+
self.isRecording = NO;
|
|
748
764
|
|
|
749
765
|
// CRITICAL FIX: Check if assetWriter exists before trying to finish it
|
|
750
766
|
// If no frames were captured, assetWriter will be nil
|
|
@@ -801,7 +817,7 @@ static BOOL MRIsContinuityCamera(AVCaptureDevice *device) {
|
|
|
801
817
|
- (void)captureOutput:(AVCaptureOutput *)output
|
|
802
818
|
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
|
|
803
819
|
fromConnection:(AVCaptureConnection *)connection {
|
|
804
|
-
if (!self.isRecording
|
|
820
|
+
if (!self.isRecording) {
|
|
805
821
|
return;
|
|
806
822
|
}
|
|
807
823
|
|
package/src/sync_timeline.mm
CHANGED
|
@@ -71,7 +71,7 @@ BOOL MRSyncShouldHoldVideoFrame(CMTime timestamp) {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
CMTime elapsed = CMTimeSubtract(timestamp, g_videoFirstTimestamp);
|
|
74
|
-
CMTime maxWait = CMTimeMakeWithSeconds(
|
|
74
|
+
CMTime maxWait = CMTimeMakeWithSeconds(0.25, 600); // Kamera gecikmesini minimumda tut
|
|
75
75
|
if (CMTIME_COMPARE_INLINE(elapsed, >, maxWait)) {
|
|
76
76
|
g_audioReady = YES;
|
|
77
77
|
g_videoFirstTimestamp = kCMTimeInvalid;
|
|
@@ -85,9 +85,9 @@ BOOL MRSyncShouldHoldVideoFrame(CMTime timestamp) {
|
|
|
85
85
|
});
|
|
86
86
|
|
|
87
87
|
if (logHold) {
|
|
88
|
-
MRLog(@"⏸️ Video pipeline waiting for audio to begin (holding frames up to
|
|
88
|
+
MRLog(@"⏸️ Video pipeline waiting for audio to begin (holding frames up to 0.35s)");
|
|
89
89
|
} else if (logRelease) {
|
|
90
|
-
MRLog(@"▶️ Video pipeline resume forced (audio not detected within
|
|
90
|
+
MRLog(@"▶️ Video pipeline resume forced (audio not detected within 0.35s)");
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
return shouldHold;
|