Dont construct logger before rageshake initialization (#3434)
Signed-off-by: Timo K <toger5@hotmail.de>
This commit is contained in:
@@ -6,9 +6,7 @@ Please see LICENSE in the repository root for full details.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Subject } from "rxjs";
|
import { Subject } from "rxjs";
|
||||||
import { logger as rootLogger } from "matrix-js-sdk/lib/logger";
|
import { logger } from "matrix-js-sdk/lib/logger";
|
||||||
|
|
||||||
const logger = rootLogger.getChild("[controlled-output]");
|
|
||||||
|
|
||||||
export interface Controls {
|
export interface Controls {
|
||||||
canEnterPip(): boolean;
|
canEnterPip(): boolean;
|
||||||
|
|||||||
@@ -14,13 +14,12 @@ import {
|
|||||||
type AudioTrackProps,
|
type AudioTrackProps,
|
||||||
} from "@livekit/components-react";
|
} from "@livekit/components-react";
|
||||||
import { type CallMembership } from "matrix-js-sdk/lib/matrixrtc";
|
import { type CallMembership } from "matrix-js-sdk/lib/matrixrtc";
|
||||||
import { logger as rootLogger } from "matrix-js-sdk/lib/logger";
|
import { logger } from "matrix-js-sdk/lib/logger";
|
||||||
|
|
||||||
import { useEarpieceAudioConfig } from "../MediaDevicesContext";
|
import { useEarpieceAudioConfig } from "../MediaDevicesContext";
|
||||||
import { useReactiveState } from "../useReactiveState";
|
import { useReactiveState } from "../useReactiveState";
|
||||||
import * as controls from "../controls";
|
import * as controls from "../controls";
|
||||||
|
|
||||||
const logger = rootLogger.getChild("[MatrixAudioRenderer]");
|
|
||||||
export interface MatrixAudioRendererProps {
|
export interface MatrixAudioRendererProps {
|
||||||
/**
|
/**
|
||||||
* The list of participants to render audio for.
|
* The list of participants to render audio for.
|
||||||
@@ -72,7 +71,7 @@ export function MatrixAudioRenderer({
|
|||||||
const logInvalid = (identity: string, validIdentities: Set<string>): void => {
|
const logInvalid = (identity: string, validIdentities: Set<string>): void => {
|
||||||
if (loggedInvalidIdentities.current.has(identity)) return;
|
if (loggedInvalidIdentities.current.has(identity)) return;
|
||||||
logger.warn(
|
logger.warn(
|
||||||
`Audio track ${identity} has no matching matrix call member`,
|
`[MatrixAudioRenderer] Audio track ${identity} has no matching matrix call member`,
|
||||||
`current members: ${Array.from(validIdentities.values())}`,
|
`current members: ${Array.from(validIdentities.values())}`,
|
||||||
`track will not get rendered`,
|
`track will not get rendered`,
|
||||||
);
|
);
|
||||||
@@ -102,7 +101,7 @@ export function MatrixAudioRenderer({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!tracks.some((t) => !validIdentities.has(t.participant.identity))) {
|
if (!tracks.some((t) => !validIdentities.has(t.participant.identity))) {
|
||||||
logger.debug(
|
logger.debug(
|
||||||
`All audio tracks have a matching matrix call member identity.`,
|
`[MatrixAudioRenderer] All audio tracks have a matching matrix call member identity.`,
|
||||||
);
|
);
|
||||||
loggedInvalidIdentities.current.clear();
|
loggedInvalidIdentities.current.clear();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import {
|
|||||||
type Observable,
|
type Observable,
|
||||||
} from "rxjs";
|
} from "rxjs";
|
||||||
import { createMediaDeviceObserver } from "@livekit/components-core";
|
import { createMediaDeviceObserver } from "@livekit/components-core";
|
||||||
import { logger as rootLogger } from "matrix-js-sdk/lib/logger";
|
import { type Logger, logger as rootLogger } from "matrix-js-sdk/lib/logger";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
audioInput as audioInputSetting,
|
audioInput as audioInputSetting,
|
||||||
@@ -38,7 +38,6 @@ import { type Behavior, constant } from "./Behavior";
|
|||||||
// This hardcoded id is used in EX ios! It can only be changed in coordination with
|
// This hardcoded id is used in EX ios! It can only be changed in coordination with
|
||||||
// the ios swift team.
|
// the ios swift team.
|
||||||
const EARPIECE_CONFIG_ID = "earpiece-id";
|
const EARPIECE_CONFIG_ID = "earpiece-id";
|
||||||
const logger = rootLogger.getChild("[MediaDevices]");
|
|
||||||
|
|
||||||
export type DeviceLabel =
|
export type DeviceLabel =
|
||||||
| { type: "name"; name: string }
|
| { type: "name"; name: string }
|
||||||
@@ -100,6 +99,7 @@ function availableRawDevices$(
|
|||||||
kind: MediaDeviceKind,
|
kind: MediaDeviceKind,
|
||||||
usingNames$: Behavior<boolean>,
|
usingNames$: Behavior<boolean>,
|
||||||
scope: ObservableScope,
|
scope: ObservableScope,
|
||||||
|
logger: Logger,
|
||||||
): Behavior<MediaDeviceInfo[]> {
|
): Behavior<MediaDeviceInfo[]> {
|
||||||
const logError = (e: Error): void =>
|
const logError = (e: Error): void =>
|
||||||
logger.error("Error creating MediaDeviceObserver", e);
|
logger.error("Error creating MediaDeviceObserver", e);
|
||||||
@@ -162,8 +162,15 @@ function selectDevice$<Label>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
class AudioInput implements MediaDevice<DeviceLabel, SelectedAudioInputDevice> {
|
class AudioInput implements MediaDevice<DeviceLabel, SelectedAudioInputDevice> {
|
||||||
|
private logger = rootLogger.getChild("[MediaDevices AudioInput]");
|
||||||
|
|
||||||
private readonly availableRaw$: Behavior<MediaDeviceInfo[]> =
|
private readonly availableRaw$: Behavior<MediaDeviceInfo[]> =
|
||||||
availableRawDevices$("audioinput", this.usingNames$, this.scope);
|
availableRawDevices$(
|
||||||
|
"audioinput",
|
||||||
|
this.usingNames$,
|
||||||
|
this.scope,
|
||||||
|
this.logger,
|
||||||
|
);
|
||||||
|
|
||||||
public readonly available$ = this.scope.behavior(
|
public readonly available$ = this.scope.behavior(
|
||||||
this.availableRaw$.pipe(map(buildDeviceMap)),
|
this.availableRaw$.pipe(map(buildDeviceMap)),
|
||||||
@@ -200,7 +207,7 @@ class AudioInput implements MediaDevice<DeviceLabel, SelectedAudioInputDevice> {
|
|||||||
private readonly scope: ObservableScope,
|
private readonly scope: ObservableScope,
|
||||||
) {
|
) {
|
||||||
this.available$.subscribe((available) => {
|
this.available$.subscribe((available) => {
|
||||||
logger.info("[audio-input] available devices:", available);
|
this.logger.info("[audio-input] available devices:", available);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -208,8 +215,14 @@ class AudioInput implements MediaDevice<DeviceLabel, SelectedAudioInputDevice> {
|
|||||||
class AudioOutput
|
class AudioOutput
|
||||||
implements MediaDevice<AudioOutputDeviceLabel, SelectedAudioOutputDevice>
|
implements MediaDevice<AudioOutputDeviceLabel, SelectedAudioOutputDevice>
|
||||||
{
|
{
|
||||||
|
private logger = rootLogger.getChild("[MediaDevices AudioOutput]");
|
||||||
public readonly available$ = this.scope.behavior(
|
public readonly available$ = this.scope.behavior(
|
||||||
availableRawDevices$("audiooutput", this.usingNames$, this.scope).pipe(
|
availableRawDevices$(
|
||||||
|
"audiooutput",
|
||||||
|
this.usingNames$,
|
||||||
|
this.scope,
|
||||||
|
this.logger,
|
||||||
|
).pipe(
|
||||||
map((availableRaw) => {
|
map((availableRaw) => {
|
||||||
const available: Map<string, AudioOutputDeviceLabel> =
|
const available: Map<string, AudioOutputDeviceLabel> =
|
||||||
buildDeviceMap(availableRaw);
|
buildDeviceMap(availableRaw);
|
||||||
@@ -250,7 +263,7 @@ class AudioOutput
|
|||||||
private readonly scope: ObservableScope,
|
private readonly scope: ObservableScope,
|
||||||
) {
|
) {
|
||||||
this.available$.subscribe((available) => {
|
this.available$.subscribe((available) => {
|
||||||
logger.info("[audio-output] available devices:", available);
|
this.logger.info("[audio-output] available devices:", available);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -258,6 +271,7 @@ class AudioOutput
|
|||||||
class ControlledAudioOutput
|
class ControlledAudioOutput
|
||||||
implements MediaDevice<AudioOutputDeviceLabel, SelectedAudioOutputDevice>
|
implements MediaDevice<AudioOutputDeviceLabel, SelectedAudioOutputDevice>
|
||||||
{
|
{
|
||||||
|
private logger = rootLogger.getChild("[MediaDevices ControlledAudioOutput]");
|
||||||
// We need to subscribe to the raw devices so that the OS does update the input
|
// 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
|
// back to what it was before. otherwise we will switch back to the default
|
||||||
// whenever we allocate a new stream.
|
// whenever we allocate a new stream.
|
||||||
@@ -265,6 +279,7 @@ class ControlledAudioOutput
|
|||||||
"audiooutput",
|
"audiooutput",
|
||||||
this.usingNames$,
|
this.usingNames$,
|
||||||
this.scope,
|
this.scope,
|
||||||
|
this.logger,
|
||||||
);
|
);
|
||||||
|
|
||||||
public readonly available$ = this.scope.behavior(
|
public readonly available$ = this.scope.behavior(
|
||||||
@@ -328,26 +343,37 @@ class ControlledAudioOutput
|
|||||||
// 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) {
|
if (device !== undefined) {
|
||||||
logger.info("[controlled-output] onAudioDeviceSelect called:", device);
|
this.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
|
||||||
window.controls.onOutputDeviceSelect?.(device.id);
|
window.controls.onOutputDeviceSelect?.(device.id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.available$.subscribe((available) => {
|
this.available$.subscribe((available) => {
|
||||||
logger.info("[controlled-output] available devices:", available);
|
this.logger.info("[controlled-output] available devices:", available);
|
||||||
});
|
});
|
||||||
this.availableRaw$.subscribe((availableRaw) => {
|
this.availableRaw$.subscribe((availableRaw) => {
|
||||||
logger.info("[controlled-output] available raw devices:", availableRaw);
|
this.logger.info(
|
||||||
|
"[controlled-output] available raw devices:",
|
||||||
|
availableRaw,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class VideoInput implements MediaDevice<DeviceLabel, SelectedDevice> {
|
class VideoInput implements MediaDevice<DeviceLabel, SelectedDevice> {
|
||||||
|
private logger = rootLogger.getChild("[MediaDevices VideoInput]");
|
||||||
|
|
||||||
public readonly available$ = this.scope.behavior(
|
public readonly available$ = this.scope.behavior(
|
||||||
availableRawDevices$("videoinput", this.usingNames$, this.scope).pipe(
|
availableRawDevices$(
|
||||||
map(buildDeviceMap),
|
"videoinput",
|
||||||
),
|
this.usingNames$,
|
||||||
|
this.scope,
|
||||||
|
this.logger,
|
||||||
|
).pipe(map(buildDeviceMap)),
|
||||||
);
|
);
|
||||||
public readonly selected$ = this.scope.behavior(
|
public readonly selected$ = this.scope.behavior(
|
||||||
selectDevice$(this.available$, videoInputSetting.value$).pipe(
|
selectDevice$(this.available$, videoInputSetting.value$).pipe(
|
||||||
@@ -364,7 +390,7 @@ class VideoInput implements MediaDevice<DeviceLabel, SelectedDevice> {
|
|||||||
) {
|
) {
|
||||||
// This also has the purpose of subscribing to the available devices
|
// This also has the purpose of subscribing to the available devices
|
||||||
this.available$.subscribe((available) => {
|
this.available$.subscribe((available) => {
|
||||||
logger.info("[video-input] available devices:", available);
|
this.logger.info("[video-input] available devices:", available);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user