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/services/oboeservice/FakeAudioHal.cpp b/services/oboeservice/FakeAudioHal.cpp
index cf0dc86..34a2476 100644
--- a/services/oboeservice/FakeAudioHal.cpp
+++ b/services/oboeservice/FakeAudioHal.cpp
@@ -94,14 +94,25 @@
 #define FRAMES_PER_BURST_QUALCOMM 192
 #define FRAMES_PER_BURST_NVIDIA   128
 
-int fake_hal_open(int card_id, int device_id, fake_hal_stream_ptr *streamPP) {
+int fake_hal_open(int card_id, int device_id,
+                  int frameCapacity,
+                  fake_hal_stream_ptr *streamPP) {
     int framesPerBurst = FRAMES_PER_BURST_QUALCOMM; // TODO update as needed
+    int periodCountRequested = frameCapacity / framesPerBurst;
     int periodCount = 32;
     unsigned int offset1;
     unsigned int frames1;
     void *area = nullptr;
     int mmapAvail = 0;
 
+    // Try to match requested size with a power of 2.
+    while (periodCount < periodCountRequested && periodCount < 1024) {
+        periodCount *= 2;
+    }
+    std::cout << "fake_hal_open() requested frameCapacity = " << frameCapacity << std::endl;
+    std::cout << "fake_hal_open() periodCountRequested = " << periodCountRequested << std::endl;
+    std::cout << "fake_hal_open() periodCount = " << periodCount << std::endl;
+
     // Configuration for an ALSA stream.
     pcm_config cfg;
     memset(&cfg, 0, sizeof(cfg));