libaaudio: changes for API council

Removed typedefs like aaudio_sample_rate_t
Removed use of handles. Just pass back opaque pointers.
Simplified gettersi in Stream.
Removed getters from Builder.
Update libaaudio.map.txt

Test: CTS test_aaudio.cpp
Change-Id: I63eaec3e5a8ecc516cfc1f950f4b4f54df1bd518
Signed-off-by: Phil Burk <philburk@google.com>
diff --git a/services/oboeservice/AAudioService.cpp b/services/oboeservice/AAudioService.cpp
index dfa9753..99b0b4d 100644
--- a/services/oboeservice/AAudioService.cpp
+++ b/services/oboeservice/AAudioService.cpp
@@ -57,7 +57,7 @@
         ALOGE("AAudioService::openStream(): open returned %d", result);
         return result;
     } else {
-        AAudioStream handle = mHandleTracker.put(AAUDIO_HANDLE_TYPE_STREAM, serviceStream);
+        aaudio_handle_t handle = mHandleTracker.put(AAUDIO_HANDLE_TYPE_STREAM, serviceStream);
         ALOGD("AAudioService::openStream(): handle = 0x%08X", handle);
         if (handle < 0) {
             delete serviceStream;
@@ -127,7 +127,7 @@
 
 aaudio_result_t AAudioService::registerAudioThread(aaudio_handle_t streamHandle,
                                                          pid_t clientThreadId,
-                                                         aaudio_nanoseconds_t periodNanoseconds) {
+                                                         int64_t periodNanoseconds) {
     AAudioServiceStreamBase *serviceStream = convertHandleToServiceStream(streamHandle);
     ALOGD("AAudioService::registerAudioThread(), serviceStream = %p", serviceStream);
     if (serviceStream == nullptr) {
diff --git a/services/oboeservice/AAudioService.h b/services/oboeservice/AAudioService.h
index e9625b2..a520d7a 100644
--- a/services/oboeservice/AAudioService.h
+++ b/services/oboeservice/AAudioService.h
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-#ifndef AAUDIO_AAUDIO_AUDIO_SERVICE_H
-#define AAUDIO_AAUDIO_AUDIO_SERVICE_H
+#ifndef AAUDIO_AAUDIO_SERVICE_H
+#define AAUDIO_AAUDIO_SERVICE_H
 
 #include <time.h>
 #include <pthread.h>
@@ -58,7 +58,7 @@
     virtual aaudio_result_t flushStream(aaudio_handle_t streamHandle);
 
     virtual aaudio_result_t registerAudioThread(aaudio_handle_t streamHandle,
-                                              pid_t pid, aaudio_nanoseconds_t periodNanoseconds) ;
+                                              pid_t pid, int64_t periodNanoseconds) ;
 
     virtual aaudio_result_t unregisterAudioThread(aaudio_handle_t streamHandle, pid_t pid);
 
@@ -72,4 +72,4 @@
 
 } /* namespace android */
 
-#endif //AAUDIO_AAUDIO_AUDIO_SERVICE_H
+#endif //AAUDIO_AAUDIO_SERVICE_H
diff --git a/services/oboeservice/AAudioServiceDefinitions.h b/services/oboeservice/AAudioServiceDefinitions.h
index ee9aaa7..f98acbf 100644
--- a/services/oboeservice/AAudioServiceDefinitions.h
+++ b/services/oboeservice/AAudioServiceDefinitions.h
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-#ifndef AAUDIO_AAUDIO_SERVICE_H
-#define AAUDIO_AAUDIO_SERVICE_H
+#ifndef AAUDIO_AAUDIO_SERVICE_DEFINITIONS_H
+#define AAUDIO_AAUDIO_SERVICE_DEFINITIONS_H
 
 #include <stdint.h>
 
@@ -28,9 +28,9 @@
 // TODO move this an "include" folder for the service.
 
 struct AAudioMessageTimestamp {
-    aaudio_position_frames_t position;
+    int64_t position;
     int64_t                deviceOffset; // add to client position to get device position
-    aaudio_nanoseconds_t     timestamp;
+    int64_t     timestamp;
 };
 
 typedef enum aaudio_service_event_e : uint32_t {
@@ -61,7 +61,6 @@
     };
 } AAudioServiceMessage;
 
-
 } /* namespace aaudio */
 
