Skip to content

Commit

Permalink
Fix for ofAVFoundationGrabber.mm setDevice(...) after close()
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sebleedelisle authored and arturoc committed Jul 31, 2018
1 parent 432b122 commit 58ea2b8
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions libs/openFrameworks/video/ofAVFoundationGrabber.mm
Expand Up @@ -496,6 +496,9 @@ - (void)eraseGrabberPtr {
}

void ofAVFoundationGrabber::setDeviceID(int deviceID) {
if( grabber == nil ){
grabber = [OSXVideoGrabber alloc];
}
[grabber setDevice:deviceID];
device = deviceID;
}
Expand Down

0 comments on commit 58ea2b8

Please sign in to comment.