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

Commit 9bacfeb5 authored by Puneeth Prabhu's avatar Puneeth Prabhu Committed by Andy Hung
Browse files

libeffects: Fix for crash during playback on bluetooth headset

Crash was because of uninitialized (invalid) number of channels.
Initialized channels to default value and ensured
that during set config channel and channel mask value
are updated per the input config.

Test: BT playback with Spotify, GPM (Sailfish)
Bug: 129804987
Bug: 130013184
Change-Id: I71069b13a90e02bfc3b5cb9bf69c4c65c10ae36f
parent 4066749e
Loading
Loading
Loading
Loading
+16 −0
Original line number Original line Diff line number Diff line
@@ -650,6 +650,9 @@ int LvmBundle_init(EffectContext *pContext){
    params.SpeakerType            = LVM_HEADPHONES;
    params.SpeakerType            = LVM_HEADPHONES;


    pContext->pBundledContext->SampleRate = LVM_FS_44100;
    pContext->pBundledContext->SampleRate = LVM_FS_44100;
#ifdef SUPPORT_MC
    pContext->pBundledContext->ChMask = AUDIO_CHANNEL_OUT_STEREO;
#endif


    /* Concert Sound parameters */
    /* Concert Sound parameters */
    params.VirtualizerOperatingMode   = LVM_MODE_OFF;
    params.VirtualizerOperatingMode   = LVM_MODE_OFF;
@@ -695,6 +698,11 @@ int LvmBundle_init(EffectContext *pContext){
    params.TE_OperatingMode       = LVM_TE_OFF;
    params.TE_OperatingMode       = LVM_TE_OFF;
    params.TE_EffectLevel         = 0;
    params.TE_EffectLevel         = 0;


#ifdef SUPPORT_MC
    params.NrChannels             =
        audio_channel_count_from_out_mask(AUDIO_CHANNEL_OUT_STEREO);
    params.ChMask                 = AUDIO_CHANNEL_OUT_STEREO;
#endif
    /* Activate the initial settings */
    /* Activate the initial settings */
    LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance,
    LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance,
                                         &params);
                                         &params);
@@ -1297,7 +1305,12 @@ int Effect_setConfig(EffectContext *pContext, effect_config_t *pConfig){
        return -EINVAL;
        return -EINVAL;
    }
    }


#ifdef SUPPORT_MC
    if (pContext->pBundledContext->SampleRate != SampleRate ||
        pContext->pBundledContext->ChMask != pConfig->inputCfg.channels) {
#else
    if(pContext->pBundledContext->SampleRate != SampleRate){
    if(pContext->pBundledContext->SampleRate != SampleRate){
#endif


        LVM_ControlParams_t     ActiveParams;
        LVM_ControlParams_t     ActiveParams;
        LVM_ReturnStatus_en     LvmStatus = LVM_SUCCESS;
        LVM_ReturnStatus_en     LvmStatus = LVM_SUCCESS;
@@ -1323,6 +1336,9 @@ int Effect_setConfig(EffectContext *pContext, effect_config_t *pConfig){
        LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "Effect_setConfig")
        LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "Effect_setConfig")
        ALOGV("\tEffect_setConfig Succesfully called LVM_SetControlParameters\n");
        ALOGV("\tEffect_setConfig Succesfully called LVM_SetControlParameters\n");
        pContext->pBundledContext->SampleRate = SampleRate;
        pContext->pBundledContext->SampleRate = SampleRate;
#ifdef SUPPORT_MC
        pContext->pBundledContext->ChMask = pConfig->inputCfg.channels;
#endif


        LvmEffect_limitLevel(pContext);
        LvmEffect_limitLevel(pContext);


+3 −0
Original line number Original line Diff line number Diff line
@@ -107,6 +107,9 @@ struct BundledEffectContext{
    LVM_FLOAT                       *pInputBuffer;
    LVM_FLOAT                       *pInputBuffer;
    LVM_FLOAT                       *pOutputBuffer;
    LVM_FLOAT                       *pOutputBuffer;
#endif
#endif
#ifdef SUPPORT_MC
    LVM_INT32                       ChMask;
#endif
};
};


/* SessionContext : One session */
/* SessionContext : One session */