Search Unity

SoundChannel.cpp

Discussion in 'Audio & Video' started by thehobliks, Dec 5, 2015.

  1. thehobliks

    thehobliks

    Joined:
    Jul 31, 2014
    Posts:
    1
    Does anyone know anything about this error?

    C:/buildslave/unity/build/Runtime/Audio/sound/SoundChannel.cpp(374) : Error executing result (An invalid seek position was passed to this function. )
    UnityEngine.AudioSource:play()

    I've seen only a few cases of it online and unable to find any information regarding the error in order to fix it. Any help would be greatly appreciated.
     
  2. Smackware_

    Smackware_

    Joined:
    Apr 12, 2015
    Posts:
    1
    This is old, but we encountered this error as well.

    In our case, some code set audioSource.time, but did not verify that the time is logical when comparing to the played clip duration.

    Using audioSource.time = Mathf.Min(wantedTime, audioClip.length - 0.01f) did the trick (Not sure that const at the end is actually required.)
     
    taolazu and Rioneer like this.
  3. Unicorn-slayer

    Unicorn-slayer

    Joined:
    Jan 1, 2016
    Posts:
    1
    In my case, I was reusing the AudioSource for different SFX.
    Putting:

    source.time = 0f

    before source.Play (), did the trick to me
     
    chin13577, ROBYER1, hworld and 3 others like this.
  4. Cathy47

    Cathy47

    Joined:
    May 10, 2019
    Posts:
    1
    yeah this is the right way! and the const -0.01f is not necessary
     
  5. igor_usanin

    igor_usanin

    Joined:
    Apr 12, 2020
    Posts:
    1
    In my case an error occurred

    Code (CSharp):
    1. public static void SetClip(string name, bool useRandom)
    2. {
    3.       var clip = _music.Where(m => m.name == name).FirstOrDefault();
    4.       if (useRandom)
    5.       {
    6.            _audio.time = Random.Range(0, clip.length);
    7.       }
    8.       else
    9.       {
    10.            _audio.time = 0;
    11.       }
    12.  
    13.       _audio.clip = clip;
    14.       _audio.Play();
    15. }
    Solved the problem through audio stop at the beginning of the method

    Code (CSharp):
    1. _audio.Stop();  
    The error was that the time of the current clip was changing, and not the next one)