aaudio: fix EXCLUSIVE mode interfering with SHARED
The MMAP endpoints were not tracked by the EndpointManager
so it could not broker EXCLUSIVE access. To fix this the MMAP stream
was refactored to use a per-client stream and a per-device endpoint.
Cleanup close() of MMAP stream.
Add AAudioServiceEndpointShared.cpp.
Extract AAudioServiceEndpointMMAP from AAudioServiceStreamMMAP.
Track MMAP endpoints so we can manage EXCLUSIVE and SHARED access.
Bug: 64494572
Bug: 64310586
Test: see bug, use write_sine to play a shared stream and a excl stream
Change-Id: I5053193abfd9b8a69a2f7e1110739d65e2af5d64
Merged-In: I5053193abfd9b8a69a2f7e1110739d65e2af5d64
diff --git a/services/oboeservice/AAudioService.cpp b/services/oboeservice/AAudioService.cpp
index 3992719..855ae69 100644
--- a/services/oboeservice/AAudioService.cpp
+++ b/services/oboeservice/AAudioService.cpp
@@ -114,14 +114,12 @@
mAudioClient.clientUid == IPCThreadState::self()->getCallingUid()) {
inService = request.isInService();
}
- serviceStream = new AAudioServiceStreamMMAP(mAudioClient, inService);
- result = serviceStream->open(request, configurationOutput);
+ serviceStream = new AAudioServiceStreamMMAP(*this, inService);
+ result = serviceStream->open(request);
if (result != AAUDIO_OK) {
- // fall back to using a shared stream
+ // Clear it so we can possibly fall back to using a shared stream.
ALOGW("AAudioService::openStream(), could not open in EXCLUSIVE mode");
serviceStream.clear();
- } else {
- configurationOutput.setSharingMode(AAUDIO_SHARING_MODE_EXCLUSIVE);
}
}
@@ -129,8 +127,7 @@
if (sharingMode == AAUDIO_SHARING_MODE_SHARED
|| (serviceStream == nullptr && !sharingModeMatchRequired)) {
serviceStream = new AAudioServiceStreamShared(*this);
- result = serviceStream->open(request, configurationOutput);
- configurationOutput.setSharingMode(AAUDIO_SHARING_MODE_SHARED);
+ result = serviceStream->open(request);
}
if (result != AAUDIO_OK) {
@@ -149,6 +146,7 @@
serviceStream->setHandle(handle);
pid_t pid = request.getProcessId();
AAudioClientTracker::getInstance().registerClientStream(pid, serviceStream);
+ configurationOutput.copyFrom(*serviceStream);
}
return handle;
}