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

Do not create a new loop if it's the same as an existing loop #11006

Merged
merged 5 commits into from
Nov 3, 2022

Conversation

ywwg
Copy link
Member

@ywwg ywwg commented Oct 25, 2022

This works around #11003 in which the adjustment of the spinbox creates a new loop, causing a sudden unexpected seek

This works around mixxxdj#11003 in which the adjustment of the spinbox creates a new loop, causing a sudden unexpected seek
@ywwg ywwg marked this pull request as ready for review October 25, 2022 16:53
@ywwg ywwg marked this pull request as draft October 25, 2022 16:54
@ywwg
Copy link
Member Author

ywwg commented Oct 25, 2022

hmmmm this is supposed to be covered by currentLoopMatchesBeatloopSize

@ywwg ywwg closed this Oct 25, 2022
@ywwg ywwg reopened this Oct 25, 2022
@ywwg ywwg marked this pull request as ready for review October 25, 2022 18:53
Also pass in loopinfo to checking functions to make more const-safe
Copy link
Member

@daschuer daschuer left a comment

Choose a reason for hiding this comment

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

Even though this PR fixes the issue, we have the situation that the final loop does not match the stored one. It is the normalized version due to the Beat Spin Box roundtrip.

I think we should avoid this in the first place.

Looking at your backtrace we may call
blockSignals(true);
in WBeatSpinBox::slotControlValueChanged

Will this this be a solution?

return positionNear(loopInfo.endPosition, loopEndPosition);
}

bool LoopingControl::positionNear(mixxx::audio::FramePos a, mixxx::audio::FramePos target) const {
Copy link
Member

Choose a reason for hiding this comment

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

This function does not use the object and can be therefore a free function in the anonymous namespace.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

// Only update seek mode if the endpoints have changed sufficiently.
if (positionNear(newloopInfo.startPosition, loopInfo.startPosition) &&
positionNear(newloopInfo.endPosition, loopInfo.endPosition)) {
newloopInfo.seekMode = loopInfo.seekMode;
Copy link
Member

Choose a reason for hiding this comment

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

When the play head is behind the new playposition but before the old position, the loop is activated but the playhead keeps running outside the loop. This must not happen.
So I think we need here:

newloopInfo.seekMode = LoopSeekMode::MovedOut;

Copy link
Member Author

Choose a reason for hiding this comment

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

when you say "new play position" do you mean "new start position"? This function has no concept of "old and new play head position".

It is fine to activate loops when the play head is before the loop start position, this is the intended behavior.

Copy link
Member

Choose a reason for hiding this comment

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

The current play position is relevant when seek mode is used. In a rare condition it can be in the gap between the old and new end position. Let's say loopInfo.endPosition 101, play-position at 100.5 and newloopInfo.endPosition = 100.
Without LoopSeekMode::MovedOut; the loop will be exited. I think that is undesired,

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, updated

@ywwg
Copy link
Member Author

ywwg commented Oct 30, 2022

Will this this be a solution?

yes I think that might do it, I'll try that.

ah, but we do want to emit a signal when the user changes the spinbox.

Block signals in setLoop to prevent loop size widget updating from emitting more signals.
Small refactor
@ywwg ywwg requested a review from daschuer November 3, 2022 02:49
Copy link
Member

@daschuer daschuer left a comment

Choose a reason for hiding this comment

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

LGTM, thank you.

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

Successfully merging this pull request may close these issues.

None yet

2 participants