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

AutoDJ: handle "enabled" CO change requests like clicks on the GUI button #11495

Merged
merged 3 commits into from
May 3, 2023

Conversation

ronso0
Copy link
Member

@ronso0 ronso0 commented Apr 18, 2023

otherwise, if AutoDJ refuses to start because of unmet conditions, no error messages are shown and the CO remains in 'enabled' state.

Fixes #11494

@daschuer
Copy link
Member

I experience a stack overflow during due a recursive loop during testing:

#57 AutoDJProcessor::toggleAutoDJ(bool) (this=0x0, enable=<optimized out>)
    at ../../src/library/autodj/autodjprocessor.cpp:432
#58 0x0000555555dfed91 in DlgAutoDJ::toggleAutoDJButton(bool)
    (this=0x55556a42c4a0, enable=<optimized out>)
    at ../../src/library/autodj/dlgautodj.cpp:279
#59 0x00007ffff3cbf328 in QtPrivate::QSlotObjectBase::call(QObject*, void**)
    (a=0x7fffff801a70, r=0x55556a42c4a0, this=0x55556a4ba1e0)
    at ../../include/QtCore/../../src/corelib/kernel/qobjectdefs_impl.h:394
#60 QMetaObject::activate(QObject*, int, int, void**)
    (sender=0x55555b644550, signalOffset=<optimized out>, local_signal_index=<optimized out>, argv=<optimized out>) at kernel/qobject.cpp:3784
#61 0x0000555555df2086 in AutoDJProcessor::autoDJStateChangeRequest(bool)
    (this=<optimized out>, _t1=<optimized out>)
    at mixxx-lib_autogen/include/moc_autodjprocessor.cpp:805
#62 0x00007ffff3cbf328 in QtPrivate::QSlotObjectBase::call(QObject*, void**)
    (a=0x7fffff801ba0, r=0x55555b644550, this=0x55555b63e950)
    at ../../include/QtCore/../../src/corelib/kernel/qobjectdefs_impl.h:394
#63 QMetaObject::activate(QObject*, int, int, void**)
    (sender=0x55555b6682d0, signalOffset=<optimized out>, local_signal_index=<optimized out>, argv=<optimized out>) at kernel/qobject.cpp:3784
#64 0x00005555559a5d67 in ControlDoublePrivate::valueChangeRequest(double)
    (this=this@entry=0x55555b6682d0, _t1=<optimized out>)
--Type <RET> for more, q to quit, c to continue without paging--
    at mixxx-lib_autogen/include/moc_control.cpp:151
#65 0x00005555559a6658 in ControlDoublePrivate::set(double, QObject*)
    (this=0x55555b6682d0, value=<optimized out>, pSender=0x55555b63f4c0)
    at ../../src/control/control.cpp:208
#66 0x0000555555df6b73 in ControlObject::set(double)
    (value=1, this=<optimized out>) at ../../src/control/controlobject.h:83
#67 AutoDJProcessor::toggleAutoDJ(bool) (this=0x0, enable=<optimized out>)
    at ../../src/library/autodj/autodjprocessor.cpp:432

@daschuer
Copy link
Member

The loop can be broken by m_pEnabledAutoDJ->setAndConfirm() inside AutoDJProcessor::toggleAutoDJ() maybe we also need to adjust the checks of the m_pEnabledAutoDJ->get(), because it returns now the confirmed value and not like before unconfirmed value.

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.

.

@ronso0
Copy link
Member Author

ronso0 commented Apr 18, 2023

Yep, I agree. I simply forgot to change set to setAndConfirm.

@ronso0 ronso0 force-pushed the autodj-refuse-start-hotkey branch from 7827453 to c2e715c Compare April 19, 2023 00:07
@ronso0
Copy link
Member Author

ronso0 commented Apr 19, 2023

The previous fix / hack with the signal sent to DlgAutoDJ and back to AutoDJPrcessor felt too much like a ahck so I tried to fix the root cause by emitting an error code signal (instead of return values).

m_pEnabledAutoDJ->set(0.0);
}
qDebug() << "Queue is empty now, disable Auto DJ";
m_pEnabledAutoDJ->setAndConfirm(0.0);
Copy link
Member Author

Choose a reason for hiding this comment

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

I think we don't need these in the enable anymore.
Didn't look close enough, yet, to be sure.


// TODO If there's a way to migrate the translations move this
// to AutoDJProcessor in order to keep this class minimal
void DlgAutoDJ::autoDJError(AutoDJProcessor::AutoDJError error) {
Copy link
Member Author

Choose a reason for hiding this comment

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

I have no experience with Transifex: is it smart enough to keep the existing translations?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, as long as the original string and the name of the surrounding QObject is not changed.

@ronso0 ronso0 force-pushed the autodj-refuse-start-hotkey branch from c2e715c to d717db0 Compare April 19, 2023 00:16
switch (error) {
case AutoDJProcessor::ADJ_NOT_TWO_DECKS:
QMessageBox::warning(nullptr,
tr("Auto DJ"),
tr("Auto DJ requires two decks assigned to opposite sides of the crossfader."),
QMessageBox::Ok);
// Make sure the button becomes unpushed.
pushButtonAutoDJ->setChecked(false);
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 and below: obsolete, since AutoDJProcessor::autoDJStateChanged signal >> DlgAutoDJ::autoDJStateChanged updates the GUI

@ronso0 ronso0 force-pushed the autodj-refuse-start-hotkey branch from d717db0 to 7f50877 Compare April 19, 2023 12:56
@ronso0
Copy link
Member Author

ronso0 commented Apr 19, 2023

In the first run I didn't build the tests and didn't notice they require the return value.

This is now unchanged and the error codes are emitted additionally after the new/unchanged AutoDJ state is emitted to update the GUI. The separate error handling also allows to show error messages in some yet uncovered situations.

This allows to handle both clicks on the Enable GUI button and 'enabled' CO's change requests
in the same place.
Also, there's now a separate slot in DlgAutoDJ that receive error codes and pop up respective
messages, which means any AutoDJProcessor method can warn the user.
@ronso0 ronso0 force-pushed the autodj-refuse-start-hotkey branch from 7f50877 to d9f9f68 Compare April 19, 2023 20:19
@@ -625,7 +629,11 @@ void AutoDJProcessor::crossfaderChanged(double value) {
}
pToDeck->play();
} else {
// TODO Is this also only possible if the user changed the
// deck orientation?
Copy link
Member

Choose a reason for hiding this comment

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

This happens if the track in the To Deck has been ejected or shorter than 200 ms.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, I understood the above condition, and it seems 'eject' and a manually loaded, very short track could be the only cause, since IIUC tracks shorter than kMinimumTrackDurationSec are skipped

VERIFY_OR_DEBUG_ASSERT(toDeckDuration >= kMinimumTrackDurationSec) {
// Track has no duration or too short. This should not happen, because short
// tracks are skipped after load.
loadNextTrackFromQueue(*pToDeck, false);
return;
}

If AutoDJ stops unexpectedly a popup would be helpful to notify users.
But if that happens after user interaction (eject) we don't need it IMO

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 and works good.
Can you please remove the question in the comment, once it is clarified?

@ronso0 ronso0 force-pushed the autodj-refuse-start-hotkey branch from d9f9f68 to 216a080 Compare May 2, 2023 23:07
@daschuer daschuer merged commit 3a87ad2 into mixxxdj:2.3 May 3, 2023
8 checks passed
@ronso0 ronso0 deleted the autodj-refuse-start-hotkey branch May 3, 2023 06:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants