Loading drm/libmediadrm/DrmHal.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -1186,9 +1186,9 @@ status_t DrmHal::setCipherAlgorithm(Vector<uint8_t> const &sessionId, DrmSessionManager::Instance()->useSession(sessionId); Status status = mPlugin->setCipherAlgorithm(toHidlVec(sessionId), Return<Status> status = mPlugin->setCipherAlgorithm(toHidlVec(sessionId), toHidlString(algorithm)); return toStatusT(status); return status.isOk() ? toStatusT(status) : DEAD_OBJECT; } status_t DrmHal::setMacAlgorithm(Vector<uint8_t> const &sessionId, Loading @@ -1198,9 +1198,9 @@ status_t DrmHal::setMacAlgorithm(Vector<uint8_t> const &sessionId, DrmSessionManager::Instance()->useSession(sessionId); Status status = mPlugin->setMacAlgorithm(toHidlVec(sessionId), Return<Status> status = mPlugin->setMacAlgorithm(toHidlVec(sessionId), toHidlString(algorithm)); return toStatusT(status); return status.isOk() ? toStatusT(status) : DEAD_OBJECT; } status_t DrmHal::encrypt(Vector<uint8_t> const &sessionId, Loading services/audioflinger/Threads.cpp +11 −2 Original line number Diff line number Diff line Loading @@ -6603,8 +6603,17 @@ reacquire_wakelock: if (mPipeSource != 0) { size_t framesToRead = mBufferSize / mFrameSize; framesToRead = min(mRsmpInFramesOA - rear, mRsmpInFramesP2 / 2); // The audio fifo read() returns OVERRUN on overflow, and advances the read pointer // to the full buffer point (clearing the overflow condition). Upon OVERRUN error, // we immediately retry the read() to get data and prevent another overflow. for (int retries = 0; retries <= 2; ++retries) { ALOGW_IF(retries > 0, "overrun on read from pipe, retry #%d", retries); framesRead = mPipeSource->read((uint8_t*)mRsmpInBuffer + rear * mFrameSize, framesToRead); if (framesRead != OVERRUN) break; } // since pipe is non-blocking, simulate blocking input by waiting for 1/2 of // buffer size or at least for 20ms. size_t sleepFrames = max( Loading services/oboeservice/AAudioServiceEndpoint.h +2 −2 Original line number Diff line number Diff line Loading @@ -49,9 +49,9 @@ public: virtual aaudio_result_t close() = 0; virtual aaudio_result_t registerStream(android::sp<AAudioServiceStreamBase> stream); aaudio_result_t registerStream(android::sp<AAudioServiceStreamBase> stream); virtual aaudio_result_t unregisterStream(android::sp<AAudioServiceStreamBase> stream); aaudio_result_t unregisterStream(android::sp<AAudioServiceStreamBase> stream); virtual aaudio_result_t startStream(android::sp<AAudioServiceStreamBase> stream, audio_port_handle_t *clientHandle) = 0; Loading services/oboeservice/AAudioServiceStreamBase.cpp +34 −24 Original line number Diff line number Diff line Loading @@ -105,6 +105,9 @@ aaudio_result_t AAudioServiceStreamBase::open(const aaudio::AAudioStreamRequest goto error; } // This is not protected by a lock because the stream cannot be // referenced until the service returns a handle to the client. // So only one thread can open a stream. mServiceEndpoint = mEndpointManager.openEndpoint(mAudioService, request, sharingMode); Loading @@ -113,6 +116,9 @@ aaudio_result_t AAudioServiceStreamBase::open(const aaudio::AAudioStreamRequest result = AAUDIO_ERROR_UNAVAILABLE; goto error; } // Save a weak pointer that we will use to access the endpoint. mServiceEndpointWeak = mServiceEndpoint; mFramesPerBurst = mServiceEndpoint->getFramesPerBurst(); copyFrom(*mServiceEndpoint); } Loading @@ -131,13 +137,16 @@ aaudio_result_t AAudioServiceStreamBase::close() { stop(); if (mServiceEndpoint == nullptr) { sp<AAudioServiceEndpoint> endpoint = mServiceEndpointWeak.promote(); if (endpoint == nullptr) { result = AAUDIO_ERROR_INVALID_STATE; } else { mServiceEndpoint->unregisterStream(this); AAudioEndpointManager &mEndpointManager = AAudioEndpointManager::getInstance(); mEndpointManager.closeEndpoint(mServiceEndpoint); mServiceEndpoint.clear(); endpoint->unregisterStream(this); AAudioEndpointManager &endpointManager = AAudioEndpointManager::getInstance(); endpointManager.closeEndpoint(endpoint); // AAudioService::closeStream() prevents two threads from closing at the same time. mServiceEndpoint.clear(); // endpoint will hold the pointer until this method returns. } { Loading @@ -153,7 +162,12 @@ aaudio_result_t AAudioServiceStreamBase::close() { aaudio_result_t AAudioServiceStreamBase::startDevice() { mClientHandle = AUDIO_PORT_HANDLE_NONE; return mServiceEndpoint->startStream(this, &mClientHandle); sp<AAudioServiceEndpoint> endpoint = mServiceEndpointWeak.promote(); if (endpoint == nullptr) { ALOGE("%s() has no endpoint", __func__); return AAUDIO_ERROR_INVALID_STATE; } return endpoint->startStream(this, &mClientHandle); } /** Loading @@ -163,16 +177,11 @@ aaudio_result_t AAudioServiceStreamBase::startDevice() { */ aaudio_result_t AAudioServiceStreamBase::start() { aaudio_result_t result = AAUDIO_OK; if (isRunning()) { return AAUDIO_OK; } if (mServiceEndpoint == nullptr) { ALOGE("%s() missing endpoint", __func__); result = AAUDIO_ERROR_INVALID_STATE; goto error; } setFlowing(false); // Start with fresh presentation timestamps. Loading Loading @@ -201,10 +210,6 @@ aaudio_result_t AAudioServiceStreamBase::pause() { if (!isRunning()) { return result; } if (mServiceEndpoint == nullptr) { ALOGE("%s() missing endpoint", __func__); return AAUDIO_ERROR_INVALID_STATE; } // Send it now because the timestamp gets rounded up when stopStream() is called below. // Also we don't need the timestamps while we are shutting down. Loading @@ -216,7 +221,12 @@ aaudio_result_t AAudioServiceStreamBase::pause() { return result; } result = mServiceEndpoint->stopStream(this, mClientHandle); sp<AAudioServiceEndpoint> endpoint = mServiceEndpointWeak.promote(); if (endpoint == nullptr) { ALOGE("%s() has no endpoint", __func__); return AAUDIO_ERROR_INVALID_STATE; } result = endpoint->stopStream(this, mClientHandle); if (result != AAUDIO_OK) { ALOGE("%s() mServiceEndpoint returned %d, %s", __func__, result, getTypeText()); disconnect(); // TODO should we return or pause Base first? Loading @@ -233,11 +243,6 @@ aaudio_result_t AAudioServiceStreamBase::stop() { return result; } if (mServiceEndpoint == nullptr) { ALOGE("%s() missing endpoint", __func__); return AAUDIO_ERROR_INVALID_STATE; } setState(AAUDIO_STREAM_STATE_STOPPING); // Send it now because the timestamp gets rounded up when stopStream() is called below. Loading @@ -249,10 +254,15 @@ aaudio_result_t AAudioServiceStreamBase::stop() { return result; } sp<AAudioServiceEndpoint> endpoint = mServiceEndpointWeak.promote(); if (endpoint == nullptr) { ALOGE("%s() has no endpoint", __func__); return AAUDIO_ERROR_INVALID_STATE; } // TODO wait for data to be played out result = mServiceEndpoint->stopStream(this, mClientHandle); result = endpoint->stopStream(this, mClientHandle); if (result != AAUDIO_OK) { ALOGE("%s() mServiceEndpoint returned %d, %s", __func__, result, getTypeText()); ALOGE("%s() stopStream returned %d, %s", __func__, result, getTypeText()); disconnect(); // TODO what to do with result here? } Loading services/oboeservice/AAudioServiceStreamBase.h +5 −0 Original line number Diff line number Diff line Loading @@ -279,7 +279,12 @@ protected: SimpleDoubleBuffer<Timestamp> mAtomicTimestamp; android::AAudioService &mAudioService; // The mServiceEndpoint variable can be accessed by multiple threads. // So we access it by locally promoting a weak pointer to a smart pointer, // which is thread-safe. android::sp<AAudioServiceEndpoint> mServiceEndpoint; android::wp<AAudioServiceEndpoint> mServiceEndpointWeak; private: aaudio_handle_t mHandle = -1; Loading Loading
drm/libmediadrm/DrmHal.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -1186,9 +1186,9 @@ status_t DrmHal::setCipherAlgorithm(Vector<uint8_t> const &sessionId, DrmSessionManager::Instance()->useSession(sessionId); Status status = mPlugin->setCipherAlgorithm(toHidlVec(sessionId), Return<Status> status = mPlugin->setCipherAlgorithm(toHidlVec(sessionId), toHidlString(algorithm)); return toStatusT(status); return status.isOk() ? toStatusT(status) : DEAD_OBJECT; } status_t DrmHal::setMacAlgorithm(Vector<uint8_t> const &sessionId, Loading @@ -1198,9 +1198,9 @@ status_t DrmHal::setMacAlgorithm(Vector<uint8_t> const &sessionId, DrmSessionManager::Instance()->useSession(sessionId); Status status = mPlugin->setMacAlgorithm(toHidlVec(sessionId), Return<Status> status = mPlugin->setMacAlgorithm(toHidlVec(sessionId), toHidlString(algorithm)); return toStatusT(status); return status.isOk() ? toStatusT(status) : DEAD_OBJECT; } status_t DrmHal::encrypt(Vector<uint8_t> const &sessionId, Loading
services/audioflinger/Threads.cpp +11 −2 Original line number Diff line number Diff line Loading @@ -6603,8 +6603,17 @@ reacquire_wakelock: if (mPipeSource != 0) { size_t framesToRead = mBufferSize / mFrameSize; framesToRead = min(mRsmpInFramesOA - rear, mRsmpInFramesP2 / 2); // The audio fifo read() returns OVERRUN on overflow, and advances the read pointer // to the full buffer point (clearing the overflow condition). Upon OVERRUN error, // we immediately retry the read() to get data and prevent another overflow. for (int retries = 0; retries <= 2; ++retries) { ALOGW_IF(retries > 0, "overrun on read from pipe, retry #%d", retries); framesRead = mPipeSource->read((uint8_t*)mRsmpInBuffer + rear * mFrameSize, framesToRead); if (framesRead != OVERRUN) break; } // since pipe is non-blocking, simulate blocking input by waiting for 1/2 of // buffer size or at least for 20ms. size_t sleepFrames = max( Loading
services/oboeservice/AAudioServiceEndpoint.h +2 −2 Original line number Diff line number Diff line Loading @@ -49,9 +49,9 @@ public: virtual aaudio_result_t close() = 0; virtual aaudio_result_t registerStream(android::sp<AAudioServiceStreamBase> stream); aaudio_result_t registerStream(android::sp<AAudioServiceStreamBase> stream); virtual aaudio_result_t unregisterStream(android::sp<AAudioServiceStreamBase> stream); aaudio_result_t unregisterStream(android::sp<AAudioServiceStreamBase> stream); virtual aaudio_result_t startStream(android::sp<AAudioServiceStreamBase> stream, audio_port_handle_t *clientHandle) = 0; Loading
services/oboeservice/AAudioServiceStreamBase.cpp +34 −24 Original line number Diff line number Diff line Loading @@ -105,6 +105,9 @@ aaudio_result_t AAudioServiceStreamBase::open(const aaudio::AAudioStreamRequest goto error; } // This is not protected by a lock because the stream cannot be // referenced until the service returns a handle to the client. // So only one thread can open a stream. mServiceEndpoint = mEndpointManager.openEndpoint(mAudioService, request, sharingMode); Loading @@ -113,6 +116,9 @@ aaudio_result_t AAudioServiceStreamBase::open(const aaudio::AAudioStreamRequest result = AAUDIO_ERROR_UNAVAILABLE; goto error; } // Save a weak pointer that we will use to access the endpoint. mServiceEndpointWeak = mServiceEndpoint; mFramesPerBurst = mServiceEndpoint->getFramesPerBurst(); copyFrom(*mServiceEndpoint); } Loading @@ -131,13 +137,16 @@ aaudio_result_t AAudioServiceStreamBase::close() { stop(); if (mServiceEndpoint == nullptr) { sp<AAudioServiceEndpoint> endpoint = mServiceEndpointWeak.promote(); if (endpoint == nullptr) { result = AAUDIO_ERROR_INVALID_STATE; } else { mServiceEndpoint->unregisterStream(this); AAudioEndpointManager &mEndpointManager = AAudioEndpointManager::getInstance(); mEndpointManager.closeEndpoint(mServiceEndpoint); mServiceEndpoint.clear(); endpoint->unregisterStream(this); AAudioEndpointManager &endpointManager = AAudioEndpointManager::getInstance(); endpointManager.closeEndpoint(endpoint); // AAudioService::closeStream() prevents two threads from closing at the same time. mServiceEndpoint.clear(); // endpoint will hold the pointer until this method returns. } { Loading @@ -153,7 +162,12 @@ aaudio_result_t AAudioServiceStreamBase::close() { aaudio_result_t AAudioServiceStreamBase::startDevice() { mClientHandle = AUDIO_PORT_HANDLE_NONE; return mServiceEndpoint->startStream(this, &mClientHandle); sp<AAudioServiceEndpoint> endpoint = mServiceEndpointWeak.promote(); if (endpoint == nullptr) { ALOGE("%s() has no endpoint", __func__); return AAUDIO_ERROR_INVALID_STATE; } return endpoint->startStream(this, &mClientHandle); } /** Loading @@ -163,16 +177,11 @@ aaudio_result_t AAudioServiceStreamBase::startDevice() { */ aaudio_result_t AAudioServiceStreamBase::start() { aaudio_result_t result = AAUDIO_OK; if (isRunning()) { return AAUDIO_OK; } if (mServiceEndpoint == nullptr) { ALOGE("%s() missing endpoint", __func__); result = AAUDIO_ERROR_INVALID_STATE; goto error; } setFlowing(false); // Start with fresh presentation timestamps. Loading Loading @@ -201,10 +210,6 @@ aaudio_result_t AAudioServiceStreamBase::pause() { if (!isRunning()) { return result; } if (mServiceEndpoint == nullptr) { ALOGE("%s() missing endpoint", __func__); return AAUDIO_ERROR_INVALID_STATE; } // Send it now because the timestamp gets rounded up when stopStream() is called below. // Also we don't need the timestamps while we are shutting down. Loading @@ -216,7 +221,12 @@ aaudio_result_t AAudioServiceStreamBase::pause() { return result; } result = mServiceEndpoint->stopStream(this, mClientHandle); sp<AAudioServiceEndpoint> endpoint = mServiceEndpointWeak.promote(); if (endpoint == nullptr) { ALOGE("%s() has no endpoint", __func__); return AAUDIO_ERROR_INVALID_STATE; } result = endpoint->stopStream(this, mClientHandle); if (result != AAUDIO_OK) { ALOGE("%s() mServiceEndpoint returned %d, %s", __func__, result, getTypeText()); disconnect(); // TODO should we return or pause Base first? Loading @@ -233,11 +243,6 @@ aaudio_result_t AAudioServiceStreamBase::stop() { return result; } if (mServiceEndpoint == nullptr) { ALOGE("%s() missing endpoint", __func__); return AAUDIO_ERROR_INVALID_STATE; } setState(AAUDIO_STREAM_STATE_STOPPING); // Send it now because the timestamp gets rounded up when stopStream() is called below. Loading @@ -249,10 +254,15 @@ aaudio_result_t AAudioServiceStreamBase::stop() { return result; } sp<AAudioServiceEndpoint> endpoint = mServiceEndpointWeak.promote(); if (endpoint == nullptr) { ALOGE("%s() has no endpoint", __func__); return AAUDIO_ERROR_INVALID_STATE; } // TODO wait for data to be played out result = mServiceEndpoint->stopStream(this, mClientHandle); result = endpoint->stopStream(this, mClientHandle); if (result != AAUDIO_OK) { ALOGE("%s() mServiceEndpoint returned %d, %s", __func__, result, getTypeText()); ALOGE("%s() stopStream returned %d, %s", __func__, result, getTypeText()); disconnect(); // TODO what to do with result here? } Loading
services/oboeservice/AAudioServiceStreamBase.h +5 −0 Original line number Diff line number Diff line Loading @@ -279,7 +279,12 @@ protected: SimpleDoubleBuffer<Timestamp> mAtomicTimestamp; android::AAudioService &mAudioService; // The mServiceEndpoint variable can be accessed by multiple threads. // So we access it by locally promoting a weak pointer to a smart pointer, // which is thread-safe. android::sp<AAudioServiceEndpoint> mServiceEndpoint; android::wp<AAudioServiceEndpoint> mServiceEndpointWeak; private: aaudio_handle_t mHandle = -1; Loading