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