protected virtual void ConfigureWASAPI(IBassStreamComponent previous) { BassWasapiDevice.Init(this.Rate, this.Channels); if (this.Rate != BassWasapiDevice.Info.Rate) { Logger.Write(this, LogLevel.Warn, "Failed to set the requested rate {0}, falling back to device default {1}.", this.Rate, BassWasapiDevice.Info.Rate); this.Rate = BassWasapiDevice.Info.Rate; } if (this.Channels != BassWasapiDevice.Info.Outputs) { Logger.Write(this, LogLevel.Warn, "Failed to set the requested channel count {0}, falling back to device default {1}.", this.Channels, BassWasapiDevice.Info.Outputs); this.Channels = BassWasapiDevice.Info.Outputs; } }
protected virtual void ConfigureWASAPI(IBassStreamComponent previous) { if (this.Behaviour.Output.EnforceRate) { if (!BassWasapiDevice.Info.SupportedRates.Contains(this.Rate)) { var nearestRate = BassWasapiDevice.Info.GetNearestRate(this.Rate); Logger.Write(this, LogLevel.Warn, "Enforced rate {0} isn't supposed by the device, falling back to {1}.", this.Rate, nearestRate); this.Rate = nearestRate; } else { //Enfoced rate is supported by the device, nothing to do. } } else { if (!BassWasapiDevice.Info.SupportedRates.Contains(previous.Rate)) { var nearestRate = BassWasapiDevice.Info.GetNearestRate(previous.Rate); Logger.Write(this, LogLevel.Debug, "Stream rate {0} isn't supposed by the device, falling back to {1}.", this.Rate, nearestRate); this.Rate = nearestRate; } else { //Stream rate is supported by the device, nothing to do. this.Rate = previous.Rate; } } BassWasapiDevice.Init( this.Behaviour.WasapiDevice, this.Behaviour.Exclusive, this.Behaviour.AutoFormat, this.Behaviour.BufferLength, this.Behaviour.DoubleBuffer, this.Behaviour.EventDriven, this.Behaviour.Async, this.Behaviour.Dither, this.Behaviour.Raw, this.Rate, this.Channels ); }
protected virtual void OnInitDevice() { if (BassWasapiDevice.IsInitialized) { return; } BassWasapiDevice.Init(this.WasapiDevice, this.Exclusive, this.EventDriven, this.Dither); if (this.Output.EnforceRate && !BassWasapiDevice.Info.SupportedRates.Contains(this.Output.Rate)) { var supportedRates = string.Join( ", ", BassWasapiDevice.Info.SupportedRates.Select( supportedRate => string.Format( "{0}@{1}", Enum.GetName(typeof(WasapiFormat), BassWasapiDevice.Info.SupportedFormats[supportedRate]), supportedRate ) ) ); Logger.Write(this, LogLevel.Error, "The output rate {0} is not supported by the device, supported rates are: {1}", this.Output.Rate, supportedRates); BassWasapiDevice.Free(); throw new NotImplementedException(string.Format("The output rate {0} is not supported by the device, supported rates are: {1}", this.Output.Rate, supportedRates)); } }