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

Commit 91b0018d authored by Eric Laurent's avatar Eric Laurent Committed by Android (Google) Code Review
Browse files

Merge "Bug fix on Engine Configurable" into mnc-dev

parents 46d8eb1a 0f17ab7f
Loading
Loading
Loading
Loading
+3 −9
Original line number Original line Diff line number Diff line
@@ -49,17 +49,11 @@ PolicySubsystem::PolicySubsystem(const std::string &name)
    // Try to connect a Plugin Interface from Audio Policy Engine
    // Try to connect a Plugin Interface from Audio Policy Engine
    EngineInstance *engineInstance = EngineInstance::getInstance();
    EngineInstance *engineInstance = EngineInstance::getInstance();


    if (engineInstance == NULL) {
    ALOG_ASSERT(engineInstance != NULL, "NULL Plugin Interface");
    ALOG_ASSERT(engineInstance != NULL, "NULL Plugin Interface");
        return;

    }
    // Retrieve the Route Interface
    // Retrieve the Route Interface
    mPluginInterface = engineInstance->queryInterface<android::AudioPolicyPluginInterface>();
    mPluginInterface = engineInstance->queryInterface<android::AudioPolicyPluginInterface>();
    if (mPluginInterface == NULL) {
        // bailing out
    ALOG_ASSERT(mPluginInterface != NULL, "NULL Plugin Interface");
    ALOG_ASSERT(mPluginInterface != NULL, "NULL Plugin Interface");
        return;
    }


    // Provide mapping keys to the core, necessary when parsing the XML Structure files.
    // Provide mapping keys to the core, necessary when parsing the XML Structure files.
    addContextMappingKey(mKeyName);
    addContextMappingKey(mKeyName);
+26 −37
Original line number Original line Diff line number Diff line
@@ -87,11 +87,6 @@ Engine::Engine()
      mPolicyParameterMgr(new ParameterManagerWrapper()),
      mPolicyParameterMgr(new ParameterManagerWrapper()),
      mApmObserver(NULL)
      mApmObserver(NULL)
{
{
    if (mPolicyParameterMgr->start() != NO_ERROR) {
        ALOGE("%s: could not start Policy PFW", __FUNCTION__);
        delete mPolicyParameterMgr;
        mPolicyParameterMgr = NULL;
    }
}
}


Engine::~Engine()
Engine::~Engine()
@@ -111,10 +106,13 @@ void Engine::setObserver(AudioPolicyManagerObserver *observer)


status_t Engine::initCheck()
status_t Engine::initCheck()
{
{
    return (mPolicyParameterMgr != NULL) &&
    if (mPolicyParameterMgr != NULL && mPolicyParameterMgr->start() != NO_ERROR) {
            mPolicyParameterMgr->isStarted() &&
        ALOGE("%s: could not start Policy PFW", __FUNCTION__);
            (mApmObserver != NULL)?
        delete mPolicyParameterMgr;
                NO_ERROR : NO_INIT;
        mPolicyParameterMgr = NULL;
        return NO_INIT;
    }
    return (mApmObserver != NULL)? NO_ERROR : NO_INIT;
}
}


bool Engine::setVolumeProfileForStream(const audio_stream_type_t &streamType,
bool Engine::setVolumeProfileForStream(const audio_stream_type_t &streamType,
@@ -143,19 +141,6 @@ status_t Engine::add(const std::string &name, const Key &key)
    return collection.add(name, key);
    return collection.add(name, key);
}
}


template <>
routing_strategy Engine::getPropertyForKey<routing_strategy, audio_usage_t>(audio_usage_t usage) const
{
    const SwAudioOutputCollection &outputs = mApmObserver->getOutputs();

    if (usage == AUDIO_USAGE_ASSISTANCE_ACCESSIBILITY &&
            (outputs.isStreamActive(AUDIO_STREAM_RING) ||
             outputs.isStreamActive(AUDIO_STREAM_ALARM))) {
        return STRATEGY_SONIFICATION;
    }
    return getPropertyForKey<routing_strategy, audio_usage_t>(usage);
}

