Skip to content
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

Open
wants to merge 9 commits into
base: 2.5
Choose a base branch
from
Open

Num deck steamline #14112

wants to merge 9 commits into from

Conversation

daschuer
Copy link
Member

@daschuer daschuer commented Jan 3, 2025

This mainly fixes a lifetime issue with the non owning

static QAtomicPointer<ControlProxy> PlayerManager::m_pCOPNumDecks;

Since it is non owning it can become dangling. I have fixed it by moving it as a PollingControlProxy to the singleton PlayerInfo class

auto deck1 = m_pPlayerManager->getDeck(1);
auto deck1 = m_pPlayerManager->getDeck(0);
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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);
Copy link
Member Author

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);
Copy link
Member Author

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

@daschuer daschuer changed the base branch from main to 2.5 January 3, 2025 16:40
src/coreservices.cpp Outdated Show resolved Hide resolved
Comment on lines 39 to 40
// 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;
Copy link
Member

Choose a reason for hiding this comment

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

Why this replacement?

Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants