Skip to content

Commit 4e6625b

Browse files
committed
vcap/avfoundation: fixed cmdline dev spec parsing
fixed commits from 2023-01-03 (a9c001b and 4a91545): 1. unspecified device index is -1, not 0; this fixes run without device spec (`-t avfoundation`) 2. device_name was not include in the condition for explicit device selection. It coincidentally worked because of the bug nr. 1, because the device_index was set to -1 and checked to not equal 0, which fulfills the if condition
1 parent 5bc0077 commit 4e6625b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/video_capture/avfoundation.mm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,8 @@ - (id)initWithParams: (NSDictionary *) params
247247
int device_idx = [params valueForKey:@"device"] ? [[params valueForKey:@"device"] intValue] : -1;
248248
NSString *device_uid = [params valueForKey:@"uid"];
249249
NSString *device_name = [params valueForKey:@"name"];
250-
if (device_idx != 0 || device_uid) {
250+
if (device_idx != -1 || device_name != nullptr ||
251+
device_uid != nullptr) {
251252
int i = -1;
252253
for (AVCaptureDevice *device in [vidcap_avfoundation_state devices]) {
253254
i++;

0 commit comments

Comments
 (0)