Bug 134159

Summary: dynamic playlists sometimes queue songs in the playlist which are already in the playlist
Product: [Applications] amarok Reporter: Kai Krakow <kai>
Component: generalAssignee: Amarok Developers <amarok-bugs-dist>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: 1.4.3   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Smart playlist
The faulty playlist

Description Kai Krakow 2006-09-16 11:46:46 UTC
Version:           1.4.3 (using KDE 3.5.4, Gentoo)
Compiler:          Target: i686-pc-linux-gnu
OS:                Linux (i686) release 2.6.17-ck1-r3

When populating the playlist it may happen that the same songs is added twice (probably from two different smart playlists). It even happens sometimes when adding a new song after one has played. The problem is not the same song being twice on my file system, Amarok adds the same file twice.

Amarok should check if a file/song is already on the playlist while adding a new song, and/or if it is already in the list of to be added songs during population.

This bug is easier to reproduce with smaller selections (short smart playlists) or smaller collections.
Comment 1 Seb Ruiz 2006-11-13 01:15:16 UTC
SVN commit 604494 by seb:

Refactor of dynamic mode. This revised implementation solves a number of bugs. The logic of adding tracks from a dynamic mode is now delegated to the DynamicMode object, and is not done within the playlist. When a dynamic mode is loaded, a cache of 200 elements is create from the playlist sources. By caching a subset of the possible tracks to be inserted, there is no longer a requirement to execute complex SQL statements on each track change or playlist repopulation. Additionally, by grabbing random tracks from this cache, items are no longer fetched from just one source, but all of them. Once these cached tracks have been inserted into the playlist, they are removed from the cache list in order to avoid duplicating song insertions. Once the cache has been depleted, it is simply regenerated. 200 elements is approximately 12 hours worth of music, so the set should be sufficiently large to handle the user's requirements.

I've done quite a bit of regression testing, but the more the merrier :). The only feature which needs to be fixed is the Suggested mode of dynamic playlists, but this should be easily rectifiable.

BUG: 134159
BUG: 137212
BUG: 107693
BUG: 130542
BUG: 133269
BUG: 113120


 M  +233 -14   dynamicmode.cpp  
 M  +51 -6     dynamicmode.h  
 M  +12 -204   playlist.cpp  
 M  +3 -4      playlist.h  
 M  +1 -1      playlistbrowser.cpp  
Comment 2 Thomas Schwarzgruber 2008-04-24 18:23:23 UTC
Hello
I guess this bug is not completly resolved.
I use here amarok-1.4-svn from rev. 799857 and it seems the same bug appears here.

I use a dynamic playlist which is feeded through a smart playlist. This smart playlist (see Screenshot) only adds tracks which have not been played within the last 28 days.
As you can see in the other Screenshot, there appears a song which has been played 12 hours ago. I already had this problem once with amarok-1.3-svn and there was the fault not at the smart playlist, but that the dynamic playlist didn't check if the file was already in the playlist. Therefore such a situation could appear:

Playlist before adding duplicate:
Song:                                           Last Played:
Track1                                            4 weeks ago
Track2                                            2 months ago
Track3                                            5 weeks ago

Now smart playlist proposes Track3, which was still not played within 5 weeks, and therefore, for the smart playlist, is valid:
Song:                                            Last Played:
Track1                                           1 minute ago
Track2                                            2 months ago
Track3                                           5 weeks ago
Track3                                           5 weeks ago
Comment 3 Thomas Schwarzgruber 2008-04-24 18:24:26 UTC
Created attachment 24495 [details]
Smart playlist

The smart playlist
Comment 4 Thomas Schwarzgruber 2008-04-24 18:24:54 UTC
Created attachment 24496 [details]
The faulty playlist