Lines Matching refs:pContext
110 uint32_t Visualizer_getDeltaTimeMsFromUpdatedTime(VisualizerContext* pContext) { in Visualizer_getDeltaTimeMsFromUpdatedTime() argument
112 if (pContext->mBufferUpdateTime.tv_sec != 0) { in Visualizer_getDeltaTimeMsFromUpdatedTime()
115 time_t secs = ts.tv_sec - pContext->mBufferUpdateTime.tv_sec; in Visualizer_getDeltaTimeMsFromUpdatedTime()
116 long nsec = ts.tv_nsec - pContext->mBufferUpdateTime.tv_nsec; in Visualizer_getDeltaTimeMsFromUpdatedTime()
128 void Visualizer_reset(VisualizerContext *pContext) in Visualizer_reset() argument
130 pContext->mCaptureIdx = 0; in Visualizer_reset()
131 pContext->mLastCaptureIdx = 0; in Visualizer_reset()
132 pContext->mBufferUpdateTime.tv_sec = 0; in Visualizer_reset()
133 pContext->mLatency = 0; in Visualizer_reset()
134 memset(pContext->mCaptureBuf, 0x80, CAPTURE_BUF_SIZE); in Visualizer_reset()
151 int Visualizer_setConfig(VisualizerContext *pContext, effect_config_t *pConfig) in Visualizer_setConfig() argument
168 pContext->mConfig = *pConfig; in Visualizer_setConfig()
170 Visualizer_reset(pContext); in Visualizer_setConfig()
190 void Visualizer_getConfig(VisualizerContext *pContext, effect_config_t *pConfig) in Visualizer_getConfig() argument
192 *pConfig = pContext->mConfig; in Visualizer_getConfig()
208 int Visualizer_init(VisualizerContext *pContext) in Visualizer_init() argument
210 pContext->mConfig.inputCfg.accessMode = EFFECT_BUFFER_ACCESS_READ; in Visualizer_init()
211 pContext->mConfig.inputCfg.channels = AUDIO_CHANNEL_OUT_STEREO; in Visualizer_init()
212 pContext->mConfig.inputCfg.format = kProcessFormat; in Visualizer_init()
213 pContext->mConfig.inputCfg.samplingRate = 44100; in Visualizer_init()
214 pContext->mConfig.inputCfg.bufferProvider.getBuffer = NULL; in Visualizer_init()
215 pContext->mConfig.inputCfg.bufferProvider.releaseBuffer = NULL; in Visualizer_init()
216 pContext->mConfig.inputCfg.bufferProvider.cookie = NULL; in Visualizer_init()
217 pContext->mConfig.inputCfg.mask = EFFECT_CONFIG_ALL; in Visualizer_init()
218 pContext->mConfig.outputCfg.accessMode = EFFECT_BUFFER_ACCESS_ACCUMULATE; in Visualizer_init()
219 pContext->mConfig.outputCfg.channels = AUDIO_CHANNEL_OUT_STEREO; in Visualizer_init()
220 pContext->mConfig.outputCfg.format = kProcessFormat; in Visualizer_init()
221 pContext->mConfig.outputCfg.samplingRate = 44100; in Visualizer_init()
222 pContext->mConfig.outputCfg.bufferProvider.getBuffer = NULL; in Visualizer_init()
223 pContext->mConfig.outputCfg.bufferProvider.releaseBuffer = NULL; in Visualizer_init()
224 pContext->mConfig.outputCfg.bufferProvider.cookie = NULL; in Visualizer_init()
225 pContext->mConfig.outputCfg.mask = EFFECT_CONFIG_ALL; in Visualizer_init()
228 pContext->mCaptureSize = VISUALIZER_CAPTURE_SIZE_MAX; in Visualizer_init()
229 pContext->mScalingMode = VISUALIZER_SCALING_MODE_NORMALIZED; in Visualizer_init()
232 pContext->mChannelCount = in Visualizer_init()
233 audio_channel_count_from_out_mask(pContext->mConfig.inputCfg.channels); in Visualizer_init()
234 pContext->mMeasurementMode = MEASUREMENT_MODE_NONE; in Visualizer_init()
235 pContext->mMeasurementWindowSizeInBuffers = MEASUREMENT_WINDOW_MAX_SIZE_IN_BUFFERS; in Visualizer_init()
236 pContext->mMeasurementBufferIdx = 0; in Visualizer_init()
237 for (uint32_t i=0 ; i<pContext->mMeasurementWindowSizeInBuffers ; i++) { in Visualizer_init()
238 pContext->mPastMeasurements[i].mIsValid = false; in Visualizer_init()
239 pContext->mPastMeasurements[i].mPeakU16 = 0; in Visualizer_init()
240 pContext->mPastMeasurements[i].mRmsSquared = 0; in Visualizer_init()
243 Visualizer_setConfig(pContext, &pContext->mConfig); in Visualizer_init()
266 VisualizerContext *pContext = new VisualizerContext; in VisualizerLib_Create() local
268 pContext->mItfe = &gVisualizerInterface; in VisualizerLib_Create()
269 pContext->mState = VISUALIZER_STATE_UNINITIALIZED; in VisualizerLib_Create()
271 ret = Visualizer_init(pContext); in VisualizerLib_Create()
274 delete pContext; in VisualizerLib_Create()
278 *pHandle = (effect_handle_t)pContext; in VisualizerLib_Create()
280 pContext->mState = VISUALIZER_STATE_INITIALIZED; in VisualizerLib_Create()
282 ALOGV("VisualizerLib_Create %p", pContext); in VisualizerLib_Create()
289 VisualizerContext * pContext = (VisualizerContext *)handle; in VisualizerLib_Release() local
292 if (pContext == NULL) { in VisualizerLib_Release()
295 pContext->mState = VISUALIZER_STATE_UNINITIALIZED; in VisualizerLib_Release()
296 delete pContext; in VisualizerLib_Release()
324 VisualizerContext * pContext = (VisualizerContext *)self; in Visualizer_process() local
326 if (pContext == NULL) { in Visualizer_process()
337 const size_t sampleLen = inBuffer->frameCount * pContext->mChannelCount; in Visualizer_process()
340 if (pContext->mMeasurementMode & MEASUREMENT_MODE_PEAK_RMS) { in Visualizer_process()
360 pContext->mPastMeasurements[pContext->mMeasurementBufferIdx].mPeakU16 = (uint16_t)maxSample; in Visualizer_process()
361 pContext->mPastMeasurements[pContext->mMeasurementBufferIdx].mRmsSquared = in Visualizer_process()
363 pContext->mPastMeasurements[pContext->mMeasurementBufferIdx].mIsValid = true; in Visualizer_process()
364 if (++pContext->mMeasurementBufferIdx >= pContext->mMeasurementWindowSizeInBuffers) { in Visualizer_process()
365 pContext->mMeasurementBufferIdx = 0; in Visualizer_process()
375 if (pContext->mScalingMode == VISUALIZER_SCALING_MODE_NORMALIZED) { in Visualizer_process()
385 for (int i = 0; i < pContext->mChannelCount; ++i) { in Visualizer_process()
421 assert(pContext->mScalingMode == VISUALIZER_SCALING_MODE_AS_PLAYED); in Visualizer_process()
424 fscale = 1.f / pContext->mChannelCount; // account for summing all the channels together. in Visualizer_process()
432 uint8_t *buf = pContext->mCaptureBuf; in Visualizer_process()
433 for (inIdx = 0, captIdx = pContext->mCaptureIdx; in Visualizer_process()
440 for (uint32_t i = 0; i < pContext->mChannelCount; ++i) { in Visualizer_process()
453 pContext->mCaptureIdx = captIdx; in Visualizer_process()
455 if (clock_gettime(CLOCK_MONOTONIC, &pContext->mBufferUpdateTime) < 0) { in Visualizer_process()
456 pContext->mBufferUpdateTime.tv_sec = 0; in Visualizer_process()
461 if (pContext->mConfig.outputCfg.accessMode == EFFECT_BUFFER_ACCESS_ACCUMULATE) { in Visualizer_process()
469 if (pContext->mConfig.outputCfg.accessMode == EFFECT_BUFFER_ACCESS_ACCUMULATE) { in Visualizer_process()
478 if (pContext->mState != VISUALIZER_STATE_ACTIVE) { in Visualizer_process()
487 VisualizerContext * pContext = (VisualizerContext *)self; in Visualizer_command() local
489 if (pContext == NULL || pContext->mState == VISUALIZER_STATE_UNINITIALIZED) { in Visualizer_command()
500 *(int *) pReplyData = Visualizer_init(pContext); in Visualizer_command()
507 *(int *) pReplyData = Visualizer_setConfig(pContext, in Visualizer_command()
515 Visualizer_getConfig(pContext, (effect_config_t *)pReplyData); in Visualizer_command()
518 Visualizer_reset(pContext); in Visualizer_command()
524 if (pContext->mState != VISUALIZER_STATE_INITIALIZED) { in Visualizer_command()
527 pContext->mState = VISUALIZER_STATE_ACTIVE; in Visualizer_command()
535 if (pContext->mState != VISUALIZER_STATE_ACTIVE) { in Visualizer_command()
538 pContext->mState = VISUALIZER_STATE_INITIALIZED; in Visualizer_command()
559 ALOGV("get mCaptureSize = %" PRIu32, pContext->mCaptureSize); in Visualizer_command()
560 *((uint32_t *)p->data + 1) = pContext->mCaptureSize; in Visualizer_command()
565 ALOGV("get mScalingMode = %" PRIu32, pContext->mScalingMode); in Visualizer_command()
566 *((uint32_t *)p->data + 1) = pContext->mScalingMode; in Visualizer_command()
571 ALOGV("get mMeasurementMode = %" PRIu32, pContext->mMeasurementMode); in Visualizer_command()
572 *((uint32_t *)p->data + 1) = pContext->mMeasurementMode; in Visualizer_command()
600 pContext->mCaptureSize = captureSize; in Visualizer_command()
605 pContext->mScalingMode = *((uint32_t *)p->data + 1); in Visualizer_command()
606 ALOGV("set mScalingMode = %" PRIu32, pContext->mScalingMode); in Visualizer_command()
613 pContext->mLatency = latency; in Visualizer_command()
617 pContext->mMeasurementMode = *((uint32_t *)p->data + 1); in Visualizer_command()
618 ALOGV("set mMeasurementMode = %" PRIu32, pContext->mMeasurementMode); in Visualizer_command()
631 uint32_t captureSize = pContext->mCaptureSize; in Visualizer_command()
637 if (pContext->mState == VISUALIZER_STATE_ACTIVE) { in Visualizer_command()
638 const uint32_t deltaMs = Visualizer_getDeltaTimeMsFromUpdatedTime(pContext); in Visualizer_command()
642 if ((pContext->mLastCaptureIdx == pContext->mCaptureIdx) && in Visualizer_command()
643 (pContext->mBufferUpdateTime.tv_sec != 0) && in Visualizer_command()
646 pContext->mBufferUpdateTime.tv_sec = 0; in Visualizer_command()
649 int32_t latencyMs = pContext->mLatency; in Visualizer_command()
655 + pContext->mConfig.inputCfg.samplingRate * latencyMs / 1000; in Visualizer_command()
666 __builtin_sub_overflow((int32_t)pContext->mCaptureIdx, deltaSmpl, &capturePoint); in Visualizer_command()
674 pContext->mCaptureBuf + CAPTURE_BUF_SIZE + capturePoint, in Visualizer_command()
681 pContext->mCaptureBuf + capturePoint, in Visualizer_command()
685 pContext->mLastCaptureIdx = pContext->mCaptureIdx; in Visualizer_command()
711 const int32_t delayMs = Visualizer_getDeltaTimeMsFromUpdatedTime(pContext); in Visualizer_command()
714 for (uint32_t i=0 ; i<pContext->mMeasurementWindowSizeInBuffers ; i++) { in Visualizer_command()
715 pContext->mPastMeasurements[i].mIsValid = false; in Visualizer_command()
716 pContext->mPastMeasurements[i].mPeakU16 = 0; in Visualizer_command()
717 pContext->mPastMeasurements[i].mRmsSquared = 0; in Visualizer_command()
719 pContext->mMeasurementBufferIdx = 0; in Visualizer_command()
724 for (uint32_t i=0 ; i < pContext->mMeasurementWindowSizeInBuffers ; i++) { in Visualizer_command()
725 if (pContext->mPastMeasurements[i].mIsValid) { in Visualizer_command()
726 if (pContext->mPastMeasurements[i].mPeakU16 > peakU16) { in Visualizer_command()
727 peakU16 = pContext->mPastMeasurements[i].mPeakU16; in Visualizer_command()
729 sumRmsSquared += pContext->mPastMeasurements[i].mRmsSquared; in Visualizer_command()
765 VisualizerContext * pContext = (VisualizerContext *) self; in Visualizer_getDescriptor() local
767 if (pContext == NULL || pDescriptor == NULL) { in Visualizer_getDescriptor()