IAudioDeviceCollection
The IAudioDeviceCollection interface. You can get the information of audio devices with this interface.
getApplicationVolume
Retrieves the volume of the app.
virtual int getApplicationVolume(int& volume) = 0;
Parameters
- volume
- The volume of the app. The value range is [0,255].
Returns
- 0: Success.
- < 0: Failure.
getCount
Gets the total number of audio playback or audio capture devices.
virtual int getCount() = 0;
Details
If you call enumeratePlaybackDevices before this method, the SDK returns the number of audio playback devices. If you call enumerateRecordingDevices before this method, the SDK returns the number of audio capture devices.
Returns
The number of audio playback or audio capture devices.
getDefaultDevice [1/2]
Gets the default audio device of the system.
virtual int getDefaultDevice(char deviceName[MAX_DEVICE_ID_LENGTH], char deviceId[MAX_DEVICE_ID_LENGTH]) = 0;
- This method is for Windows and macOS only.
- You need to call enumeratePlaybackDevices or enumerateRecordingDevices to get the device list before calling this method.
Parameters
- deviceName
- Output parameter; the name of the system's default audio device. The maximum length is MAX_DEVICE_ID_LENGTH_TYPE.
- deviceId
- Output parameter; the device ID of the system default audio device. The maximum length is MAX_DEVICE_ID_LENGTH_TYPE.
Returns
- 0: Success.
- < 0: Failure.
getDefaultDevice [2/2]
Get the system‘s default audio device and its type.
virtual int getDefaultDevice(char deviceName[MAX_DEVICE_ID_LENGTH], char deviceTypeName[MAX_DEVICE_ID_LENGTH], char deviceId[MAX_DEVICE_ID_LENGTH]) = 0;
Details
- This method applies to macOS only.
- You need to call enumeratePlaybackDevices or enumerateRecordingDevices to get the device list before calling this method.
Parameters
- deviceName
- Output parameter; the name of the system's default audio device. The maximum length is MAX_DEVICE_ID_LENGTH_TYPE.
- deviceTypeName
- Output parameter; indicates the type of audio devices, such as built-in, USB and HDMI. The maximum length is MAX_DEVICE_ID_LENGTH_TYPE.
- deviceId
- Output parameter; the device ID of the system default audio device. The maximum length is MAX_DEVICE_ID_LENGTH_TYPE.
Returns
- 0: Success.
- < 0: Failure.
getDevice [1/2]
Gets the information of a specified audio device by index.
virtual int getDevice(int index, char deviceName[MAX_DEVICE_ID_LENGTH], char deviceId[MAX_DEVICE_ID_LENGTH]) = 0;
This method is for Windows and macOS only.
Parameters
- index
- An input parameter. The index of the device.
- deviceName
- An output parameter. The device name. The maximum length is MAX_DEVICE_ID_LENGTH_TYPE.
- deviceId
- An output parameter. The device ID. The maximum length is MAX_DEVICE_ID_LENGTH_TYPE.
Returns
- 0: Success.
- < 0: Failure.
getDevice [2/2]
Get the audio device information and device type by index.
virtual int getDevice(int index, char deviceName[MAX_DEVICE_ID_LENGTH], char deviceTypeName[MAX_DEVICE_ID_LENGTH],
char deviceId[MAX_DEVICE_ID_LENGTH]) = 0;
Details
You can call this method to get the name, type and ID of a specified audio device.
Parameters
- index
- An input parameter. The index of the device.
- deviceId
- An output parameter. The device ID. The maximum length is MAX_DEVICE_ID_LENGTH_TYPE.
- deviceName
- An output parameter. The device name. The maximum length is MAX_DEVICE_ID_LENGTH_TYPE.
- deviceTypeName
- Output parameter; indicates the type of audio devices, such as built-in, USB and HDMI. The maximum length is MAX_DEVICE_ID_LENGTH_TYPE.
Returns
- 0: Success.
- < 0: Failure.
isApplicationMute
Checks whether the app is muted.
virtual int isApplicationMute(bool &mute) = 0;
Parameters
- mute
-
Whether the app is muted:
true
: The app is muted.false
: The app is not muted.
Returns
- 0: Success.
- < 0: Failure.
release
Releases all the resources occupied by the IAudioDeviceCollection object.
virtual void release() = 0;
setApplicationMute
Mutes/Unmutes the app.
virtual int setApplicationMute(bool mute) = 0;
Parameters
- mute
- Whether to mute the app:
true
: Mute the app.false
: Unmute the app.
Returns
- 0: Success.
- < 0: Failure.
setApplicationVolume
Sets the volume of the app.
virtual int setApplicationVolume(int volume) = 0;
Parameters
- volume
- The volume of the app. The value range is [0,255].
Returns
- 0: Success.
- < 0: Failure.
setDevice
Specifies an audio device.
virtual int setDevice(const char deviceId[MAX_DEVICE_ID_LENGTH]) = 0;
Details
You can call this method to change the audio route currently being used, but this does not change the default audio route. For example, if the default audio route is speaker 1, you call this method to set the audio route as speaker 2 before joinging a channel and then start a device test, the SDK conducts device test on speaker 2. After the device test is completed and you join a channel, the SDK still uses speaker 1, the default audio route.
Parameters
- deviceId
- The device ID. The maximum length is MAX_DEVICE_ID_LENGTH_TYPE.
Returns
- 0: Success.
- < 0: Failure.