blackjack / webcam

Golang webcam library for Linux
MIT License
411 stars 90 forks source link

Prevent file handles from leaking on failed open. #67

Closed bpstark closed 5 months ago

bpstark commented 5 months ago

Since the webcam open function only returns the open fh on success, we need to close the FH ourselves in the event that the subsequent tests fail.

Testing: iterate over all files in /dev/video* and attempt to open each one as a webcam then log the details of said video device if successfully opened as a webcam. This was used to find the initial leak of file handles, as a device which opend fine, but failed to be recognized as a valid webcam (supportsVideoCapture/ supportsVideoStreaming)the handle would be lost.