Bug 124440 - Playlist length, modified by enqueing tracks in dynamic mode doesn't get resized after playing.
Summary: Playlist length, modified by enqueing tracks in dynamic mode doesn't get resi...
Status: RESOLVED FIXED
Alias: None
Product: amarok
Classification: Applications
Component: Playlist (show other bugs)
Version: 1.4-SVN
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: Amarok Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-03-28 20:12 UTC by Lorenz Röhrl
Modified: 2006-11-13 11:28 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lorenz Röhrl 2006-03-28 20:12:02 UTC
Version:           1.4-SVN (using KDE KDE 3.5.1)
Installed from:    Gentoo Packages

Hi

I'm in dynamic mode, upcoming tracks is 5. (another bug in current svn: editing the random-mode-playlist, upcoming tracks is set to 1, but 5 are visible!)

If i queue a new track, playlist lenght of upcoming tracks is 6. After playing the enqueued track, a new one gets appended, playlist length is 6.

After playing an enqued track, no new one should be appended.

Thanks

Cu hurra
Comment 1 Eric Vaandering 2006-06-20 05:13:43 UTC
Not just enqueuing, but adding a track to the playlist in any way. When listening to a playlist, I often look at the suggested tracks or even artists and add a song, two, or a whole album. I can easily get into a mode where there are 50 tracks in the playlist and dynamic mode is still adding them even though I only ask for 10. 
Comment 2 richlv 2006-07-13 13:28:24 UTC
see also bug 113276
i'd really like to see dynamic playlist add songs only if the playlist length is less than upcoming tracks, not on every chance - i quite often find myself in a situation described by eric.
Comment 3 Amand Tihon 2006-09-09 22:30:16 UTC
Yes, this would be really nice.

I have quite a big collection playing in dynamic random mode. This random mode helps me determine what album to enqueue. 

This leads to a rapidly growing playlist that I must clean up every now and then if I want it to remain useable.
Comment 4 Johannes Stamminger 2006-11-03 14:44:40 UTC
From the described usage I would expect it to behave another way: I would expect tracks being added automatically only if the current track length becomes less then the number specified in the upcoming tracks. I would not like to get manual additions rejected because the upcoming tracks size is exceeded.

Scenario would be: playlist shows 5 upcoming tracks, limit is five. Each time a song finished, a new one is added automatically. Now user adds manually an album with 10 tracks, playlist now contains 15. The next 10 times a track finishes, no track is added automatically but on the 11th one this starts again ...

This way someone may add tracks without removing others (evtl. being added manually by someone else) but the playlist keeps somehow limited.

Just my few cents on this.
Comment 5 richlv 2006-11-03 15:07:31 UTC
well, i guess most amarok users would see it work that way, but current behaviour is only annoying, not unbearable.
a somewhat related issue to dynamic playlist length management is registered at bug 132447.
that behaviour is exactly opposite if current adding of tracks - it overzealously reduces length.
having both these issues resolved the way suggested would make dynamic playlist usage more pleasant indeed.
Comment 6 Seb Ruiz 2006-11-13 11:28:49 UTC
SVN commit 604569 by seb:

* Don't remove tracks from the playlist when reducing the upcoming count of the current dynamic mode
* Only append tracks to the playlist if the playlist track count is greater than dynamic mode upcoming count
BUG: 132447
BUG: 124440


 M  +13 -29    playlist.cpp  


--- trunk/extragear/multimedia/amarok/src/playlist.cpp #604568:604569
@@ -617,8 +617,6 @@
 void
 Playlist::adjustDynamicUpcoming( bool saveUndo )
 {
-    int  x = 0;
-
     /**
      *  If m_currentTrack exists, we iterate until we find it
      *  Else, we iterate until we find an item which is enabled
@@ -636,36 +634,16 @@
     if( m_currentTrack )
         ++it;
 
-
+    int  x = 0;
     for ( ; *it && x < dynamicMode()->upcomingCount() ; ++it, ++x );
 
     if ( x < dynamicMode()->upcomingCount() )
     {
         addDynamicModeTracks( dynamicMode()->upcomingCount() - x );
     }
-    else
-    {
-        if( isLocked() ) return;
 
-        //assemble a list of what needs removing
-        //calling removeItem() iteratively is more efficient if they are in _reverse_ order, hence the prepend()
-        QPtrList<QListViewItem> list;
-        for ( ; *it ; ++it ) {
-            list.append( it.current() );
-        }
-
-        if( list.isEmpty() ) return;
-        if( saveUndo )
-            saveUndoState();
-
-        //remove the items
-        for( QListViewItem *item = list.last(); item; item = list.prev() )
-        {
-            removeItem( static_cast<PlaylistItem*>( item ) );
-            delete item;
-        }
-        //NOTE no need to emit childCountChanged(), removeItem() does that for us
-    }
+    if( saveUndo )
+        saveUndoState();
 }
 
 /**
@@ -1212,13 +1190,15 @@
     MyIterator it( this, MyIterator::Visible );
     if( !item ) item = currentTrack();
 
-    for( int x=0 ; *it; ++it, x++ )
+    int x = 0;
+    for( ; *it; ++it, x++ )
     {
         if( *it == item )
         {
             for ( PlaylistItem *first = firstChild();
                   dynamicMode()->cycleTracks() && x >= dynamicMode()->previousCount() && first;
-                  first = firstChild(), x-- ) {
+                  first = firstChild(), x-- )
+            {
                 removeItem( first ); //first visible item
                 delete first;
             }
@@ -1226,9 +1206,13 @@
         }
     }
 
-    //Just starting to play from stopped, don't append something needlessely
-    bool dontAppend = EngineController::instance()->engine()->state() == Engine::Empty;
+    const int upcomingTracks = childCount() - x;
 
+    // Just starting to play from stopped, don't append something needlessely
+    // or, we have more than enough items in the queue.
+    bool dontAppend = ( EngineController::instance()->engine()->state() == Engine::Empty ) ||
+                        upcomingTracks >= dynamicMode()->upcomingCount();
+
     //keep upcomingTracks requirement, this seems to break StopAfterCurrent
     if( !dontAppend && m_stopAfterTrack != m_currentTrack )
     {