-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Num deck steamline #14112
base: 2.5
Are you sure you want to change the base?
Num deck steamline #14112
Conversation
…c lifetime issues.
auto deck1 = m_pPlayerManager->getDeck(1); | ||
auto deck1 = m_pPlayerManager->getDeck(0); |
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.
our [ChannelN]
COs are 1-based while this is now 0-based. Is that really an improvement? I'm concerned this will cause confusion and off-by-one errors later.
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.
You point out the downside of the change.
The benefit is that it now matches PlayerManager::groupForDeck(i)
and pevents cases where we have to + 1 before the call and - 1 after it.
Like here: (I will also place an inline comment)
for (int i = 0; i < m_pPlayerManager->numberOfSamplers(); ++i) {
In addition there was a naming clash with Index vs. Number.
In general we should stick to the rule to use 0 based counting inside the code base and 1 base in all user visible cases.
Please have a second look. If you still think we should keep the 1 based index here I will fix the issue in that direction.
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.
Thank you for the explanation. I see the tension there. I too prefer 0-based indexing. I will take a second look.
QString group = PlayerManager::groupForDeck(i); | ||
BaseTrackPlayer* pPlayer = pPlayerManager->getPlayer(group); | ||
for (int i = 0; i < pPlayerManager->numberOfDecks(); ++i) { | ||
BaseTrackPlayer* pPlayer = pPlayerManager->getDeckBase(i); |
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.
Here we benefit form the 0 base.
for (unsigned int i = 0; i < m_pPlayerManager->numSamplers(); ++i) { | ||
Sampler* pSampler = m_pPlayerManager->getSampler(i + 1); | ||
for (int i = 0; i < m_pPlayerManager->numberOfSamplers(); ++i) { | ||
Sampler* pSampler = m_pPlayerManager->getSampler(i); |
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.
Here we benefit form the 0 based index
src/mixer/playermanager.h
Outdated
// Get the deck by its deck number. Decks are numbered starting with 1. | ||
virtual Deck* getDeck(unsigned int player) const = 0; | ||
// Get the deck by its deck index | ||
virtual BaseTrackPlayer* getDeckBase(int deckIndex) const = 0; |
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.
Why this replacement?
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.
This interface allows the unittest to return a mocked Deck instead of the real one. I will add a comment. Before getPlayer()
has been used, which requires a QString group for lookup. I will add a comment.
53ab2c0
to
b47a282
Compare
Co-authored-by: Swiftb0y <[email protected]>
b47a282
to
6ec70aa
Compare
This mainly fixes a lifetime issue with the non owning
Since it is non owning it can become dangling. I have fixed it by moving it as a PollingControlProxy to the singleton PlayerInfo class