# Agora - Unity - Voice Transmission Works for ~5 seconds

**URL:** <https://forum.magicleap.cloud/t/agora-unity-voice-transmission-works-for-5-seconds/1119>\
**Category:** Unity Development\
**Tags:** development, unity\
**Created:** [October 19, 2022, 8:20pm UTC](https://forum.magicleap.cloud/t/agora-unity-voice-transmission-works-for-5-seconds/1119 "2022-10-19T20:20:55Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![drew](https://avatars.discourse-cdn.com/v4/letter/d/b19c9b/32.png) [@drew](https://forum.magicleap.cloud/u/drew)\
**Post date:** [October 19, 2022, 8:20pm UTC](https://forum.magicleap.cloud/t/agora-unity-voice-transmission-works-for-5-seconds/1119/1 "2022-10-19T20:20:55Z")

</div>

**Unity Editor version** : 2022.2.0b9.3080  
**ML2 OS version** : B3E.220818.12-R.046-R.417  
**MLSDK version** : 1.0.0  
**Host OS** : WINDOWS

Agora SDK 3.7.1

No errors - The service runs correctly for ~5 seconds (green microphone icon visible in the left top corner of FOV).  
During this time, audio is successfully transmitted to other users. After approximately 5 seconds, the microphone disappears and audio data is no longer transmitted from the ML2, but audio is still received from other users.

---

<div class="post-metadata">

**Author:** ![sengelman](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/sengelman/32/11_2.png) [@sengelman](https://forum.magicleap.cloud/u/sengelman)\
**Post date:** [October 20, 2022, 3:28pm UTC](https://forum.magicleap.cloud/t/agora-unity-voice-transmission-works-for-5-seconds/1119/3 "2022-10-20T15:28:28Z")

</div>

@rick any ideas on what might be happening here?

---

<div class="post-metadata">

**Author:** ![rick](https://avatars.discourse-cdn.com/v4/letter/r/9f8e36/32.png) [@rick](https://forum.magicleap.cloud/u/rick)\
**Post date:** [October 20, 2022, 4:27pm UTC](https://forum.magicleap.cloud/t/agora-unity-voice-transmission-works-for-5-seconds/1119/4 "2022-10-20T16:27:42Z")

</div>

@drew do you see any thing suspicious from the adb log? If you grep for Unity, is there any error happening in the Unity application layer, like an exception?

---

<div class="post-metadata">

**Author:** ![drew](https://avatars.discourse-cdn.com/v4/letter/d/b19c9b/32.png) [@drew](https://forum.magicleap.cloud/u/drew)\
**Post date:** [October 20, 2022, 6:09pm UTC](https://forum.magicleap.cloud/t/agora-unity-voice-transmission-works-for-5-seconds/1119/5 "2022-10-20T18:09:12Z")

</div>

I'll check again today, I didn't notice anything in logcat for the system/Unity

---

<div class="post-metadata">

**Author:** ![drew](https://avatars.discourse-cdn.com/v4/letter/d/b19c9b/32.png) [@drew](https://forum.magicleap.cloud/u/drew)\
**Post date:** [October 20, 2022, 9:35pm UTC](https://forum.magicleap.cloud/t/agora-unity-voice-transmission-works-for-5-seconds/1119/6 "2022-10-20T21:35:22Z")

</div>

Ah - I do have some messages here - they snuck by me.  
Nothing in unity, but this looks interesting:

10-20 21:30:12.941 22539 22789 I libOpenSLES: Emulating old channel mask behavior (ignoring positional mask 0x3, using default mask 0x3 based on channel count of 2)  
10-20 21:30:12.941 22539 22789 E AudioTrack: AudioTrack Constructor 2 not supported  
10-20 21:30:12.941 3439 22056 E audiorenderservice: audio\_render.cc:225: Track listing (135095420578592,10100,22539) not found  
10-20 21:30:12.942 3439 22056 E audiorenderservice: audio\_render\_service.cc:332: MLAudioDestroySound: [FAILED (-1643053055) (MLAudioResult\_HandleNotFound)]  
10-20 21:30:12.942 22539 22789 E AudioTrack: Failed to destroy audio output: -1643053055  
10-20 21:30:12.942 22539 22789 E libOpenSLES: AudioTrack::initCheck status 1519250568  
10-20 21:30:12.942 22539 22789 W libOpenSLES: Leaving Object::Realize (SL\_RESULT\_CONTENT\_UNSUPPORTED)  
10-20 21:30:12.942 22539 22789 W libOpenSLES: Conversion from OpenSL ES positional channel mask 0x4 to Android mask 0 loses channels  
10-20 21:30:12.942 22539 22789 I libOpenSLES: Emulating old channel mask behavior (ignoring positional mask 0x4, using default mask 0x10 based on channel count of 1)  
10-20 21:30:12.942 22539 22789 I AudioRecord: Format:  
10-20 21:30:12.942 22539 22789 I AudioRecord: samples\_per\_second=48000  
10-20 21:30:12.942 22539 22789 I AudioRecord: channel\_count=1  
10-20 21:30:12.942 22539 22789 I AudioRecord: bits\_per\_sample=16  
10-20 21:30:12.942 22539 22789 I AudioRecord: valid\_bits\_per\_sample=16  
10-20 21:30:12.942 22539 22789 I AudioRecord: sample\_format=0  
10-20 21:30:12.942 22539 22789 I AudioRecord: Buffer Size: 1920 bytes (960 frames)  
10-20 21:30:12.943 3423 3423 I audiocaptureservice: audio\_capture.cc:198: New stream listing (30,10100,22539)  
10-20 21:30:12.944 3423 4960 I audiocaptureservice: mea\_device.cc:118: MEA: attempting to grab mutex for open  
10-20 21:30:12.944 3423 4960 I audiocaptureservice: mea\_device.cc:123: MEA: attempting to open mea device 2  
10-20 21:30:12.944 4379 4412 I AudioProxyService: setCaptureAudioIndication: isRecording = true  
10-20 21:30:12.945 3423 4960 I audiocaptureservice: mea\_device.cc:133: MEA: successfully opened mea device 2 with pointer 0x78d6ba891c10  
10-20 21:30:12.965 4403 4896 W MagicleapGodotApp: Loading resource: res://Indicators/Indicators.tscn  
10-20 21:30:12.966 4403 4896 W MagicleapGodotApp: Loading resource: res://Indicators/textures/circle\_white\_128px.png  
10-20 21:30:12.967 4403 4896 W MagicleapGodotApp: Loading resource: res://Indicators/animation/indicator\_dual.anim  
10-20 21:30:12.968 4403 4896 W MagicleapGodotApp: Loading resource: res://Indicators/animation/indicator\_passive.anim  
10-20 21:30:12.969 4403 4896 W MagicleapGodotApp: Loading resource: res://Indicators/animation/indicator\_triple.anim  
10-20 21:30:12.970 4403 4896 W MagicleapGodotApp: Loading resource: res://Indicators/animation/indicator\_single.anim  
10-20 21:30:12.970 4403 4896 W MagicleapGodotApp: Loading resource: res://Indicators/Indicators.gd

10-20 21:30:13.707 4379 4412 I AudioProxyService: setCaptureAudioIndication: isRecording = false  
10-20 21:30:13.708 3423 4960 I audiocaptureservice: mea\_device.cc:150: MEA: attempting to close mea device 2 with pointer 0x78d6ba891c10  
10-20 21:30:13.708 3423 4960 I audiocaptureservice: mea\_device.cc:152: MEA: returned from mea device close (success unknown)  
10-20 21:30:13.711 22539 22789 E libOpenSLES: Object::Destroy(0x7add55408600) for OutputMix ignored; 1 players attached  
10-20 21:30:13.711 22539 22789 E libOpenSLES: Object::Destroy(0x7add55408600) not allowed  
10-20 21:30:13.711 22539 22789 E libOpenSLES: Object::Destroy(0x7add5a5fd000) for engine ignored; 2 total active objects  
10-20 21:30:13.711 22539 22789 E libOpenSLES: Object::Destroy(0x7add5a5fd000) for engine ignored; active object ID 2 at 0x7add55408600  
10-20 21:30:13.711 22539 22789 E libOpenSLES: Object::Destroy(0x7add5a5fd000) for engine ignored; active object ID 3 at 0x7add3eb34c00

10-20 21:30:13.720 22539 22889 I AudioTrack: Format:  
10-20 21:30:13.720 22539 22889 I AudioTrack: samples\_per\_second=48000  
10-20 21:30:13.720 22539 22889 I AudioTrack: channel\_count=2  
10-20 21:30:13.720 22539 22889 I AudioTrack: bits\_per\_sample=16  
10-20 21:30:13.720 22539 22889 I AudioTrack: valid\_bits\_per\_sample=16  
10-20 21:30:13.720 22539 22889 I AudioTrack: sample\_format=0  
10-20 21:30:13.720 22539 22889 I AudioTrack: channel\_format=0  
10-20 21:30:13.721 22539 22889 W AudioTrack: Use of stream types is deprecated for operations other than volume control  
10-20 21:30:13.721 22539 22889 W AudioTrack: See the documentation of AudioTrack() for what to use instead with android.media.AudioAttributes to qualify your playback use case  
10-20 21:30:13.722 22539 22539 V MediaRouter: Selecting route: RouteInfo{ name=Phone, description=null, status=null, category=RouteCategory{ name=System types=ROUTE\_TYPE\_LIVE\_AUDIO ROUTE\_TYPE\_LIVE\_VIDEO groupable=false }, supportedTypes=ROUTE\_TYPE\_LIVE\_AUDIO ROUTE\_TYPE\_LIVE\_VIDEO , presentationDisplay=null }  
10-20 21:30:13.725 22539 22889 E AudioRecord-JNI: Error creating AudioRecord instance: initialization check failed with status -1.  
10-20 21:30:13.725 3423 3423 E audiocaptureservice: audio\_capture.cc:127: Stream listing (1065353216,10100,22539) not found  
10-20 21:30:13.725 3423 3423 E audiocaptureservice: audio\_capture\_service.cc:440: MLAudioStopInput: [FAILED (-1643053055) (MLAudioResult\_HandleNotFound)]  
10-20 21:30:13.725 3423 3423 E audiocaptureservice: audio\_capture.cc:127: Stream listing (1065353216,10100,22539) not found  
10-20 21:30:13.725 3423 3423 E audiocaptureservice: audio\_capture\_service.cc:399: MLAudioDestroyInput: [FAILED (-1643053055) (MLAudioResult\_HandleNotFound)]  
10-20 21:30:13.725 22539 22889 E AudioRecord: Failed to destroy audio input: -1643053055  
10-20 21:30:13.725 22539 22889 E android.media.AudioRecord: Error code -20 when initializing native AudioRecord object.

---

<div class="post-metadata">

**Author:** ![rick](https://avatars.discourse-cdn.com/v4/letter/r/9f8e36/32.png) [@rick](https://forum.magicleap.cloud/u/rick)\
**Post date:** [October 22, 2022, 12:04am UTC](https://forum.magicleap.cloud/t/agora-unity-voice-transmission-works-for-5-seconds/1119/7 "2022-10-22T00:04:18Z")

</div>

Hi Drew, I got no clue from these messages. Let's go through how you integrated Agora. Did you use the AgoraController prefab that is included in the SDK? Did you try out the demo and see the same audio issue happening there?

---

<div class="post-metadata">

**Author:** ![rick](https://avatars.discourse-cdn.com/v4/letter/r/9f8e36/32.png) [@rick](https://forum.magicleap.cloud/u/rick)\
**Post date:** [October 24, 2022, 10:18pm UTC](https://forum.magicleap.cloud/t/agora-unity-voice-transmission-works-for-5-seconds/1119/8 "2022-10-24T22:18:19Z")

</div>

@drew , can you confirm if you tested with the demo we included. Also, the base SDK for the plugin is actually 3.7.0.3. When you said 3.7.1, did you mean you download the Unity SDK and use it directly? If so, that could be the gap here. We have a dedicated SDK bundle built for the ML2. You may find it [here](https://github.com/AgoraIO-Extensions/Agora_MagicLeap2_Plugin).

---

<div class="post-metadata">

**Author:** ![drew](https://avatars.discourse-cdn.com/v4/letter/d/b19c9b/32.png) [@drew](https://forum.magicleap.cloud/u/drew)\
**Post date:** [October 26, 2022, 8:49pm UTC](https://forum.magicleap.cloud/t/agora-unity-voice-transmission-works-for-5-seconds/1119/9 "2022-10-26T20:49:28Z")

</div>

The custom audio source scripts work just fine, thanks.  
We have been internally doing the same thing (using a custom audio source) until recently when I was told this was no longer necessary and we would no longer need to do so.  
Again, this works for us, but I do have a question:  
The quality is fine, but the transmission latency is more noticeable than on other devices (like Oculus Quest 2). Should we expect relative parity between the custom audio source implementation vs what I'm assuming is a native implementation?

Edit: Quick test gives us ~1.5 seconds on Quest 2 -\> Desktop vs ~5 seconds ML2-\>Desktop

---

<div class="post-metadata">

**Author:** ![rick](https://avatars.discourse-cdn.com/v4/letter/r/9f8e36/32.png) [@rick](https://forum.magicleap.cloud/u/rick)\
**Post date:** [October 27, 2022, 5:09pm UTC](https://forum.magicleap.cloud/t/agora-unity-voice-transmission-works-for-5-seconds/1119/10 "2022-10-27T17:09:08Z")

</div>

Hi Drew, we will look into the latency issue and see if there is optimization that can be done. Also, we will check if the audio can be done without custom audio source now. Do you have a reference to that knowledge?
