V3.0.9 b629: Playlist Options bug

If the option Only clean-up items at top of history is off, mAirList seems to behave exactly the same as if this option is on.

In other words, when the option is off, and I play an item some way ‘down’ the Playlist, I had expected that ‘out of sequence’ item to count as one of the ‘number of items to keep in the Playlist History’ (let’s call that number n) and therefore to be automatically moved to the Recycle Bin when the number of played items is n+1.

What actually happens is that the ‘out of sequence’ item remains greyed-out and in its same place in the Playlist until enough items have been played for it to get to the top of the Playlist, at which point it DOES get automatically moved to the Recycle Bin. This is what I would expect to happen when the option is on.

Have I misunderstood what this option does, or is this a bug?

BFN
CAD

Seems like a bug to me. Even when the option is set to off, only the number of played items at the top is considered for the clean-up. It should rather be the total number of played items.

This will be corrected in Buil 631. Can you please give a feedback then?

Will do. :slight_smile:

BFN
CAD

This bug is still present in b632. :frowning:

BFN
CAD

Sorry, for me it seems that everything works the way it is supposed to work now. Here’s what I did:

  • Set MaxHistoryCount to 3
  • switched off the “only at top” option.
  • Loaded a fresh playlist

Test 1:

  • mark the first three items as played: they will remain in the playlist, grayed (with an ‘a’)
  • mark another item further down the playlist as played: top-most played item is removed, total number of grayed items is 3 again

Test 2:

  • start with a fresh playlist again
  • mark four items from somewhere in the middle as played: the first one is removed, three grayed items remain

What do you think is wrong about that?

My Test 1:
(with Max History = 3 and Only auto clean-up at top of history on)

  1. Load and stop an item mid-way down the Playlist. It turns grey.
  2. Automate the Playlist.
  3. The top 2 items are ‘played and greyed.’
  4. The third top item is ‘played and greyed.’
  5. The item moved to the Recycle Bin is the current top item, not (as I would expect) the item mid-way down the Playlist, which was played first, and logically, is at the ‘top’ of ‘played items list.’

If what I’ve reported is expected behaviour, played items not at the top of the Playlist will never be cleaned up (moved to Recycle Bin) until they reach the physical top of the Playlist. Which would make the Only auto clean-up at top of history setting pointless because it has no effect on how mAirList operates: effectively, it will be ‘always on.’

Am I missing something? If so, what is different when Only auto clean-up at top of history is off?

BFN
CAD

Oh, now I see what you mean.

You’re right, the “purge algorithm” will always remove the items in the order they appear in the playlist, not in the order they were actually played. The reason is that that information may not be consistent or even unavailable (in case the item was manually marked as played by the user).

To give a definitive answer to your questions, let’s have a look at the original code:

function CleanUpHistory: boolean;
var
  i: integer;
  canDelete: boolean;
begin
  Result := false;
  i := 0;
  while (i < GetCount) and ((fMaxHistoryCount = 0) or (fMaxHistoryCount < GetTotalHistoryCount)) do begin
    if Items[i].HistoryFlag then begin
      canDelete := true;
      DoBeforeDelete(i, false, canDelete);
      if canDelete then begin
        Items[i].HistoryFlag := false;
        Delete(i);
        Result := true;
        continue;
      end;
    end
    else if (plcoCleanupHistoryTop in fOptions) then break;
    inc(i);
  end;
end;

The algorithm walks through the playlist and expects each item, one by one, until it reaches the end of the playlist or the desired total number of played items (GetTotalHistoryCount) is reached. When it encounters an item with the HistoryFlag set, it checks if it can be deleted (not locked by any player etc.), and if so, deletes it from the playlist, also resetting the HistoryFlag. The Delete() function does not only delete it from the playlist but also gathers all deleted items in a temporary playlist which is later appended to the recycle bin. That happens outside this function.

Now it’s pretty obvious what the plcoCleanupHistoryTop option does: As soon as it encounters an item whose HistoryFlag is not set (that is, the item is still active), it just stops the algorithm. In other words, when the option is enabled, at item will never be moved to the history as long as at least one non-history item exists above it.

When the option is turned off, it can in fact happen that a non-topmost item is purged, namely when the total number of history items exceeds the threshold, that is, when there are n or more history items below that item.

Just try it for your self: Take a fresh playlist, then mark item #2 as played, and then items #5, #6, #7. Item #2 will be removed, although item #1 is still active.

OK, I think I understand now. What the option means is that items are not removed from the playlist unless they are at the top of the Playlist, correct? I’ll need to try this out: it looks like it’s possible to have more than the requested ‘number of items to keep in the History’ if you mark ‘later’ items as played.

BFN
CAD

Yes. So in a way, the option has precedence over the “maximum number” setting.

“Alles klaar,” ;D as they say in the League of Gentlemen (TV comedy series, not 1950s UK movie!).

BFN
CAD