/// <summary>
 /// Called when start the package.
 /// </summary>
 /// <exception cref="Exception">Unable to read the SSound configuration section !</exception>
 public override void OnStart()
 {
     if (!PackageHost.TryGetSettingAsConfigurationSection <SSoundConfigurationSection>("ssoundConfiguration", out configuration))
     {
         PackageHost.WriteError("Unable to read the configuration, the defaut configuration will be use !");
     }
     PackageHost.SubscribeMessages("SSound");
     PackageHost.WriteInfo("Starting S-Sound endpoint '{0}'", this.EndpointName);
     // Discovering and load the Output device
     this.PushAllDevices();
     this.outDevice = this.GetDevice(configuration?.OutputDeviceName);
     this.outDevice.AudioEndpointVolume.OnVolumeNotification += (AudioVolumeNotificationData data) =>
     {
         PackageHost.PushStateObject <bool>("Mute", this.outDevice.AudioEndpointVolume.Mute);
         PackageHost.PushStateObject <float>("Volume", this.outPlayer.Volume);
         PackageHost.WriteInfo("AudioEndpointVolume notification. Volume: {0} - IsMute: {1}",
                               outPlayer.Volume, this.outDevice.AudioEndpointVolume.Mute);
     };
     PackageHost.WriteInfo("Output device : '{0}' ({1})", this.outDevice.FriendlyName, this.outDevice.ID);
     PackageHost.PushStateObject("OutDevice", new SSoundDevice(this.outDevice));
     // Create output player
     this.outPlayer = this.CreateWasapiOut(this.outDevice);
     this.outPlayer.PlaybackStopped += (object sender, StoppedEventArgs e) =>
     {
         this.Stop();
     };
     if (configuration?.InitialVolume >= 0)
     {
         this.outPlayer.Volume = (float)configuration.InitialVolume;
     }
     // Push current state
     PackageHost.PushStateObject("CurrentPlayer", string.Empty);
     PackageHost.PushStateObject <bool>("Mute", this.outDevice.AudioEndpointVolume.Mute);
     PackageHost.PushStateObject <float>("Volume", this.outPlayer.Volume);
     PackageHost.PushStateObject <PlaybackState>("State", PlaybackState.Stopped);
     // Load WaveInPlayers
     this.LoadWaveInPlayers();
     // Started DLNA MediaRenderer is needeed
     if (configuration?.EnableDlnaRenderer ?? true)
     {
         dlnaDevice.StartRenderer(this.EndpointName);
     }
     // SSound is ready !
     PackageHost.WriteInfo("S-Sound '{0}' is ready", this.EndpointName);
 }