Loading services/oboeservice/AAudioService.cpp +10 −4 Original line number Diff line number Diff line Loading @@ -78,6 +78,11 @@ void AAudioService::registerClient(const sp<IAAudioClient>& client) { AAudioClientTracker::getInstance().registerClient(pid, client); } bool AAudioService::isCallerInService() { return mAudioClient.clientPid == IPCThreadState::self()->getCallingPid() && mAudioClient.clientUid == IPCThreadState::self()->getCallingUid(); } aaudio_handle_t AAudioService::openStream(const aaudio::AAudioStreamRequest &request, aaudio::AAudioStreamConfiguration &configurationOutput) { aaudio_result_t result = AAUDIO_OK; Loading Loading @@ -105,8 +110,7 @@ aaudio_handle_t AAudioService::openStream(const aaudio::AAudioStreamRequest &req if (sharingMode == AAUDIO_SHARING_MODE_EXCLUSIVE) { // only trust audioserver for in service indication bool inService = false; if (mAudioClient.clientPid == IPCThreadState::self()->getCallingPid() && mAudioClient.clientUid == IPCThreadState::self()->getCallingUid()) { if (isCallerInService()) { inService = request.isInService(); } serviceStream = new AAudioServiceStreamMMAP(*this, inService); Loading Loading @@ -274,12 +278,14 @@ aaudio_result_t AAudioService::registerAudioThread(aaudio_handle_t streamHandle, result = AAUDIO_ERROR_INVALID_STATE; } else { const pid_t ownerPid = IPCThreadState::self()->getCallingPid(); // TODO review int32_t priority = isCallerInService() ? kRealTimeAudioPriorityService : kRealTimeAudioPriorityClient; serviceStream->setRegisteredThread(clientThreadId); int err = android::requestPriority(ownerPid, clientThreadId, DEFAULT_AUDIO_PRIORITY, true /* isForApp */); priority, true /* isForApp */); if (err != 0) { ALOGE("AAudioService::registerAudioThread(%d) failed, errno = %d, priority = %d", clientThreadId, errno, DEFAULT_AUDIO_PRIORITY); clientThreadId, errno, priority); result = AAUDIO_ERROR_INTERNAL; } } Loading services/oboeservice/AAudioService.h +8 −3 Original line number Diff line number Diff line Loading @@ -87,6 +87,10 @@ public: private: /** @return true if the client is the audioserver */ bool isCallerInService(); /** * Lookup stream and then validate access to the stream. * @param streamHandle Loading @@ -106,9 +110,10 @@ private: aaudio::AAudioStreamTracker mStreamTracker; enum constants { DEFAULT_AUDIO_PRIORITY = 2 }; // TODO Extract the priority constants from services/audioflinger/Threads.cpp // and share them with this code. Look for "kPriorityFastMixer". static constexpr int32_t kRealTimeAudioPriorityClient = 2; static constexpr int32_t kRealTimeAudioPriorityService = 3; }; } /* namespace android */ Loading Loading
services/oboeservice/AAudioService.cpp +10 −4 Original line number Diff line number Diff line Loading @@ -78,6 +78,11 @@ void AAudioService::registerClient(const sp<IAAudioClient>& client) { AAudioClientTracker::getInstance().registerClient(pid, client); } bool AAudioService::isCallerInService() { return mAudioClient.clientPid == IPCThreadState::self()->getCallingPid() && mAudioClient.clientUid == IPCThreadState::self()->getCallingUid(); } aaudio_handle_t AAudioService::openStream(const aaudio::AAudioStreamRequest &request, aaudio::AAudioStreamConfiguration &configurationOutput) { aaudio_result_t result = AAUDIO_OK; Loading Loading @@ -105,8 +110,7 @@ aaudio_handle_t AAudioService::openStream(const aaudio::AAudioStreamRequest &req if (sharingMode == AAUDIO_SHARING_MODE_EXCLUSIVE) { // only trust audioserver for in service indication bool inService = false; if (mAudioClient.clientPid == IPCThreadState::self()->getCallingPid() && mAudioClient.clientUid == IPCThreadState::self()->getCallingUid()) { if (isCallerInService()) { inService = request.isInService(); } serviceStream = new AAudioServiceStreamMMAP(*this, inService); Loading Loading @@ -274,12 +278,14 @@ aaudio_result_t AAudioService::registerAudioThread(aaudio_handle_t streamHandle, result = AAUDIO_ERROR_INVALID_STATE; } else { const pid_t ownerPid = IPCThreadState::self()->getCallingPid(); // TODO review int32_t priority = isCallerInService() ? kRealTimeAudioPriorityService : kRealTimeAudioPriorityClient; serviceStream->setRegisteredThread(clientThreadId); int err = android::requestPriority(ownerPid, clientThreadId, DEFAULT_AUDIO_PRIORITY, true /* isForApp */); priority, true /* isForApp */); if (err != 0) { ALOGE("AAudioService::registerAudioThread(%d) failed, errno = %d, priority = %d", clientThreadId, errno, DEFAULT_AUDIO_PRIORITY); clientThreadId, errno, priority); result = AAUDIO_ERROR_INTERNAL; } } Loading
services/oboeservice/AAudioService.h +8 −3 Original line number Diff line number Diff line Loading @@ -87,6 +87,10 @@ public: private: /** @return true if the client is the audioserver */ bool isCallerInService(); /** * Lookup stream and then validate access to the stream. * @param streamHandle Loading @@ -106,9 +110,10 @@ private: aaudio::AAudioStreamTracker mStreamTracker; enum constants { DEFAULT_AUDIO_PRIORITY = 2 }; // TODO Extract the priority constants from services/audioflinger/Threads.cpp // and share them with this code. Look for "kPriorityFastMixer". static constexpr int32_t kRealTimeAudioPriorityClient = 2; static constexpr int32_t kRealTimeAudioPriorityService = 3; }; } /* namespace android */ Loading