Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use retry for decode error #3413

Merged
merged 2 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { HMSRemoteAudioTrack } from '../media/tracks';
import { HMSRemotePeer } from '../sdk/models/peer';
import { Store } from '../sdk/store';
import HMSLogger from '../utils/logger';
import { sleep } from '../utils/timer-utils';

/**
* Following are the errors thrown when autoplay is blocked in different browsers
Expand Down Expand Up @@ -137,11 +138,15 @@ export class AudioSinkManager {
);
this.eventBus.analytics.publish(AnalyticsEventFactory.audioPlaybackError(ex));
if (audioEl?.error?.code === MediaError.MEDIA_ERR_DECODE) {
await track.setVolume(0);
await track.setVolume(this.volume);
this.eventBus.analytics.publish(
AnalyticsEventFactory.audioRecovered('Audio recovered after media decode error'),
);
// try to wait for main execution to complete first
this.removeAudioElement(audioEl, track);
await sleep(500);
await this.handleTrackAdd({ track, peer, callListener: false });
if (!this.state.autoplayFailed) {
this.eventBus.analytics.publish(
AnalyticsEventFactory.audioRecovered('Audio recovered after media decode error'),
);
}
}
};
track.setAudioElement(audioEl);
Expand Down
3 changes: 2 additions & 1 deletion packages/hms-video-store/src/device-manager/DeviceManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,8 @@ export class DeviceManager implements HMSDeviceManager {
*/
// eslint-disable-next-line complexity
public autoSelectAudioOutput = async () => {
if ('ondevicechange' in navigator.mediaDevices || !this.audioInputChanged) {
// do this only after join so the earpiece would be selected at the right time
if ('ondevicechange' in navigator.mediaDevices || !this.store.getLocalPeer()?.joinedAt) {
return;
}
const { bluetoothDevice, earpiece, speakerPhone, wired } = this.categorizeAudioInputDevices();
Expand Down
Loading