// TODO: Check for more effective way of clearing removed drivers and adding new ones /// <summary> /// Called if the number of recording drivers is not equal to the number of drivers we have reference to. /// Will completely clear and refill our dictionary of drivers. /// Plus, it will stop all recording sounds. /// </summary> void RefreshRecordingDrivers() { if (OnDriverRefresh != null) { OnDriverRefresh.Invoke(); } // Remove all our previous drivers as they're going to probably be in the wrong order or just not there anymore allRecordDrivers.Clear(); // Get number of drivers RESULT result = RESULT.OK; result = LowLevelSystem.getRecordNumDrivers(out NumberOfDrivers, out NumberOfConnectedDrivers); CheckResult(result, "FMOD.GetRecordNumDrivers"); // Add our new list of drivers for (int i = 0; i < NumberOfDrivers; i++) { RecordDriver tempDriver = new RecordDriver(); LowLevelSystem.getRecordDriverInfo(i, out tempDriver.name, Settings.Instance.DriverNameLength, out tempDriver.guid, out tempDriver.systemRate, out tempDriver.speakerMode, out tempDriver.speakerModeChannels, out tempDriver.state); tempDriver.id = i; allRecordDrivers.Add(tempDriver.id, tempDriver); } // If there are sounds recording, stop them. // (Assumption) FMOD will stop recording anyway as connections will be lost if (recordingSounds.Count > 0) { foreach (KeyValuePair <int, RecordingSound> entry in recordingSounds) { entry.Value.Stop(); } } }
/// <summary> /// Called when Extensions is initalised. Will not update removed or added drivers /// </summary> void GetRecordingInformation() { RESULT result = RESULT.OK; result = LowLevelSystem.getRecordNumDrivers(out NumberOfDrivers, out NumberOfConnectedDrivers); CheckResult(result, "FMOD.GetRecordNumDrivers"); if (NumberOfDrivers == 0) { UnityEngine.Debug.LogWarning("FMOD Extensions: No recording drivers found!"); return; } for (int i = 0; i < NumberOfDrivers; i++) { RecordDriver tempDriver = new RecordDriver(); LowLevelSystem.getRecordDriverInfo(i, out tempDriver.name, Settings.Instance.DriverNameLength, out tempDriver.guid, out tempDriver.systemRate, out tempDriver.speakerMode, out tempDriver.speakerModeChannels, out tempDriver.state); tempDriver.id = i; if (!allRecordDrivers.ContainsKey(i)) { allRecordDrivers.Add(i, tempDriver); } } }