From 58ea2b8dd512d77ba15b147c227e24d6bd75aeb4 Mon Sep 17 00:00:00 2001 From: Seb Lee-Delisle Date: Tue, 31 Jul 2018 16:22:24 +0100 Subject: [PATCH] Fix for ofAVFoundationGrabber.mm setDevice(...) after close() Fix for a bug outlined in this forum post : https://forum.openframeworks.cc/t/changing-the-camera-input-while-the-app-is-running/7622/5 If you attempt to set the device ID after you have called close() on the grabber, the grabber object no longer exists, and any subsequent calls to setup() will use the default device (id=0). I have added a check that reallocates the OSXVideoGrabber if necessary. --- libs/openFrameworks/video/ofAVFoundationGrabber.mm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libs/openFrameworks/video/ofAVFoundationGrabber.mm b/libs/openFrameworks/video/ofAVFoundationGrabber.mm index ab1b70b9394..2a0561a2658 100644 --- a/libs/openFrameworks/video/ofAVFoundationGrabber.mm +++ b/libs/openFrameworks/video/ofAVFoundationGrabber.mm @@ -496,6 +496,9 @@ - (void)eraseGrabberPtr { } void ofAVFoundationGrabber::setDeviceID(int deviceID) { + if( grabber == nil ){ + grabber = [OSXVideoGrabber alloc]; + } [grabber setDevice:deviceID]; device = deviceID; }