node-mac-recorder 2.21.9 → 2.21.11

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-mac-recorder",
3
- "version": "2.21.9",
3
+ "version": "2.21.11",
4
4
  "description": "Native macOS screen recording package for Node.js applications",
5
5
  "main": "index.js",
6
6
  "keywords": [
@@ -212,22 +212,26 @@ extern "C" bool startAVFoundationRecording(const std::string& outputPath,
212
212
  MRLog(@"🎤 Starting audio capture (mic=%d, system=%d)", includeMicrophone, includeSystemAudio);
213
213
 
214
214
  // Use provided audio output path or generate one
215
+ NSString *audioPath = nil;
215
216
  if (audioOutputPath && [audioOutputPath length] > 0) {
216
- g_avAudioOutputPath = audioOutputPath;
217
- MRLog(@"🎤 Using provided audio path: %@", g_avAudioOutputPath);
217
+ audioPath = audioOutputPath;
218
+ MRLog(@"🎤 Using provided audio path: %@", audioPath);
218
219
  } else {
219
220
  NSString *videoDir = [outputPathStr stringByDeletingLastPathComponent];
220
221
  NSString *audioFilename = [NSString stringWithFormat:@"avf_audio_%ld.mov", (long)[[NSDate date] timeIntervalSince1970]];
221
- g_avAudioOutputPath = [videoDir stringByAppendingPathComponent:audioFilename];
222
- MRLog(@"🎤 Generated audio path: %@", g_avAudioOutputPath);
222
+ audioPath = [videoDir stringByAppendingPathComponent:audioFilename];
223
+ MRLog(@"🎤 Generated audio path: %@", audioPath);
223
224
  }
224
225
 
225
226
  // Ensure .mov extension
226
- if (![g_avAudioOutputPath.pathExtension.lowercaseString isEqualToString:@"mov"]) {
227
- g_avAudioOutputPath = [[g_avAudioOutputPath stringByDeletingPathExtension] stringByAppendingPathExtension:@"mov"];
228
- MRLog(@"🔧 Fixed audio extension to .mov: %@", g_avAudioOutputPath);
227
+ if (![audioPath.pathExtension.lowercaseString isEqualToString:@"mov"]) {
228
+ audioPath = [[audioPath stringByDeletingPathExtension] stringByAppendingPathExtension:@"mov"];
229
+ MRLog(@"🔧 Fixed audio extension to .mov: %@", audioPath);
229
230
  }
230
231
 
232
+ // Copy to retain the string (ARC will manage it)
233
+ g_avAudioOutputPath = [audioPath copy];
234
+
231
235
  // Create audio recorder
232
236
  g_avAudioRecorder = createNativeAudioRecorder();
233
237
 
@@ -404,9 +408,14 @@ extern "C" bool stopAVFoundationRecording() {
404
408
  // Stop audio recording if active
405
409
  if (g_avAudioRecorder) {
406
410
  MRLog(@"🛑 Stopping audio recording");
407
- stopNativeAudioRecording(g_avAudioRecorder);
408
- destroyNativeAudioRecorder(g_avAudioRecorder);
411
+ @try {
412
+ stopNativeAudioRecording(g_avAudioRecorder);
413
+ destroyNativeAudioRecorder(g_avAudioRecorder);
414
+ } @catch (NSException *exception) {
415
+ NSLog(@"⚠️ Exception while stopping audio: %@", exception.reason);
416
+ }
409
417
  g_avAudioRecorder = nil;
418
+ g_avAudioOutputPath = nil;
410
419
  MRLog(@"✅ Audio recording stopped");
411
420
  }
412
421
 
@@ -501,16 +501,9 @@ Napi::Value StartRecording(const Napi::CallbackInfo& info) {
501
501
  return Napi::Boolean::New(env, false);
502
502
  }
503
503
 
504
- if (!startAudioIfRequested(captureAnyAudio, audioOutputPath, preferredAudioDeviceId)) {
505
- MRLog(@"❌ Audio start failed - stopping AVFoundation session");
506
- if (captureCamera) {
507
- stopCameraRecording();
508
- }
509
- stopAVFoundationRecording();
510
- g_isRecording = false;
511
- return Napi::Boolean::New(env, false);
512
- }
513
-
504
+ // NOTE: Audio is handled internally by AVFoundation, no need for standalone audio
505
+ // AVFoundation integrates audio recording directly
506
+
514
507
  g_isRecording = true;
515
508
  return Napi::Boolean::New(env, true);
516
509
  } else {