From ab4eadf58f654c99cebfb9d468c1b0997d779eff Mon Sep 17 00:00:00 2001 From: Timo Date: Fri, 20 Jun 2025 18:32:51 +0200 Subject: [PATCH 1/5] Only rerequest permissions if we do not yet get labels when enumerating --- src/state/MediaDevices.ts | 77 +++++++++++++++++++++++++----------- src/state/ObservableScope.ts | 12 ++++++ 2 files changed, 66 insertions(+), 23 deletions(-) diff --git a/src/state/MediaDevices.ts b/src/state/MediaDevices.ts index f441918b..adc21b3f 100644 --- a/src/state/MediaDevices.ts +++ b/src/state/MediaDevices.ts @@ -8,6 +8,7 @@ Please see LICENSE in the repository root for full details. import { combineLatest, filter, + identity, map, merge, of, @@ -18,7 +19,7 @@ import { type Observable, } from "rxjs"; import { createMediaDeviceObserver } from "@livekit/components-core"; -import { logger } from "matrix-js-sdk/lib/logger"; +import { logger as rootLogger } from "matrix-js-sdk/lib/logger"; import { audioInput as audioInputSetting, @@ -37,6 +38,7 @@ import { platform } from "../Platform"; // This hardcoded id is used in EX ios! It can only be changed in coordination with // the ios swift team. const EARPIECE_CONFIG_ID = "earpiece-id"; +const logger = rootLogger.getChild("[MediaDevices]"); export type DeviceLabel = | { type: "name"; name: string } @@ -93,15 +95,15 @@ export const iosDeviceMenu$ = function availableRawDevices$( kind: MediaDeviceKind, - usingNames$: Observable, + recomputeDevicesWithPermissions$: Observable, scope: ObservableScope, ): Observable { - return usingNames$.pipe( - switchMap((usingNames) => + return recomputeDevicesWithPermissions$.pipe( + switchMap((recomputeDevicesWithPermissions) => createMediaDeviceObserver( kind, (e) => logger.error("Error creating MediaDeviceObserver", e), - usingNames, + recomputeDevicesWithPermissions, ), ), startWith([]), @@ -145,7 +147,11 @@ function selectDevice$