mediadevices icon indicating copy to clipboard operation
mediadevices copied to clipboard

Call stopRunning on captureSession when freeing

Open hetelek opened this issue 2 years ago • 1 comments

Currently, the green light (on a Mac) indicating the camera is in use never goes off, even after closing the videoTrack. I think stopRunning should be called on the captureSession when the videoTrack is closed. This patch seems to work for me:

diff --git a/pkg/avfoundation/AVFoundationBind/AVFoundationBind.m b/pkg/avfoundation/AVFoundationBind/AVFoundationBind.m
index ed75c99..db8f838 100644
--- a/pkg/avfoundation/AVFoundationBind/AVFoundationBind.m
+++ b/pkg/avfoundation/AVFoundationBind/AVFoundationBind.m
@@ -236,6 +236,7 @@ STATUS AVBindSessionFree(PAVBindSession *ppSession) {
     CHK(ppSession != NULL, STATUS_NULL_ARG);
     PAVBindSession pSession = *ppSession;
     if (pSession->refCaptureSession != NULL) {
+        [pSession->refCaptureSession stopRunning];
         [pSession->refCaptureSession release];
         pSession->refCaptureSession = NULL;
     }

or maybe call AVBindSessionClose instead?

hetelek avatar Mar 12 '22 02:03 hetelek

Do you still experience this ? I have tested it and the green light stops when I close the video track.

Do you have an example that triggers the bug for you ?

EmrysMyrddin avatar Jul 29 '22 07:07 EmrysMyrddin