private async Task <PcAudio> GetCurrentAudioStateAsync(CoreAudioController coreAudioController)
    {
        var audioState = new PcAudio
        {
            ApplicationVersion = ApplicationVersion,
            ProtocolVersion    = ProtocolVersion
        };

        var devices = await coreAudioController.GetPlaybackDevicesAsync();

        foreach (var device in devices.Where(x => x.State == DeviceState.Active).ToList())
        {
            audioState.DeviceIds.Add(device.Id.ToString(), device.FullName);
        }

        var defaultPlaybackDevice = coreAudioController.DefaultPlaybackDevice;

        audioState.DefaultDevice = new AudioDevice
        {
            Name         = defaultPlaybackDevice.FullName,
            DeviceId     = defaultPlaybackDevice.Id.ToString(),
            MasterVolume = defaultPlaybackDevice.Volume,
            MasterMuted  = defaultPlaybackDevice.IsMuted
        };

        return(audioState);
    }
        protected async Task UpdateDevice()
        {
            deviceInvalidated = false;

            if (DeviceID.HasValue)
            {
                var devices = await Controller.GetPlaybackDevicesAsync();

                Device = devices.FirstOrDefault(d => d.Id == DeviceID.Value);

                // Even if a specific device is selected and not available, do not fall back to the default device
                return;
            }

            Device = await Controller.GetDefaultDeviceAsync(DeviceType.Playback, Role.Multimedia);
        }
        public void GetDevices()
        {
            var devtask = _audioctrl.GetPlaybackDevicesAsync(DeviceState.All);

            devtask.ContinueWith(task =>
            {
                var devices = task.Result;
                _devassoc.Clear();
                foreach (var device in devices)
                {
                    _devassoc.UpdateGeneric(device.FullName, device);
                }
                _devicesChanged = true;
                Loading[0]      = false;
            });
        }