From 29210ac2bec8201ff452a8287411926f1397fa66 Mon Sep 17 00:00:00 2001 From: davidliu Date: Fri, 21 Jun 2024 22:05:29 +0900 Subject: [PATCH] android: release audio device module after creating factory --- .../main/java/com/oney/WebRTCModule/WebRTCModule.java | 11 +++-------- examples/GumTestApp/package.json | 2 +- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java b/android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java index f32bac9c9..6c6ed9d38 100644 --- a/android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java +++ b/android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java @@ -102,6 +102,9 @@ public WebRTCModule(ReactApplicationContext reactContext) { .setVideoDecoderFactory(decoderFactory) .createPeerConnectionFactory(); + // PeerConnectionFactory now owns the adm native pointer, and we don't need it anymore. + adm.release(); + // Saving the encoder and decoder factories to get codec info later when needed. mVideoEncoderFactory = encoderFactory; mVideoDecoderFactory = decoderFactory; @@ -116,14 +119,6 @@ public String getName() { return "WebRTCModule"; } - @Override - public void onCatalystInstanceDestroy() { - if (mAudioDeviceModule != null) { - mAudioDeviceModule.release(); - } - super.onCatalystInstanceDestroy(); - } - private PeerConnection getPeerConnection(int id) { PeerConnectionObserver pco = mPeerConnectionObservers.get(id); return (pco == null) ? null : pco.getPeerConnection(); diff --git a/examples/GumTestApp/package.json b/examples/GumTestApp/package.json index 7bd8507e5..9dbcaade0 100644 --- a/examples/GumTestApp/package.json +++ b/examples/GumTestApp/package.json @@ -13,7 +13,7 @@ "dependencies": { "react": "18.2.0", "react-native": "0.71.4", - "react-native-webrtc": "*" + "@livekit/react-native-webrtc": "*" }, "devDependencies": { "@babel/core": "^7.20.0",