PreProcessing Effects

238 views
Skip to first unread message

Uday Gupta

unread,
Jan 13, 2014, 2:35:15 PM1/13/14
to android...@googlegroups.com
Hi,

I understand that platform developers can add their own pre processing effects in audio_effects.conf.

If the conditions match, then in audio policy service getInput function, new AudioEffect will be created.

My question is how does this effect start. Basically, how does add_audio_effect get called to the HAL?

Thanks

Uday Gupta

unread,
Jan 14, 2014, 11:20:15 AM1/14/14
to android...@googlegroups.com
Hi,

Was able to figure out how the add_audio_effect is called. Was not loading the correct audio_effects.conf because of which the logs I had added were not showing up.

Now I have another problem. remove_audio_effects is not getting called.

AudioPolicyService::releaseInput->AudioPolicyManagerBase::releaseInput->mpClientInterface->closeInput->AudioFlinger::closeInput->closeInput_nonvirtual->AudioFlinger::RecordThread::clearInput(This will set mInput to NULL)
Then
AudioPolicyService::releaseInput->setPreProcessorEnabled

Now when with either AudioFlinger::EffectModule::stop_l or AudioFlinger::EffectModule::~EffectModule() is called audio_stream_t *stream = thread->stream(); returns NULL as mInput is already set to NULL earlier and therefore remove_audio_effect doesn't get called.

Is that a bug or I am looking at it wrong.

Thanks

Eric Laurent

unread,
Jan 14, 2014, 4:51:52 PM1/14/14
to android...@googlegroups.com
It is possible that remove_audio_effect is not called but as it is because the input stream has already been closed it should not be a problem. The HAL implementation should clean up its effect configuration if needed when the input stream is closed.

Uday Gupta

unread,
Jan 14, 2014, 8:16:09 PM1/14/14
to android...@googlegroups.com
Hi Eric,

We can take care of it in Audio HAL but logically speaking since audio flinger calls add_audio_effect, it should also call remove_audio_effect. Tried below change to call setPreProcessorEnabled before release_input and seems to work but don't know if it is right thing to do. Now I see remove_audio_effect being called twice.

void AudioPolicyService::releaseInput(audio_io_handle_t input)
{
    if (mpAudioPolicy == NULL) {
        return;
    }
    Mutex::Autolock _l(mLock);
    ssize_t index = mInputs.indexOfKey(input);
    if (index >= 0) {
        InputDesc *inputDesc = mInputs.valueAt(index);
        setPreProcessorEnabled(inputDesc, false);
        delete inputDesc;
    }

    mpAudioPolicy->release_input(mpAudioPolicy, input);

    mInputs.removeItemsAt(index);

Eric Laurent

unread,
Jan 15, 2014, 12:10:08 PM1/15/14
to android...@googlegroups.com
We could remove all effects in closeInput() but have to be careful with race conditions.
This is the only way to also address the case of pre processing controlled by apps and not released before the AudioRecord is closed.
But again I don't think this is a critical problem as any HAL design should take care of resource allocation and release for all possible code paths.

Uday Gupta

unread,
Jan 15, 2014, 1:12:52 PM1/15/14
to android...@googlegroups.com
Sure. Thanks for the help.
Reply all
Reply to author
Forward
0 new messages