audioflinger: initialize strategy to PRODUCT_STRATEGY_NONE
Properly initialize strategy to PRODUCT_STRATEGY_NONE.
In case, when there is no track created for a session, effect is not created at Threads.cpp, instead put in orphan chain. However, at the same time, effect is registered to audiopolicy.
AudioPolicy based on the strategy decides whether it is a music effect or not. As currently, default value is not set, strategy default is set to 0, which does not match to PRODUCT_STRATEGY_NONE, hence effects are not categorized properly as "music" effects in APM, which leads to starting a direct/offload track even though s/w effect is enabled.
Test: Enable s/w only effect, play a track, check it should not use offload/ direct output.
Test: run cts -m android.media.player.cts.MediaPlayerTest#testGapless1
Bug: 350667379
Change-Id: Id8305a7b6ac6ecddf00f6a9b5cb3bb7906857741
diff --git a/services/audioflinger/Effects.h b/services/audioflinger/Effects.h
index 46c44a6..b073fa6 100644
--- a/services/audioflinger/Effects.h
+++ b/services/audioflinger/Effects.h
@@ -683,7 +683,7 @@
uint32_t mRightVolume; // previous volume on right channel
uint32_t mNewLeftVolume; // new volume on left channel
uint32_t mNewRightVolume; // new volume on right channel
- product_strategy_t mStrategy; // strategy for this effect chain
+ product_strategy_t mStrategy = PRODUCT_STRATEGY_NONE; // strategy for this effect chain
// mSuspendedEffects lists all effects currently suspended in the chain.
// Use effect type UUID timelow field as key. There is no real risk of identical
// timeLow fields among effect type UUIDs.
@@ -778,7 +778,7 @@
void checkSuspendOnEffectEnabled(const sp<IAfEffectBase>& effect __unused,
bool enabled __unused, bool threadLocked __unused) override {}
void resetVolume_l() override REQUIRES(audio_utils::EffectChain_Mutex) {}
- product_strategy_t strategy() const override { return static_cast<product_strategy_t>(0); }
+ product_strategy_t strategy() const override { return PRODUCT_STRATEGY_NONE; }
int32_t activeTrackCnt() const override { return 0; }
void onEffectEnable(const sp<IAfEffectBase>& effect __unused) override;
void onEffectDisable(const sp<IAfEffectBase>& effect __unused) override;