public void Dispose() { if (BassWasapiOutput != null) { BassWasapiOutput.Dispose(); BassWasapiOutput = null; } }
public static IOutputDevice CreateOutputDevice(OutputDevice.StreamProc streamProc, uint freq, uint chans, bool useFloat, int bufferLen, string preferredDeviceName = null) { lock (outputChannelLock) { Logger.Debug("Rebuild output"); if (Lutea.Core.AppCore.EnableWASAPIExclusive) { try { var ret = new BASSWASAPIOutputChannel(streamProc, true, freq, chans, preferredDeviceName, (uint)bufferLen); BASS.SetPriority(System.Diagnostics.ThreadPriorityLevel.TimeCritical); BASSWASAPIOutput.SetPriority(System.Diagnostics.ThreadPriorityLevel.TimeCritical); return(ret); } catch (BASSWASAPIOutput.BASSWASAPIException) { } } try { var ret = new BASSWASAPIOutputChannel(streamProc, false, freq, chans, preferredDeviceName, (uint)bufferLen); BASS.SetPriority(System.Diagnostics.ThreadPriorityLevel.TimeCritical); BASSWASAPIOutput.SetPriority(System.Diagnostics.ThreadPriorityLevel.TimeCritical); return(ret); } catch (BASSWASAPIOutput.BASSWASAPIException) { } try { var ret = new BASSOutput(streamProc, freq, chans, preferredDeviceName, bufferLen); BASS.SetPriority(System.Diagnostics.ThreadPriorityLevel.TimeCritical); return(ret); } catch (BASS.BASSException) { } throw new NotSupportedException(); } }
public BASSWASAPIOutputChannel(OutputDevice.StreamProc proc, bool exclusive, uint freq, uint chans, string preferredDeviceName, uint bufLen) { this.Exclusive = exclusive; BASS.BASS_SetDevice(0); int deviceid = -1; var devices = BASSWASAPIOutput.GetDevices(); for (int i = 0; i < devices.Length; i++) { var device = devices[i]; if ((device.Name == preferredDeviceName) && ((device.Flag & BASSWASAPIOutput.BASS_WASAPI_DEVICEINFO.Flags.BASS_DEVICE_INPUT) == 0) && (device.Mixchans >= chans)) { deviceid = i; Logger.Debug("Found preferred output device:" + device.ToString()); break; } } StreamProc = proc; BassWasapiOutput = new BASSWASAPIOutput(freq, chans, (x, y) => StreamProc(x, y), BASSWASAPIOutput.InitFlags.Buffer | (exclusive ? BASSWASAPIOutput.InitFlags.Exclusive : 0), deviceid, bufLen); Logger.Log("Use WASAPI Exclusive Output: freq=" + BassWasapiOutput.Info.Freq + ", format=" + BassWasapiOutput.Info.Format); }