文档

支持

Vivox Core SDK

Vivox Core SDK

In-game audio device selection

Allow players to select audio input and output devices.
阅读时间1 分钟最后更新于 12 天前

The Vivox SDK automatically uses the default system audio input and output devices. Changes to available audio devices are performed through system events. When a new device or a new user with a new device is detected, or the currently active device is removed, configure your application to perform the following actions:
  1. Determine if the new device requires a change to either the active capture or render device.
  2. If a change is required, change the capture or render device.
To provide users with a choice of which audio device to use for group voice chat independent of the audio devices that are used for a game, build a user interface that displays a list of available devices to users that they can select a device from. Use the following requests for this user interface, where audio output devices are called render devices, and audio input devices are called capture devices:
  • vx_req_aux_get_render_devices
  • vx_req_aux_get_capture_devices
  • vx_req_aux_set_render_device
  • vx_req_aux_set_capture_device
Each of the
vx_resp_aux_get_*_devices
responses include OS default devices, a list of devices that are available for selection with a
vx_req_aux_set_*_device
request, the current device selection, and the effective device in use. The
current_*_device
is the
vx_device_t
entry as it appears in the list of available devices. In the scenario where the current device is a representative audio device that serves as a reference to some other device (for example, Default System Device),
effective_*_device
is set to the real device in use. The current and effective devices match if a specific, discrete audio device is set.
If either the capture or render device is set to Default System Device, when a compatible audio device is plugged in or the existing in-use audio device is unplugged, audio automatically switches to the other device, and the application is notified with an
evt_audio_device_hot_swap
message. Use this message to provide a visual cue to the user that they are now using a different audio device.
For example, if a user is using a speaker device for audio and a headset is plugged in, set the current Vivox capture and render devices to the headset by using
vx_req_aux_set_capture_device
and
vx_req_aux_set_render_device
. If there is no capture device to fall back to, but there is a render device (for example, HDMI output), set the capture device to No Device.