-#endif //AAUDIO_AAUDIO_SERVICE_H
+#endif //AAUDIO_AAUDIO_SERVICE_DEFINITIONS_H
diff --git a/services/oboeservice/AAudioServiceStreamBase.h b/services/oboeservice/AAudioServiceStreamBase.h
index 4a59253..7a812f9 100644
--- a/services/oboeservice/AAudioServiceStreamBase.h
+++ b/services/oboeservice/AAudioServiceStreamBase.h
@@ -72,7 +72,7 @@
 
     virtual void sendCurrentTimestamp() = 0;
 
-    aaudio_size_frames_t getFramesPerBurst() {
+    int32_t getFramesPerBurst() {
         return mFramesPerBurst;
     }
 
@@ -90,17 +90,17 @@
 
 protected:
 
-    pid_t                    mRegisteredClientThread = ILLEGAL_THREAD_ID;
+    pid_t              mRegisteredClientThread = ILLEGAL_THREAD_ID;
 
-    SharedRingBuffer *       mUpMessageQueue;
+    SharedRingBuffer*  mUpMessageQueue;
 
-    aaudio_sample_rate_t       mSampleRate = 0;
-    aaudio_size_bytes_t        mBytesPerFrame = 0;
-    aaudio_size_frames_t       mFramesPerBurst = 0;
-    aaudio_size_frames_t       mCapacityInFrames = 0;
-    aaudio_size_bytes_t        mCapacityInBytes = 0;
+    int32_t            mSampleRate = 0;
+    int32_t            mBytesPerFrame = 0;
+    int32_t            mFramesPerBurst = 0;
+    int32_t            mCapacityInFrames = 0;
+    int32_t            mCapacityInBytes = 0;
 
-    android::Mutex           mLockUpMessageQueue;
+    android::Mutex     mLockUpMessageQueue;
 };
 
 } /* namespace aaudio */
