Skip to content

Misc player loop/stream refactors#13135

Merged
absurdlylongusername merged 2 commits intodevfrom
unknown repository
Feb 21, 2026
Merged

Misc player loop/stream refactors#13135
absurdlylongusername merged 2 commits intodevfrom
unknown repository

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Jan 28, 2026

What is it?

  • Codebase improvement (dev facing)

Description of the changes in your PR

  • Some player loop/stream refactors

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. You can find more info and a video demonstration on this wiki page.

Due diligence

@github-actions github-actions Bot added the size/medium PRs with less than 250 changed lines label Jan 28, 2026
Comment on lines -819 to +826
int before = 0;
int after = 0;

final List<PlayQueueItem> streams = playQueue.getStreams();
final int nStreams = streams.size();

for (int i = 0; i < nStreams; i++) {
if (i < currentStream) {
before += streams.get(i).getDuration();
} else {
after += streams.get(i).getDuration();
}
}
final long before = streams.subList(0, currentStream).stream()
.collect(Collectors.summingLong(PlayQueueItem::getDuration)) * 1000;

before *= 1000;
after *= 1000;
final long after = streams.subList(currentStream, streams.size()).stream()
.collect(Collectors.summingLong(PlayQueueItem::getDuration)) * 1000;
Copy link
Copy Markdown
Author

@ghost ghost Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@absurdlylongusername this part was getting messy because before and after were expected to be int (consumed later as int but PlayQeueItem stored longs). That is why I asked about this strange mix of ints and longs...

@ShareASmile ShareASmile added the code quality Improvements to the codebase to improve the code quality label Jan 29, 2026
@ghost ghost force-pushed the player_loop_refactor branch from e93c90e to 5ab024e Compare January 31, 2026 10:35
Yevhen Babiichuk (DustDFG) added 2 commits February 10, 2026 11:24
Duration data in the player code incosnistently typed. Half code
uses ints and half uses longs. Recieve longs in this function to
allow both halfs of player code just use the function without
nasty long to int downcasting warnings/errors in code
@ghost ghost force-pushed the player_loop_refactor branch from 5ab024e to 3a0a3a4 Compare February 10, 2026 09:26
@absurdlylongusername
Copy link
Copy Markdown
Member

absurdlylongusername commented Feb 10, 2026

Looks good to me, but I think all refactors should come with tests, otherwise we have absolutely no guarantee on functionality apart from just eyeballing the code. @dustdfg Are you able to add tests for the refactored code?

@ghost
Copy link
Copy Markdown
Author

ghost commented Feb 10, 2026

Looks good to me, but I think all refactors should come with tests, otherwise we have absolutely no guarantee on functionality apart from just eyeballing the code. @dustdfg Are you able to add tests for the refactored code?

Yeah, I think

@ghost
Copy link
Copy Markdown
Author

ghost commented Feb 16, 2026

@dustdfg Are you able to add tests for the refactored code?

Yeah, I think

I don't think so anymore, I've failed on adding test for much simpler thing with much less dependencies and mocking

@absurdlylongusername
Copy link
Copy Markdown
Member

@dustdfg Okay. If I haven't added the tests myself to this PR within 48hrs, then I will approve and merge.

@absurdlylongusername absurdlylongusername merged commit 4481dd7 into TeamNewPipe:dev Feb 21, 2026
5 checks passed
@absurdlylongusername
Copy link
Copy Markdown
Member

Changed my mind; it's more efficient to merge this and add tests in a later PR

@ghost ghost deleted the player_loop_refactor branch February 21, 2026 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code quality Improvements to the codebase to improve the code quality size/medium PRs with less than 250 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants