-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Various fixes related to MediasessionManager #7166
Various fixes related to MediasessionManager #7166
Conversation
* Built on top of Redirons changes * MediaSessionManager-Metadata get's only update when metadata changes - not every second as it only changes when the metadata changes * Reworked mediasessionmanager
you could add the result of isLiveEdge to decide whether to check the duration |
I can't follow. Where do you mean should I add this? |
sorry isLiveEdge was wrong. But you can use isLive():
you could use it as an additional parameter:
this way you can use duration for comparisons if it isn't a livestream |
Duration comparison is already always done: NewPipe/app/src/main/java/org/schabi/newpipe/player/helper/MediaSessionManager.java Line 143 in bbc1375
So I don't understand the problem in the first place... Anyway the check for I changed the code so that it now considers livestream and always uses duration -1 for them 😄 |
Yep sorry, all good |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Two personal preferences as a comment:
- I would always prefer equals over hashCode for String comparisons
- I would rather have a bit duplicated code by using more than one method than having a method with many return statements
I also considered that. However the deal with hashCode is that storing an int requires usually way less RAM than a String by - what I think are accaptable odds - of having an collision: Which is technically 1 in 2^32. |
What is it?
Description of the changes in your PR
The following things are fixed
from #7161 (credits to @Redirion)
I also reworked/de-duplicated the code a bit 😉
Issue 3: #7087
#7087 (comment)
Issue 4:
Comparisons e.g. if the current title/artist/duration is also the requested one have been missing.
Added those by caching the last requested data using hashcodes.
This also avoids resource-intensive
mediaSession.getController().getMetadata()
calls.With the changes applied there is a massive performance improvement
triggerProgressUpdate
now runs within 4-13ms / 0,7-2ms (cpu):Before it has been 30-130ms / 6-12ms (cpu):
So this decreases execution time of the
progress update loop
by about 10x (at least on my emulated Pixel 3a).Fixes the following issue(s)
APK testing
The APK can be found by going to the "Checks" tab below the title. On the left pane, click on "CI", scroll down to "artifacts" and click "app" to download the zip file which contains the debug APK of this PR.
Due diligence