Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Error executing instance->m_Sound->unlock

Discussion in 'Audio & Video' started by fredsom, Jul 9, 2015.

  1. fredsom

    fredsom

    Joined:
    Feb 15, 2015
    Posts:
    19
    Since we updated Unity to 5.1.1f1, we encounter this error that never showed up before:

    It leads to this part of the code:
    Code (CSharp):
    1.  
    2.     int newOffset = Microphone.GetPosition(selectedDevice);
    3.     int nbSamplesToRetrieve;
    4.     if (newOffset < sampleOffset)
    5.         nbSamplesToRetrieve = newOffset + GetComponent<AudioSource>().clip.samples - sampleOffset;
    6.     else
    7.         nbSamplesToRetrieve = newOffset - sampleOffset;
    8.     float[] samples = new float[nbSamplesToRetrieve];
    9.     float sampleRate = GetComponent<AudioSource>().clip.frequency;
    10.  
    11.     GetComponent<AudioSource>().clip.GetData(samples, sampleOffset);
    12.  
    It still seems to work fine, but the cosole is spammed with this error and it becomes hard to debug on mobile platforms.
     
  2. TerabyteTim

    TerabyteTim

    Joined:
    Oct 20, 2011
    Posts:
    115
    I'm getting this error as well, did you ever find a solution to this?
     
  3. IvanAlvarez

    IvanAlvarez

    Joined:
    Apr 30, 2013
    Posts:
    9
    Any solutions?
     
  4. doggan

    doggan

    Joined:
    Aug 12, 2012
    Posts:
    23
    We're using 5.1.4f and seeing this issue a lot on user devices (iOS).

    Anyone know if it is still occurring in newer versions of Unity?
     
  5. 0Alic

    0Alic

    Joined:
    Jun 6, 2016
    Posts:
    1
    I am having the same problem.
    I am kind of "solve it" declaring the buffer float[] array
    Code (CSharp):
    1. float[] audioBuffer = new float[audioSource.clip.samples * audioSource.clip.channels];
    Assuming that I have just one channel, the dimension is frequency * seconds, the parameters that you use when you call Microphone.Start(). (For example 44100Hz * 10sec)

    If I put a bigger number I get a warning that that number is bigger than 441000. If I put a calculated length (like you) I get your same error.

    Now I am trying to work out to see if the program returns good results. But at least I can move on
     
    Last edited: Jun 28, 2016
  6. Sami_AlEsh

    Sami_AlEsh

    Joined:
    Sep 17, 2018
    Posts:
    5
    how to catch this exception ?
    i cant catch it in code !!!