diff --git a/services/oboeservice/AAudioServiceStreamFakeHal.cpp b/services/oboeservice/AAudioServiceStreamFakeHal.cpp
index 1caeb3f..71d3542 100644
--- a/services/oboeservice/AAudioServiceStreamFakeHal.cpp
+++ b/services/oboeservice/AAudioServiceStreamFakeHal.cpp
@@ -191,7 +191,7 @@
     timestampScheduler.setBurstPeriod(mFramesPerBurst, mSampleRate);
     timestampScheduler.start(AudioClock::getNanoseconds());
     while(mThreadEnabled.load()) {
-        aaudio_nanoseconds_t nextTime = timestampScheduler.nextAbsoluteTime();
+        int64_t nextTime = timestampScheduler.nextAbsoluteTime();
         if (AudioClock::getNanoseconds() >= nextTime) {
             sendCurrentTimestamp();
         } else  {
diff --git a/services/oboeservice/AAudioThread.h b/services/oboeservice/AAudioThread.h
index 1f676dc..a5d43a4 100644
--- a/services/oboeservice/AAudioThread.h
+++ b/services/oboeservice/AAudioThread.h
@@ -62,9 +62,9 @@
     void dispatch(); // called internally from 'C' thread wrapper
 
 private:
-    Runnable*                mRunnable = nullptr; // TODO make atomic with memory barrier?
-    bool                     mHasThread = false;
-    pthread_t                mThread; // initialized in constructor
+    Runnable*          mRunnable = nullptr; // TODO make atomic with memory barrier?
+    bool               mHasThread = false;
+    pthread_t          mThread; // initialized in constructor
 
 };
 
diff --git a/services/oboeservice/TimestampScheduler.cpp b/services/oboeservice/TimestampScheduler.cpp
index 5875909..d54996f 100644
--- a/services/oboeservice/TimestampScheduler.cpp
+++ b/services/oboeservice/TimestampScheduler.cpp
@@ -21,12 +21,12 @@
 
 using namespace aaudio;
 
-void TimestampScheduler::start(aaudio_nanoseconds_t startTime) {
+void TimestampScheduler::start(int64_t startTime) {
     mStartTime = startTime;
     mLastTime = startTime;
 }
 
-aaudio_nanoseconds_t TimestampScheduler::nextAbsoluteTime() {
+int64_t TimestampScheduler::nextAbsoluteTime() {
     int64_t periodsElapsed = (mLastTime - mStartTime) / mBurstPeriod;
     // This is an arbitrary schedule that could probably be improved.
     // It starts out sending a timestamp on every period because we want to
@@ -35,10 +35,10 @@
     int64_t minPeriodsToDelay = (periodsElapsed < 10) ? 1 :
         (periodsElapsed < 100) ? 3 :
         (periodsElapsed < 1000) ? 10 : 50;
-    aaudio_nanoseconds_t sleepTime = minPeriodsToDelay * mBurstPeriod;
+    int64_t sleepTime = minPeriodsToDelay * mBurstPeriod;
     // Generate a random rectangular distribution one burst wide so that we get
     // an uncorrelated sampling of the MMAP pointer.
-    sleepTime += (aaudio_nanoseconds_t)(random() * mBurstPeriod / RAND_MAX);
+    sleepTime += (int64_t)(random() * mBurstPeriod / RAND_MAX);
     mLastTime += sleepTime;
     return mLastTime;
 }
diff --git a/services/oboeservice/TimestampScheduler.h b/services/oboeservice/TimestampScheduler.h
index efc9c5f..91a2477 100644
--- a/services/oboeservice/TimestampScheduler.h
+++ b/services/oboeservice/TimestampScheduler.h
@@ -17,7 +17,7 @@
 #ifndef AAUDIO_TIMESTAMP_SCHEDULER_H
 #define AAUDIO_TIMESTAMP_SCHEDULER_H
 
-//#include <stdlib.h> // random()
+
 
 #include "IAAudioService.h"
 #include "AAudioServiceDefinitions.h"
@@ -25,6 +25,7 @@
 #include "fifo/FifoBuffer.h"
 #include "SharedRingBuffer.h"
 #include "AudioEndpointParcelable.h"
+#include "utility/AudioClock.h"
 
 namespace aaudio {
 
@@ -43,32 +44,32 @@
     /**
      * Start the schedule at the given time.
      */
-    void start(aaudio_nanoseconds_t startTime);
+    void start(int64_t startTime);
 
     /**
      * Calculate the next time that the read position should be
      * measured.
      */
-    aaudio_nanoseconds_t nextAbsoluteTime();
+    int64_t nextAbsoluteTime();
 
-    void setBurstPeriod(aaudio_nanoseconds_t burstPeriod) {
+    void setBurstPeriod(int64_t burstPeriod) {
         mBurstPeriod = burstPeriod;
     }
 
-    void setBurstPeriod(aaudio_size_frames_t framesPerBurst,
-                        aaudio_sample_rate_t sampleRate) {
+    void setBurstPeriod(int32_t framesPerBurst,
+                        int32_t sampleRate) {
         mBurstPeriod = AAUDIO_NANOS_PER_SECOND * framesPerBurst / sampleRate;
     }
 
-    aaudio_nanoseconds_t getBurstPeriod() {
+    int64_t getBurstPeriod() {
         return mBurstPeriod;
     }
 
 private:
     // Start with an arbitrary default so we do not divide by zero.
-    aaudio_nanoseconds_t mBurstPeriod = AAUDIO_NANOS_PER_MILLISECOND;
-    aaudio_nanoseconds_t mStartTime;
-    aaudio_nanoseconds_t mLastTime;
+    int64_t mBurstPeriod = AAUDIO_NANOS_PER_MILLISECOND;
+    int64_t mStartTime;
+    int64_t mLastTime;
 };
 
 } /* namespace aaudio */