# gvr::AudioSurroundApi

`#include <gvr_audio_surround.h>`

This is a convenience C++ wrapper for the Audio Surround C API.

## Summary

This wrapper strategy prevents ABI compatibility issues between compilers by ensuring that the interface between client code and the implementation code in libgvr.so is a pure C interface. The translation from C++ calls to C calls provided by this wrapper runs entirely in the client's binary and is compiled by the client's compiler.

Methods in this class are only documented insofar as the C++ wrapping logic is concerned; for information about the method itself, please refer to the corresponding function in the C API.

THREADING: this class is thread-safe and reentrant after initialized with [Init()](https://developers.google.com/vr/reference/android-ndk/class/gvr/audio-surround-api#classgvr_1_1_audio_surround_api_1a3b52399375c39f001856920b4819b8d0).

### Inheritance

Inherits from: [gvr::WrapperBase\< gvr_audio_surround_context, gvr_audio_surround_destroy \>](https://developers.google.com/vr/reference/android-ndk/class/gvr/wrapper-base)

| ### Public functions ||
|---|---|
| `https://developers.google.com/vr/reference/android-ndk/class/gvr/audio-surround-api#classgvr_1_1_audio_surround_api_1a6f415c6d8c497cde7d6bde4d7ab08b97(const int16_t *input_buffer_ptr, int64_t num_samples)` | `int64_t` Adds interleaved audio data to the renderer. |
| `https://developers.google.com/vr/reference/android-ndk/class/gvr/audio-surround-api#classgvr_1_1_audio_surround_api_1ade71b2f3655fb77e19cff0a46c21430d()` | `void` Removes all buffered input and processed output buffers from the buffer queues. |
| `https://developers.google.com/vr/reference/android-ndk/class/gvr/audio-surround-api#classgvr_1_1_audio_surround_api_1a6f5abd48313b486f2e083f5bc30cb473() const ` | `int64_t` Returns the number of samples the input buffer is currently able to consume. |
| `https://developers.google.com/vr/reference/android-ndk/class/gvr/audio-surround-api#classgvr_1_1_audio_surround_api_1a7f0e88298206d3620e0add3631a11c77() const ` | `int64_t` Returns the number of samples available in the output buffer. |
| `https://developers.google.com/vr/reference/android-ndk/class/gvr/audio-surround-api#classgvr_1_1_audio_surround_api_1a9dadb386ee0f488338b63dceba4f6f91(int16_t *output_buffer_ptr, int64_t num_samples)` | `int64_t` Gets a processed output buffer in interleaved format. |
| `https://developers.google.com/vr/reference/android-ndk/class/gvr/audio-surround-api#classgvr_1_1_audio_surround_api_1a3b52399375c39f001856920b4819b8d0(https://developers.google.com/vr/reference/android-ndk/group/types#group__types_1gab85687cb403c1ee4b589bb29d5b0dfa0 surround_format, int32_t num_input_channels, int32_t frames_per_buffer, int sample_rate_hz)` | `bool` Creates and initializes a gvr_audio_context. |
| `https://developers.google.com/vr/reference/android-ndk/class/gvr/audio-surround-api#classgvr_1_1_audio_surround_api_1a800dac701c9136cdaa4e39d51a5d041f(float w, float x, float y, float z)` | `void` Updates the head rotation. |
| `https://developers.google.com/vr/reference/android-ndk/class/gvr/audio-surround-api#classgvr_1_1_audio_surround_api_1a19db5bb494ad6cdb4f7914bbde4ae719()` | `bool` Triggers the processing of data that has been input but not yet processed. |

## Public functions

### AddInterleavedInput

```
int64_t AddInterleavedInput(
  const int16_t *input_buffer_ptr,
  int64_t num_samples
)
```
Adds interleaved audio data to the renderer.

For more information, see [gvr_audio_surround_add_interleaved_input()](https://developers.google.com/vr/reference/android-ndk/group/audio-surround#group___audio_surround_1ga9bc0ff92bdaa03f12d4ade5c0c9b27bf).

### Clear

```
void Clear()
```
Removes all buffered input and processed output buffers from the buffer queues.

For more information, see [gvr_audio_surround_clear()](https://developers.google.com/vr/reference/android-ndk/group/audio-surround#group___audio_surround_1gaacbb3206db208b0b8d705745eafb0ce0).

### GetAvailableInputSizeSamples

```
int64_t GetAvailableInputSizeSamples() const 
```
Returns the number of samples the input buffer is currently able to consume.

For more information, see [gvr_audio_surround_get_available_input_size_samples()](https://developers.google.com/vr/reference/android-ndk/group/audio-surround#group___audio_surround_1gac06bedb0b155d54e1f4f721aa1ce144b).

### GetAvailableOutputSizeSamples

```
int64_t GetAvailableOutputSizeSamples() const 
```
Returns the number of samples available in the output buffer.

For more information, see [gvr_audio_surround_get_available_output_size_samples()](https://developers.google.com/vr/reference/android-ndk/group/audio-surround#group___audio_surround_1ga0435f5c19ce1900ab8ff0d45d0f25fc6).

### GetInterleavedOutput

```
int64_t GetInterleavedOutput(
  int16_t *output_buffer_ptr,
  int64_t num_samples
)
```
Gets a processed output buffer in interleaved format.

For more information, see [gvr_audio_surround_get_interleaved_output()](https://developers.google.com/vr/reference/android-ndk/group/audio-surround#group___audio_surround_1ga51d3aeefaa2c480f66d7949d0888588c).

### Init

```
bool Init(
  AudioSurroundFormat surround_format,
  int32_t num_input_channels,
  int32_t frames_per_buffer,
  int sample_rate_hz
)
```
Creates and initializes a gvr_audio_context.

For more information, see [gvr_audio_surround_create()](https://developers.google.com/vr/reference/android-ndk/group/audio-surround#group___audio_surround_1ga31f1e804fe02850fc105a64422a584ce).

### SetHeadRotation

```
void SetHeadRotation(
  float w,
  float x,
  float y,
  float z
)
```
Updates the head rotation.

For more information, see [gvr_audio_surround_set_head_rotation()](https://developers.google.com/vr/reference/android-ndk/group/audio-surround#group___audio_surround_1ga7bd29287df0cd57c51981406678782de).

### TriggerProcessing

```
bool TriggerProcessing()
```
Triggers the processing of data that has been input but not yet processed.

For more information, see [gvr_audio_surround_trigger_processing()](https://developers.google.com/vr/reference/android-ndk/group/audio-surround#group___audio_surround_1ga868300c2322231fbb2cec8f9dce8bede).