AAudio: add setBufferCapacity()

This is needed so that an app can request a larger buffer.
Also fix a bug related to passing configuration data to the service.

Test: test_aaudio.cpp
Change-Id: Idd3066c84f6bac76a5d545b12081bc311025a6c3
Signed-off-by: Phil Burk <philburk@google.com>
diff --git a/media/liboboe/include/aaudio/AAudio.h b/media/liboboe/include/aaudio/AAudio.h
index 7324137..6987955 100644
--- a/media/liboboe/include/aaudio/AAudio.h
+++ b/media/liboboe/include/aaudio/AAudio.h
@@ -195,7 +195,7 @@
  * @return AAUDIO_OK or a negative error.
  */
 AAUDIO_API aaudio_result_t AAudioStreamBuilder_setDirection(AAudioStreamBuilder builder,
-                                                      aaudio_direction_t direction);
+                                                            aaudio_direction_t direction);
 
 /**
  * @param builder handle provided by AAudio_createStreamBuilder()
@@ -203,7 +203,31 @@
  * @return AAUDIO_OK or a negative error.
  */
 AAUDIO_API aaudio_result_t AAudioStreamBuilder_getDirection(AAudioStreamBuilder builder,
-                                                      aaudio_direction_t *direction);
+                                                            aaudio_direction_t *direction);
+
+/**
+ * Set the requested maximum buffer capacity in frames.
+ * The final AAudioStream capacity may differ, but will probably be at least this big.
+ *
+ * Default is AAUDIO_UNSPECIFIED.
+ *
+ * @param builder handle provided by AAudio_createStreamBuilder()
+ * @param frames the desired buffer capacity in frames or AAUDIO_UNSPECIFIED
+ * @return AAUDIO_OK or a negative error.
+ */
+AAUDIO_API aaudio_result_t AAudioStreamBuilder_setBufferCapacity(AAudioStreamBuilder builder,
+                                                                 aaudio_size_frames_t frames);
+
+/**
+ * Query the requested maximum buffer capacity in frames that was passed to
+ * AAudioStreamBuilder_setBufferCapacity().
+ *
+ * @param builder handle provided by AAudio_createStreamBuilder()
+ * @param frames pointer to variable to receive the requested buffer capacity
+ * @return AAUDIO_OK or a negative error.
+ */
+AAUDIO_API aaudio_result_t AAudioStreamBuilder_getBufferCapacity(AAudioStreamBuilder builder,
+                                                                 aaudio_size_frames_t *frames);
 
 /**
  * Open a stream based on the options in the StreamBuilder.
@@ -422,8 +446,8 @@
  * @return AAUDIO_OK or a negative error
  */
 AAUDIO_API aaudio_result_t AAudioStream_setBufferSize(AAudioStream stream,
-                                                aaudio_size_frames_t requestedFrames,
-                                                aaudio_size_frames_t *actualFrames);
+                                                      aaudio_size_frames_t requestedFrames,
+                                                      aaudio_size_frames_t *actualFrames);
 
 /**
  * Query the maximum number of frames that can be filled without blocking.
@@ -432,7 +456,8 @@
  * @param frames pointer to variable to receive the buffer size
  * @return AAUDIO_OK or a negative error.
  */
-AAUDIO_API aaudio_result_t AAudioStream_getBufferSize(AAudioStream stream, aaudio_size_frames_t *frames);
+AAUDIO_API aaudio_result_t AAudioStream_getBufferSize(AAudioStream stream,
+                                                      aaudio_size_frames_t *frames);
 
 /**
  * Query the number of frames that are read or written by the endpoint at one time.
@@ -441,7 +466,8 @@
  * @param frames pointer to variable to receive the burst size
  * @return AAUDIO_OK or a negative error.
  */
-AAUDIO_API aaudio_result_t AAudioStream_getFramesPerBurst(AAudioStream stream, aaudio_size_frames_t *frames);
+AAUDIO_API aaudio_result_t AAudioStream_getFramesPerBurst(AAudioStream stream,
+                                                          aaudio_size_frames_t *frames);
 
 /**
  * Query maximum buffer capacity in frames.
@@ -450,7 +476,8 @@
  * @param frames pointer to variable to receive the buffer capacity
  * @return AAUDIO_OK or a negative error.
  */
-AAUDIO_API aaudio_result_t AAudioStream_getBufferCapacity(AAudioStream stream, aaudio_size_frames_t *frames);
+AAUDIO_API aaudio_result_t AAudioStream_getBufferCapacity(AAudioStream stream,
+                                                          aaudio_size_frames_t *frames);
 
 /**
  * An XRun is an Underrun or an Overrun.
@@ -472,7 +499,8 @@
  * @param sampleRate pointer to variable to receive the actual sample rate
  * @return AAUDIO_OK or a negative error.
  */
-AAUDIO_API aaudio_result_t AAudioStream_getSampleRate(AAudioStream stream, aaudio_sample_rate_t *sampleRate);
+AAUDIO_API aaudio_result_t AAudioStream_getSampleRate(AAudioStream stream,
+                                                      aaudio_sample_rate_t *sampleRate);
 
 /**
  * The samplesPerFrame is also known as channelCount.
@@ -481,21 +509,24 @@
  * @param samplesPerFrame pointer to variable to receive the actual samples per frame
  * @return AAUDIO_OK or a negative error.
  */
-AAUDIO_API aaudio_result_t AAudioStream_getSamplesPerFrame(AAudioStream stream, int32_t *samplesPerFrame);
+AAUDIO_API aaudio_result_t AAudioStream_getSamplesPerFrame(AAudioStream stream,
+                                                           int32_t *samplesPerFrame);
 
 /**
  * @param stream handle provided by AAudioStreamBuilder_openStream()
  * @param deviceId pointer to variable to receive the actual device ID
  * @return AAUDIO_OK or a negative error.
  */
-AAUDIO_API aaudio_result_t AAudioStream_getDeviceId(AAudioStream stream, aaudio_device_id_t *deviceId);
+AAUDIO_API aaudio_result_t AAudioStream_getDeviceId(AAudioStream stream,
+                                                    aaudio_device_id_t *deviceId);
 
 /**
  * @param stream handle provided by AAudioStreamBuilder_openStream()
  * @param format pointer to variable to receive the actual data format
  * @return AAUDIO_OK or a negative error.
  */
-AAUDIO_API aaudio_result_t AAudioStream_getFormat(AAudioStream stream, aaudio_audio_format_t *format);
+AAUDIO_API aaudio_result_t AAudioStream_getFormat(AAudioStream stream,
+                                                  aaudio_audio_format_t *format);
 
 /**
  * Provide actual sharing mode.
@@ -511,7 +542,8 @@
  * @param direction pointer to a variable to be set to the current direction.
  * @return AAUDIO_OK or a negative error.
  */
-AAUDIO_API aaudio_result_t AAudioStream_getDirection(AAudioStream stream, aaudio_direction_t *direction);
+AAUDIO_API aaudio_result_t AAudioStream_getDirection(AAudioStream stream,
+                                                     aaudio_direction_t *direction);
 
 /**
  * Passes back the number of frames that have been written since the stream was created.
@@ -538,7 +570,8 @@
  * @param frames pointer to variable to receive the frames written
  * @return AAUDIO_OK or a negative error.
  */
-AAUDIO_API aaudio_result_t AAudioStream_getFramesRead(AAudioStream stream, aaudio_position_frames_t *frames);
+AAUDIO_API aaudio_result_t AAudioStream_getFramesRead(AAudioStream stream,
+                                                      aaudio_position_frames_t *frames);
 
 /**
  * Passes back the time at which a particular frame was presented.