Loading media/libaaudio/src/client/AudioStreamInternal.cpp +11 −5 Original line number Diff line number Diff line Loading @@ -392,19 +392,25 @@ aaudio_result_t AudioStreamInternal::unregisterThread() { } aaudio_result_t AudioStreamInternal::startClient(const android::AudioClient& client, audio_port_handle_t *clientHandle) { audio_port_handle_t *portHandle) { ALOGV("%s() called", __func__); if (mServiceStreamHandle == AAUDIO_HANDLE_INVALID) { return AAUDIO_ERROR_INVALID_STATE; } return mServiceInterface.startClient(mServiceStreamHandle, client, clientHandle); aaudio_result_t result = mServiceInterface.startClient(mServiceStreamHandle, client, portHandle); ALOGV("%s(%d) returning %d", __func__, *portHandle, result); return result; } aaudio_result_t AudioStreamInternal::stopClient(audio_port_handle_t clientHandle) { aaudio_result_t AudioStreamInternal::stopClient(audio_port_handle_t portHandle) { ALOGV("%s(%d) called", __func__, portHandle); if (mServiceStreamHandle == AAUDIO_HANDLE_INVALID) { return AAUDIO_ERROR_INVALID_STATE; } return mServiceInterface.stopClient(mServiceStreamHandle, clientHandle); aaudio_result_t result = mServiceInterface.stopClient(mServiceStreamHandle, portHandle); ALOGV("%s(%d) returning %d", __func__, portHandle, result); return result; } aaudio_result_t AudioStreamInternal::getTimestamp(clockid_t clockId, Loading services/oboeservice/AAudioEndpointManager.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -150,7 +150,7 @@ sp<AAudioServiceEndpoint> AAudioEndpointManager::openEndpoint(AAudioService &aud } sp<AAudioServiceEndpoint> AAudioEndpointManager::openExclusiveEndpoint( AAudioService &aaudioService __unused, AAudioService &aaudioService, const aaudio::AAudioStreamRequest &request) { std::lock_guard<std::mutex> lock(mExclusiveLock); Loading @@ -166,13 +166,14 @@ sp<AAudioServiceEndpoint> AAudioEndpointManager::openExclusiveEndpoint( // Already open so do not allow a second stream. return nullptr; } else { sp<AAudioServiceEndpointMMAP> endpointMMap = new AAudioServiceEndpointMMAP(); sp<AAudioServiceEndpointMMAP> endpointMMap = new AAudioServiceEndpointMMAP(aaudioService); ALOGV("openExclusiveEndpoint(), no match so try to open MMAP %p for dev %d", endpointMMap.get(), configuration.getDeviceId()); endpoint = endpointMMap; aaudio_result_t result = endpoint->open(request); if (result != AAUDIO_OK) { ALOGE("openExclusiveEndpoint(), open failed"); endpoint.clear(); } else { mExclusiveStreams.push_back(endpointMMap); Loading services/oboeservice/AAudioService.cpp +22 −6 Original line number Diff line number Diff line Loading @@ -288,11 +288,11 @@ aaudio_result_t AAudioService::unregisterAudioThread(aaudio_handle_t streamHandl aaudio_result_t result = AAUDIO_OK; sp<AAudioServiceStreamBase> serviceStream = convertHandleToServiceStream(streamHandle); if (serviceStream.get() == nullptr) { ALOGE("unregisterAudioThread(), illegal stream handle = 0x%0x", streamHandle); ALOGE("%s(), illegal stream handle = 0x%0x", __func__, streamHandle); return AAUDIO_ERROR_INVALID_HANDLE; } if (serviceStream->getRegisteredThread() != clientThreadId) { ALOGE("AAudioService::unregisterAudioThread(), wrong thread"); ALOGE("%s(), wrong thread", __func__); result = AAUDIO_ERROR_ILLEGAL_ARGUMENT; } else { serviceStream->setRegisteredThread(0); Loading @@ -305,7 +305,7 @@ aaudio_result_t AAudioService::startClient(aaudio_handle_t streamHandle, audio_port_handle_t *clientHandle) { sp<AAudioServiceStreamBase> serviceStream = convertHandleToServiceStream(streamHandle); if (serviceStream.get() == nullptr) { ALOGE("startClient(), illegal stream handle = 0x%0x", streamHandle); ALOGE("%s(), illegal stream handle = 0x%0x", __func__, streamHandle); return AAUDIO_ERROR_INVALID_HANDLE; } aaudio_result_t result = serviceStream->startClient(client, clientHandle); Loading @@ -313,12 +313,28 @@ aaudio_result_t AAudioService::startClient(aaudio_handle_t streamHandle, } aaudio_result_t AAudioService::stopClient(aaudio_handle_t streamHandle, audio_port_handle_t clientHandle) { audio_port_handle_t portHandle) { sp<AAudioServiceStreamBase> serviceStream = convertHandleToServiceStream(streamHandle); if (serviceStream.get() == nullptr) { ALOGE("stopClient(), illegal stream handle = 0x%0x", streamHandle); ALOGE("%s(), illegal stream handle = 0x%0x", __func__, streamHandle); return AAUDIO_ERROR_INVALID_HANDLE; } aaudio_result_t result = serviceStream->stopClient(clientHandle); aaudio_result_t result = serviceStream->stopClient(portHandle); return checkForPendingClose(serviceStream, result); } // This is only called internally when AudioFlinger wants to tear down a stream. // So we do not have to check permissions. aaudio_result_t AAudioService::disconnectStreamByPortHandle(audio_port_handle_t portHandle) { ALOGD("%s(%d) called", __func__, portHandle); sp<AAudioServiceStreamBase> serviceStream = mStreamTracker.findStreamByPortHandle(portHandle); if (serviceStream.get() == nullptr) { ALOGE("%s(), could not find stream with portHandle = %d", __func__, portHandle); return AAUDIO_ERROR_INVALID_HANDLE; } serviceStream->incrementServiceReferenceCount(); aaudio_result_t result = serviceStream->stop(); serviceStream->disconnect(); return checkForPendingClose(serviceStream, result); } services/oboeservice/AAudioService.h +2 −0 Original line number Diff line number Diff line Loading @@ -83,6 +83,8 @@ public: aaudio_result_t stopClient(aaudio::aaudio_handle_t streamHandle, audio_port_handle_t clientHandle) override; aaudio_result_t disconnectStreamByPortHandle(audio_port_handle_t portHandle); private: /** Loading services/oboeservice/AAudioServiceEndpoint.cpp +11 −0 Original line number Diff line number Diff line Loading @@ -78,6 +78,17 @@ std::string AAudioServiceEndpoint::dump() const { return result.str(); } // @return true if stream found bool AAudioServiceEndpoint::isStreamRegistered(audio_port_handle_t portHandle) { std::lock_guard<std::mutex> lock(mLockStreams); for (const auto stream : mRegisteredStreams) { if (stream->getPortHandle() == portHandle) { return true; } } return false; } void AAudioServiceEndpoint::disconnectRegisteredStreams() { std::lock_guard<std::mutex> lock(mLockStreams); mConnected.store(false); Loading Loading
media/libaaudio/src/client/AudioStreamInternal.cpp +11 −5 Original line number Diff line number Diff line Loading @@ -392,19 +392,25 @@ aaudio_result_t AudioStreamInternal::unregisterThread() { } aaudio_result_t AudioStreamInternal::startClient(const android::AudioClient& client, audio_port_handle_t *clientHandle) { audio_port_handle_t *portHandle) { ALOGV("%s() called", __func__); if (mServiceStreamHandle == AAUDIO_HANDLE_INVALID) { return AAUDIO_ERROR_INVALID_STATE; } return mServiceInterface.startClient(mServiceStreamHandle, client, clientHandle); aaudio_result_t result = mServiceInterface.startClient(mServiceStreamHandle, client, portHandle); ALOGV("%s(%d) returning %d", __func__, *portHandle, result); return result; } aaudio_result_t AudioStreamInternal::stopClient(audio_port_handle_t clientHandle) { aaudio_result_t AudioStreamInternal::stopClient(audio_port_handle_t portHandle) { ALOGV("%s(%d) called", __func__, portHandle); if (mServiceStreamHandle == AAUDIO_HANDLE_INVALID) { return AAUDIO_ERROR_INVALID_STATE; } return mServiceInterface.stopClient(mServiceStreamHandle, clientHandle); aaudio_result_t result = mServiceInterface.stopClient(mServiceStreamHandle, portHandle); ALOGV("%s(%d) returning %d", __func__, portHandle, result); return result; } aaudio_result_t AudioStreamInternal::getTimestamp(clockid_t clockId, Loading
services/oboeservice/AAudioEndpointManager.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -150,7 +150,7 @@ sp<AAudioServiceEndpoint> AAudioEndpointManager::openEndpoint(AAudioService &aud } sp<AAudioServiceEndpoint> AAudioEndpointManager::openExclusiveEndpoint( AAudioService &aaudioService __unused, AAudioService &aaudioService, const aaudio::AAudioStreamRequest &request) { std::lock_guard<std::mutex> lock(mExclusiveLock); Loading @@ -166,13 +166,14 @@ sp<AAudioServiceEndpoint> AAudioEndpointManager::openExclusiveEndpoint( // Already open so do not allow a second stream. return nullptr; } else { sp<AAudioServiceEndpointMMAP> endpointMMap = new AAudioServiceEndpointMMAP(); sp<AAudioServiceEndpointMMAP> endpointMMap = new AAudioServiceEndpointMMAP(aaudioService); ALOGV("openExclusiveEndpoint(), no match so try to open MMAP %p for dev %d", endpointMMap.get(), configuration.getDeviceId()); endpoint = endpointMMap; aaudio_result_t result = endpoint->open(request); if (result != AAUDIO_OK) { ALOGE("openExclusiveEndpoint(), open failed"); endpoint.clear(); } else { mExclusiveStreams.push_back(endpointMMap); Loading
services/oboeservice/AAudioService.cpp +22 −6 Original line number Diff line number Diff line Loading @@ -288,11 +288,11 @@ aaudio_result_t AAudioService::unregisterAudioThread(aaudio_handle_t streamHandl aaudio_result_t result = AAUDIO_OK; sp<AAudioServiceStreamBase> serviceStream = convertHandleToServiceStream(streamHandle); if (serviceStream.get() == nullptr) { ALOGE("unregisterAudioThread(), illegal stream handle = 0x%0x", streamHandle); ALOGE("%s(), illegal stream handle = 0x%0x", __func__, streamHandle); return AAUDIO_ERROR_INVALID_HANDLE; } if (serviceStream->getRegisteredThread() != clientThreadId) { ALOGE("AAudioService::unregisterAudioThread(), wrong thread"); ALOGE("%s(), wrong thread", __func__); result = AAUDIO_ERROR_ILLEGAL_ARGUMENT; } else { serviceStream->setRegisteredThread(0); Loading @@ -305,7 +305,7 @@ aaudio_result_t AAudioService::startClient(aaudio_handle_t streamHandle, audio_port_handle_t *clientHandle) { sp<AAudioServiceStreamBase> serviceStream = convertHandleToServiceStream(streamHandle); if (serviceStream.get() == nullptr) { ALOGE("startClient(), illegal stream handle = 0x%0x", streamHandle); ALOGE("%s(), illegal stream handle = 0x%0x", __func__, streamHandle); return AAUDIO_ERROR_INVALID_HANDLE; } aaudio_result_t result = serviceStream->startClient(client, clientHandle); Loading @@ -313,12 +313,28 @@ aaudio_result_t AAudioService::startClient(aaudio_handle_t streamHandle, } aaudio_result_t AAudioService::stopClient(aaudio_handle_t streamHandle, audio_port_handle_t clientHandle) { audio_port_handle_t portHandle) { sp<AAudioServiceStreamBase> serviceStream = convertHandleToServiceStream(streamHandle); if (serviceStream.get() == nullptr) { ALOGE("stopClient(), illegal stream handle = 0x%0x", streamHandle); ALOGE("%s(), illegal stream handle = 0x%0x", __func__, streamHandle); return AAUDIO_ERROR_INVALID_HANDLE; } aaudio_result_t result = serviceStream->stopClient(clientHandle); aaudio_result_t result = serviceStream->stopClient(portHandle); return checkForPendingClose(serviceStream, result); } // This is only called internally when AudioFlinger wants to tear down a stream. // So we do not have to check permissions. aaudio_result_t AAudioService::disconnectStreamByPortHandle(audio_port_handle_t portHandle) { ALOGD("%s(%d) called", __func__, portHandle); sp<AAudioServiceStreamBase> serviceStream = mStreamTracker.findStreamByPortHandle(portHandle); if (serviceStream.get() == nullptr) { ALOGE("%s(), could not find stream with portHandle = %d", __func__, portHandle); return AAUDIO_ERROR_INVALID_HANDLE; } serviceStream->incrementServiceReferenceCount(); aaudio_result_t result = serviceStream->stop(); serviceStream->disconnect(); return checkForPendingClose(serviceStream, result); }
services/oboeservice/AAudioService.h +2 −0 Original line number Diff line number Diff line Loading @@ -83,6 +83,8 @@ public: aaudio_result_t stopClient(aaudio::aaudio_handle_t streamHandle, audio_port_handle_t clientHandle) override; aaudio_result_t disconnectStreamByPortHandle(audio_port_handle_t portHandle); private: /** Loading
services/oboeservice/AAudioServiceEndpoint.cpp +11 −0 Original line number Diff line number Diff line Loading @@ -78,6 +78,17 @@ std::string AAudioServiceEndpoint::dump() const { return result.str(); } // @return true if stream found bool AAudioServiceEndpoint::isStreamRegistered(audio_port_handle_t portHandle) { std::lock_guard<std::mutex> lock(mLockStreams); for (const auto stream : mRegisteredStreams) { if (stream->getPortHandle() == portHandle) { return true; } } return false; } void AAudioServiceEndpoint::disconnectRegisteredStreams() { std::lock_guard<std::mutex> lock(mLockStreams); mConnected.store(false); Loading