Bug 265654 - Score decreases incorrectly for songs when "Stop playing after this track" is on
Summary: Score decreases incorrectly for songs when "Stop playing after this track" is on
Status: RESOLVED FIXED
Alias: None
Product: amarok
Classification: Applications
Component: Playlist (show other bugs)
Version: 2.4-GIT
Platform: Compiled Sources Linux
: HI normal
Target Milestone: 2.4.1
Assignee: Amarok Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-06 23:43 UTC by Armin Straub
Modified: 2011-02-10 12:48 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 2.4.1


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Armin Straub 2011-02-06 23:43:34 UTC
Version:           2.4-GIT (using KDE 4.6.0) 
OS:                Linux

If "Stop playing after this track" is selected, then the scores are updated incorrectly.

This happens because in this case, both slotAboutToFinish() and (shortly after) slotFinished() are called in EngineController.  Each of them calls m_currentTrack->finishedPlaying causing the score to get updated twice (which shouldn't happen because of the incremental way the score is computed).  Moreover, the second time around the playedFraction is incorrectly determined to be zero which causes the overall decrease in score.

Reproducible: Always

Steps to Reproduce:
Play a song, select "Stop playing after this track", and wait until it is completely played (or skip to the end).  Let's assume the track has a playcount of 9 and a score of 96.

Actual Results:  
The song now has a score of 87.
(In the first step it gets a score of (9*96+100)/10 = 96 as it should, but then this is decreased to (10*96+0)/11 = 87.)

Expected Results:  
The song should get a score of (9*96+100)/10 = 96.4.

OS: Linux (x86_64) release 2.6.35-25-generic
Compiler: cc
Comment 1 Myriam Schweingruber 2011-02-09 10:01:28 UTC
Ouch, confirmed in current git
Comment 2 Sergey Ivanov 2011-02-09 13:37:52 UTC
Git commit ee4cb2b3c72880a9a4da83756770fcd0298bedc8 by Sergey Ivanov.
Committed on 09/02/11 at 13:32.
Pushed by ivanov into branch 'master'.

Fixed track's statistics update in case of StopAfterCurrent playback mode (prevent double statistics change).
BUG: 265654

M  +2    -0    ChangeLog     
M  +0    -4    src/EngineController.cpp     

http://commits.kde.org/amarok/ee4cb2b3c72880a9a4da83756770fcd0298bedc8
Comment 3 Armin Straub 2011-02-09 15:45:03 UTC
Many thanks for the quick attention!

I haven't had time to actually test the proposed fix, but it seems to me that it has a troublesome side effect: in case, a song is manually stopped by the user (so that slotAboutToFinish isn't called) the score is not going to be updated at all.  Or am I missing something?
Comment 4 Sergey Ivanov 2011-02-10 12:45:02 UTC
When you stop track manually, Amarok calls stop() method which updates track statistics.