// Token: 0x060001E0 RID: 480 RVA: 0x0000A084 File Offset: 0x00008284 public bool Initlize() { global::Debug.Log(string.Format("AudioManager4CRI.Initlize start", new object[0])); this.m_muteSound = false; if (AudioManager4CRI.m_criProviderType == null) { global::Debug.LogError("AudioManager4CRI.Initialize() m_CriProviderType is null."); return(false); } this.m_CRIProvider = (Activator.CreateInstance(AudioManager4CRI.m_criProviderType) as ICRIProvider); if (this.m_CRIProvider == null) { global::Debug.LogError("Failed to create ICRIProvider by m_criProviderType."); return(false); } if (!AudioManager4CRI.LoadAllFilesPaths()) { global::Debug.LogError("AudioManager4CRI.Initialize Failed to LoadAllFilesPaths()."); return(false); } bool result; try { if (this.m_CRIProvider.GetCRIManagerObject() == null) { global::Debug.LogError("Failed to initialize AduioManager4Cri, Cri Ware created failed"); result = false; } else { this.CreateCRI(); this.CreatePlayerVoiceSource(); List <string> resourceFiles = this.GetResourceFiles(".acf"); if (resourceFiles.Count == 0) { global::Debug.LogError("Failed to initialize AduioManager4Cri, acf file not found!"); result = false; } else if (resourceFiles.Count != 1) { global::Debug.LogError("Failed to initialize AduioManager4Cri, found more than one .acf files!"); result = false; } else { this.m_criDesc.m_acfFullPath = resourceFiles[0]; this.m_CRIProvider.CriRegisterAcf(this.m_criDesc.m_acfFullPath); result = true; } } } catch (Exception ex) { global::Debug.LogError("AudioManager4CRI.Start() failed, error: " + ex.Message); result = true; } return(result); }
protected IAudioManager CreateAudioManager() { if (this.m_gameClientSetting.AudioSetting.EnableCRI) { return(AudioManager4CRI.CreateAudioManager()); } return(AudioManager4Unity.CreateAudioManager()); }
// Token: 0x060001E3 RID: 483 RVA: 0x0000A28C File Offset: 0x0000848C private static bool LoadAllFilesPaths() { string assetPath = Path.Combine(GameManager.Instance.GameClientSetting.AudioSetting.CRIAudioManagerAsset, "AllFilesPath.txt"); AudioManager4CRI.m_clientCriAssetFileInfos = AudioManager4CRI.LoadFileInfos(Util.GetFileStreamingAssetsPath4WWW(assetPath)); if (AudioManager4CRI.m_clientCriAssetFileInfos == null) { global::Debug.LogError("AudioManager4CRI.LoadFileInfos Error: m_criAssetFileInfos == null "); return(false); } return(true); }
// Token: 0x060001E5 RID: 485 RVA: 0x0000A3B8 File Offset: 0x000085B8 public static List <AudioManager4CRI.FileInfo> LoadFileInfos(string filepath) { return(AudioManager4CRI.ParseFileInfosText(AudioManager4CRI.LoadTextFile(filepath))); }
// Token: 0x060001D2 RID: 466 RVA: 0x00009AC0 File Offset: 0x00007CC0 public static IEnumerator DownloadAudioFiles(Action <bool> onEnd, Action <long, long> onUpdate = null, Action <long> onEndAfterGotDownloadLength = null, MonoBehaviour coroutineOwner = null) { if (GameManager.Instance == null || GameManager.Instance.GameClientSetting == null) { yield break; } if (!GameManager.Instance.GameClientSetting.AudioSetting.EnableDownload) { yield break; } if (!AudioManager4CRI.LoadAllFilesPaths()) { global::Debug.LogError("AudioManager4CRI.DownloadAudioFiles Failed to LoadAllFilesPaths()."); yield break; } bool isSuccess = false; string serverFileListMd5 = string.Empty; yield return(Util.DownloadHttpFile(string.Format("{0}/{1}", AudioManager4CRI.DownloadUrlRoot, "AllFilesPath.txt.md5"), delegate(bool ret, WWW www) { isSuccess = ret; if (ret) { serverFileListMd5 = www.text; } }, null)); if (!isSuccess) { global::Debug.LogError("AudioManager4CRI.DownloadAudioFiles download filelist's md5 Failed ."); if (onEnd != null) { onEnd(false); } yield break; } string localFileListMd5 = AudioManager4CRI.LoadTextFile(string.Format("{0}/{1}", AudioManager4CRI.CacheFolderPath, "ServerAllFilesPath.txt.md5")); if (string.IsNullOrEmpty(localFileListMd5) || localFileListMd5 != serverFileListMd5) { yield return(Util.DownloadHttpFile(string.Format("{0}/{1}", AudioManager4CRI.DownloadUrlRoot, "AllFilesPath.txt"), delegate(bool ret, WWW www) { isSuccess = ret; if (ret) { try { if (!Directory.Exists(AudioManager4CRI.CacheFolderPath)) { Directory.CreateDirectory(AudioManager4CRI.CacheFolderPath); } File.WriteAllText(string.Format("{0}/{1}", AudioManager4CRI.CacheFolderPath, "ServerAllFilesPath.txt"), www.text); File.WriteAllText(string.Format("{0}/{1}", AudioManager4CRI.CacheFolderPath, "ServerAllFilesPath.txt.md5"), serverFileListMd5); } catch (Exception ex) { global::Debug.LogError(string.Format("AudioManager4CRI.DownloadAudioFiles exception: {0}", ex.Message)); isSuccess = false; } } }, null)); if (!isSuccess) { global::Debug.LogError("AudioManager4CRI.DownloadAudioFiles download filelist Failed ."); if (onEnd != null) { onEnd(false); } yield break; } } AudioManager4CRI.m_serverCriAssetFileInfos = AudioManager4CRI.LoadFileInfos(string.Format("{0}/{1}", AudioManager4CRI.CacheFolderPath, "ServerAllFilesPath.txt")); AudioManager4CRI.m_cacheCriAssetFileInfos = AudioManager4CRI.LoadFileInfos(string.Format("{0}/{1}", AudioManager4CRI.CacheFolderPath, "AllFilesPath.txt")); List <AudioManager4CRI.FileInfo> differentFileInfos = AudioManager4CRI.DifferentiateFileInfos(AudioManager4CRI.m_serverCriAssetFileInfos, AudioManager4CRI.m_clientCriAssetFileInfos, AudioManager4CRI.m_cacheCriAssetFileInfos); long totalDownloadLength = AudioManager4CRI.GetTotalFileLengh(differentFileInfos); if (onEndAfterGotDownloadLength != null) { onEndAfterGotDownloadLength(totalDownloadLength); yield break; } long downloadedLength = 0L; if (coroutineOwner == null || coroutineOwner.gameObject == null || !coroutineOwner.gameObject.activeInHierarchy) { using (List <AudioManager4CRI.FileInfo> .Enumerator enumerator = differentFileInfos.GetEnumerator()) { while (enumerator.MoveNext()) { AudioManager4CRI.FileInfo i = enumerator.Current; yield return(AudioManager4CRI.DownloadAudioFileToCache(i, delegate(bool ret) { if (!ret) { global::Debug.LogError(string.Format("AudioManager4CRI.DownloadAudioFiles download audio file {0} Failed .", i.m_path)); isSuccess = false; } else { downloadedLength += i.m_length; } if (!AudioManager4CRI.SaveFileInfos(Path.Combine(AudioManager4CRI.CacheFolderPath, "AllFilesPath.txt"), AudioManager4CRI.m_cacheCriAssetFileInfos)) { global::Debug.LogError("AudioManager4CRI.DownloadAudioFiles save cache filelist Failed ."); isSuccess = false; } }, delegate(WWW www) { if (onUpdate != null) { onUpdate(downloadedLength + (long)www.bytesDownloaded, totalDownloadLength); } })); } } } else { int downloadCoroutinCount = 0; HashSet <WWW> runningWWW = new HashSet <WWW>(); using (List <AudioManager4CRI.FileInfo> .Enumerator enumerator2 = differentFileInfos.GetEnumerator()) { while (enumerator2.MoveNext()) { AudioManager4CRI.FileInfo i = enumerator2.Current; yield return(new WaitUntil(() => downloadCoroutinCount < 4)); downloadCoroutinCount++; coroutineOwner.StartCoroutine(AudioManager4CRI.DownloadAudioFileToCache(i, delegate(bool ret) { if (!ret) { global::Debug.LogError(string.Format("AudioManager4CRI.DownloadAudioFiles download audio file {0} Failed .", i.m_path)); isSuccess = false; } else { downloadedLength += i.m_length; } if (!AudioManager4CRI.SaveFileInfos(Path.Combine(AudioManager4CRI.CacheFolderPath, "AllFilesPath.txt"), AudioManager4CRI.m_cacheCriAssetFileInfos)) { global::Debug.LogError("AudioManager4CRI.DownloadAudioFiles save cache filelist Failed ."); isSuccess = false; } downloadCoroutinCount--; }, delegate(WWW www) { if (!runningWWW.Contains(www) && !www.isDone) { runningWWW.Add(www); } long num = 0L; foreach (WWW www2 in runningWWW) { num += (long)www2.bytesDownloaded; } if (onUpdate != null) { onUpdate(downloadedLength + num, totalDownloadLength); } if (runningWWW.Contains(www) && www.isDone) { runningWWW.Remove(www); } })); } } yield return(new WaitUntil(() => downloadCoroutinCount == 0)); } if (!isSuccess) { if (onEnd != null) { onEnd(false); } yield break; } if (onEnd != null) { onEnd(true); } yield break; }