public DirectXOutputDevice(Controller controller) { _controller = controller; _deviceState = DeviceState.Stopped; _streamWriteProcDelegate = OutputStreamWriteProc; _silence = new Silence(); _deviceNo = GetDeviceNo(); BASSInit flags = BASSInit.BASS_DEVICE_DEFAULT; // Because all deviceinfo is saved in a static dictionary, // we need to determine the latency only once. if (!_deviceInfos.ContainsKey(_deviceNo)) flags |= BASSInit.BASS_DEVICE_LATENCY; bool result = Bass.BASS_Init( _deviceNo, 44100, //Only relevant for -> pre-XP (VxD drivers) flags, IntPtr.Zero); BASSError? bassInitErrorCode = result ? null : new BASSError?(Bass.BASS_ErrorGetCode()); // If the GetDeviceNo() method returned BassConstants.BassDefaultDevice, we must request the actual device number // of the choosen default device _deviceNo = Bass.BASS_GetDevice(); if (bassInitErrorCode.HasValue) { if (bassInitErrorCode.Value == BASSError.BASS_ERROR_ALREADY) { if (!Bass.BASS_SetDevice(_deviceNo)) throw new BassLibraryException("BASS_SetDevice"); bassInitErrorCode = null; } } if (bassInitErrorCode.HasValue) throw new BassLibraryException("BASS_Init", bassInitErrorCode.Value); CollectDeviceInfo(_deviceNo); int ms = Convert.ToInt32(Controller.GetSettings().DirectSoundBufferSize.TotalMilliseconds); if (!Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_BUFFER, ms)) throw new BassLibraryException("BASS_SetConfig"); // Enable update thread while the output device is active if (!Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_UPDATEPERIOD, ms / 4)) throw new BassLibraryException("BASS_SetConfig"); }
public PlaybackBuffer(Controller controller) { _controller = controller; _silence = new Silence(); BassPlayerSettings settings = Controller.GetSettings(); _bufferSize = settings.PlaybackBufferSize; _streamWriteProcDelegate = OutputStreamWriteProc; _vizRawStreamWriteProcDelegate = VizRawStreamWriteProc; _notifyBufferUpdateThread = new AutoResetEvent(false); _updateThreadFinished = new AutoResetEvent(false); }
protected AbstractOutputDevice(Controller controller) { _controller = controller; _deviceState = DeviceState.Stopped; _silence = new Silence(); }