Fix AAudio waiting for stop SIGABRT

WaitForStateChange is a function that notifies the user if the
state moves from a specific state. When the state moves to closed,
however, a SIGABRT is thrown because waitForStateChange is in a
deleted pointer.

android::sp has a property where casting an instance to a sp increments
the usage count by 1. Thus, by adding casting the AAudioStream to a sp,
the AAudioStream is no longer deleted when the stream closes. With this
change, the SIGABRT is no longer thrown.

Bug: 63089499
Test: Ran new wait_for_state_change_closed with and without change.
Verified that the test fails before the cl and the test now passes
after the change.

Change-Id: Id865ef3f55f3cf006fd94d7b376d1b87ad999ca5
Merged-In: Id865ef3f55f3cf006fd94d7b376d1b87ad999ca5
(cherry picked from commit 676764f235ff5b0fe8c4cd6e6dcc9855d740e0f4)
2 files changed