diff options
Diffstat (limited to 'services')
-rw-r--r-- | services/audioflinger/AudioMixerOps.h | 5 | ||||
-rw-r--r-- | services/audioflinger/Threads.cpp | 17 | ||||
-rw-r--r-- | services/audioflinger/Threads.h | 2 | ||||
-rw-r--r-- | services/audiopolicy/managerdefault/AudioPolicyManager.cpp | 25 | ||||
-rw-r--r-- | services/audiopolicy/managerdefault/AudioPolicyManager.h | 2 | ||||
-rw-r--r-- | services/camera/libcameraservice/device3/Camera3Device.cpp | 6 |
6 files changed, 44 insertions, 13 deletions
diff --git a/services/audioflinger/AudioMixerOps.h b/services/audioflinger/AudioMixerOps.h index 2678857..8d74024 100644 --- a/services/audioflinger/AudioMixerOps.h +++ b/services/audioflinger/AudioMixerOps.h @@ -164,13 +164,12 @@ inline int32_t MixMul<int32_t, int16_t, float>(int16_t value, float volume) { template <> inline int16_t MixMul<int16_t, int16_t, float>(int16_t value, float volume) { LOG_ALWAYS_FATAL("MixMul<int16_t, int16_t, float> Runtime Should not be here"); - return value * volume; + return clamp16_from_float(MixMul<float, int16_t, float>(value, volume)); } template <> inline int16_t MixMul<int16_t, float, float>(float value, float volume) { - static const float q_15_from_float = (1 << 15); - return value * volume * q_15_from_float; + return clamp16_from_float(value * volume); } /* diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp index 489f2d4..410fff5 100644 --- a/services/audioflinger/Threads.cpp +++ b/services/audioflinger/Threads.cpp @@ -2194,6 +2194,8 @@ void AudioFlinger::PlaybackThread::readOutputParameters_l() // Check if we want to throttle the processing to no more than 2x normal rate mThreadThrottle = property_get_bool("af.thread.throttle", true /* default_value */); + mThreadThrottleTimeMs = 0; + mThreadThrottleEndMs = 0; mHalfBufferMs = mNormalFrameCount * 1000 / (2 * mSampleRate); // mSinkBuffer is the sink buffer. Size is always multiple-of-16 frames. @@ -2960,8 +2962,19 @@ bool AudioFlinger::PlaybackThread::threadLoop() const int32_t throttleMs = mHalfBufferMs - deltaMs; if ((signed)mHalfBufferMs >= throttleMs && throttleMs > 0) { usleep(throttleMs * 1000); - ALOGD("mixer(%p) throttle: ret(%zd) deltaMs(%d) requires sleep %d ms", + // notify of throttle start on verbose log + ALOGV_IF(mThreadThrottleEndMs == mThreadThrottleTimeMs, + "mixer(%p) throttle begin:" + " ret(%zd) deltaMs(%d) requires sleep %d ms", this, ret, deltaMs, throttleMs); + mThreadThrottleTimeMs += throttleMs; + } else { + uint32_t diff = mThreadThrottleTimeMs - mThreadThrottleEndMs; + if (diff > 0) { + // notify of throttle end on debug log + ALOGD("mixer(%p) throttle end: throttle time(%u)", this, diff); + mThreadThrottleEndMs = mThreadThrottleTimeMs; + } } } } @@ -4340,7 +4353,7 @@ void AudioFlinger::MixerThread::dumpInternals(int fd, const Vector<String16>& ar String8 result; PlaybackThread::dumpInternals(fd, args); - + dprintf(fd, " Thread throttle time (msecs): %u\n", mThreadThrottleTimeMs); dprintf(fd, " AudioMixer tracks: 0x%08x\n", mAudioMixer->trackNames()); // Make a non-atomic copy of fast mixer dump state so it won't change underneath us diff --git a/services/audioflinger/Threads.h b/services/audioflinger/Threads.h index 4ebe615..b12b091 100644 --- a/services/audioflinger/Threads.h +++ b/services/audioflinger/Threads.h @@ -614,6 +614,8 @@ protected: size_t mNormalFrameCount; // normal mixer and effects bool mThreadThrottle; // throttle the thread processing + uint32_t mThreadThrottleTimeMs; // throttle time for MIXER threads + uint32_t mThreadThrottleEndMs; // notify once per throttling uint32_t mHalfBufferMs; // half the buffer size in milliseconds void* mSinkBuffer; // frame size aligned sink buffer diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp index deebc23..a0de34d 100644 --- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp +++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp @@ -213,7 +213,7 @@ status_t AudioPolicyManager::setDeviceConnectionStateInt(audio_devices_t device, device); return INVALID_OPERATION; } - if (checkInputsForDevice(device, state, inputs, devDesc->mAddress) != NO_ERROR) { + if (checkInputsForDevice(devDesc, state, inputs, devDesc->mAddress) != NO_ERROR) { return INVALID_OPERATION; } @@ -247,7 +247,7 @@ status_t AudioPolicyManager::setDeviceConnectionStateInt(audio_devices_t device, param.addInt(String8(AUDIO_PARAMETER_DEVICE_DISCONNECT), device); mpClientInterface->setParameters(AUDIO_IO_HANDLE_NONE, param.toString()); - checkInputsForDevice(device, state, inputs, devDesc->mAddress); + checkInputsForDevice(devDesc, state, inputs, devDesc->mAddress); mAvailableInputDevices.remove(devDesc); // Propagate device availability to Engine @@ -3196,7 +3196,9 @@ status_t AudioPolicyManager::checkOutputsForDevice(const sp<DeviceDescriptor> de if (!desc->isDuplicated() && desc->mProfile == profile) { // matching profile: save the sample rates, format and channel masks supported // by the profile in our device descriptor - devDesc->importAudioPort(profile); + if (audio_device_is_digital(device)) { + devDesc->importAudioPort(profile); + } break; } } @@ -3359,7 +3361,10 @@ status_t AudioPolicyManager::checkOutputsForDevice(const sp<DeviceDescriptor> de profile_index--; } else { outputs.add(output); - devDesc->importAudioPort(profile); + // Load digital format info only for digital devices + if (audio_device_is_digital(device)) { + devDesc->importAudioPort(profile); + } if (device_distinguishes_on_address(device)) { ALOGV("checkOutputsForDevice(): setOutputDevice(dev=0x%x, addr=%s)", @@ -3422,11 +3427,13 @@ status_t AudioPolicyManager::checkOutputsForDevice(const sp<DeviceDescriptor> de return NO_ERROR; } -status_t AudioPolicyManager::checkInputsForDevice(audio_devices_t device, +status_t AudioPolicyManager::checkInputsForDevice(const sp<DeviceDescriptor> devDesc, audio_policy_dev_state_t state, SortedVector<audio_io_handle_t>& inputs, const String8 address) { + audio_devices_t device = devDesc->type(); + sp<AudioInputDescriptor> desc; if (state == AUDIO_POLICY_DEVICE_STATE_AVAILABLE) { // first list already open inputs that can be routed to this device @@ -3477,6 +3484,9 @@ status_t AudioPolicyManager::checkInputsForDevice(audio_devices_t device, for (input_index = 0; input_index < mInputs.size(); input_index++) { desc = mInputs.valueAt(input_index); if (desc->mProfile == profile) { + if (audio_device_is_digital(device)) { + devDesc->importAudioPort(profile); + } break; } } @@ -3562,6 +3572,9 @@ status_t AudioPolicyManager::checkInputsForDevice(audio_devices_t device, profile_index--; } else { inputs.add(input); + if (audio_device_is_digital(device)) { + devDesc->importAudioPort(profile); + } ALOGV("checkInputsForDevice(): adding input %d", input); } } // end scan profiles @@ -3591,7 +3604,7 @@ status_t AudioPolicyManager::checkInputsForDevice(audio_devices_t device, profile_index < mHwModules[module_index]->mInputProfiles.size(); profile_index++) { sp<IOProfile> profile = mHwModules[module_index]->mInputProfiles[profile_index]; - if (profile->mSupportedDevices.types() & device & ~AUDIO_DEVICE_BIT_IN) { + if (profile->mSupportedDevices.types() & (device & ~AUDIO_DEVICE_BIT_IN)) { ALOGV("checkInputsForDevice(): clearing direct input profile %zu on module %zu", profile_index, module_index); if (profile->mSamplingRates[0] == 0) { diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.h b/services/audiopolicy/managerdefault/AudioPolicyManager.h index f9d1198..cf64154 100644 --- a/services/audiopolicy/managerdefault/AudioPolicyManager.h +++ b/services/audiopolicy/managerdefault/AudioPolicyManager.h @@ -456,7 +456,7 @@ protected: SortedVector<audio_io_handle_t>& outputs, const String8 address); - status_t checkInputsForDevice(audio_devices_t device, + status_t checkInputsForDevice(const sp<DeviceDescriptor> devDesc, audio_policy_dev_state_t state, SortedVector<audio_io_handle_t>& inputs, const String8 address); diff --git a/services/camera/libcameraservice/device3/Camera3Device.cpp b/services/camera/libcameraservice/device3/Camera3Device.cpp index c28a57e..9d725de 100644 --- a/services/camera/libcameraservice/device3/Camera3Device.cpp +++ b/services/camera/libcameraservice/device3/Camera3Device.cpp @@ -1033,7 +1033,11 @@ status_t Camera3Device::configureStreams(bool isConstrainedHighSpeed) { Mutex::Autolock il(mInterfaceLock); Mutex::Autolock l(mLock); - mIsConstrainedHighSpeedConfiguration = isConstrainedHighSpeed; + + if (mIsConstrainedHighSpeedConfiguration != isConstrainedHighSpeed) { + mNeedConfig = true; + mIsConstrainedHighSpeedConfiguration = isConstrainedHighSpeed; + } return configureStreamsLocked(); } |