mirror of
https://github.com/vector-im/element-call.git
synced 2026-08-08 20:09:19 +00:00
simplification but same solution
Signed-off-by: Timo K <toger5@hotmail.de>
This commit is contained in:
@@ -264,28 +264,13 @@ class AudioOutput
|
|||||||
class ControlledAudioOutput
|
class ControlledAudioOutput
|
||||||
implements MediaDevice<AudioOutputDeviceLabel, SelectedAudioOutputDevice>
|
implements MediaDevice<AudioOutputDeviceLabel, SelectedAudioOutputDevice>
|
||||||
{
|
{
|
||||||
|
// We need to subscribe to the raw devices so that the OS does update the input
|
||||||
|
// back to what it was before. otherwise we will switch back to the default
|
||||||
|
// whenever we allocate a new stream.
|
||||||
public readonly availableRaw$ = availableRawDevices$(
|
public readonly availableRaw$ = availableRawDevices$(
|
||||||
"audiooutput",
|
"audiooutput",
|
||||||
this.usingNames$,
|
this.usingNames$,
|
||||||
this.scope,
|
this.scope,
|
||||||
).pipe(
|
|
||||||
map((availableRaw) => {
|
|
||||||
const available: Map<string, AudioOutputDeviceLabel> =
|
|
||||||
buildDeviceMap(availableRaw);
|
|
||||||
// Create a virtual default audio output for browsers that don't have one.
|
|
||||||
// Its device ID must be the empty string because that's what setSinkId
|
|
||||||
// recognizes.
|
|
||||||
if (available.size && !available.has("") && !available.has("default"))
|
|
||||||
available.set("", {
|
|
||||||
type: "default",
|
|
||||||
name: availableRaw[0]?.label || null,
|
|
||||||
});
|
|
||||||
// Note: creating virtual default input devices would be another problem
|
|
||||||
// entirely, because requesting a media stream from deviceId "" won't
|
|
||||||
// automatically track the default device.
|
|
||||||
return available;
|
|
||||||
}),
|
|
||||||
this.scope.state(),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
public readonly available$ = combineLatest(
|
public readonly available$ = combineLatest(
|
||||||
@@ -330,7 +315,7 @@ class ControlledAudioOutput
|
|||||||
(available, preferredId) => {
|
(available, preferredId) => {
|
||||||
const id = preferredId ?? available.keys().next().value;
|
const id = preferredId ?? available.keys().next().value;
|
||||||
return id === undefined
|
return id === undefined
|
||||||
? { id: "default", virtualEarpiece: false }
|
? undefined
|
||||||
: { id, virtualEarpiece: id === EARPIECE_CONFIG_ID };
|
: { id, virtualEarpiece: id === EARPIECE_CONFIG_ID };
|
||||||
},
|
},
|
||||||
).pipe(this.scope.state());
|
).pipe(this.scope.state());
|
||||||
@@ -344,7 +329,7 @@ class ControlledAudioOutput
|
|||||||
// This information is probably only of interest if the earpiece mode has
|
// This information is probably only of interest if the earpiece mode has
|
||||||
// been selected - for example, Element X iOS listens to this to determine
|
// been selected - for example, Element X iOS listens to this to determine
|
||||||
// whether it should enable the proximity sensor.
|
// whether it should enable the proximity sensor.
|
||||||
if (device !== undefined && platform !== "ios") {
|
if (device !== undefined) {
|
||||||
logger.info("[controlled-output] onAudioDeviceSelect called:", device);
|
logger.info("[controlled-output] onAudioDeviceSelect called:", device);
|
||||||
window.controls.onAudioDeviceSelect?.(device.id);
|
window.controls.onAudioDeviceSelect?.(device.id);
|
||||||
// Also invoke the deprecated callback for backward compatibility
|
// Also invoke the deprecated callback for backward compatibility
|
||||||
@@ -352,7 +337,10 @@ class ControlledAudioOutput
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.available$.subscribe((available) => {
|
this.available$.subscribe((available) => {
|
||||||
logger.info("[controlled-output] available devices:", available);
|
logger.info(
|
||||||
|
"[controlled-output] available controlled devices:",
|
||||||
|
available,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
this.availableRaw$.subscribe((availableRaw) => {
|
this.availableRaw$.subscribe((availableRaw) => {
|
||||||
logger.info("[controlled-output] available raw devices:", availableRaw);
|
logger.info("[controlled-output] available raw devices:", availableRaw);
|
||||||
|
|||||||
Reference in New Issue
Block a user