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. Accessing devices is handled by the sound backend shared libraries, found in the soundbackends directory in the SDK. There are different backends available on the supported operating systems: DirectSound and Windows Audio Session API on Windows, Alsa and PulseAudio on Linux, CoreAudio on Mac OS X.

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`)`; |

`uint64 serverConnectionHandlerID`;
`const char* 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`.

  Passing an empty string will use the default playback mode.

- `playbackDevice`

  Valid parameters are:

  - The `device` parameter returned by `ts3client_getDefaultPlaybackDevice`

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

  - Empty string to initialize the default playback device.

  - Linux with Alsa only: Custom device name in the form of e.g. “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 the sound backend fails to find a usable playback device.

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

`uint64 serverConnectionHandlerID`;
`const char* 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`.

  Passing an empty string will use the default capture mode.

- `captureDevice`

  Valid parameters are:

  - The `device` parameter returned by `ts3client_getDefaultCaptureDevice`

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

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

  - Linux with Alsa only: Custom device name in the form of e.g. “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