aaudio service: prevent disconnected endpoints from being used

Also close the internal stream used by AAudioServiceEndpointShared.

This prevents a resource leak caused by an app not closing a
disconnected stream.
It also prevents an app from reopening a device that was just
disconnected.

Bug: 67664976
Test: test_bad_disconnect.cpp should get new device ID after disconnect
Change-Id: I9a234b5704d62af788064fdd352b63181ad7e559
diff --git a/services/oboeservice/AAudioServiceEndpoint.h b/services/oboeservice/AAudioServiceEndpoint.h
index 2ef6234..6312c51 100644
--- a/services/oboeservice/AAudioServiceEndpoint.h
+++ b/services/oboeservice/AAudioServiceEndpoint.h
@@ -97,6 +97,10 @@
         mOpenCount = count;
     }
 
+    bool isConnected() const {
+        return mConnected;
+    }
+
 protected:
     void                     disconnectRegisteredStreams();
 
@@ -111,6 +115,8 @@
     int32_t                  mOpenCount = 0;
     int32_t                  mRequestedDeviceId = 0;
 
+    std::atomic<bool>        mConnected{true};
+
 };
 
 } /* namespace aaudio */