public void Start(IHardwareDeviceDriver deviceDriver) { OutputDevices = new IHardwareDevice[Constants.AudioRendererSessionCountMax]; // TODO: Before enabling this, we need up-mixing from stereo to 5.1. // uint channelCount = GetHardwareChannelCount(deviceDriver); uint channelCount = 2; for (int i = 0; i < OutputDevices.Length; i++) { // TODO: Don't hardcode sample rate. OutputDevices[i] = new HardwareDeviceImpl(deviceDriver, channelCount, Constants.TargetSampleRate); } _mailbox = new Mailbox <MailboxMessage>(); _sessionCommandList = new RendererSession[Constants.AudioRendererSessionCountMax]; _event.Reset(); _lastTime = PerformanceCounter.ElapsedNanoseconds; StartThread(); _mailbox.SendMessage(MailboxMessage.Start); if (_mailbox.ReceiveResponse() != MailboxMessage.Start) { throw new InvalidOperationException("Audio Processor Start response was invalid!"); } }
public HardwareDeviceImpl(IHardwareDeviceDriver deviceDriver, uint channelCount, uint sampleRate, float volume) { _session = deviceDriver.OpenDeviceSession(IHardwareDeviceDriver.Direction.Output, null, SampleFormat.PcmInt16, sampleRate, channelCount, volume); _channelCount = channelCount; _sampleRate = sampleRate; _currentBufferTag = 0; _buffer = new byte[Constants.TargetSampleCount * channelCount * sizeof(ushort)]; _session.Start(); }
private static uint GetHardwareChannelCount(IHardwareDeviceDriver deviceDriver) { // Get the real device driver (In case the compat layer is on top of it). deviceDriver = deviceDriver.GetRealDeviceDriver(); if (deviceDriver.SupportsChannelCount(6)) { return(6); } else { // NOTE: We default to stereo as this will get downmixed to mono by the compat layer if it's not compatible. return(2); } }
public HLEConfiguration(VirtualFileSystem virtualFileSystem, LibHacHorizonManager libHacHorizonManager, ContentManager contentManager, AccountManager accountManager, UserChannelPersistence userChannelPersistence, IRenderer gpuRenderer, IHardwareDeviceDriver audioDeviceDriver, MemoryConfiguration memoryConfiguration, IHostUiHandler hostUiHandler, SystemLanguage systemLanguage, RegionCode region, bool enableVsync, bool enableDockedMode, bool enablePtc, bool enableInternetAccess, IntegrityCheckLevel fsIntegrityCheckLevel, int fsGlobalAccessLogMode, long systemTimeOffset, string timeZone, MemoryManagerMode memoryManagerMode, bool ignoreMissingServices, AspectRatio aspectRatio, float audioVolume) { VirtualFileSystem = virtualFileSystem; LibHacHorizonManager = libHacHorizonManager; AccountManager = accountManager; ContentManager = contentManager; UserChannelPersistence = userChannelPersistence; GpuRenderer = gpuRenderer; AudioDeviceDriver = audioDeviceDriver; MemoryConfiguration = memoryConfiguration; HostUiHandler = hostUiHandler; SystemLanguage = systemLanguage; Region = region; EnableVsync = enableVsync; EnableDockedMode = enableDockedMode; EnablePtc = enablePtc; EnableInternetAccess = enableInternetAccess; FsIntegrityCheckLevel = fsIntegrityCheckLevel; FsGlobalAccessLogMode = fsGlobalAccessLogMode; SystemTimeOffset = systemTimeOffset; TimeZone = timeZone; MemoryManagerMode = memoryManagerMode; IgnoreMissingServices = ignoreMissingServices; AspectRatio = aspectRatio; AudioVolume = audioVolume; }
public CompatLayerHardwareDeviceDriver(IHardwareDeviceDriver realDevice) { _realDriver = realDevice; }
public Switch(VirtualFileSystem fileSystem, ContentManager contentManager, UserChannelPersistence userChannelPersistence, IRenderer renderer, IHardwareDeviceDriver audioDeviceDriver) { if (renderer == null) { throw new ArgumentNullException(nameof(renderer)); } if (audioDeviceDriver == null) { throw new ArgumentNullException(nameof(audioDeviceDriver)); } if (userChannelPersistence == null) { throw new ArgumentNullException(nameof(userChannelPersistence)); } UserChannelPersistence = userChannelPersistence; AudioDeviceDriver = new CompatLayerHardwareDeviceDriver(audioDeviceDriver); Memory = new MemoryBlock(1UL << 32); Gpu = new GpuContext(renderer); MemoryAllocator = new NvMemoryAllocator(); Host1x = new Host1xDevice(Gpu.Synchronization); var nvdec = new NvdecDevice(Gpu.MemoryManager); var vic = new VicDevice(Gpu.MemoryManager); Host1x.RegisterDevice(ClassId.Nvdec, nvdec); Host1x.RegisterDevice(ClassId.Vic, vic); nvdec.FrameDecoded += (FrameDecodedEventArgs e) => { // FIXME: // Figure out what is causing frame ordering issues on H264. // For now this is needed as workaround. if (e.CodecId == CodecId.H264) { vic.SetSurfaceOverride(e.LumaOffset, e.ChromaOffset, 0); } else { vic.DisableSurfaceOverride(); } }; FileSystem = fileSystem; System = new Horizon(this, contentManager); System.InitializeServices(); Statistics = new PerformanceStatistics(); Hid = new Hid(this, System.HidBaseAddress); Hid.InitDevices(); Application = new ApplicationLoader(this, fileSystem, contentManager); }
/// <summary> /// Initialize the <see cref="AudioRendererManager"/>. /// </summary> /// <param name="sessionSystemEvents">The events associated to each session.</param> /// <param name="deviceDriver">The device driver to use to create audio outputs.</param> public void Initialize(IWritableEvent[] sessionSystemEvents, IHardwareDeviceDriver deviceDriver) { _sessionsSystemEvent = sessionSystemEvents; _deviceDriver = deviceDriver; }
/// <summary> /// Initialize the <see cref="AudioInputManager"/>. /// </summary> /// <param name="deviceDriver">The device driver.</param> /// <param name="sessionRegisterEvents">The events associated to each session.</param> public void Initialize(IHardwareDeviceDriver deviceDriver, IWritableEvent[] sessionRegisterEvents) { _deviceDriver = deviceDriver; _sessionsBufferEvents = sessionRegisterEvents; }
public DummyHardwareDeviceSessionInput(IHardwareDeviceDriver manager, IVirtualMemoryManager memoryManager, SampleFormat requestedSampleFormat, uint requestedSampleRate, uint requestedChannelCount) { _volume = 1.0f; _manager = manager; _memoryManager = memoryManager; }
public DummyHardwareDeviceSessionOutput(IHardwareDeviceDriver manager, IVirtualMemoryManager memoryManager, SampleFormat requestedSampleFormat, uint requestedSampleRate, uint requestedChannelCount, float requestedVolume) : base(memoryManager, requestedSampleFormat, requestedSampleRate, requestedChannelCount) { _volume = requestedVolume; _manager = manager; }