public FMOD.RESULT getEvent(FmodEventAudioSource wantedSource) { if (wantedSource == null || wantedSource.getSource() == null) { Debug.LogError(getErrorPrefix() + "Invalid data was passed for FmodEventAudioSource"); return(FMOD.RESULT.ERR_EVENT_FAILED); } if (wantedSource.getSource() != m_event) { Debug.LogError(getErrorPrefix() + "FmodEventAudioSource tried to load event '" + wantedSource.getSource().getName() + "' from the bad pool."); return(FMOD.RESULT.ERR_EVENT_FAILED); } if (wantedSource.isRuntimeEventLoaded()) { return(FMOD.RESULT.OK); } if (m_availableEvents.Count > 0) { // below, we take back an event that was loaded and unused FMOD.Event oldestEvent = m_availableEvents[0]; m_availableEvents.RemoveAt(0); wantedSource.SetEvent(oldestEvent); if (m_activeSources.Contains(wantedSource)) { Debug.LogWarning(getErrorPrefix() + "FmodEventAudioSource '" + wantedSource.name + "' loaded an event but was already active. Are you sure this should happen ?"); } else { m_activeSources.Add(wantedSource); } } else { // here we have no event loaded, so we must load a new one. using (FmodEventSystemHandle handle = new FmodEventSystemHandle()) { FmodEventSystem system = handle.getEventSystem(); if (system != null && system.wasCleaned() == false) { FMOD.RESULT result = FMOD.RESULT.OK; result = system.loadEventFromFile(wantedSource); if (result == FMOD.RESULT.OK) { m_activeSources.Add(wantedSource); } return(result); } } } return(FMOD.RESULT.OK); }
public FMOD.RESULT getEvent(FmodEventAudioSource wantedSource) { if (wantedSource == null || wantedSource.getSource() == null) { Debug.LogError(getErrorPrefix() + "Invalid data was passed for FmodEventAudioSource"); return (FMOD.RESULT.ERR_EVENT_FAILED); } if (wantedSource.getSource() != m_event) { Debug.LogError(getErrorPrefix() + "FmodEventAudioSource tried to load event '" + wantedSource.getSource().getName() + "' from the bad pool."); return (FMOD.RESULT.ERR_EVENT_FAILED); } if (wantedSource.isRuntimeEventLoaded()) { return (FMOD.RESULT.OK); } if (m_availableEvents.Count > 0) { // below, we take back an event that was loaded and unused FMOD.Event oldestEvent = m_availableEvents[0]; m_availableEvents.RemoveAt(0); wantedSource.SetEvent(oldestEvent); if (m_activeSources.Contains(wantedSource)) { Debug.LogWarning (getErrorPrefix() + "FmodEventAudioSource '" + wantedSource.name + "' loaded an event but was already active. Are you sure this should happen ?"); } else { m_activeSources.Add(wantedSource); } } else { // here we have no event loaded, so we must load a new one. using (FmodEventSystemHandle handle = new FmodEventSystemHandle()) { FmodEventSystem system = handle.getEventSystem(); if (system != null && system.wasCleaned() == false) { FMOD.RESULT result = FMOD.RESULT.OK; result = system.loadEventFromFile(wantedSource); if (result == FMOD.RESULT.OK) { m_activeSources.Add(wantedSource); } return (result); } } } return (FMOD.RESULT.OK); }
public FMOD.RESULT loadEventFromFile(FmodEventAudioSource src) { FmodEvent evt = src.getSource(); FmodEventAsset asset = evt.getAsset(); FMOD.RESULT result = FMOD.RESULT.OK; FMOD.EVENT_LOADINFO loadInfo = new FMOD.EVENT_LOADINFO(); FMOD.EventProject project = null; FMOD.Event fmodEvent = null; _loadFile(asset.getMediaPath(), asset.getName(), ref loadInfo, ref project); _loadEventGroup(evt); result = _loadEvent(evt, ref fmodEvent); ERRCHECK(result); if (result == FMOD.RESULT.OK) { src.SetEvent(fmodEvent); } return(result); }
public FMOD.RESULT loadEventFromFile(FmodEventAudioSource src) { FmodEvent evt = src.getSource(); FmodEventAsset asset = evt.getAsset(); FMOD.RESULT result = FMOD.RESULT.OK; FMOD.EVENT_LOADINFO loadInfo = new FMOD.EVENT_LOADINFO(); FMOD.EventProject project = null; FMOD.Event fmodEvent = null; _loadFile(asset.getMediaPath(), asset.getName(), ref loadInfo, ref project); _loadEventGroup(evt); result = _loadEvent(evt, ref fmodEvent); ERRCHECK(result); if (result == FMOD.RESULT.OK) { src.SetEvent(fmodEvent); } return (result); }