Loading media/libaudioclient/aidl/android/media/AudioVibratorInfo.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -24,4 +24,5 @@ parcelable AudioVibratorInfo { int id; float resonantFrequency; float qFactor; float maxAmplitude; } media/libaudioprocessing/AudioMixer.cpp +9 −1 Original line number Diff line number Diff line Loading @@ -434,6 +434,12 @@ void AudioMixer::setParameter(int name, int target, int param, void *value) track->mHapticIntensity = hapticIntensity; } } break; case HAPTIC_MAX_AMPLITUDE: { const float hapticMaxAmplitude = *reinterpret_cast<float*>(value); if (track->mHapticMaxAmplitude != hapticMaxAmplitude) { track->mHapticMaxAmplitude = hapticMaxAmplitude; } } break; default: LOG_ALWAYS_FATAL("setParameter track: bad param %d", param); } Loading Loading @@ -553,6 +559,7 @@ status_t AudioMixer::postCreateTrack(TrackBase *track) // haptic t->mHapticPlaybackEnabled = false; t->mHapticIntensity = os::HapticScale::NONE; t->mHapticMaxAmplitude = NAN; t->mMixerHapticChannelMask = AUDIO_CHANNEL_NONE; t->mMixerHapticChannelCount = 0; t->mAdjustInChannelCount = t->channelCount + t->mHapticChannelCount; Loading Loading @@ -602,7 +609,8 @@ void AudioMixer::postProcess() switch (t->mMixerFormat) { // Mixer format should be AUDIO_FORMAT_PCM_FLOAT. case AUDIO_FORMAT_PCM_FLOAT: { os::scaleHapticData((float*) buffer, sampleCount, t->mHapticIntensity); os::scaleHapticData((float*) buffer, sampleCount, t->mHapticIntensity, t->mHapticMaxAmplitude); } break; default: LOG_ALWAYS_FATAL("bad mMixerFormat: %#x", t->mMixerFormat); Loading media/libaudioprocessing/include/media/AudioMixer.h +2 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ public: // for haptic HAPTIC_ENABLED = 0x4007, // Set haptic data from this track should be played or not. HAPTIC_INTENSITY = 0x4008, // Set the intensity to play haptic data. HAPTIC_MAX_AMPLITUDE = 0x4009, // Set the max amplitude allowed for haptic data. // for target TIMESTRETCH PLAYBACK_RATE = 0x4300, // Configure timestretch on this track name; // parameter 'value' is a pointer to the new playback rate. Loading Loading @@ -145,6 +146,7 @@ private: // Haptic bool mHapticPlaybackEnabled; os::HapticScale mHapticIntensity; float mHapticMaxAmplitude; audio_channel_mask_t mHapticChannelMask; uint32_t mHapticChannelCount; audio_channel_mask_t mMixerHapticChannelMask; Loading media/libeffects/hapticgenerator/EffectHapticGenerator.cpp +5 −2 Original line number Diff line number Diff line Loading @@ -302,15 +302,17 @@ int HapticGenerator_SetParameter(struct HapticGeneratorContext *context, break; } case HG_PARAM_VIBRATOR_INFO: { if (value == nullptr || size != 2 * sizeof(float)) { if (value == nullptr || size != 3 * sizeof(float)) { return -EINVAL; } const float resonantFrequency = *(float*) value; const float qFactor = *((float *) value + 1); const float maxAmplitude = *((float *) value + 2); context->param.resonantFrequency = isnan(resonantFrequency) ? DEFAULT_RESONANT_FREQUENCY : resonantFrequency; context->param.bsfZeroQ = isnan(qFactor) ? DEFAULT_BSF_POLE_Q : qFactor; context->param.bsfPoleQ = context->param.bsfZeroQ / 2.0f; context->param.maxHapticAmplitude = maxAmplitude; if (context->processorsRecord.bpf != nullptr) { context->processorsRecord.bpf->setCoefficients( Loading Loading @@ -463,7 +465,8 @@ int32_t HapticGenerator_Process(effect_handle_t self, float* hapticOutBuffer = HapticGenerator_runProcessingChain( context->processingChain, context->inputBuffer.data(), context->outputBuffer.data(), inBuffer->frameCount); os::scaleHapticData(hapticOutBuffer, hapticSampleCount, context->param.maxHapticIntensity); os::scaleHapticData(hapticOutBuffer, hapticSampleCount, context->param.maxHapticIntensity, context->param.maxHapticAmplitude); // For haptic data, the haptic playback thread will copy the data from effect input buffer, // which contains haptic data at the end of the buffer, directly to sink buffer. Loading media/libeffects/hapticgenerator/EffectHapticGenerator.h +1 −0 Original line number Diff line number Diff line Loading @@ -51,6 +51,7 @@ struct HapticGeneratorParam { // A map from track id to haptic intensity. std::map<int, os::HapticScale> id2Intensity; os::HapticScale maxHapticIntensity; // max intensity will be used to scale haptic data. float maxHapticAmplitude; // max amplitude will be used to limit haptic data absolute values. float resonantFrequency; float bpfQ; Loading Loading
media/libaudioclient/aidl/android/media/AudioVibratorInfo.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -24,4 +24,5 @@ parcelable AudioVibratorInfo { int id; float resonantFrequency; float qFactor; float maxAmplitude; }
media/libaudioprocessing/AudioMixer.cpp +9 −1 Original line number Diff line number Diff line Loading @@ -434,6 +434,12 @@ void AudioMixer::setParameter(int name, int target, int param, void *value) track->mHapticIntensity = hapticIntensity; } } break; case HAPTIC_MAX_AMPLITUDE: { const float hapticMaxAmplitude = *reinterpret_cast<float*>(value); if (track->mHapticMaxAmplitude != hapticMaxAmplitude) { track->mHapticMaxAmplitude = hapticMaxAmplitude; } } break; default: LOG_ALWAYS_FATAL("setParameter track: bad param %d", param); } Loading Loading @@ -553,6 +559,7 @@ status_t AudioMixer::postCreateTrack(TrackBase *track) // haptic t->mHapticPlaybackEnabled = false; t->mHapticIntensity = os::HapticScale::NONE; t->mHapticMaxAmplitude = NAN; t->mMixerHapticChannelMask = AUDIO_CHANNEL_NONE; t->mMixerHapticChannelCount = 0; t->mAdjustInChannelCount = t->channelCount + t->mHapticChannelCount; Loading Loading @@ -602,7 +609,8 @@ void AudioMixer::postProcess() switch (t->mMixerFormat) { // Mixer format should be AUDIO_FORMAT_PCM_FLOAT. case AUDIO_FORMAT_PCM_FLOAT: { os::scaleHapticData((float*) buffer, sampleCount, t->mHapticIntensity); os::scaleHapticData((float*) buffer, sampleCount, t->mHapticIntensity, t->mHapticMaxAmplitude); } break; default: LOG_ALWAYS_FATAL("bad mMixerFormat: %#x", t->mMixerFormat); Loading
media/libaudioprocessing/include/media/AudioMixer.h +2 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ public: // for haptic HAPTIC_ENABLED = 0x4007, // Set haptic data from this track should be played or not. HAPTIC_INTENSITY = 0x4008, // Set the intensity to play haptic data. HAPTIC_MAX_AMPLITUDE = 0x4009, // Set the max amplitude allowed for haptic data. // for target TIMESTRETCH PLAYBACK_RATE = 0x4300, // Configure timestretch on this track name; // parameter 'value' is a pointer to the new playback rate. Loading Loading @@ -145,6 +146,7 @@ private: // Haptic bool mHapticPlaybackEnabled; os::HapticScale mHapticIntensity; float mHapticMaxAmplitude; audio_channel_mask_t mHapticChannelMask; uint32_t mHapticChannelCount; audio_channel_mask_t mMixerHapticChannelMask; Loading
media/libeffects/hapticgenerator/EffectHapticGenerator.cpp +5 −2 Original line number Diff line number Diff line Loading @@ -302,15 +302,17 @@ int HapticGenerator_SetParameter(struct HapticGeneratorContext *context, break; } case HG_PARAM_VIBRATOR_INFO: { if (value == nullptr || size != 2 * sizeof(float)) { if (value == nullptr || size != 3 * sizeof(float)) { return -EINVAL; } const float resonantFrequency = *(float*) value; const float qFactor = *((float *) value + 1); const float maxAmplitude = *((float *) value + 2); context->param.resonantFrequency = isnan(resonantFrequency) ? DEFAULT_RESONANT_FREQUENCY : resonantFrequency; context->param.bsfZeroQ = isnan(qFactor) ? DEFAULT_BSF_POLE_Q : qFactor; context->param.bsfPoleQ = context->param.bsfZeroQ / 2.0f; context->param.maxHapticAmplitude = maxAmplitude; if (context->processorsRecord.bpf != nullptr) { context->processorsRecord.bpf->setCoefficients( Loading Loading @@ -463,7 +465,8 @@ int32_t HapticGenerator_Process(effect_handle_t self, float* hapticOutBuffer = HapticGenerator_runProcessingChain( context->processingChain, context->inputBuffer.data(), context->outputBuffer.data(), inBuffer->frameCount); os::scaleHapticData(hapticOutBuffer, hapticSampleCount, context->param.maxHapticIntensity); os::scaleHapticData(hapticOutBuffer, hapticSampleCount, context->param.maxHapticIntensity, context->param.maxHapticAmplitude); // For haptic data, the haptic playback thread will copy the data from effect input buffer, // which contains haptic data at the end of the buffer, directly to sink buffer. Loading
media/libeffects/hapticgenerator/EffectHapticGenerator.h +1 −0 Original line number Diff line number Diff line Loading @@ -51,6 +51,7 @@ struct HapticGeneratorParam { // A map from track id to haptic intensity. std::map<int, os::HapticScale> id2Intensity; os::HapticScale maxHapticIntensity; // max intensity will be used to scale haptic data. float maxHapticAmplitude; // max amplitude will be used to limit haptic data absolute values. float resonantFrequency; float bpfQ; Loading