Пример #1
0
        public IAsyncResult BeginRefresh(AsyncCallback callback)
        {
            AsyncNoResult result  = new AsyncNoResult(callback);
            var           request = new vx_req_aux_get_render_devices_t();

            _client.BeginIssueRequest(request, ar =>
            {
                vx_resp_aux_get_render_devices_t response;
                try
                {
                    response = _client.EndIssueRequest(ar);
                    _devices.Clear();
                    for (var i = 0; i < response.count; ++i)
                    {
                        var device   = VivoxCoreInstance.get_device(i, response.render_devices);
                        var id       = device.device;
                        var name     = device.display_name;
                        _devices[id] = new AudioDevice {
                            Key = id, Name = name
                        };
                    }

                    _systemDevice = new AudioDevice
                    {
                        Key  = response.default_render_device.device,
                        Name = response.default_render_device.display_name
                    };
                    _communicationDevice = new AudioDevice
                    {
                        Key  = response.default_communication_render_device.device,
                        Name = response.default_communication_render_device.display_name
                    };
                    var effectiveDevice = new AudioDevice
                    {
                        Key  = response.effective_render_device.device,
                        Name = response.effective_render_device.display_name,
                    };
                    if (!effectiveDevice.Equals(_effectiveDevice))
                    {
                        // Only fire the event if the effective device has truly changed.
                        _effectiveDevice = effectiveDevice;
                        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(EffectiveDevice)));
                    }
                    result.SetComplete();
                }
                catch (Exception e)
                {
                    VivoxDebug.Instance.VxExceptionMessage($"{request.GetType().Name} failed: {e}");
                    result.SetComplete(e);
                    if (VivoxDebug.Instance.throwInternalExcepetions)
                    {
                        throw;
                    }
                    return;
                }
            });
            return(result);
        }
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(vx_req_aux_get_render_devices_t obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }