node-mac-recorder 2.15.3 → 2.15.4
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 +31 -4
package/package.json
CHANGED
package/src/mac_recorder.mm
CHANGED
|
@@ -401,10 +401,37 @@ Napi::Value GetAudioDevices(const Napi::CallbackInfo& info) {
|
|
|
401
401
|
for (NSUInteger i = 0; i < devices.count; i++) {
|
|
402
402
|
NSDictionary *device = devices[i];
|
|
403
403
|
Napi::Object deviceObj = Napi::Object::New(env);
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
404
|
+
|
|
405
|
+
// Safe string conversion with null checks
|
|
406
|
+
NSString *deviceId = device[@"id"];
|
|
407
|
+
NSString *deviceName = device[@"name"];
|
|
408
|
+
NSString *deviceManufacturer = device[@"manufacturer"];
|
|
409
|
+
NSNumber *isDefault = device[@"isDefault"];
|
|
410
|
+
|
|
411
|
+
if (deviceId && [deviceId isKindOfClass:[NSString class]]) {
|
|
412
|
+
deviceObj.Set("id", Napi::String::New(env, [deviceId UTF8String]));
|
|
413
|
+
} else {
|
|
414
|
+
deviceObj.Set("id", Napi::String::New(env, "default"));
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
if (deviceName && [deviceName isKindOfClass:[NSString class]]) {
|
|
418
|
+
deviceObj.Set("name", Napi::String::New(env, [deviceName UTF8String]));
|
|
419
|
+
} else {
|
|
420
|
+
deviceObj.Set("name", Napi::String::New(env, "Default Audio Device"));
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
if (deviceManufacturer && [deviceManufacturer isKindOfClass:[NSString class]]) {
|
|
424
|
+
deviceObj.Set("manufacturer", Napi::String::New(env, [deviceManufacturer UTF8String]));
|
|
425
|
+
} else {
|
|
426
|
+
deviceObj.Set("manufacturer", Napi::String::New(env, "System"));
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
if (isDefault && [isDefault isKindOfClass:[NSNumber class]]) {
|
|
430
|
+
deviceObj.Set("isDefault", Napi::Boolean::New(env, [isDefault boolValue]));
|
|
431
|
+
} else {
|
|
432
|
+
deviceObj.Set("isDefault", Napi::Boolean::New(env, true));
|
|
433
|
+
}
|
|
434
|
+
|
|
408
435
|
result[i] = deviceObj;
|
|
409
436
|
}
|
|
410
437
|
|