Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b38362b6 authored by Haynes Mathew George's avatar Haynes Mathew George Committed by Linux Build Service Account
Browse files

audiopolicy: Add synchronization to EffectDescriptorCollection

Synchronize public APIs of EffectDescriptorCollection

CRs-Fixed: 920103
Change-Id: I04ccac526c6f99e61e43288776653d6b7ff325c4
parent 8e7ad521
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@
#include <utils/KeyedVector.h>
#include <utils/RefBase.h>
#include <utils/Errors.h>
#include <utils/Thread.h>

namespace android {

@@ -67,6 +68,8 @@ private:
     * Maximum memory allocated to audio effects in KB
     */
    static const uint32_t MAX_EFFECTS_MEMORY = 512;

    Mutex mLock;
};

}; // namespace android
+5 −0
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ status_t EffectDescriptorCollection::registerEffect(const effect_descriptor_t *d
                                                    int session,
                                                    int id)
{
    Mutex::Autolock _l(mLock);
    if (mTotalEffectsMemory + desc->memoryUsage > getMaxEffectsMemory()) {
        ALOGW("registerEffect() memory limit exceeded for Fx %s, Memory %d KB",
                desc->name, desc->memoryUsage);
@@ -84,6 +85,7 @@ status_t EffectDescriptorCollection::registerEffect(const effect_descriptor_t *d

status_t EffectDescriptorCollection::unregisterEffect(int id)
{
    Mutex::Autolock _l(mLock);
    ssize_t index = indexOfKey(id);
    if (index < 0) {
        ALOGW("unregisterEffect() unknown effect ID %d", id);
@@ -110,6 +112,7 @@ status_t EffectDescriptorCollection::unregisterEffect(int id)

status_t EffectDescriptorCollection::setEffectEnabled(int id, bool enabled)
{
    Mutex::Autolock _l(mLock);
    ssize_t index = indexOfKey(id);
    if (index < 0) {
        ALOGW("unregisterEffect() unknown effect ID %d", id);
@@ -152,6 +155,7 @@ status_t EffectDescriptorCollection::setEffectEnabled(const sp<EffectDescriptor>

bool EffectDescriptorCollection::isNonOffloadableEffectEnabled()
{
    Mutex::Autolock _l(mLock);
    for (size_t i = 0; i < size(); i++) {
        sp<EffectDescriptor> effectDesc = valueAt(i);
        if (effectDesc->mEnabled && (effectDesc->mStrategy == STRATEGY_MEDIA) &&
@@ -176,6 +180,7 @@ uint32_t EffectDescriptorCollection::getMaxEffectsMemory() const

status_t EffectDescriptorCollection::dump(int fd)
{
    Mutex::Autolock _l(mLock);
    const size_t SIZE = 256;
    char buffer[SIZE];