template <typename Property, typename Key>
template <typename Property, typename Key>
Property Engine::getPropertyForKey(Key key) const
Property Engine::getPropertyForKey(Key key) const
{
{
@@ -167,10 +152,21 @@ Property Engine::getPropertyForKey(Key key) const
    return element->template get<Property>();
    return element->template get<Property>();
}
}


template <>
routing_strategy Engine::ManagerInterfaceImpl::getStrategyForUsage(audio_usage_t usage)
audio_devices_t Engine::getPropertyForKey<audio_devices_t, routing_strategy>(routing_strategy strategy) const
{
{
    const SwAudioOutputCollection &outputs = mApmObserver->getOutputs();
    const SwAudioOutputCollection &outputs = mPolicyEngine->mApmObserver->getOutputs();

    if (usage == AUDIO_USAGE_ASSISTANCE_ACCESSIBILITY &&
            (outputs.isStreamActive(AUDIO_STREAM_RING) ||
             outputs.isStreamActive(AUDIO_STREAM_ALARM))) {
        return STRATEGY_SONIFICATION;
    }
    return mPolicyEngine->getPropertyForKey<routing_strategy, audio_usage_t>(usage);
}

audio_devices_t Engine::ManagerInterfaceImpl::getDeviceForStrategy(routing_strategy strategy) const
{
    const SwAudioOutputCollection &outputs = mPolicyEngine->mApmObserver->getOutputs();


    /** This is the only case handled programmatically because the PFW is unable to know the
    /** This is the only case handled programmatically because the PFW is unable to know the
     * activity of streams.
     * activity of streams.
@@ -187,19 +183,9 @@ audio_devices_t Engine::getPropertyForKey<audio_devices_t, routing_strategy>(rou
            !outputs.isStreamActiveRemotely(AUDIO_STREAM_MUSIC,
            !outputs.isStreamActiveRemotely(AUDIO_STREAM_MUSIC,
                                    SONIFICATION_RESPECTFUL_AFTER_MUSIC_DELAY) &&
                                    SONIFICATION_RESPECTFUL_AFTER_MUSIC_DELAY) &&
            outputs.isStreamActive(AUDIO_STREAM_MUSIC, SONIFICATION_RESPECTFUL_AFTER_MUSIC_DELAY)) {
            outputs.isStreamActive(AUDIO_STREAM_MUSIC, SONIFICATION_RESPECTFUL_AFTER_MUSIC_DELAY)) {
        return getPropertyForKey<audio_devices_t, routing_strategy>(STRATEGY_MEDIA);
        return mPolicyEngine->getPropertyForKey<audio_devices_t, routing_strategy>(STRATEGY_MEDIA);
    }
    }
    return getPropertyForKey<audio_devices_t, routing_strategy>(strategy);
    return mPolicyEngine->getPropertyForKey<audio_devices_t, routing_strategy>(strategy);
}

routing_strategy Engine::ManagerInterfaceImpl::getStrategyForUsage(audio_usage_t usage)
{
    return mPolicyEngine->getPropertyForKey<routing_strategy, audio_usage_t>(usage);
}

audio_devices_t Engine::ManagerInterfaceImpl::getDeviceForStrategy(routing_strategy stategy) const
{
    return mPolicyEngine->getPropertyForKey<audio_devices_t, routing_strategy>(stategy);
}
}


template <typename Property, typename Key>
template <typename Property, typename Key>
@@ -233,6 +219,9 @@ status_t Engine::initStreamVolume(audio_stream_type_t streamType,
        ALOGE("%s: Stream Type %d not found", __FUNCTION__, streamType);
        ALOGE("%s: Stream Type %d not found", __FUNCTION__, streamType);
        return BAD_TYPE;
        return BAD_TYPE;
    }
    }
    mApmObserver->getStreamDescriptors().setVolumeIndexMin(streamType, indexMin);
    mApmObserver->getStreamDescriptors().setVolumeIndexMax(streamType, indexMax);

    return stream->initVolume(indexMin, indexMax);
    return stream->initVolume(indexMin, indexMax);
}
}


+2 −1
Original line number Original line Diff line number Diff line
@@ -145,7 +145,7 @@ void ParameterManagerWrapper::loadCriterionType(cnode *root, bool isInclusive)


        ALOG_ASSERT(node != NULL, "error in parsing file");
        ALOG_ASSERT(node != NULL, "error in parsing file");
        const char *typeName = node->name;
        const char *typeName = node->name;
        char *valueNames = (char *)node->value;
        char *valueNames = strndup(node->value, strlen(node->value));


        addCriterionType(typeName, isInclusive);
        addCriterionType(typeName, isInclusive);


@@ -178,6 +178,7 @@ void ParameterManagerWrapper::loadCriterionType(cnode *root, bool isInclusive)
            }
            }
            valueName = strtok_r(NULL, ",", &ctx);
            valueName = strtok_r(NULL, ",", &ctx);
        }
        }
        free(valueNames);
    }
    }
}
}


+7 −62
Original line number Original line Diff line number Diff line
@@ -24,7 +24,7 @@
#          * 1 << N -> (N+1)th literal value,
#          * 1 << N -> (N+1)th literal value,
#
#
#########################################################
#########################################################
# Route|Audio {
# Policy {
#    InclusiveCriterionType|ExclusiveCriterionType {
#    InclusiveCriterionType|ExclusiveCriterionType {
#        <Criterion Name>  [numerical value 1:]<literal value 1>,[numerical value 2:]<literal value 2>,<literal value 3>,...
#        <Criterion Name>  [numerical value 1:]<literal value 1>,[numerical value 2:]<literal value 2>,<literal value 3>,...
#    }
#    }
@@ -33,7 +33,7 @@
#########################################################
#########################################################
# Criterion:
# Criterion:
#########################################################
#########################################################
# Route|Audio {
# Policy {
#    Criterion {
#    Criterion {
#        <Criterion Name> {
#        <Criterion Name> {
#            Type            <Criterion type name>
#            Type            <Criterion type name>
@@ -43,21 +43,12 @@
# }
# }


Policy {
Policy {
    ExclusiveCriterionType {
        #
        # The values of the mode MUST be aligned with the definition of the audio_mode_t
        # from system/audio.h
        #
        AndroidModeType     0:Normal,1:RingTone,2:InCall,3:InCommunication
    }
    InclusiveCriterionType {
    InclusiveCriterionType {
        #
        #
        # DO NOT CHANGE ORDER. This definition must be aligned with the definition of
        # DO NOT CHANGE ORDER. This definition must be aligned with the definition of
        # AUDIO_DEVICE_OUT_* within <system/audio.h> file of android.
        # AUDIO_DEVICE_OUT_* within <system/audio.h> file of android.
        #
        #
        OutputDevicesMaskType   Earpiece,Speaker,WiredHeadset,WiredHeadphone,BluetoothSco,BluetoothScoHeadset,BluetoothScoCarkit,BluetoothA2dp,BluetoothA2dpHeadphones,BluetoothA2dpSpeaker,Hdmi,AnlgDockHeadset,DgtlDockHeadset,UsbAccessory,UsbDevice,RemoteSubmix,TelephonyTx,Line,HdmiArc,Spdif,Fm,AuxLine,SpeakerSafe
        OutputDevicesMaskType   Earpiece,Speaker,WiredHeadset,WiredHeadphone,BluetoothSco,BluetoothScoHeadset,BluetoothScoCarkit,BluetoothA2dp,BluetoothA2dpHeadphones,BluetoothA2dpSpeaker,Hdmi,AnlgDockHeadset,DgtlDockHeadset,UsbAccessory,UsbDevice,RemoteSubmix,TelephonyTx,Line,HdmiArc,Spdif,Fm,AuxLine,SpeakerSafe
    }
    InclusiveCriterionType {
        #
        #
        # DO NOT CHANGE ORDER. This definition must be aligned with the definition of
        # DO NOT CHANGE ORDER. This definition must be aligned with the definition of
        # AUDIO_DEVICE_IN_* within <system/audio.h> file of android.
        # AUDIO_DEVICE_IN_* within <system/audio.h> file of android.
@@ -67,122 +58,76 @@ Policy {
        InputDevicesMaskType    Communication,Ambient,BuiltinMic,BluetoothScoHeadset,WiredHeadset,Hdmi,TelephonyRx,BackMic,RemoteSubmix,AnlgDockHeadset,DgtlDockHeadset,UsbAccessory,UsbDevice,FmTuner,TvTune,Line,Spdif,BluetoothA2dp,Loopback
        InputDevicesMaskType    Communication,Ambient,BuiltinMic,BluetoothScoHeadset,WiredHeadset,Hdmi,TelephonyRx,BackMic,RemoteSubmix,AnlgDockHeadset,DgtlDockHeadset,UsbAccessory,UsbDevice,FmTuner,TvTune,Line,Spdif,BluetoothA2dp,Loopback
    }
    }
    ExclusiveCriterionType {
    ExclusiveCriterionType {
        #
        # The values of the mode MUST be aligned with the definition of the audio_mode_t
        # from system/audio.h
        #
        AndroidModeType     0:Normal,1:RingTone,2:InCall,3:InCommunication
        #
        #
        # The values of the mode MUST be aligned with the definition of the
        # The values of the mode MUST be aligned with the definition of the
        # audio_policy_forced_config_t from system/audio.h
        # audio_policy_forced_config_t from system/audio.h
        #
        #
        ForceUseForCommunicationType    0:ForceNone,1:ForceSpeaker,3:ForceBtSco
        ForceUseForCommunicationType    0:ForceNone,1:ForceSpeaker,3:ForceBtSco
    }
    ExclusiveCriterionType {
        #
        #
        # The values of the mode MUST be aligned with the definition of the
        # The values of the mode MUST be aligned with the definition of the
        # audio_policy_forced_config_t from system/audio.h
        # audio_policy_forced_config_t from system/audio.h
        #
        #
        ForceUseForMediaType            0:ForceNone,1:ForceSpeaker,2:ForceHeadphones,4:ForceBtA2dp,5:ForceWiredAccessory,8:ForceAnalogDock,9:ForceDigitalDock,10:ForceNoBtA2dp
        ForceUseForMediaType            0:ForceNone,1:ForceSpeaker,2:ForceHeadphones,4:ForceBtA2dp,5:ForceWiredAccessory,8:ForceAnalogDock,9:ForceDigitalDock,10:ForceNoBtA2dp
    }
    ExclusiveCriterionType {
        #
        #
        # The values of the mode MUST be aligned with the definition of the
        # The values of the mode MUST be aligned with the definition of the
        # audio_policy_forced_config_t from system/audio.h
        # audio_policy_forced_config_t from system/audio.h
        #
        #
        ForceUseForRecordType           0:ForceNone,3:ForceBtSco,5:ForceWiredAccessory
        ForceUseForRecordType           0:ForceNone,3:ForceBtSco,5:ForceWiredAccessory
    }
    ExclusiveCriterionType {
        #
        #
        # The values of the mode MUST be aligned with the definition of the
        # The values of the mode MUST be aligned with the definition of the
        # audio_policy_forced_config_t from system/audio.h
        # audio_policy_forced_config_t from system/audio.h
        #
        #
        ForceUseForDockType             0:ForceNone,5:ForceWiredAccessory,6:ForceBtCarDock,7:ForceBtDeskDock,8:ForceAnalogDock,9:ForceDigitalDock
        ForceUseForDockType             0:ForceNone,5:ForceWiredAccessory,6:ForceBtCarDock,7:ForceBtDeskDock,8:ForceAnalogDock,9:ForceDigitalDock
    }
    ExclusiveCriterionType {
        #
        #
        # The values of the mode MUST be aligned with the definition of the
        # The values of the mode MUST be aligned with the definition of the
        # audio_policy_forced_config_t from system/audio.h
        # audio_policy_forced_config_t from system/audio.h
        #
        #
        ForceUseForSystemType           0:ForceNone,11:ForceSystemEnforced
        ForceUseForSystemType           0:ForceNone,11:ForceSystemEnforced
    }
    ExclusiveCriterionType {
        #
        #
        # The values of the mode MUST be aligned with the definition of the
        # The values of the mode MUST be aligned with the definition of the
        # audio_policy_forced_config_t from system/audio.h
        # audio_policy_forced_config_t from system/audio.h
        #
        #
        ForceUseForHdmiSystemAudioType  0:ForceNone,12:ForceHdmiSystemEnforced
        ForceUseForHdmiSystemAudioType  0:ForceNone,12:ForceHdmiSystemEnforced
    }
    }
    ExclusiveCriterionType {
        Rate   8000,11025,12000,16000,22050,24000,32000,44100,48000,96000,176400,192000
    }
    ExclusiveCriterionType {
        Format  Mp3,AmrNb,AmrWb,Aac,HeAacV1,HeAacV2,Vorbis,Pcm16Bit,Pcm8Bit,Pcm32Bit,Pcm8_24Bit
    }
    InclusiveCriterionType {
        OutputChannelMask    FrontLeft,FrontRight,FrontCenter,LowFrequence,BackLeft,BackRight,FromLeftOfCenter,FromRightOfCenter,BackCenter,SideLeft,SideRight,TopCenter,TopFrontLeft,TopFrontCenter,TopFrontRight,TopBackLeft,TopBackCenter,TopBackRight
    }
    ExclusiveCriterionType {
        OutputChannelMasks    Mono,Stereo,Quad,QuadBack,QuadSide,5Point1,5Point1Back,5Point1Side,7Point1,All
    }
    InclusiveCriterionType {
        InputChannelMask   Left,Right,Front,Back,LeftProcessed,RightProcessed,FrontProcessed,BackProcessed,Pressure,XAxis,YAxis,ZAxis,VoiceUplink,VoiceDnlink
    }
    ExclusiveCriterionType {
        InputChannelMasks   Mono,Stereo,FrontBack,VoiceUplinkDnlink,All
    }
    InclusiveCriterionType {
        OutputFlags  Direct,Primary,Fast,DeepBuffer,CompressOffload,NonBlocking,HwAvSync
    }
    ExclusiveCriterionType {
        InputSource     Default,Mic,VoiceUplink,VoiceDownlink,VoiceCall,Camcorder,VoiceRecognition,VoiceCommunication,RemoteSubmix,Hotword
    }



    Criterion {
    Criterion {
        AvailableInputDevices {
        AvailableInputDevices {
            Type            InputDevicesMaskType
            Type            InputDevicesMaskType
            Default         none
            Default         none
        }
        }
    }
    Criterion {
        AvailableOutputDevices {
        AvailableOutputDevices {
            Type            OutputDevicesMaskType
            Type            OutputDevicesMaskType
            Default         none
            Default         none
        }
        }
    }
    Criterion {
        TelephonyMode {
        TelephonyMode {
            Type            AndroidModeType
            Type            AndroidModeType
            Default         Normal
            Default         Normal
        }
        }
    }
    Criterion {
        ForceUseForCommunication {
        ForceUseForCommunication {
            Type            ForceUseForCommunicationType
            Type            ForceUseForCommunicationType
            Default         ForceNone
            Default         ForceNone
        }
        }
    }
    Criterion {
        ForceUseForMedia {
        ForceUseForMedia {
            Type            ForceUseForMediaType
            Type            ForceUseForMediaType
            Default         ForceNone
            Default         ForceNone
        }
        }
    }
    Criterion {
        ForceUseForRecord {
        ForceUseForRecord {
            Type            ForceUseForRecordType
            Type            ForceUseForRecordType
            Default         ForceNone
            Default         ForceNone
        }
        }
    }
    Criterion {
        ForceUseForDock {
        ForceUseForDock {
            Type            ForceUseForDockType
            Type            ForceUseForDockType
            Default         ForceNone
            Default         ForceNone
        }
        }
    }
    Criterion {
        ForceUseForSystem {
        ForceUseForSystem {
            Type            ForceUseForSystemType
            Type            ForceUseForSystemType
            Default         ForceNone
            Default         ForceNone
        }
        }
    }
    Criterion {
        ForceUseForHdmiSystemAudio {
        ForceUseForHdmiSystemAudio {
            Type            ForceUseForHdmiSystemAudioType
            Type            ForceUseForHdmiSystemAudioType
            Default         ForceNone
            Default         ForceNone