diff --git a/package.json b/package.json index c2367820c..ce62815d0 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "classnames": "^2.3.1", "color-hash": "^2.0.1", "events": "^3.3.0", - "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#ebcb26f1b3b9e2d709615fde03f9ce6ac77871f1", + "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#f9672cf3076bf5e1868c92ee94c780040b0c6fb1", "mermaid": "^8.13.8", "normalize.css": "^8.0.1", "pako": "^2.0.4", diff --git a/src/video-grid/useMediaStream.ts b/src/video-grid/useMediaStream.ts index 2b8f8f727..79e8292be 100644 --- a/src/video-grid/useMediaStream.ts +++ b/src/video-grid/useMediaStream.ts @@ -16,6 +16,10 @@ limitations under the License. import { useRef, useEffect, RefObject } from "react"; import { parse as parseSdp, write as writeSdp } from "sdp-transform"; +import { + acquireContext, + releaseContext, +} from "matrix-js-sdk/src/webrtc/audioContext"; import { useSpatialAudio } from "../settings/useSetting"; @@ -152,7 +156,7 @@ export const useAudioContext = (): [ useEffect(() => { if (audioRef.current && !context.current) { - context.current = new AudioContext(); + context.current = acquireContext(); if (window.chrome) { // We're in Chrome, which needs a loopback hack applied to enable AEC @@ -166,9 +170,11 @@ export const useAudioContext = (): [ })(); return () => { audioEl.srcObject = null; + releaseContext(); }; } else { destination.current = context.current.destination; + return releaseContext; } } }, []); diff --git a/yarn.lock b/yarn.lock index 68339b6f9..5376e3184 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8602,11 +8602,12 @@ matrix-events-sdk@^0.0.1-beta.7: resolved "https://registry.yarnpkg.com/matrix-events-sdk/-/matrix-events-sdk-0.0.1-beta.7.tgz#5ffe45eba1f67cc8d7c2377736c728b322524934" integrity sha512-9jl4wtWanUFSy2sr2lCjErN/oC8KTAtaeaozJtrgot1JiQcEI4Rda9OLgQ7nLKaqb4Z/QUx/fR3XpDzm5Jy1JA== -"matrix-js-sdk@github:matrix-org/matrix-js-sdk#404f8e130e44a78b0159c55902df1b129b3816d1": - version "17.2.0" - resolved "https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/404f8e130e44a78b0159c55902df1b129b3816d1" +"matrix-js-sdk@github:matrix-org/matrix-js-sdk#f9672cf3076bf5e1868c92ee94c780040b0c6fb1": + version "18.1.0" + resolved "https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/f9672cf3076bf5e1868c92ee94c780040b0c6fb1" dependencies: "@babel/runtime" "^7.12.5" + "@types/sdp-transform" "^2.4.5" another-json "^0.2.0" browser-request "^0.3.3" bs58 "^4.0.1" @@ -8616,6 +8617,7 @@ matrix-events-sdk@^0.0.1-beta.7: p-retry "^4.5.0" qs "^6.9.6" request "^2.88.2" + sdp-transform "^2.14.1" unhomoglyph "^1.0.6" md5.js@^1.3.4: