Skip to content

Commit

Permalink
Allow audio processing for react native without AudioContext (#1395)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidliu authored Feb 4, 2025
1 parent 3f31680 commit 061105f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/many-paws-join.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'livekit-client': patch
---

Allow audio processing for react native without AudioContext
7 changes: 4 additions & 3 deletions src/room/track/LocalAudioTrack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { TrackEvent } from '../events';
import { computeBitrate, monitorFrequency } from '../stats';
import type { AudioSenderStats } from '../stats';
import type { LoggerOptions } from '../types';
import { isWeb, unwrapConstraint } from '../utils';
import { isReactNative, isWeb, unwrapConstraint } from '../utils';
import LocalTrack from './LocalTrack';
import { Track } from './Track';
import type { AudioCaptureOptions } from './options';
Expand Down Expand Up @@ -171,7 +171,7 @@ export default class LocalAudioTrack extends LocalTrack<Track.Kind.Audio> {
async setProcessor(processor: TrackProcessor<Track.Kind.Audio, AudioProcessorOptions>) {
const unlock = await this.processorLock.lock();
try {
if (!this.audioContext) {
if (!isReactNative() && !this.audioContext) {
throw Error(
'Audio context needs to be set on LocalAudioTrack in order to enable processors',
);
Expand All @@ -183,7 +183,8 @@ export default class LocalAudioTrack extends LocalTrack<Track.Kind.Audio> {
const processorOptions = {
kind: this.kind,
track: this._mediaStreamTrack,
audioContext: this.audioContext,
// RN won't have or use AudioContext
audioContext: this.audioContext as AudioContext,
};
this.log.debug(`setting up audio processor ${processor.name}`, this.logContext);

Expand Down

0 comments on commit 061105f

Please sign in to comment.