mirror of
https://codeberg.org/uzu/strudel
synced 2026-07-24 05:57:17 -04:00
suspend and close exisiting audio context
This commit is contained in:
@@ -19,10 +19,14 @@ export const getAudioDevices = async () => {
|
||||
};
|
||||
|
||||
export const setAudioDevice = async (id) => {
|
||||
const audioCtx = getAudioContext();
|
||||
let audioCtx = getAudioContext();
|
||||
if (audioCtx.sinkId === id) {
|
||||
return;
|
||||
}
|
||||
await audioCtx.suspend();
|
||||
await audioCtx.close();
|
||||
audioCtx = setDefaultAudioContext();
|
||||
await audioCtx.resume();
|
||||
const isValidID = (id ?? '').length > 0;
|
||||
if (isValidID) {
|
||||
try {
|
||||
@@ -30,9 +34,6 @@ export const setAudioDevice = async (id) => {
|
||||
} catch {
|
||||
logger('failed to set audio interface', 'warning');
|
||||
}
|
||||
} else {
|
||||
// reset the audio context and dont set the sink id if it is invalid AKA System Standard selection
|
||||
setDefaultAudioContext();
|
||||
}
|
||||
initializeAudioOutput();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user