Skip to content

Commit ec3acac

Browse files
Immediately handle audio device changes
1 parent ecca208 commit ec3acac

File tree

4 files changed

+62
-14
lines changed

4 files changed

+62
-14
lines changed

ACKNOWLEDGMENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14350,7 +14350,7 @@ For more information on this, and how to apply and follow the GNU AGPL, see
1435014350

1435114351
```
1435214352

14353-
## libsignal-account-keys 0.1.0, libsignal-core 0.1.0, mrp 2.57.1, protobuf 2.57.1, ringrtc 2.57.1, regex-aot 0.1.0, partial-default-derive 0.1.0
14353+
## libsignal-account-keys 0.1.0, libsignal-core 0.1.0, mrp 2.58.0, protobuf 2.58.0, ringrtc 2.58.0, regex-aot 0.1.0, partial-default-derive 0.1.0
1435414354

1435514355
```
1435614356
GNU AFFERO GENERAL PUBLIC LICENSE

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@
133133
"@signalapp/libsignal-client": "0.80.3",
134134
"@signalapp/minimask": "1.0.1",
135135
"@signalapp/quill-cjs": "2.1.2",
136-
"@signalapp/ringrtc": "2.57.1",
136+
"@signalapp/ringrtc": "2.58.0",
137137
"@signalapp/sqlcipher": "2.4.4",
138138
"@signalapp/windows-ucv": "1.0.1",
139139
"@tanstack/react-virtual": "3.11.2",

pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ts/services/calling.ts

Lines changed: 55 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,10 @@ export class CallingClass {
508508
RingRTC.handleOutgoingSignaling = this.#handleOutgoingSignaling.bind(this);
509509
RingRTC.handleIncomingCall = this.#handleIncomingCall.bind(this);
510510
RingRTC.handleStartCall = this.#handleStartCall.bind(this);
511+
RingRTC.handleOutputDeviceChanged =
512+
this.#handleOutputDeviceChanged.bind(this);
513+
RingRTC.handleInputDeviceChanged =
514+
this.#handleInputDeviceChanged.bind(this);
511515
RingRTC.handleAutoEndedIncomingCallRequest =
512516
this.#handleAutoEndedIncomingCallRequest.bind(this);
513517
RingRTC.handleLogMessage = this.#handleLogMessage.bind(this);
@@ -2688,8 +2692,7 @@ export class CallingClass {
26882692
return true;
26892693
}
26902694

2691-
async #pollForMediaDevices(): Promise<void> {
2692-
const newSettings = await this.getMediaDeviceSettings();
2695+
async #maybeUpdateDevices(newSettings: MediaDeviceSettings): Promise<void> {
26932696
if (
26942697
!this.#mediaDeviceSettingsEqual(
26952698
this.#lastMediaDeviceSettings,
@@ -2708,10 +2711,19 @@ export class CallingClass {
27082711
}
27092712
}
27102713

2711-
async getAvailableIODevices(): Promise<AvailableIODevicesType> {
2714+
async #pollForMediaDevices(): Promise<void> {
2715+
const newSettings = await this.getMediaDeviceSettings();
2716+
return this.#maybeUpdateDevices(newSettings);
2717+
}
2718+
2719+
async #getAvailableIODevicesWithPrefetchedDevices(
2720+
prefetchedMicrophones: Array<AudioDevice> | undefined,
2721+
prefetchedSpeakers: Array<AudioDevice> | undefined
2722+
): Promise<AvailableIODevicesType> {
27122723
const availableCameras = await this.#videoCapturer.enumerateDevices();
2713-
const availableMicrophones = RingRTC.getAudioInputs();
2714-
const availableSpeakers = RingRTC.getAudioOutputs();
2724+
const availableMicrophones =
2725+
prefetchedMicrophones || RingRTC.getAudioInputs();
2726+
const availableSpeakers = prefetchedSpeakers || RingRTC.getAudioOutputs();
27152727

27162728
return {
27172729
availableCameras,
@@ -2720,9 +2732,22 @@ export class CallingClass {
27202732
};
27212733
}
27222734

2723-
async getMediaDeviceSettings(): Promise<MediaDeviceSettings> {
2735+
async getAvailableIODevices(): Promise<AvailableIODevicesType> {
2736+
return this.#getAvailableIODevicesWithPrefetchedDevices(
2737+
undefined,
2738+
undefined
2739+
);
2740+
}
2741+
2742+
async #getMediaDeviceSettingsWithPrefetchedDevices(
2743+
prefetchedMicrophones: Array<AudioDevice> | undefined,
2744+
prefetchedSpeakers: Array<AudioDevice> | undefined
2745+
): Promise<MediaDeviceSettings> {
27242746
const { availableCameras, availableMicrophones, availableSpeakers } =
2725-
await this.getAvailableIODevices();
2747+
await this.#getAvailableIODevicesWithPrefetchedDevices(
2748+
prefetchedMicrophones,
2749+
prefetchedSpeakers
2750+
);
27262751

27272752
const preferredMicrophone = getPreferredAudioInputDevice();
27282753
const selectedMicIndex = findBestMatchingAudioDeviceIndex(
@@ -2766,6 +2791,13 @@ export class CallingClass {
27662791
};
27672792
}
27682793

2794+
async getMediaDeviceSettings(): Promise<MediaDeviceSettings> {
2795+
return this.#getMediaDeviceSettingsWithPrefetchedDevices(
2796+
undefined,
2797+
undefined
2798+
);
2799+
}
2800+
27692801
setPreferredMicrophone(device: AudioDevice): void {
27702802
log.info(
27712803
'MediaDevice: setPreferredMicrophone',
@@ -3730,6 +3762,22 @@ export class CallingClass {
37303762
return true;
37313763
}
37323764

3765+
async #handleOutputDeviceChanged(devices: Array<AudioDevice>): Promise<void> {
3766+
const newSettings = await this.#getMediaDeviceSettingsWithPrefetchedDevices(
3767+
undefined,
3768+
devices
3769+
);
3770+
return this.#maybeUpdateDevices(newSettings);
3771+
}
3772+
3773+
async #handleInputDeviceChanged(devices: Array<AudioDevice>): Promise<void> {
3774+
const newSettings = await this.#getMediaDeviceSettingsWithPrefetchedDevices(
3775+
devices,
3776+
undefined
3777+
);
3778+
return this.#maybeUpdateDevices(newSettings);
3779+
}
3780+
37333781
public async updateCallHistoryForAdhocCall(
37343782
roomId: string,
37353783
joinState: GroupCallJoinState | null,

0 commit comments

Comments
 (0)