Using playback and capture modes and devices

## Using playback and capture modes and devices

The Client Lib takes care of initializing, using and releasing sound playback and capture devices. As a cross-platform library, the Client Lib handles all the low-level interfacing for multiple operating systems with Speex, FMOD, DirectSound, CoreAudio, ALSA and OSS.

All strings passed to and from the Client Lib have to be encoded in UTF-8 format.

### Initializing modes and devices

To initialize a playback and capture device for a TeamSpeak 3 server connection handler, call

`unsigned int ts3client_openPlaybackDevice(` | serverConnectionHandlerID, |
| modeID, |
| playbackDevice`)`; |

`anyID serverConnectionHandlerID`;
`int modeID`;
`const char* playbackDevice`;

Parameters

- `serverConnectionHandlerID`

  Connection handler of the server on which you want to initialize the playback device.

- `modeID`

  The playback mode to use. Valid modes are returned by `ts3client_getDefaultPlayBackMode` and `ts3client_getPlaybackModeList`.

- `playbackDevice`

  Valid parameters are:

  - The `device` parameter returned by `ts3client_getDefaultPlaybackDevice`

  - One of the `device` parameters returned by `ts3client_getPlaybackDeviceList`

  - Empty string or NULL to initialize the default playback device.

  - Linux with Alsa only: Custom device name in the form of: “hw:1,0”.

  The string needs to be encoded in UTF-8 format.

Returns `ERROR_ok` on success, otherwise an error code as defined in `public_errors.h`. A likely error is `ERROR_sound_could_not_open_playback_device` if FMOD fails to find a usable playback device.

`unsigned int ts3client_openCaptureDevice(` | serverConnectionHandlerID, |
| modeID, |
| captureDevice`)`; |

`anyID serverConnectionHandlerID`;
`int modeID`;
`const char* captureDevice`;

Parameters

- `serverConnectionHandlerID`

  Connection handler of the server on which you want to initialize the capture device.

- `modeID`

  The capture mode to use. Valid modes are returned by `ts3client_getDefaultCaptureMode` and `ts3client_getCaptureModeList`.

- `captureDevice`

  Valid parameters are:

  - The `device` parameter returned by `ts3client_getDefaultCaptureDevice`

  - One of the `device` parameters returned by `ts3client_getCaptureDeviceList`

  - Empty string or NULL to initialize the default capture device. Encoded in UTF-8 format.

  - Linux with Alsa only: Custom device name in the form of: “hw:1,0”.

Returns `ERROR_ok` on success, otherwise an error code as defined in `public_errors.h`. Likely errors are `ERROR_sound_could_not_open_capture_device` if the device fails to open or `ERROR_sound_handler_has_device` if the device is already opened. To avoid this problem, it is recommended to close the capture device before opening it again.

Logging |  | Querying available modes and devices