Loading services/oboeservice/AAudioServiceEndpoint.cpp +6 −0 Original line number Diff line number Diff line Loading @@ -60,6 +60,7 @@ std::string AAudioServiceEndpoint::dump() const { result << " Reference Count: " << mOpenCount << "\n"; result << " Requested Device Id: " << mRequestedDeviceId << "\n"; result << " Device Id: " << getDeviceId() << "\n"; result << " Connected: " << mConnected.load() << "\n"; result << " Registered Streams:" << "\n"; result << AAudioServiceStreamShared::dumpHeader() << "\n"; for (const auto stream : mRegisteredStreams) { Loading @@ -74,7 +75,9 @@ std::string AAudioServiceEndpoint::dump() const { void AAudioServiceEndpoint::disconnectRegisteredStreams() { std::lock_guard<std::mutex> lock(mLockStreams); mConnected.store(false); for (const auto stream : mRegisteredStreams) { ALOGD("disconnectRegisteredStreams() stop and disconnect %p", stream.get()); stream->stop(); stream->disconnect(); } Loading @@ -96,6 +99,9 @@ aaudio_result_t AAudioServiceEndpoint::unregisterStream(sp<AAudioServiceStreamBa } bool AAudioServiceEndpoint::matches(const AAudioStreamConfiguration& configuration) { if (!mConnected.load()) { return false; // Only use an endpoint if it is connected to a device. } if (configuration.getDirection() != getDirection()) { return false; } Loading services/oboeservice/AAudioServiceEndpoint.h +6 −0 Original line number Diff line number Diff line Loading @@ -97,6 +97,10 @@ public: mOpenCount = count; } bool isConnected() const { return mConnected; } protected: void disconnectRegisteredStreams(); Loading @@ -111,6 +115,8 @@ protected: int32_t mOpenCount = 0; int32_t mRequestedDeviceId = 0; std::atomic<bool> mConnected{true}; }; } /* namespace aaudio */ Loading services/oboeservice/AAudioServiceEndpointShared.cpp +6 −1 Original line number Diff line number Diff line Loading @@ -91,7 +91,12 @@ aaudio_result_t AAudioServiceEndpointShared::close() { static void *aaudio_endpoint_thread_proc(void *context) { AAudioServiceEndpointShared *endpoint = (AAudioServiceEndpointShared *) context; if (endpoint != NULL) { return endpoint->callbackLoop(); void *result = endpoint->callbackLoop(); // Close now so that the HW resource is freed and we can open a new device. if (!endpoint->isConnected()) { endpoint->close(); } return result; } else { return NULL; } Loading Loading
services/oboeservice/AAudioServiceEndpoint.cpp +6 −0 Original line number Diff line number Diff line Loading @@ -60,6 +60,7 @@ std::string AAudioServiceEndpoint::dump() const { result << " Reference Count: " << mOpenCount << "\n"; result << " Requested Device Id: " << mRequestedDeviceId << "\n"; result << " Device Id: " << getDeviceId() << "\n"; result << " Connected: " << mConnected.load() << "\n"; result << " Registered Streams:" << "\n"; result << AAudioServiceStreamShared::dumpHeader() << "\n"; for (const auto stream : mRegisteredStreams) { Loading @@ -74,7 +75,9 @@ std::string AAudioServiceEndpoint::dump() const { void AAudioServiceEndpoint::disconnectRegisteredStreams() { std::lock_guard<std::mutex> lock(mLockStreams); mConnected.store(false); for (const auto stream : mRegisteredStreams) { ALOGD("disconnectRegisteredStreams() stop and disconnect %p", stream.get()); stream->stop(); stream->disconnect(); } Loading @@ -96,6 +99,9 @@ aaudio_result_t AAudioServiceEndpoint::unregisterStream(sp<AAudioServiceStreamBa } bool AAudioServiceEndpoint::matches(const AAudioStreamConfiguration& configuration) { if (!mConnected.load()) { return false; // Only use an endpoint if it is connected to a device. } if (configuration.getDirection() != getDirection()) { return false; } Loading
services/oboeservice/AAudioServiceEndpoint.h +6 −0 Original line number Diff line number Diff line Loading @@ -97,6 +97,10 @@ public: mOpenCount = count; } bool isConnected() const { return mConnected; } protected: void disconnectRegisteredStreams(); Loading @@ -111,6 +115,8 @@ protected: int32_t mOpenCount = 0; int32_t mRequestedDeviceId = 0; std::atomic<bool> mConnected{true}; }; } /* namespace aaudio */ Loading
services/oboeservice/AAudioServiceEndpointShared.cpp +6 −1 Original line number Diff line number Diff line Loading @@ -91,7 +91,12 @@ aaudio_result_t AAudioServiceEndpointShared::close() { static void *aaudio_endpoint_thread_proc(void *context) { AAudioServiceEndpointShared *endpoint = (AAudioServiceEndpointShared *) context; if (endpoint != NULL) { return endpoint->callbackLoop(); void *result = endpoint->callbackLoop(); // Close now so that the HW resource is freed and we can open a new device. if (!endpoint->isConnected()) { endpoint->close(); } return result; } else { return NULL; } Loading