- Home /
My App will carsh when I use Microphone and OnAudioFilterRead under IL2CPP
void Update ()
{
if (Input.GetKeyDown (KeyCode.Mouse0)) {
mySources = this.gameObject.GetComponent<AudioSource> ();
selectedDevice = Microphone.devices [0].ToString ();
mySources.clip = Microphone.Start (null, true, 10, 16000);
while (!(Microphone.GetPosition(selectedDevice) > 0)) {
}
mySources.Play ();
}
if (Input.GetKeyUp (KeyCode.Mouse0)) {
AudioClip clip = mySources.clip;
mySources.Stop ();
Microphone.End (selectedDevice);
}
}
void OnAudioFilterRead (float[] samples, int channel)
{
}
Hi All.
My App will crash (iOS) with this code when I select IL2CPP but when i Select Mono2x It is OK,How to solve the problem?Thanks.
Can you provide some more information about the crash? Specifically, do you get a call stack for this crash?
I use ipad's microphone to record audio and use OnAudioFilterRead to get audio date then send them to a robot by network. Always ,use void OnAudioFilterRead (float[] samples, int channel) and $$anonymous$$icrophone.Start ,it will crash ,can you try it? you just build an app for ios with the follow code:(if you tap de screen ,it will crash).thank you very mach!
using UnityEngine;
using System.Collections;
using System;
using System.IO;
using UnityEngine.Audio;
public class Test001 : $$anonymous$$onoBehaviour
{
string selectedDevice;
public AudioSource mySources;
AudioClip clip;
bool key = false;
void Start ()
{
}
void Update ()
{
if (Input.Get$$anonymous$$eyDown ($$anonymous$$eyCode.$$anonymous$$ouse0)) {
mySources = this.gameObject.GetComponent<AudioSource> ();
selectedDevice = $$anonymous$$icrophone.devices [0].ToString ();
mySources.clip = $$anonymous$$icrophone.Start (null, true, 10, 16000);
while (!($$anonymous$$icrophone.GetPosition(selectedDevice) > 0)) {
}
key = true;
mySources.Play ();
}
if (Input.Get$$anonymous$$eyUp ($$anonymous$$eyCode.$$anonymous$$ouse0)) {
AudioClip clip = mySources.clip;
key = false;
mySources.Stop ();
$$anonymous$$icrophone.End (selectedDevice);
}
}
}
I'm not seeing a crash with this code. You may want to try the latest version of Unity then (if you have not already). Or, can you provide details about the crash you see. $$anonymous$$aybe I'm doing something wrong when I try to reproduce this.
Thanks for providing the call stack. Actually, we are correcting one bug now that looks similar. We end up with a crash in the GC code on an Audio callback thread, so we may have already corrected this issue. Check this again with 5.3.0p1 (when is it out, next week), as I believe the fix will land in that release. You can find the Unity patch releases here: http://unity3d.com/unity/qa/patch-releases
Hello,When Unity 5.3.0p1 releases?I am waiting for it to fix the bug.
The 5.3.1p1 version, which might have this fix, was just released. You can find it here: