<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="Content-Style-Type" content="text/css" />
  <meta name="generator" content="pandoc" />
  <title></title>
  <style type="text/css">code{white-space: pre;}</style>
</head>
<body>
<p>Hi Rémi,</p>
<p>On 2017-05-21 22:15, Rémi Denis-Courmont wrote:</p>
<blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;color:#500050">
<pre><code> Le sunnuntaina 21. toukokuuta 2017, 20.48.14 EEST Filip Roséen a écrit :</code></pre>
<blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;color:#500050">
<pre><code> ---
  src/playlist/item.c | 20 ++++++++++++++++++++
  1 file changed, 20 insertions(+)

 diff --git a/src/playlist/item.c b/src/playlist/item.c
 index e912b0bcbc..5be9bba118 100644
 --- a/src/playlist/item.c
 +++ b/src/playlist/item.c
 @@ -190,6 +190,26 @@ static void input_item_add_subitem_tree ( const
 vlc_event_t * p_event,

              playlist_ViewPlay( p_playlist, NULL, p_play_item );
          }
 +        else if( b_flat && p_playlist->current.i_size > 0 )
 +        {
 +            /* If the playlist is flat, empty nodes are automatically
 deleted; +             * meaning that moving from the current index (the
 index of the now +             * removed node) to the next would result in
 a skip of one entry +             * (as the empty node is deleted, the
 logical next item would be +             * the one that now resides in its
 place).
 +             *
 +             * By resetting the currently playing to the item immediately
 +             * before the insertion point of the non-existing children, or
 the +             * start of the playlist if we are at offset 0, this
 problem is +             * fixed.
 +             **/
 +            if( last_pos )
 +                ResetCurrentlyPlaying( p_playlist,
 +                    ARRAY_VAL( p_playlist->current, last_pos - 1 ) );
 +            else
 +                playlist_ViewPlay( p_playlist, NULL,
 +                    ARRAY_VAL( p_playlist->current, 0 ) );
 +        }
      }

      PL_UNLOCK;</code></pre>
</blockquote>
<pre><code> Doesn´t this cause the previous item of the parent to be played again? At 
 least, that´s how I interpret the comments.</code></pre>
</blockquote>
<p>Later on, after this function is invoked, the playlist will advance to the next item, so “rewinding” the position to the one before the index where the deleted node was removed will correctly advance to the logical next one.</p>
<p>Imagine <code>{ A, B, C, D }</code> where <code>B</code> is currently played and removed, the playlist will be at index <code>1</code> (0-based index), though after removal of <code>B</code> the playlist is <code>{ A, C, D }</code>. When we later go to the “next” item, we would end up at <code>D</code>, even though <code>C</code> is supposed to be played.</p>
<p>By pretending that it is <code>A</code> that is currently being played, <code>C</code> will correctly play when advancing the playback.</p>
<p>I wasn’t sure how to put the above in shorter or clearer comments than what I wrote, and I spend quite some time coming up with a good way of putting it, but maybe I should rethink the comments; or what do you think?</p>
<p>Best Regards,<br />
Filip</p>
</body>
</html>