{"version":3,"file":"audioContext.js","names":["audioContext","refCount","acquireContext","AudioContext","exports","releaseContext","_audioContext","close"],"sources":["../../src/webrtc/audioContext.ts"],"sourcesContent":["/*\nCopyright 2022 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nlet audioContext: AudioContext | null = null;\nlet refCount = 0;\n\n/**\n * Acquires a reference to the shared AudioContext.\n * It's highly recommended to reuse this AudioContext rather than creating your\n * own, because multiple AudioContexts can be problematic in some browsers.\n * Make sure to call releaseContext when you're done using it.\n * @returns The shared AudioContext\n */\nexport const acquireContext = (): AudioContext => {\n if (audioContext === null) audioContext = new AudioContext();\n refCount++;\n return audioContext;\n};\n\n/**\n * Signals that one of the references to the shared AudioContext has been\n * released, allowing the context and associated hardware resources to be\n * cleaned up if nothing else is using it.\n */\nexport const releaseContext = (): void => {\n refCount--;\n if (refCount === 0) {\n audioContext?.close();\n audioContext = null;\n }\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,IAAIA,YAAiC,GAAG,IAAI;AAC5C,IAAIC,QAAQ,GAAG,CAAC;;AAEhB;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,cAAc,GAAGA,CAAA,KAAoB;EAC9C,IAAIF,YAAY,KAAK,IAAI,EAAEA,YAAY,GAAG,IAAIG,YAAY,EAAE;EAC5DF,QAAQ,EAAE;EACV,OAAOD,YAAY;AACvB,CAAC;;AAED;AACA;AACA;AACA;AACA;AAJAI,OAAA,CAAAF,cAAA,GAAAA,cAAA;AAKO,MAAMG,cAAc,GAAGA,CAAA,KAAY;EACtCJ,QAAQ,EAAE;EACV,IAAIA,QAAQ,KAAK,CAAC,EAAE;IAAA,IAAAK,aAAA;IAChB,CAAAA,aAAA,GAAAN,YAAY,cAAAM,aAAA,uBAAZA,aAAA,CAAcC,KAAK,EAAE;IACrBP,YAAY,GAAG,IAAI;EACvB;AACJ,CAAC;AAACI,OAAA,CAAAC,cAAA,GAAAA,cAAA"}