internal void UpdateWorkerMainState() { switch (State) { case WorkerState.Idle: break; case WorkerState.Running: ThreadCallbackUpdate(); break; case WorkerState.WaitingClose: ThreadCallbackClosed(); HyperThreadDispatcher.DetachWorker(this); break; case WorkerState.CloseError: ThreadCallbackError(); HyperThreadDispatcher.DetachWorker(this); break; default: throw new ArgumentOutOfRangeException(); } }
internal static void ImportAudioThreaded(string path) { AudioDecodeWorker worker = new AudioDecodeWorker(path, Path.Combine(Application.persistentDataPath, "TempConversion"), (sampleArray, channels, sampleRate) => { AudioClip clip = AudioClip.Create(Path.GetFileNameWithoutExtension(path), sampleArray.Length / channels, channels, sampleRate, false); clip.SetData(sampleArray, 0); _source.clip = clip; _samples = sampleArray; }); HyperThreadDispatcher.StartWorker(worker); }