private void InitializeAudioRenderer() { AudioRendererManager = new AudioRendererManager(); AudioDeviceSessionRegistry = new VirtualDeviceSessionRegistry(); IWritableEvent[] writableEvents = new IWritableEvent[RendererConstants.AudioRendererSessionCountMax]; for (int i = 0; i < writableEvents.Length; i++) { KEvent systemEvent = new KEvent(KernelContext); writableEvents[i] = new AudioKernelEvent(systemEvent); } HardwareDevice[] devices = new HardwareDevice[RendererConstants.AudioRendererSessionCountMax]; // TODO: don't hardcode those values. // TODO: keep the device somewhere and dispose it when exiting. // TODO: This is kind of wrong, we should have an high level API for that and mix all buffers between them. for (int i = 0; i < devices.Length; i++) { devices[i] = new AalHardwareDevice(i, Device.AudioOut, 2, RendererConstants.TargetSampleRate); } AudioRendererManager.Initialize(writableEvents, devices); }
private void InitializeAudioRenderer(ITickSource tickSource) { AudioManager = new AudioManager(); AudioOutputManager = new AudioOutputManager(); AudioInputManager = new AudioInputManager(); AudioRendererManager = new AudioRendererManager(tickSource); AudioRendererManager.SetVolume(Device.Configuration.AudioVolume); AudioDeviceSessionRegistry = new VirtualDeviceSessionRegistry(); IWritableEvent[] audioOutputRegisterBufferEvents = new IWritableEvent[Constants.AudioOutSessionCountMax]; for (int i = 0; i < audioOutputRegisterBufferEvents.Length; i++) { KEvent registerBufferEvent = new KEvent(KernelContext); audioOutputRegisterBufferEvents[i] = new AudioKernelEvent(registerBufferEvent); } AudioOutputManager.Initialize(Device.AudioDeviceDriver, audioOutputRegisterBufferEvents); AudioOutputManager.SetVolume(Device.Configuration.AudioVolume); IWritableEvent[] audioInputRegisterBufferEvents = new IWritableEvent[Constants.AudioInSessionCountMax]; for (int i = 0; i < audioInputRegisterBufferEvents.Length; i++) { KEvent registerBufferEvent = new KEvent(KernelContext); audioInputRegisterBufferEvents[i] = new AudioKernelEvent(registerBufferEvent); } AudioInputManager.Initialize(Device.AudioDeviceDriver, audioInputRegisterBufferEvents); IWritableEvent[] systemEvents = new IWritableEvent[Constants.AudioRendererSessionCountMax]; for (int i = 0; i < systemEvents.Length; i++) { KEvent systemEvent = new KEvent(KernelContext); systemEvents[i] = new AudioKernelEvent(systemEvent); } AudioManager.Initialize(Device.AudioDeviceDriver.GetUpdateRequiredEvent(), AudioOutputManager.Update, AudioInputManager.Update); AudioRendererManager.Initialize(systemEvents, Device.AudioDeviceDriver); AudioManager.Start(); }