From 4c6e77ff8e18a1551320a6b42f6a45e19dcce748 Mon Sep 17 00:00:00 2001 From: Andy Hung Date: Mon, 21 Sep 2015 12:44:54 -0700 Subject: AudioFlinger: Clear record buffers when starting RecordThread Bug: 24211743 Bug: 24267152 Change-Id: I58c55e56b85067b71e4e300f947b4dfc159637ba --- services/audioflinger/FastCapture.cpp | 4 +++- services/audioflinger/Threads.cpp | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'services') diff --git a/services/audioflinger/FastCapture.cpp b/services/audioflinger/FastCapture.cpp index 79ac12b..1bba5f6 100644 --- a/services/audioflinger/FastCapture.cpp +++ b/services/audioflinger/FastCapture.cpp @@ -131,7 +131,9 @@ void FastCapture::onStateChange() // FIXME new may block for unbounded time at internal mutex of the heap // implementation; it would be better to have normal capture thread allocate for // us to avoid blocking here and to prevent possible priority inversion - (void)posix_memalign(&mReadBuffer, 32, frameCount * Format_frameSize(mFormat)); + size_t bufferSize = frameCount * Format_frameSize(mFormat); + (void)posix_memalign(&mReadBuffer, 32, bufferSize); + memset(mReadBuffer, 0, bufferSize); // if posix_memalign fails, will segv here. mPeriodNs = (frameCount * 1000000000LL) / mSampleRate; // 1.00 mUnderrunNs = (frameCount * 1750000000LL) / mSampleRate; // 1.75 mOverrunNs = (frameCount * 500000000LL) / mSampleRate; // 0.50 diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp index 0a7d4a2..246f6ba 100644 --- a/services/audioflinger/Threads.cpp +++ b/services/audioflinger/Threads.cpp @@ -6926,6 +6926,7 @@ void AudioFlinger::RecordThread::readInputParameters_l() mRsmpInFrames = mFrameCount * 7; mRsmpInFramesP2 = roundup(mRsmpInFrames); free(mRsmpInBuffer); + mRsmpInBuffer = NULL; // TODO optimize audio capture buffer sizes ... // Here we calculate the size of the sliding buffer used as a source @@ -6935,7 +6936,9 @@ void AudioFlinger::RecordThread::readInputParameters_l() // The current value is higher than necessary. However it should not add to latency. // Over-allocate beyond mRsmpInFramesP2 to permit a HAL read past end of buffer - (void)posix_memalign(&mRsmpInBuffer, 32, (mRsmpInFramesP2 + mFrameCount - 1) * mFrameSize); + size_t bufferSize = (mRsmpInFramesP2 + mFrameCount - 1) * mFrameSize; + (void)posix_memalign(&mRsmpInBuffer, 32, bufferSize); + memset(mRsmpInBuffer, 0, bufferSize); // if posix_memalign fails, will segv here. // AudioRecord mSampleRate and mChannelCount are constant due to AudioRecord API constraints. // But if thread's mSampleRate or mChannelCount changes, how will that affect active tracks? -- cgit v1.1 From 954ca45ac30539a49f179580b667b0ab1056d113 Mon Sep 17 00:00:00 2001 From: Andy Hung Date: Wed, 9 Sep 2015 14:39:02 -0700 Subject: For static obtainBuffer(), do not set mUnreleased if acknowledging flush. static audio tracks use obtainBuffer() to update position in start(). Bug: 22938515 Change-Id: I8ae32f6cce4d122386d2cf8982e158049b04ba9a --- services/audioflinger/Tracks.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'services') diff --git a/services/audioflinger/Tracks.cpp b/services/audioflinger/Tracks.cpp index b3fac0b..0e24b52 100644 --- a/services/audioflinger/Tracks.cpp +++ b/services/audioflinger/Tracks.cpp @@ -715,6 +715,7 @@ status_t AudioFlinger::PlaybackThread::Track::start(AudioSystem::sync_event_t ev // But in this case we know the mixer thread (whether normal mixer or fast mixer) // isn't looking at this track yet: we still hold the normal mixer thread lock, // and for fast tracks the track is not yet in the fast mixer thread's active set. + // For static tracks, this is used to acknowledge change in position or loop. ServerProxy::Buffer buffer; buffer.mFrameCount = 1; (void) mAudioTrackServerProxy->obtainBuffer(&buffer, true /*ackFlush*/); -- cgit v1.1 From aba407f1a6378ac2518d0d76d0d18419b7722a81 Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Thu, 20 Aug 2015 16:18:53 -0700 Subject: audioflinger: increase shared memory heap size Bug: 21093153. Change-Id: I389af11451b01ce49fdb8957e2f322ba1925a62e (cherry picked from commit da73b6c7474aaa5616f0214e238776f12717f32b) --- services/audioflinger/AudioFlinger.cpp | 10 +++++++--- services/audioflinger/AudioFlinger.h | 8 +++++++- 2 files changed, 14 insertions(+), 4 deletions(-) (limited to 'services') diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp index 9ec5802..fab1ef5 100644 --- a/services/audioflinger/AudioFlinger.cpp +++ b/services/audioflinger/AudioFlinger.cpp @@ -1352,12 +1352,16 @@ sp AudioFlinger::getEffectThread_l(int sessionId, AudioFlinger::Client::Client(const sp& audioFlinger, pid_t pid) : RefBase(), mAudioFlinger(audioFlinger), - // FIXME should be a "k" constant not hard-coded, in .h or ro. property, see 4 lines below - mMemoryDealer(new MemoryDealer(1024*1024, "AudioFlinger::Client")), mPid(pid), mTimedTrackCount(0) { - // 1 MB of address space is good for 32 tracks, 8 buffers each, 4 KB/buffer + size_t heapSize = kClientSharedHeapSizeBytes; + // Increase heap size on non low ram devices to limit risk of reconnection failure for + // invalidated tracks + if (!audioFlinger->isLowRamDevice()) { + heapSize *= kClientSharedHeapSizeMultiplier; + } + mMemoryDealer = new MemoryDealer(heapSize, "AudioFlinger::Client"); } // Client destructor must be called with AudioFlinger::mClientLock held diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h index 20c34ef..08fa70d 100644 --- a/services/audioflinger/AudioFlinger.h +++ b/services/audioflinger/AudioFlinger.h @@ -88,6 +88,12 @@ class ServerProxy; static const nsecs_t kDefaultStandbyTimeInNsecs = seconds(3); + +// Max shared memory size for audio tracks and audio records per client process +static const size_t kClientSharedHeapSizeBytes = 1024*1024; +// Shared memory size multiplier for non low ram devices +static const size_t kClientSharedHeapSizeMultiplier = 4; + #define INCLUDING_FROM_AUDIOFLINGER_H class AudioFlinger : @@ -423,7 +429,7 @@ private: Client(const Client&); Client& operator = (const Client&); const sp mAudioFlinger; - const sp mMemoryDealer; + sp mMemoryDealer; const pid_t mPid; Mutex mTimedTrackLock; -- cgit v1.1 From 8a4a0ac6545f53a9ec4af6074caf0e935b08ffbe Mon Sep 17 00:00:00 2001 From: Oleksiy Avramchenko Date: Mon, 14 Sep 2015 11:00:33 +0200 Subject: DO NOT MERGE: Fix setTorchMode support for the old HAL version CameraHardwareInterfaceFlashControl class calls disconnectCameraDevice when torch is disabled. This closes connection to the camera module, but mDevice instance is kept and variable is non-NULL which will prevent connection next time torch is going to be enabled. Bug: 24909924 Change-Id: Icb1ffb07f05256afd92821f0f4908cda5332c05b --- services/camera/libcameraservice/CameraFlashlight.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'services') diff --git a/services/camera/libcameraservice/CameraFlashlight.cpp b/services/camera/libcameraservice/CameraFlashlight.cpp index 280bb9d..e42c596 100644 --- a/services/camera/libcameraservice/CameraFlashlight.cpp +++ b/services/camera/libcameraservice/CameraFlashlight.cpp @@ -878,6 +878,7 @@ status_t CameraHardwareInterfaceFlashControl::disconnectCameraDevice() { } mDevice->setPreviewWindow(NULL); mDevice->release(); + mDevice = NULL; return OK; } -- cgit v1.1 From d4a653a15767d4de37dbfdee22c2170951c93299 Mon Sep 17 00:00:00 2001 From: Yin-Chia Yeh Date: Wed, 14 Oct 2015 11:05:44 -0700 Subject: Camera: setup vendor tags before get_camera_info So HAL can use vendor tags on first get_camera_info call. Bug: 24913201 Change-Id: I73f17de87e3712a27f9cee366995df27a740f5cb --- services/camera/libcameraservice/CameraService.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'services') diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp index 2aaefe9..fb43e8c 100644 --- a/services/camera/libcameraservice/CameraService.cpp +++ b/services/camera/libcameraservice/CameraService.cpp @@ -173,6 +173,13 @@ void CameraService::onFirstRef() mNumberOfCameras = mModule->getNumberOfCameras(); mNumberOfNormalCameras = mNumberOfCameras; + // Setup vendor tags before we call get_camera_info the first time + // because HAL might need to setup static vendor keys in get_camera_info + VendorTagDescriptor::clearGlobalVendorTagDescriptor(); + if (mModule->getModuleApiVersion() >= CAMERA_MODULE_API_VERSION_2_2) { + setUpVendorTags(); + } + mFlashlight = new CameraFlashlight(*mModule, *this); status_t res = mFlashlight->findFlashUnits(); if (res) { @@ -239,12 +246,6 @@ void CameraService::onFirstRef() mModule->setCallbacks(this); } - VendorTagDescriptor::clearGlobalVendorTagDescriptor(); - - if (mModule->getModuleApiVersion() >= CAMERA_MODULE_API_VERSION_2_2) { - setUpVendorTags(); - } - CameraDeviceFactory::registerService(this); CameraService::pingCameraServiceProxy(); -- cgit v1.1 From 82104ebbb2cc04277ab07b355f38f73045a11770 Mon Sep 17 00:00:00 2001 From: Chien-Yu Chen Date: Wed, 14 Oct 2015 11:29:31 -0700 Subject: Camera: Add video recording stop sound Add video recording stop sound to match MediaActionSound. Bug: 24745252 Change-Id: I84b69757c7e0a98abfaafcce5f41dd45fd41cf74 --- services/camera/libcameraservice/CameraService.cpp | 3 ++- services/camera/libcameraservice/CameraService.h | 3 ++- services/camera/libcameraservice/api1/Camera2Client.cpp | 6 +++--- services/camera/libcameraservice/api1/CameraClient.cpp | 6 +++--- 4 files changed, 10 insertions(+), 8 deletions(-) (limited to 'services') diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp index 2aaefe9..19f588a 100644 --- a/services/camera/libcameraservice/CameraService.cpp +++ b/services/camera/libcameraservice/CameraService.cpp @@ -1831,7 +1831,8 @@ void CameraService::loadSound() { if (mSoundRef++) return; mSoundPlayer[SOUND_SHUTTER] = newMediaPlayer("/system/media/audio/ui/camera_click.ogg"); - mSoundPlayer[SOUND_RECORDING] = newMediaPlayer("/system/media/audio/ui/VideoRecord.ogg"); + mSoundPlayer[SOUND_RECORDING_START] = newMediaPlayer("/system/media/audio/ui/VideoRecord.ogg"); + mSoundPlayer[SOUND_RECORDING_STOP] = newMediaPlayer("/system/media/audio/ui/VideoStop.ogg"); } void CameraService::releaseSound() { diff --git a/services/camera/libcameraservice/CameraService.h b/services/camera/libcameraservice/CameraService.h index cd97b08..4b0eeb7 100644 --- a/services/camera/libcameraservice/CameraService.h +++ b/services/camera/libcameraservice/CameraService.h @@ -159,7 +159,8 @@ public: enum sound_kind { SOUND_SHUTTER = 0, - SOUND_RECORDING = 1, + SOUND_RECORDING_START = 1, + SOUND_RECORDING_STOP = 2, NUM_SOUNDS }; diff --git a/services/camera/libcameraservice/api1/Camera2Client.cpp b/services/camera/libcameraservice/api1/Camera2Client.cpp index 48b5a26..4338d64 100644 --- a/services/camera/libcameraservice/api1/Camera2Client.cpp +++ b/services/camera/libcameraservice/api1/Camera2Client.cpp @@ -1040,7 +1040,7 @@ status_t Camera2Client::startRecordingL(Parameters ¶ms, bool restart) { } if (!restart) { - mCameraService->playSound(CameraService::SOUND_RECORDING); + mCameraService->playSound(CameraService::SOUND_RECORDING_START); mStreamingProcessor->updateRecordingRequest(params); if (res != OK) { ALOGE("%s: Camera %d: Unable to update recording request: %s (%d)", @@ -1212,7 +1212,7 @@ void Camera2Client::stopRecording() { return; }; - mCameraService->playSound(CameraService::SOUND_RECORDING); + mCameraService->playSound(CameraService::SOUND_RECORDING_STOP); // Remove recording stream to prevent it from slowing down takePicture later if (!l.mParameters.recordingHint && l.mParameters.isJpegSizeOverridden()) { @@ -1638,7 +1638,7 @@ status_t Camera2Client::commandEnableShutterSoundL(bool enable) { } status_t Camera2Client::commandPlayRecordingSoundL() { - mCameraService->playSound(CameraService::SOUND_RECORDING); + mCameraService->playSound(CameraService::SOUND_RECORDING_START); return OK; } diff --git a/services/camera/libcameraservice/api1/CameraClient.cpp b/services/camera/libcameraservice/api1/CameraClient.cpp index 38e35cd..30b462b 100644 --- a/services/camera/libcameraservice/api1/CameraClient.cpp +++ b/services/camera/libcameraservice/api1/CameraClient.cpp @@ -439,7 +439,7 @@ status_t CameraClient::startRecordingMode() { // start recording mode enableMsgType(CAMERA_MSG_VIDEO_FRAME); - mCameraService->playSound(CameraService::SOUND_RECORDING); + mCameraService->playSound(CameraService::SOUND_RECORDING_START); result = mHardware->startRecording(); if (result != NO_ERROR) { ALOGE("mHardware->startRecording() failed with status %d", result); @@ -470,7 +470,7 @@ void CameraClient::stopRecording() { disableMsgType(CAMERA_MSG_VIDEO_FRAME); mHardware->stopRecording(); - mCameraService->playSound(CameraService::SOUND_RECORDING); + mCameraService->playSound(CameraService::SOUND_RECORDING_STOP); mPreviewBuffer.clear(); } @@ -648,7 +648,7 @@ status_t CameraClient::sendCommand(int32_t cmd, int32_t arg1, int32_t arg2) { } return OK; } else if (cmd == CAMERA_CMD_PLAY_RECORDING_SOUND) { - mCameraService->playSound(CameraService::SOUND_RECORDING); + mCameraService->playSound(CameraService::SOUND_RECORDING_START); } else if (cmd == CAMERA_CMD_SET_VIDEO_BUFFER_COUNT) { // Silently ignore this command return INVALID_OPERATION; -- cgit v1.1 From c171c7c47d099a52ade95c3c8d8907bf09bb88fa Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Fri, 25 Sep 2015 12:21:06 -0700 Subject: audio policy: fix USB mic selection for VoIP When transitioning from speaker phone to normal mode and a USB headset is connected, we must force a teardown of active input as the new input device cannot be reached via current input stream. Bug: 24406915. Change-Id: I9f7c1d3f3cba285c25a6da1d54a3d15a5c1f378a --- services/audiopolicy/managerdefault/AudioPolicyManager.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'services') diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp index 8419ed5..aa4486d 100644 --- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp +++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp @@ -566,9 +566,15 @@ void AudioPolicyManager::setForceUse(audio_policy_force_use_t usage, audio_io_handle_t activeInput = mInputs.getActiveInput(); if (activeInput != 0) { - setInputDevice(activeInput, getNewInputDevice(activeInput)); + sp activeDesc = mInputs.valueFor(activeInput); + audio_devices_t newDevice = getNewInputDevice(activeInput); + // Force new input selection if the new device can not be reached via current input + if (activeDesc->mProfile->mSupportedDevices.types() & (newDevice & ~AUDIO_DEVICE_BIT_IN)) { + setInputDevice(activeInput, newDevice); + } else { + closeInput(activeInput); + } } - } void AudioPolicyManager::setSystemProperty(const char* property, const char* value) -- cgit v1.1 From c0a889f766953b657a5e997bc1362661806d3a19 Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Wed, 14 Oct 2015 14:36:34 -0700 Subject: audio policy: fix transition from VoIP to voice call on USB Make sure no active capture takes place while in call and the capture device is the same as the call TX device. Bug: 23977713. Change-Id: Ia379d5e626c150ea49f0cdd581c881dbf0b8399d --- .../managerdefault/AudioPolicyManager.cpp | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'services') diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp index aa4486d..5ff1c0b 100644 --- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp +++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp @@ -402,6 +402,20 @@ void AudioPolicyManager::updateCallRouting(audio_devices_t rxDevice, int delayMs patch.num_sources = 2; } + // terminate active capture if on the same HW module as the call TX source device + // FIXME: would be better to refine to only inputs whose profile connects to the + // call TX device but this information is not in the audio patch and logic here must be + // symmetric to the one in startInput() + audio_io_handle_t activeInput = mInputs.getActiveInput(); + if (activeInput != 0) { + sp activeDesc = mInputs.valueFor(activeInput); + if (activeDesc->getModuleHandle() == txSourceDeviceDesc->getModuleHandle()) { + audio_session_t activeSession = activeDesc->mSessions.itemAt(0); + stopInput(activeInput, activeSession); + releaseInput(activeInput, activeSession); + } + } + afPatchHandle = AUDIO_PATCH_HANDLE_NONE; status = mpClientInterface->createAudioPatch(&patch, &afPatchHandle, 0); ALOGW_IF(status != NO_ERROR, "setPhoneState() error %d creating TX audio patch", @@ -1505,6 +1519,15 @@ status_t AudioPolicyManager::startInput(audio_io_handle_t input, return INVALID_OPERATION; } } + + // Do not allow capture if an active voice call is using a software patch and + // the call TX source device is on the same HW module. + // FIXME: would be better to refine to only inputs whose profile connects to the + // call TX device but this information is not in the audio patch + if (mCallTxPatch != 0 && + inputDesc->getModuleHandle() == mCallTxPatch->mPatch.sources[0].ext.device.hw_module) { + return INVALID_OPERATION; + } } // Routing? -- cgit v1.1 From 3e600894685b994849d59307721c6862ae0c45b7 Mon Sep 17 00:00:00 2001 From: Ranjith Kagathi Ananda Date: Thu, 8 Oct 2015 16:00:33 -0700 Subject: Camera: frameworks: Add NULL check for callback --Added NULL check for mRemoteCallback Ack by: Susmitha Gummalla Bug: 25023187 Change-Id: Ib88a128a52e81b8ec1052e3222b6d8b9e494afcc --- services/camera/libcameraservice/CameraService.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'services') diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp index f2d6ad6..2bb282f 100644 --- a/services/camera/libcameraservice/CameraService.cpp +++ b/services/camera/libcameraservice/CameraService.cpp @@ -2084,7 +2084,11 @@ sp CameraService::Client::getClientFromCookie(void* user) void CameraService::Client::notifyError(ICameraDeviceCallbacks::CameraErrorCode errorCode, const CaptureResultExtras& resultExtras) { - mRemoteCallback->notifyCallback(CAMERA_MSG_ERROR, CAMERA_ERROR_RELEASED, 0); + if (mRemoteCallback != NULL) { + mRemoteCallback->notifyCallback(CAMERA_MSG_ERROR, CAMERA_ERROR_RELEASED, 0); + } else { + ALOGE("mRemoteCallback is NULL!!"); + } } // NOTE: function is idempotent -- cgit v1.1 From 32ab9fdab562127ccd37a8cdb15421ebdf82a458 Mon Sep 17 00:00:00 2001 From: Ranjith Kagathi Ananda Date: Thu, 8 Oct 2015 16:41:09 -0700 Subject: libcameraservice: Fix ALOG prints in FlashLight. Add missing __FUNCTION__ arguments into log statements. Ack by: Dilip Gopalakrishna Bug: 25023187 Change-Id: I0256bad626d490fb9360a73c104afaad7a012a97 --- services/camera/libcameraservice/CameraFlashlight.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'services') diff --git a/services/camera/libcameraservice/CameraFlashlight.cpp b/services/camera/libcameraservice/CameraFlashlight.cpp index e42c596..406c1c4 100644 --- a/services/camera/libcameraservice/CameraFlashlight.cpp +++ b/services/camera/libcameraservice/CameraFlashlight.cpp @@ -99,7 +99,8 @@ status_t CameraFlashlight::createFlashlightControl(const String8& cameraId) { status_t CameraFlashlight::setTorchMode(const String8& cameraId, bool enabled) { if (!mFlashlightMapInitialized) { - ALOGE("%s: findFlashUnits() must be called before this method."); + ALOGE("%s: findFlashUnits() must be called before this method.", + __FUNCTION__); return NO_INIT; } @@ -200,7 +201,8 @@ bool CameraFlashlight::hasFlashUnit(const String8& cameraId) { bool CameraFlashlight::hasFlashUnitLocked(const String8& cameraId) { if (!mFlashlightMapInitialized) { - ALOGE("%s: findFlashUnits() must be called before this method."); + ALOGE("%s: findFlashUnits() must be called before this method.", + __FUNCTION__); return false; } @@ -219,7 +221,8 @@ status_t CameraFlashlight::prepareDeviceOpen(const String8& cameraId) { Mutex::Autolock l(mLock); if (!mFlashlightMapInitialized) { - ALOGE("%s: findFlashUnits() must be called before this method."); + ALOGE("%s: findFlashUnits() must be called before this method.", + __FUNCTION__); return NO_INIT; } @@ -256,7 +259,8 @@ status_t CameraFlashlight::deviceClosed(const String8& cameraId) { Mutex::Autolock l(mLock); if (!mFlashlightMapInitialized) { - ALOGE("%s: findFlashUnits() must be called before this method."); + ALOGE("%s: findFlashUnits() must be called before this method.", + __FUNCTION__); return NO_INIT; } -- cgit v1.1 From 5adc76c49a525993f3362cf648864fb21f4547f0 Mon Sep 17 00:00:00 2001 From: Tom Keel Date: Thu, 8 Oct 2015 16:42:56 +0200 Subject: DO NOT MERGE: libcameraservice: Fix nullptr crash when no client. This change prevents a crash in the camera service when the camera HAL notifies the service about the absence of a removable camera and there happens to be no client connected to the service. It checks that the pointer returned from clientToDisconnect.get() is non-null before trying to dereference it (as is done in existing code immediately below this change). Bug: 25165323 Change-Id: I8055654bac980542e63ea7f52bf897eaafbc09bc Signed-off-by: Tom Keel --- services/camera/libcameraservice/CameraService.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'services') diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp index 2bb282f..3deb396 100644 --- a/services/camera/libcameraservice/CameraService.cpp +++ b/services/camera/libcameraservice/CameraService.cpp @@ -315,8 +315,10 @@ void CameraService::onDeviceStatusChanged(camera_device_status_t cameraId, clientToDisconnect = removeClientLocked(id); // Notify the client of disconnection - clientToDisconnect->notifyError(ICameraDeviceCallbacks::ERROR_CAMERA_DISCONNECTED, - CaptureResultExtras{}); + if (clientToDisconnect != nullptr) { + clientToDisconnect->notifyError(ICameraDeviceCallbacks::ERROR_CAMERA_DISCONNECTED, + CaptureResultExtras{}); + } } ALOGI("%s: Client for camera ID %s evicted due to device status change from HAL", -- cgit v1.1 From 5dc9ffe50ef517591b8ffad66c7e4d6ec82b8b4b Mon Sep 17 00:00:00 2001 From: Ronghua Wu Date: Fri, 23 Oct 2015 15:01:53 -0700 Subject: Reduce lock time for dump to make sure not locked when calling back to IResourceManagerClient. Bug: 25166048 Change-Id: I35f9917079c4b783a7cf4cef94b3c7112760c0b8 --- .../ResourceManagerService.cpp | 37 +++++++++++++++------- 1 file changed, 26 insertions(+), 11 deletions(-) (limited to 'services') diff --git a/services/mediaresourcemanager/ResourceManagerService.cpp b/services/mediaresourcemanager/ResourceManagerService.cpp index 4790754..6781a36 100644 --- a/services/mediaresourcemanager/ResourceManagerService.cpp +++ b/services/mediaresourcemanager/ResourceManagerService.cpp @@ -90,11 +90,7 @@ static ResourceInfo& getResourceInfoForEdit( } status_t ResourceManagerService::dump(int fd, const Vector& /* args */) { - Mutex::Autolock lock(mLock); - String8 result; - const size_t SIZE = 256; - char buffer[SIZE]; if (checkCallingPermission(String16("android.permission.DUMP")) == false) { result.format("Permission Denial: " @@ -105,20 +101,35 @@ status_t ResourceManagerService::dump(int fd, const Vector& /* args */ return PERMISSION_DENIED; } + PidResourceInfosMap mapCopy; + bool supportsMultipleSecureCodecs; + bool supportsSecureWithNonSecureCodec; + String8 serviceLog; + { + Mutex::Autolock lock(mLock); + mapCopy = mMap; // Shadow copy, real copy will happen on write. + supportsMultipleSecureCodecs = mSupportsMultipleSecureCodecs; + supportsSecureWithNonSecureCodec = mSupportsSecureWithNonSecureCodec; + serviceLog = mServiceLog->toString(" " /* linePrefix */); + } + + const size_t SIZE = 256; + char buffer[SIZE]; snprintf(buffer, SIZE, "ResourceManagerService: %p\n", this); result.append(buffer); result.append(" Policies:\n"); - snprintf(buffer, SIZE, " SupportsMultipleSecureCodecs: %d\n", mSupportsMultipleSecureCodecs); + snprintf(buffer, SIZE, " SupportsMultipleSecureCodecs: %d\n", supportsMultipleSecureCodecs); result.append(buffer); - snprintf(buffer, SIZE, " SupportsSecureWithNonSecureCodec: %d\n", mSupportsSecureWithNonSecureCodec); + snprintf(buffer, SIZE, " SupportsSecureWithNonSecureCodec: %d\n", + supportsSecureWithNonSecureCodec); result.append(buffer); result.append(" Processes:\n"); - for (size_t i = 0; i < mMap.size(); ++i) { - snprintf(buffer, SIZE, " Pid: %d\n", mMap.keyAt(i)); + for (size_t i = 0; i < mapCopy.size(); ++i) { + snprintf(buffer, SIZE, " Pid: %d\n", mapCopy.keyAt(i)); result.append(buffer); - const ResourceInfos &infos = mMap.valueAt(i); + const ResourceInfos &infos = mapCopy.valueAt(i); for (size_t j = 0; j < infos.size(); ++j) { result.append(" Client:\n"); snprintf(buffer, SIZE, " Id: %lld\n", (long long)infos[j].clientId); @@ -136,7 +147,7 @@ status_t ResourceManagerService::dump(int fd, const Vector& /* args */ } } result.append(" Events logs (most recent at top):\n"); - result.append(mServiceLog->toString(" " /* linePrefix */)); + result.append(serviceLog); write(fd, result.string(), result.size()); return OK; @@ -307,6 +318,10 @@ bool ResourceManagerService::reclaimResource( } } + if (failedClient == NULL) { + return true; + } + { Mutex::Autolock lock(mLock); bool found = false; @@ -329,7 +344,7 @@ bool ResourceManagerService::reclaimResource( } } - return (failedClient == NULL); + return false; } bool ResourceManagerService::getAllClients_l( -- cgit v1.1