lineage-next / android_packages_apps_Twelve

🎵
8 stars 1 forks source link

Twelve: Introduce conflatedCallbackFlow #44

Closed luca020400 closed 1 month ago

luca020400 commented 1 month ago

callbackFlow has an internal buffer that most of the time we don't care about.

Switch the player to that.

SebaUbuntu commented 1 month ago

Can't you just add .conflate() to playbackStatusFlow?

SebaUbuntu commented 1 month ago

channelFlow also exists, I have no idea if there's a difference

luca020400 commented 1 month ago

Can't you just add .conflate() to playbackStatusFlow?

Yes, but I'm splitting all playback updates into singular flows to avoid uneeded UI updates and all of them are conflated

Also https://cs.android.com/android/platform/superproject/main/+/main:frameworks/base/packages/SystemUI/utils/src/com/android/systemui/utils/coroutines/flow/FlowConflated.kt https://cs.android.com/android/platform/superproject/main/+/main:frameworks/base/packages/SystemUI/utils/src/com/android/systemui/utils/coroutines/flow/LatestConflated.kt

Google uses callbackFlow (conflated) every time there is a callback, so that seems to me the correct thing to use at least for us, also callbackFlow extends ChannelFlow.