node-mac-recorder 2.21.28 → 2.21.29
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/mac_recorder.mm +33 -15
package/package.json
CHANGED
package/src/mac_recorder.mm
CHANGED
|
@@ -630,33 +630,51 @@ Napi::Value StopRecording(const Napi::CallbackInfo& info) {
|
|
|
630
630
|
if (isAVFoundationRecording()) {
|
|
631
631
|
MRLog(@"🛑 Stopping AVFoundation recording");
|
|
632
632
|
|
|
633
|
-
|
|
634
|
-
|
|
633
|
+
BOOL cameraWasRecording = isCameraRecording();
|
|
634
|
+
__block BOOL cameraStopResult = YES;
|
|
635
|
+
dispatch_group_t cameraStopGroup = NULL;
|
|
636
|
+
|
|
637
|
+
if (cameraWasRecording) {
|
|
635
638
|
MRLog(@"🛑 Stopping camera recording...");
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
639
|
+
cameraStopResult = NO;
|
|
640
|
+
cameraStopGroup = dispatch_group_create();
|
|
641
|
+
dispatch_group_enter(cameraStopGroup);
|
|
642
|
+
// Stop camera on a background queue so audio/screen shutdown can proceed immediately.
|
|
643
|
+
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
|
|
644
|
+
cameraStopResult = stopCameraRecording() ? YES : NO;
|
|
645
|
+
dispatch_group_leave(cameraStopGroup);
|
|
646
|
+
});
|
|
642
647
|
}
|
|
643
648
|
|
|
644
|
-
// Stop standalone audio if used
|
|
649
|
+
// Stop standalone audio if used (ScreenCaptureKit fallback)
|
|
645
650
|
if (g_usingStandaloneAudio && isStandaloneAudioRecording()) {
|
|
646
651
|
MRLog(@"🛑 Stopping standalone audio...");
|
|
647
652
|
stopStandaloneAudioRecording();
|
|
648
653
|
}
|
|
649
654
|
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
655
|
+
bool avFoundationStopped = stopAVFoundationRecording();
|
|
656
|
+
|
|
657
|
+
if (cameraStopGroup) {
|
|
658
|
+
dispatch_time_t waitTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC));
|
|
659
|
+
long waitResult = dispatch_group_wait(cameraStopGroup, waitTime);
|
|
660
|
+
if (waitResult != 0) {
|
|
661
|
+
MRLog(@"⚠️ Camera stop did not finish within 2 seconds (AVFoundation)");
|
|
662
|
+
cameraStopResult = NO;
|
|
663
|
+
} else if (cameraStopResult) {
|
|
664
|
+
MRLog(@"✅ Camera stopped successfully");
|
|
665
|
+
} else {
|
|
666
|
+
MRLog(@"⚠️ Camera stop reported failure");
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
g_isRecording = false;
|
|
671
|
+
g_usingStandaloneAudio = false;
|
|
672
|
+
|
|
673
|
+
if (avFoundationStopped && (!cameraWasRecording || cameraStopResult)) {
|
|
654
674
|
MRLog(@"✅ AVFoundation recording stopped");
|
|
655
675
|
return Napi::Boolean::New(env, true);
|
|
656
676
|
} else {
|
|
657
677
|
NSLog(@"❌ Failed to stop AVFoundation recording");
|
|
658
|
-
g_isRecording = false;
|
|
659
|
-
g_usingStandaloneAudio = false;
|
|
660
678
|
return Napi::Boolean::New(env, false);
|
|
661
679
|
}
|
|
662
680
|
}
|