vlc | branch: master | Thomas Guillem <[email protected]> | Fri Mar 8 09:58:45 2019 +0100| [0b9c527c789a8ffa75dc7ecfc96c8bf12d8e9fc0] | committer: Thomas Guillem
intf: move vlc_intf_GetMainPlaylist up No functional changes > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0b9c527c789a8ffa75dc7ecfc96c8bf12d8e9fc0 --- src/interface/interface.c | 126 +++++++++++++++++++++++----------------------- 1 file changed, 63 insertions(+), 63 deletions(-) diff --git a/src/interface/interface.c b/src/interface/interface.c index 278f5deeaf..f513f8d2d9 100644 --- a/src/interface/interface.c +++ b/src/interface/interface.c @@ -83,6 +83,69 @@ static playlist_t *intf_GetPlaylist(libvlc_int_t *libvlc) return playlist; } +static void +PlaylistConfigureFromVariables(vlc_playlist_t *playlist, vlc_object_t *obj) +{ + enum vlc_playlist_playback_order order; + if (var_InheritBool(obj, "random")) + order = VLC_PLAYLIST_PLAYBACK_ORDER_RANDOM; + else + order = VLC_PLAYLIST_PLAYBACK_ORDER_NORMAL; + + /* repeat = repeat current; loop = repeat all */ + enum vlc_playlist_playback_repeat repeat; + if (var_InheritBool(obj, "repeat")) + repeat = VLC_PLAYLIST_PLAYBACK_REPEAT_CURRENT; + else if (var_InheritBool(obj, "loop")) + repeat = VLC_PLAYLIST_PLAYBACK_REPEAT_ALL; + else + repeat = VLC_PLAYLIST_PLAYBACK_REPEAT_NONE; + + enum vlc_player_media_stopped_action media_stopped_action; + if (var_InheritBool(obj, "play-and-exit")) + media_stopped_action = VLC_PLAYER_MEDIA_STOPPED_EXIT; + else if (var_InheritBool(obj, "play-and-stop")) + media_stopped_action = VLC_PLAYER_MEDIA_STOPPED_STOP; + else if (var_InheritBool(obj, "play-and-pause")) + media_stopped_action = VLC_PLAYER_MEDIA_STOPPED_PAUSE; + else + media_stopped_action = VLC_PLAYER_MEDIA_STOPPED_CONTINUE; + + bool start_paused = var_InheritBool(obj, "start-paused"); + + vlc_playlist_Lock(playlist); + vlc_playlist_SetPlaybackOrder(playlist, order); + vlc_playlist_SetPlaybackRepeat(playlist, repeat); + + vlc_player_t *player = vlc_playlist_GetPlayer(playlist); + + /* the playlist and the player share the same lock, and this is not an + * implementation detail */ + vlc_player_SetMediaStoppedAction(player, media_stopped_action); + vlc_player_SetStartPaused(player, start_paused); + + vlc_playlist_Unlock(playlist); +} + +vlc_playlist_t * +vlc_intf_GetMainPlaylist(intf_thread_t *intf) +{ + libvlc_priv_t *priv = libvlc_priv(vlc_object_instance(intf)); + + vlc_mutex_lock(&lock); + vlc_playlist_t *playlist = priv->main_playlist; + if (priv->main_playlist == NULL) + { + vlc_object_t *libvlc_obj = VLC_OBJECT(vlc_object_instance(intf)); + playlist = priv->main_playlist = vlc_playlist_New(libvlc_obj); + if (playlist) + PlaylistConfigureFromVariables(playlist, libvlc_obj); + } + vlc_mutex_unlock(&lock); + + return playlist; +} + static int intf_CreateInternal( libvlc_int_t *libvlc, playlist_t *playlist, const char *chain ) { @@ -162,69 +225,6 @@ int intf_Create( libvlc_int_t *libvlc, const char *chain ) return intf_CreateInternal( libvlc, NULL, chain ); } -static void -PlaylistConfigureFromVariables(vlc_playlist_t *playlist, vlc_object_t *obj) -{ - enum vlc_playlist_playback_order order; - if (var_InheritBool(obj, "random")) - order = VLC_PLAYLIST_PLAYBACK_ORDER_RANDOM; - else - order = VLC_PLAYLIST_PLAYBACK_ORDER_NORMAL; - - /* repeat = repeat current; loop = repeat all */ - enum vlc_playlist_playback_repeat repeat; - if (var_InheritBool(obj, "repeat")) - repeat = VLC_PLAYLIST_PLAYBACK_REPEAT_CURRENT; - else if (var_InheritBool(obj, "loop")) - repeat = VLC_PLAYLIST_PLAYBACK_REPEAT_ALL; - else - repeat = VLC_PLAYLIST_PLAYBACK_REPEAT_NONE; - - enum vlc_player_media_stopped_action media_stopped_action; - if (var_InheritBool(obj, "play-and-exit")) - media_stopped_action = VLC_PLAYER_MEDIA_STOPPED_EXIT; - else if (var_InheritBool(obj, "play-and-stop")) - media_stopped_action = VLC_PLAYER_MEDIA_STOPPED_STOP; - else if (var_InheritBool(obj, "play-and-pause")) - media_stopped_action = VLC_PLAYER_MEDIA_STOPPED_PAUSE; - else - media_stopped_action = VLC_PLAYER_MEDIA_STOPPED_CONTINUE; - - bool start_paused = var_InheritBool(obj, "start-paused"); - - vlc_playlist_Lock(playlist); - vlc_playlist_SetPlaybackOrder(playlist, order); - vlc_playlist_SetPlaybackRepeat(playlist, repeat); - - vlc_player_t *player = vlc_playlist_GetPlayer(playlist); - - /* the playlist and the player share the same lock, and this is not an - * implementation detail */ - vlc_player_SetMediaStoppedAction(player, media_stopped_action); - vlc_player_SetStartPaused(player, start_paused); - - vlc_playlist_Unlock(playlist); -} - -vlc_playlist_t * -vlc_intf_GetMainPlaylist(intf_thread_t *intf) -{ - libvlc_priv_t *priv = libvlc_priv(vlc_object_instance(intf)); - - vlc_mutex_lock(&lock); - vlc_playlist_t *playlist = priv->main_playlist; - if (priv->main_playlist == NULL) - { - vlc_object_t *libvlc_obj = VLC_OBJECT(vlc_object_instance(intf)); - playlist = priv->main_playlist = vlc_playlist_New(libvlc_obj); - if (playlist) - PlaylistConfigureFromVariables(playlist, libvlc_obj); - } - vlc_mutex_unlock(&lock); - - return playlist; -} - /** * Inserts an item in the playlist. * _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
