private PlayerSet GetPlayerSet(
            string deviceID)
        {
            var ps  = default(PlayerSet);
            var key = !string.IsNullOrEmpty(deviceID) ?
                      deviceID :
                      this.GetDefaultAudioDevice().ID;

            lock (this.players)
            {
                if (this.players.ContainsKey(key))
                {
                    ps = this.players[key];
                }
                else
                {
                    var device = this.GetDevices().FirstOrDefault(x => x.ID == deviceID);

                    if (device != null)
                    {
                        ps = new PlayerSet();
                        ps.Init(device);

                        this.players[key] = ps;
                    }
                }
            }

            return(ps);
        }
        private PlayerSet GetPlayerSet(
            string deviceID)
        {
            var ps = default(PlayerSet);

            lock (this.players)
            {
                if (this.defaultAudioDevice == null ||
                    this.defaultComAudioDevice == null)
                {
                    this.UpdateDefaultAudioDevices();
                }

                var key = !string.IsNullOrEmpty(deviceID) ?
                          deviceID :
                          this.defaultAudioDevice.ID;

                var isNew = false;

                if (!this.players.ContainsKey(key))
                {
                    isNew = true;
                }
                else
                {
                    ps = this.players[key];

                    switch (deviceID)
                    {
                    case PlayDevice.DefaultDeviceID:
                        isNew = ps.DeviceID != this.defaultAudioDevice.ID;
                        break;

                    case PlayDevice.DefaultComDeviceID:
                        isNew = ps.DeviceID != this.defaultComAudioDevice.ID;
                        break;
                    }

                    if (isNew)
                    {
                        ps.Dispose();
                        this.players.Remove(key);
                    }
                }

                if (isNew)
                {
                    var device = deviceID switch
                    {
                        PlayDevice.DefaultDeviceID => this.GetDevices().FirstOrDefault(x => x.ID == this.defaultAudioDevice.ID),
                        PlayDevice.DefaultComDeviceID => this.GetDevices().FirstOrDefault(x => x.ID == this.defaultComAudioDevice.ID),
                        _ => this.GetDevices().FirstOrDefault(x => x.ID == deviceID)
                    };

                    if (device != null)
                    {
                        ps = new PlayerSet();
                        ps.Init(device);

                        this.players[key] = ps;
                    }
                }
            }

            return(ps);
        }