MediaPortal.MusicPlayer.BASS.BassAudioEngine.InitWasapi C# (CSharp) Method

InitWasapi() private method

Initialises the Wasapi Device
private InitWasapi ( ) : bool
return bool
    private bool InitWasapi()
    {
      bool result = false;

      Log.Info("BASS: Using WASAPI device: {0}", Config.SoundDevice);
      BASS_WASAPI_DEVICEINFO[] wasapiDevices = BassWasapi.BASS_WASAPI_GetDeviceInfos();

      int i = 0;
      // Check if the WASAPI device read is amongst the one retrieved
      for (i = 0; i < wasapiDevices.Length; i++)
      {
        if (wasapiDevices[i].name == Config.SoundDevice && wasapiDevices[i].id == Config.SoundDeviceID)
        {
          _deviceNumber = i;
          break;
        }
      }

      if (_deviceNumber > -1)
      {
        // Get some information about the Device
        _wasapiDeviceInfo = wasapiDevices[i];
        if (_wasapiDeviceInfo != null)
        {
          // Get the number of supported speakers from Config
          _deviceOutputChannels = GetWasApiSpeakers();

          Log.Info("BASS: Device Information");
          Log.Info("BASS: ---------------------------------------------");
          Log.Info("BASS: Name: {0}", _wasapiDeviceInfo.name);
          Log.Debug("BASS: Id: {0}", _wasapiDeviceInfo.id);
          Log.Debug("BASS: Type: {0}", _wasapiDeviceInfo.type.ToString());
          Log.Info("BASS: Shared Mode Channels: {0}", _wasapiDeviceInfo.mixchans);
          Log.Info("BASS: Shared Mode Samplerate: {0}", _wasapiDeviceInfo.mixfreq);
          GetWasApiFormats();
          Log.Info("BASS: ---------------------------------------------");

          result = true;
        }
        else
        {
          Log.Error("BASS: Error getting Device Info: {0}", Bass.BASS_ErrorGetCode());
        }
      }
      else
      {
        Log.Error("BASS: Specified WASAPI device not found. BASS is disabled.");
      }

      return result;
    }