protected virtual void OnFreeDevice()
 {
     if (!BassWasapiDevice.IsInitialized)
     {
         return;
     }
     BassWasapiDevice.Free();
 }
Beispiel #2
0
 protected override void OnDisposing()
 {
     if (this.ChannelHandle != 0)
     {
         Logger.Write(this, LogLevel.Debug, "Freeing BASS stream: {0}", this.ChannelHandle);
         Bass.StreamFree(this.ChannelHandle); //Not checking result code as it contains an error if the application is shutting down.
     }
     this.Stop();
     BassWasapiDevice.Free();
     base.OnDisposing();
 }
 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 OnInit(object sender, EventArgs e)
 {
     if (!this.Enabled)
     {
         return;
     }
     this.IsInitialized = true;
     BassUtils.OK(Bass.Configure(global::ManagedBass.Configuration.UpdateThreads, 0));
     BassUtils.OK(Bass.Configure(global::ManagedBass.Configuration.PlaybackBufferLength, this.Output.BufferLength));
     BassUtils.OK(Bass.Configure(global::ManagedBass.Configuration.SRCQuality, this.Output.ResamplingQuality));
     BassUtils.OK(Bass.Init(Bass.NoSoundDevice));
     //Always detect device for now.
     //if (BassWasapiDevice.Info != null && BassWasapiDevice.Info.Device != this.WasapiDevice)
     {
         BassWasapiDevice.Detect(this.WasapiDevice, this.Exclusive, this.AutoFormat, this.Buffer, this.EventDriven, this.Dither);
     }
     Logger.Write(this, LogLevel.Debug, "BASS (No Sound) Initialized.");
 }
Beispiel #5
0
 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
         );
 }
Beispiel #6
0
 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));
     }
 }