Loading services/oboeservice/AAudioServiceEndpointMMAP.cpp +22 −10 Original line number Diff line number Diff line Loading @@ -23,10 +23,10 @@ #include <map> #include <mutex> #include <sstream> #include <thread> #include <utils/Singleton.h> #include <vector> #include "AAudioEndpointManager.h" #include "AAudioServiceEndpoint.h" Loading @@ -36,7 +36,6 @@ #include "AAudioServiceEndpointPlay.h" #include "AAudioServiceEndpointMMAP.h" #define AAUDIO_BUFFER_CAPACITY_MIN 4 * 512 #define AAUDIO_SAMPLE_RATE_DEFAULT 48000 Loading @@ -48,7 +47,6 @@ using namespace android; // TODO just import names needed using namespace aaudio; // TODO just import names needed AAudioServiceEndpointMMAP::AAudioServiceEndpointMMAP(AAudioService &audioService) : mMmapStream(nullptr) , mAAudioService(audioService) {} Loading Loading @@ -318,9 +316,8 @@ aaudio_result_t AAudioServiceEndpointMMAP::getTimestamp(int64_t *positionFrames, return 0; // TODO } // This is called by AudioFlinger when it wants to destroy a stream. void AAudioServiceEndpointMMAP::onTearDown(audio_port_handle_t portHandle) { ALOGD("%s(portHandle = %d) called", __func__, portHandle); // This is called by onTearDown() in a separate thread to avoid deadlocks. void AAudioServiceEndpointMMAP::handleTearDownAsync(audio_port_handle_t portHandle) { // Are we tearing down the EXCLUSIVE MMAP stream? if (isStreamRegistered(portHandle)) { ALOGD("%s(%d) tearing down this entire MMAP endpoint", __func__, portHandle); Loading @@ -333,6 +330,13 @@ void AAudioServiceEndpointMMAP::onTearDown(audio_port_handle_t portHandle) { } }; // This is called by AudioFlinger when it wants to destroy a stream. void AAudioServiceEndpointMMAP::onTearDown(audio_port_handle_t portHandle) { ALOGD("%s(portHandle = %d) called", __func__, portHandle); std::thread asyncTask(&AAudioServiceEndpointMMAP::handleTearDownAsync, this, portHandle); asyncTask.detach(); } void AAudioServiceEndpointMMAP::onVolumeChanged(audio_channel_mask_t channels, android::Vector<float> values) { // TODO Do we really need a different volume for each channel? Loading @@ -345,12 +349,20 @@ void AAudioServiceEndpointMMAP::onVolumeChanged(audio_channel_mask_t channels, } }; void AAudioServiceEndpointMMAP::onRoutingChanged(audio_port_handle_t deviceId) { void AAudioServiceEndpointMMAP::onRoutingChanged(audio_port_handle_t portHandle) { const int32_t deviceId = static_cast<int32_t>(portHandle); ALOGD("%s() called with dev %d, old = %d", __func__, deviceId, getDeviceId()); if (getDeviceId() != AUDIO_PORT_HANDLE_NONE && getDeviceId() != deviceId) { if (getDeviceId() != deviceId) { if (getDeviceId() != AUDIO_PORT_HANDLE_NONE) { std::thread asyncTask([this, deviceId]() { disconnectRegisteredStreams(); } setDeviceId(deviceId); }); asyncTask.detach(); } else { setDeviceId(deviceId); } } }; /** Loading services/oboeservice/AAudioServiceEndpointMMAP.h +4 −2 Original line number Diff line number Diff line Loading @@ -68,13 +68,15 @@ public: aaudio_result_t getTimestamp(int64_t *positionFrames, int64_t *timeNanos) override; void handleTearDownAsync(audio_port_handle_t portHandle); // -------------- Callback functions for MmapStreamCallback --------------------- void onTearDown(audio_port_handle_t handle) override; void onTearDown(audio_port_handle_t portHandle) override; void onVolumeChanged(audio_channel_mask_t channels, android::Vector<float> values) override; void onRoutingChanged(audio_port_handle_t deviceId) override; void onRoutingChanged(audio_port_handle_t portHandle) override; // ------------------------------------------------------------------------------ aaudio_result_t getDownDataDescription(AudioEndpointParcelable &parcelable); Loading Loading
services/oboeservice/AAudioServiceEndpointMMAP.cpp +22 −10 Original line number Diff line number Diff line Loading @@ -23,10 +23,10 @@ #include <map> #include <mutex> #include <sstream> #include <thread> #include <utils/Singleton.h> #include <vector> #include "AAudioEndpointManager.h" #include "AAudioServiceEndpoint.h" Loading @@ -36,7 +36,6 @@ #include "AAudioServiceEndpointPlay.h" #include "AAudioServiceEndpointMMAP.h" #define AAUDIO_BUFFER_CAPACITY_MIN 4 * 512 #define AAUDIO_SAMPLE_RATE_DEFAULT 48000 Loading @@ -48,7 +47,6 @@ using namespace android; // TODO just import names needed using namespace aaudio; // TODO just import names needed AAudioServiceEndpointMMAP::AAudioServiceEndpointMMAP(AAudioService &audioService) : mMmapStream(nullptr) , mAAudioService(audioService) {} Loading Loading @@ -318,9 +316,8 @@ aaudio_result_t AAudioServiceEndpointMMAP::getTimestamp(int64_t *positionFrames, return 0; // TODO } // This is called by AudioFlinger when it wants to destroy a stream. void AAudioServiceEndpointMMAP::onTearDown(audio_port_handle_t portHandle) { ALOGD("%s(portHandle = %d) called", __func__, portHandle); // This is called by onTearDown() in a separate thread to avoid deadlocks. void AAudioServiceEndpointMMAP::handleTearDownAsync(audio_port_handle_t portHandle) { // Are we tearing down the EXCLUSIVE MMAP stream? if (isStreamRegistered(portHandle)) { ALOGD("%s(%d) tearing down this entire MMAP endpoint", __func__, portHandle); Loading @@ -333,6 +330,13 @@ void AAudioServiceEndpointMMAP::onTearDown(audio_port_handle_t portHandle) { } }; // This is called by AudioFlinger when it wants to destroy a stream. void AAudioServiceEndpointMMAP::onTearDown(audio_port_handle_t portHandle) { ALOGD("%s(portHandle = %d) called", __func__, portHandle); std::thread asyncTask(&AAudioServiceEndpointMMAP::handleTearDownAsync, this, portHandle); asyncTask.detach(); } void AAudioServiceEndpointMMAP::onVolumeChanged(audio_channel_mask_t channels, android::Vector<float> values) { // TODO Do we really need a different volume for each channel? Loading @@ -345,12 +349,20 @@ void AAudioServiceEndpointMMAP::onVolumeChanged(audio_channel_mask_t channels, } }; void AAudioServiceEndpointMMAP::onRoutingChanged(audio_port_handle_t deviceId) { void AAudioServiceEndpointMMAP::onRoutingChanged(audio_port_handle_t portHandle) { const int32_t deviceId = static_cast<int32_t>(portHandle); ALOGD("%s() called with dev %d, old = %d", __func__, deviceId, getDeviceId()); if (getDeviceId() != AUDIO_PORT_HANDLE_NONE && getDeviceId() != deviceId) { if (getDeviceId() != deviceId) { if (getDeviceId() != AUDIO_PORT_HANDLE_NONE) { std::thread asyncTask([this, deviceId]() { disconnectRegisteredStreams(); } setDeviceId(deviceId); }); asyncTask.detach(); } else { setDeviceId(deviceId); } } }; /** Loading
services/oboeservice/AAudioServiceEndpointMMAP.h +4 −2 Original line number Diff line number Diff line Loading @@ -68,13 +68,15 @@ public: aaudio_result_t getTimestamp(int64_t *positionFrames, int64_t *timeNanos) override; void handleTearDownAsync(audio_port_handle_t portHandle); // -------------- Callback functions for MmapStreamCallback --------------------- void onTearDown(audio_port_handle_t handle) override; void onTearDown(audio_port_handle_t portHandle) override; void onVolumeChanged(audio_channel_mask_t channels, android::Vector<float> values) override; void onRoutingChanged(audio_port_handle_t deviceId) override; void onRoutingChanged(audio_port_handle_t portHandle) override; // ------------------------------------------------------------------------------ aaudio_result_t getDownDataDescription(AudioEndpointParcelable &parcelable); Loading