VR. Setting Oculus Rift audio driver on Unity

Hi.
We are sending our game to the Oculus team and they are reporting that the game “must target the audio device selected in the “Audio Output in VR” setting in the Oculus app.”

We have pasted the code snippet that can be found on their website, but nothing seems to work. I also changed the deprecated “getLowLevelSystem” for the “getCoreSystem”, but nothing seems to work.

     FMOD.RESULT Initialize()
  {

#if OCULUS && !UNITY_ANDROID
FMOD.System sys;
FMODUnity.RuntimeManager.StudioSystem.getCoreSystem(out sys);

     int driverCount = 0;
      sys.getNumDrivers(out driverCount);

       string riftId = OVRManager.audioOutId;

       int driver = 0;
       while (driver < driverCount)
       {
           System.Guid guid;
           int rate, channels;
           FMOD.SPEAKERMODE mode;
           sys.getDriverInfo(driver, out guid, out rate, out mode, out channels);

           if (guid.ToString() == riftId)
           {
               break;
           }

           ++driver;
       }
       if (driver < driverCount)
       {
           sys.setDriver(driver);
       }

#endif

Maybe we are putting the code on a wrong place?

We recently made handling Oculus driver selection a lot easier and provide an example specifically for implement that behavior. Check out our Unity docs for details.

In order to prevent problems, we would like to avoid a major version upgrade. We are currently using the version 2.0.10 and the game is already published in some stores.
The last build I sended to them was this one. But they still report that there’s no audio through the target device.

    public void PreInitialize(FMOD.Studio.System studioSystem)
    {
        string riftId = OVRManager.audioOutId;
        FMOD.System coreSystem;
        FMOD.RESULT result = studioSystem.getCoreSystem(out coreSystem);

        int driverCount = 0;
        result = coreSystem.getNumDrivers(out driverCount);
        for (int i = 0; i < driverCount; i++)
        {
            int rate;
            int channels;
            System.Guid guid;
            FMOD.SPEAKERMODE mode;

            result = coreSystem.getDriverInfo(i, out guid, out rate, out mode, out channels);

            if (guid.ToString() == riftId)
            {
                result = coreSystem.setDriver(i);

                break;
            }
        }
    }

FMOD.RESULT Initialize()
{
#if OCULUS && !UNITY_ANDROID
PreInitialize(studioSystem);
#endif

Understood, it looks like you are calling PreInitialize at the top of RuntimeManager.Initialize, at this point the Studio System won’t have been created yet. Try moving your call to PreInitialize down to just before the call to studioSystem.initialize, line 244 in the version I have here.