summaryrefslogtreecommitdiffstats
path: root/src/mixins
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2021-11-30 12:07:01 +0100
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2021-11-30 12:07:01 +0100
commit9956ce1c7532d069644e7276f43d652014632b8c (patch)
treec93cb519bf67f1e47ba16e28c68fe828343d401c /src/mixins
parenta50cfc50ceaba018d38752b320ea61550c1fe42e (diff)
Fix devices not released when got after the dialog was closed
Requesting a stream is an asynchronous operation, and it may take a while to be fulfilled (for example, if the user needs to grant the browser permission to use the device). When the Talk settings and the device checker dialogs are closed the streams being used are stopped, but this will have no effect if the promises that returns the streams are fulfilled after that. In that case the streams need to be explicitly stopped once finally got. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'src/mixins')
-rw-r--r--src/mixins/devices.js20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/mixins/devices.js b/src/mixins/devices.js
index e519ec360..59fd15727 100644
--- a/src/mixins/devices.js
+++ b/src/mixins/devices.js
@@ -126,7 +126,15 @@ export const devices = {
this.mediaDevicesManager.getUserMedia({ audio: true })
.then(stream => {
- this.setAudioStream(stream)
+ if (!this.initialized) {
+ // The promise was fulfilled once the stream is no
+ // longer needed, so just discard it.
+ stream.getTracks().forEach((track) => {
+ track.stop()
+ })
+ } else {
+ this.setAudioStream(stream)
+ }
resetPendingGetUserMediaAudioCount()
})
@@ -178,7 +186,15 @@ export const devices = {
this.mediaDevicesManager.getUserMedia({ video: true })
.then(stream => {
- this.setVideoStream(stream)
+ if (!this.initialized) {
+ // The promise was fulfilled once the stream is no
+ // longer needed, so just discard it.
+ stream.getTracks().forEach((track) => {
+ track.stop()
+ })
+ } else {
+ this.setVideoStream(stream)
+ }
resetPendingGetUserMediaVideoCount()
})