[vlc-devel] [PATCH 2/3] playlist: add a toggle to shutdown the computer after the current playlist

Rémi Denis-Courmont remi at remlab.net
Wed Apr 17 17:15:01 CEST 2013


Le mercredi 17 avril 2013 13:46:35, Ludovic Fauvet a écrit :
> ---
>  src/libvlc-module.c   |  5 +++++
>  src/playlist/engine.c |  1 +
>  src/playlist/thread.c | 11 ++++++++++-
>  3 files changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/src/libvlc-module.c b/src/libvlc-module.c
> index 4bd0227..f784591 100644
> --- a/src/libvlc-module.c
> +++ b/src/libvlc-module.c
> @@ -1161,6 +1161,10 @@ static const char *const
> ppsz_albumart_descriptions[] = #define PAE_LONGTEXT N_( \
>      "Exit if there are no more items in the playlist." )
> 
> +#define PAOFF_TEXT N_("Play and shutdown")
> +#define PAOFF_LONGTEXT N_( \
> +    "Shutdown the computer if there are no more items in the playlist." )
> +
>  #define PAP_TEXT N_("Play and pause")
>  #define PAP_LONGTEXT N_( \
>      "Pause each item in the playlist on the last frame." )
> @@ -2025,6 +2029,7 @@ vlc_module_begin ()
>          change_short('R')
>          change_safe()
>      add_bool( "play-and-exit", 0, PAE_TEXT, PAE_LONGTEXT, false )
> +    add_bool( "play-and-shutdown", 0, PAOFF_TEXT, PAOFF_LONGTEXT, false )

Do not add silently unimplemented controls. This is a support nightmare.

>      add_bool( "play-and-stop", 0, PAS_TEXT, PAS_LONGTEXT, false )
>          change_safe()
>      add_bool( "play-and-pause", 0, PAP_TEXT, PAP_LONGTEXT, true )
> diff --git a/src/playlist/engine.c b/src/playlist/engine.c
> index a80c3ef..a86d2af 100644
> --- a/src/playlist/engine.c
> +++ b/src/playlist/engine.c
> @@ -485,6 +485,7 @@ static void VariablesInit( playlist_t *p_playlist )
>      var_Create( p_playlist, "playlist-autostart", VLC_VAR_BOOL |
> VLC_VAR_DOINHERIT ); var_Create( p_playlist, "play-and-stop", VLC_VAR_BOOL
> | VLC_VAR_DOINHERIT ); var_Create( p_playlist, "play-and-exit",
> VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); +    var_Create( p_playlist,
> "play-and-shutdown", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); var_Create(
> p_playlist, "random", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); var_AddCallback(
> p_playlist, "random", RandomCallback, NULL ); var_Create( p_playlist,
> "repeat", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); diff --git
> a/src/playlist/thread.c b/src/playlist/thread.c
> index 9bfbc3c..1f5092c 100644
> --- a/src/playlist/thread.c
> +++ b/src/playlist/thread.c
> @@ -33,6 +33,7 @@
>  #include <vlc_interface.h>
>  #include <vlc_playlist.h>
>  #include <vlc_rand.h>
> +#include <vlc_os.h>
>  #include "stream_output/stream_output.h"
>  #include "playlist_internal.h"
> 
> @@ -492,7 +493,15 @@ static void LoopRequest( playlist_t *p_playlist, int
> i_status ) msg_Dbg( p_playlist, "nothing to play" );
>      p_sys->status.i_status = PLAYLIST_STOPPED;
> 
> -    if( var_GetBool( p_playlist, "play-and-exit" ) )
> +    if( var_GetBool( p_playlist, "play-and-shutdown" ) )
> +    {
> +        msg_Info( p_playlist, "end of playlist, shutting down" );
> +        if( !vlc_power_off() )
> +            msg_Err( p_playlist, "unable to shutdown the computer");
> +        else
> +            libvlc_Quit( p_playlist->p_libvlc );
> +    }

So if the user stops manually, deletes the current item or shuts down VLC, the 
system powers off. I believe that will raise complaints.

> +    else if( var_GetBool( p_playlist, "play-and-exit" ) )
>      {
>          msg_Info( p_playlist, "end of playlist, exiting" );
>          libvlc_Quit( p_playlist->p_libvlc );

-- 
Rémi Denis-Courmont
http://www.remlab.net/



More information about the vlc-devel mailing list