Skip to content

Commit cff35e8

Browse files
committed
Minor fixes
1 parent cedd5ce commit cff35e8

File tree

2 files changed

+25
-27
lines changed

2 files changed

+25
-27
lines changed

src/AudioDeviceModuleEvents.ts

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class AudioDeviceModuleEventEmitter {
4646
private didDisableEngineHandler: AudioEngineEventHandler | null = null;
4747
private willReleaseEngineHandler: AudioEngineEventNoParamsHandler | null = null;
4848

49-
constructor() {
49+
public setupListeners() {
5050
if (Platform.OS !== 'android' && WebRTCModule) {
5151
this.eventEmitter = new NativeEventEmitter(WebRTCModule);
5252

@@ -158,9 +158,10 @@ class AudioDeviceModuleEventEmitter {
158158
});
159159
}
160160
}
161+
161162
/**
162-
* Subscribe to speech activity events (started/ended)
163-
*/
163+
* Subscribe to speech activity events (started/ended)
164+
*/
164165
addSpeechActivityListener(listener: (data: SpeechActivityEventData) => void) {
165166
if (!this.eventEmitter) {
166167
throw new Error('AudioDeviceModuleEvents is only available on iOS/macOS');
@@ -170,8 +171,8 @@ class AudioDeviceModuleEventEmitter {
170171
}
171172

172173
/**
173-
* Subscribe to devices updated event (input/output devices changed)
174-
*/
174+
* Subscribe to devices updated event (input/output devices changed)
175+
*/
175176
addDevicesUpdatedListener(listener: () => void) {
176177
if (!this.eventEmitter) {
177178
throw new Error('AudioDeviceModuleEvents is only available on iOS/macOS');
@@ -181,49 +182,49 @@ class AudioDeviceModuleEventEmitter {
181182
}
182183

183184
/**
184-
* Set handler for engine created delegate - MUST return 0 for success or error code
185-
* This handler blocks the native thread until it returns
186-
*/
185+
* Set handler for engine created delegate - MUST return 0 for success or error code
186+
* This handler blocks the native thread until it returns, throw to cancel audio engine's operation
187+
*/
187188
setEngineCreatedHandler(handler: AudioEngineEventNoParamsHandler | null) {
188189
this.engineCreatedHandler = handler;
189190
}
190191

191192
/**
192-
* Set handler for will enable engine delegate - MUST return 0 for success or error code
193-
* This handler blocks the native thread until it returns
194-
*/
193+
* Set handler for will enable engine delegate - MUST return 0 for success or error code
194+
* This handler blocks the native thread until it returns, throw to cancel audio engine's operation
195+
*/
195196
setWillEnableEngineHandler(handler: AudioEngineEventHandler | null) {
196197
this.willEnableEngineHandler = handler;
197198
}
198199

199200
/**
200-
* Set handler for will start engine delegate - MUST return 0 for success or error code
201-
* This handler blocks the native thread until it returns
202-
*/
201+
* Set handler for will start engine delegate - MUST return 0 for success or error code
202+
* This handler blocks the native thread until it returns, throw to cancel audio engine's operation
203+
*/
203204
setWillStartEngineHandler(handler: AudioEngineEventHandler | null) {
204205
this.willStartEngineHandler = handler;
205206
}
206207

207208
/**
208-
* Set handler for did stop engine delegate - MUST return 0 for success or error code
209-
* This handler blocks the native thread until it returns
210-
*/
209+
* Set handler for did stop engine delegate - MUST return 0 for success or error code
210+
* This handler blocks the native thread until it returns, throw to cancel audio engine's operation
211+
*/
211212
setDidStopEngineHandler(handler: AudioEngineEventHandler | null) {
212213
this.didStopEngineHandler = handler;
213214
}
214215

215216
/**
216-
* Set handler for did disable engine delegate - MUST return 0 for success or error code
217-
* This handler blocks the native thread until it returns
218-
*/
217+
* Set handler for did disable engine delegate - MUST return 0 for success or error code
218+
* This handler blocks the native thread until it returns, throw to cancel audio engine's operation
219+
*/
219220
setDidDisableEngineHandler(handler: AudioEngineEventHandler | null) {
220221
this.didDisableEngineHandler = handler;
221222
}
222223

223224
/**
224-
* Set handler for will release engine delegate - MUST return 0 for success or error code
225-
* This handler blocks the native thread until it returns
226-
*/
225+
* Set handler for will release engine delegate
226+
* This handler blocks the native thread until it returns, throw to cancel audio engine's operation
227+
*/
227228
setWillReleaseEngineHandler(handler: AudioEngineEventNoParamsHandler | null) {
228229
this.willReleaseEngineHandler = handler;
229230
}

src/index.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,5 @@ function registerGlobals(): void {
106106
global.RTCErrorEvent = RTCErrorEvent;
107107

108108
// Ensure audioDeviceModuleEvents is initialized and event listeners are registered
109-
// This forces the constructor to run and set up native event listeners.
110-
// We use void operator to explicitly indicate we're intentionally evaluating the expression
111-
// without using its value, which prevents tree-shaking from removing this reference.
112-
void audioDeviceModuleEvents;
109+
audioDeviceModuleEvents.setupListeners();
113110
}

0 commit comments

Comments
 (0)