aaudio: cleanup thread handling

Fix problem when an attempt is made to join the callback from the
callback. It used to leave mHasThread in the wrong state.
This was fixed in AAudioThread and in AudioStream.

Add "_l" suffix to functions that need to be locked.

Simplify the way that reference counted objects are passed to threads
using incStrong() and decStrong().

Bug: 171296283
Test: atest AAudioTestCases
Change-Id: I034049c4cb9021c6073fff441e49214ee898b804
diff --git a/media/libaaudio/src/client/AudioStreamInternal.h b/media/libaaudio/src/client/AudioStreamInternal.h
index d7024cf..1838b53 100644
--- a/media/libaaudio/src/client/AudioStreamInternal.h
+++ b/media/libaaudio/src/client/AudioStreamInternal.h
@@ -44,9 +44,9 @@
     AudioStreamInternal(AAudioServiceInterface  &serviceInterface, bool inService);
     virtual ~AudioStreamInternal();
 
-    aaudio_result_t requestStart() override;
+    aaudio_result_t requestStart_l() override;
 
-    aaudio_result_t requestStop() override;
+    aaudio_result_t requestStop_l() override;
 
     aaudio_result_t getTimestamp(clockid_t clockId,
                                        int64_t *framePosition,
@@ -117,7 +117,9 @@
 
     aaudio_result_t processCommands();
 
-    aaudio_result_t stopCallback();
+    aaudio_result_t stopCallback_l();
+
+    aaudio_result_t joinThread_l(void** returnArg);
 
     virtual void prepareBuffersForStart() {}