Fix non-blocking playback threads creation

Because PlaybackThread calls StreamOutHal::setCallback inside
the constructor, onFirstRef gets called while the vtable pointer
is set to PlaybackThread's vtable, not to its subclass vtable.
onFirstRef launches a thread which starts calling methods
that are abstract in PlaybackThread.

Fixed by changing the type of StreamOutHal::setCallback argument
from "sp" to "wp", as creating a weak pointer does not increase
strong refs count and thus doesn't call onFirstRef.

Bug: 31856492
Change-Id: I0d51bc73ca88b4b235260ed773870ecb7dac55d0
Test: added logging to verify the order of calls
diff --git a/media/libaudiohal/StreamHalLocal.cpp b/media/libaudiohal/StreamHalLocal.cpp
index cd97cc8..59314eb 100644
--- a/media/libaudiohal/StreamHalLocal.cpp
+++ b/media/libaudiohal/StreamHalLocal.cpp
@@ -140,7 +140,7 @@
     return mStream->get_next_write_timestamp(mStream, timestamp);
 }
 
-status_t StreamOutHalLocal::setCallback(sp<StreamOutHalInterfaceCallback> callback) {
+status_t StreamOutHalLocal::setCallback(wp<StreamOutHalInterfaceCallback> callback) {
     if (mStream->set_callback == NULL) return INVALID_OPERATION;
     status_t result = mStream->set_callback(mStream, StreamOutHalLocal::asyncCallback, this);
     if (result == OK) {
diff --git a/media/libaudiohal/StreamHalLocal.h b/media/libaudiohal/StreamHalLocal.h
index 7144e65..5e6f41a 100644
--- a/media/libaudiohal/StreamHalLocal.h
+++ b/media/libaudiohal/StreamHalLocal.h
@@ -92,7 +92,7 @@
     virtual status_t getNextWriteTimestamp(int64_t *timestamp);
 
     // Set the callback for notifying completion of non-blocking write and drain.
-    virtual status_t setCallback(sp<StreamOutHalInterfaceCallback> callback);
+    virtual status_t setCallback(wp<StreamOutHalInterfaceCallback> callback);
 
     // Returns whether pause and resume operations are supported.
     virtual status_t supportsPauseAndResume(bool *supportsPause, bool *supportsResume);