[vlc-devel] [PATCH] Fix endless loop when no playable files in playlist

Kay B kay-b at live.de
Sat Aug 5 18:03:05 CEST 2017


Sorry, something oviously went wrong with line-length. For easier
copy-paste:

From: Kay B <kay-b at live.de>
Date: Sat, 5 Aug 2017 17:29:27 +0200
Subject: [PATCH] Bugfix. When starting vlc with unexisting files, e.g. by
 doing 'vlc a b c' or deleting all playable files in the current
playlist AND
 having loop enabled, vlc currently enters an endless loop of error
messages,
 producing 100% CPU load. The given patch fixes this by checking for
 unplayable files whenever reaching the last item of the current
playlist and
 having loop enabled and stopping playback if there is no playable file.

---
 src/playlist/thread.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/src/playlist/thread.c b/src/playlist/thread.c
index 5632babe4d..c853faa367 100644
--- a/src/playlist/thread.c
+++ b/src/playlist/thread.c
@@ -401,6 +401,21 @@ static playlist_item_t *NextItem( playlist_t
*p_playlist )
                                        get_current_status_item(
p_playlist ) );
             }
             p_playlist->i_current_index = 0;
+
+            /* is there actually any input which is readable?
+               fixes bug of endless loop with 100% CPU load in case
only unplayable items in playlist and loop=ON */
+            while (ARRAY_VAL(p_playlist->current,
p_playlist->i_current_index)->p_input->b_error_when_reading == 1)
+            {
+                if (p_playlist->i_current_index ==
(p_playlist->current.i_size-1))
+                {
+                    PL_DEBUG("no playable item in playlist, playback
stopped");
+                    return NULL;
+                }
+                else
+                {
+                    p_playlist->i_current_index++;
+                }
+            }
         }
         PL_DEBUG( "using item %i", p_playlist->i_current_index );
         if ( p_playlist->current.i_size == 0 )
-- 
2.13.4


On 08/05/2017 05:55 PM, Kay B wrote:
> From: Kay B <kay-b at live.de>
> Date: Sat, 5 Aug 2017 17:29:27 +0200
> Subject: [PATCH] Bugfix. When starting vlc with unexisting files, e.g. by
>  doing 'vlc a b c' or deleting all playable files in the current
> playlist AND
>  having loop enabled, vlc currently enters an endless loop of error
> messages,
>  producing 100% CPU load. The given patch fixes this by checking for
>  unplayable files whenever reaching the last item of the current
> playlist and
>  having loop enabled and stopping playback if there is no playable file.
>
> ---
>  src/playlist/thread.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
>
> diff --git a/src/playlist/thread.c b/src/playlist/thread.c
> index 5632babe4d..c853faa367 100644
> --- a/src/playlist/thread.c
> +++ b/src/playlist/thread.c
> @@ -401,6 +401,21 @@ static playlist_item_t *NextItem( playlist_t
> *p_playlist )
>                                         get_current_status_item(
> p_playlist ) );
>              }
>              p_playlist->i_current_index = 0;
> +
> +            /* is there actually any input which is readable?
> +               fixes bug of endless loop with 100% CPU load in case
> only unplayable items in playlist and loop=ON */
> +            while (ARRAY_VAL(p_playlist->current,
> p_playlist->i_current_index)->p_input->b_error_when_reading == 1)
> +            {
> +                if (p_playlist->i_current_index ==
> (p_playlist->current.i_size-1))
> +                {
> +                    PL_DEBUG("no playable item in playlist, playback
> stopped");
> +                    return NULL;
> +                }
> +                else
> +                {
> +                    p_playlist->i_current_index++;
> +                }
> +            }
>          }
>          PL_DEBUG( "using item %i", p_playlist->i_current_index );
>          if ( p_playlist->current.i_size == 0 )



More information about the vlc-devel mailing list