https://bugs.kde.org/show_bug.cgi?id=443329
Bug ID: 443329 Summary: JuK volume setting gets into infinite loop and uses incorrect rounding Product: juk Version: 21.08.1 Platform: Other OS: Linux Status: REPORTED Severity: normal Priority: NOR Component: general Assignee: whee...@kde.org Reporter: david.cortes.riv...@gmail.com CC: mp...@kde.org Target Milestone: --- SUMMARY Since version 21.08.1, JuK always starts muted. I've dug a bit into the source code (not faimiliar with it, nor with the language, programming in general, or frameworks), and I think the problem comes from getting into a loop as follows: - File 'playermanager.cpp', method 'PlayerManager::setupAudio()', sets a listener 'PlayerManager::setVolume' for 'AudioOutput::volumeChanged'. - File 'playermanager.cpp', method 'PlayerManager::setVolume', has a line 'emit volumeChanged(volume)' right after setting the volume, which causes it to call itself again. - After a while from getting stuck in this loop, somehow the volume gets set to NAN or -NAN (passing that as a parameter to 'PlayerManager::setVolume'), at which point it sets the volume to zero and stops changing it thereafter as it compares to the same volume that was set. If I remove that line, the issue of starting muted seems to be fixed, but every time it starts, it decreases the volume by 1, which I guess happens because of two issues: - It convers fractional volumes 0-1 between 'double' and 'float', which loses precision. For example, it turns a number like 0.5 into 0.499something. - It then uses 'int(100 * float)' and 'int(int * 0.01)' for rounding volumes to integers/fractions, when it should be using 'std::round' instead, which combined with the issue above makes it pick a smaller volume in an integer 0-100 scale. >From some experiments of my own changing those seems to fix the issues, but I don't know if it introduces any new issues along. In any case, here is a callback trace of the moment in which 'PlayerManager::setVolume' is called with a NAN value: PlayerManager::setVolume(PlayerManager * const this, qreal volume) (/home/david/del/juk/juk-21.08.0/playermanager.cpp:437) QtPrivate::FunctorCall<QtPrivate::IndexesList<0>, QtPrivate::List<double>, void, void (PlayerManager::*)(double)>::call(void (PlayerManager::*)(PlayerManager * const, double) f, PlayerManager * o, void ** arg) (/usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:152) QtPrivate::FunctionPointer<void (PlayerManager::*)(double)>::call<QtPrivate::List<double>, void>(QtPrivate::FunctionPointer<void (PlayerManager::*)(double)>::Function f, PlayerManager * o, void ** arg) (/usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:185) QtPrivate::QSlotObject<void (PlayerManager::*)(double), QtPrivate::List<double>, void>::impl(int which, QtPrivate::QSlotObjectBase * this_, QObject * r, void ** a, bool * ret) (/usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:418) libQt5Core.so.5![Unknown/Just-In-Time compiled code] (Unknown Source:0) libphonon4qt5.so.4!Phonon::AudioOutput::volumeChanged(double) (Unknown Source:0) libQt5Core.so.5![Unknown/Just-In-Time compiled code] (Unknown Source:0) libQt5Core.so.5!QObject::event(QEvent*) (Unknown Source:0) libQt5Widgets.so.5!QApplicationPrivate::notify_helper(QObject*, QEvent*) (Unknown Source:0) libQt5Core.so.5!QCoreApplication::notifyInternal2(QObject*, QEvent*) (Unknown Source:0) libQt5Core.so.5!QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) (Unknown Source:0) libQt5Core.so.5![Unknown/Just-In-Time compiled code] (Unknown Source:0) libglib-2.0.so.0!g_main_context_dispatch (Unknown Source:0) libglib-2.0.so.0![Unknown/Just-In-Time compiled code] (Unknown Source:0) libglib-2.0.so.0!g_main_context_iteration (Unknown Source:0) libQt5Core.so.5!QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) (Unknown Source:0) libQt5Core.so.5!QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) (Unknown Source:0) libQt5Core.so.5!QCoreApplication::exec() (Unknown Source:0) main(int argc, char ** argv) (/home/david/del/juk/juk-21.08.0/main.cpp:122) (source code was taken from debian sid source package) STEPS TO REPRODUCE 1. Start JuK. OBSERVED RESULT Starts muted, and after that issue is fixed, stars with a lower volume every time. EXPECTED RESULT Should start with the same volume that's stored in the configuration file. SOFTWARE/OS VERSIONS Windows: macOS: Linux/KDE Plasma: (available in About System) KDE Plasma Version: 5.21.5 KDE Frameworks Version: 5.86.0 Qt Version: 5.15.2 ADDITIONAL INFORMATION -- You are receiving this mail because: You are watching all bug changes.