pion / mediadevices

Go implementation of the MediaDevices API.
https://pion.ly/
MIT License
528 stars 121 forks source link

Call stopRunning on captureSession when freeing #382

Open hetelek opened 2 years ago

hetelek commented 2 years ago

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?

EmrysMyrddin commented 2 years ago

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 ?