From 982c016f90b5992fc7d4e4f6ed5e11f6556d18a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Stenac?= Date: Tue, 6 Jan 2004 08:50:20 +0000 Subject: [PATCH] - src/misc/win32_specific: compilation fix for win32 (can someone please check that command line parsing still works for items and options? ) - src/libvlc.c include/vlc/vlc.h : New libvlc functions to get playlist status and clear the playlist Patch by Tong Ka Man - src/playlist/* : Update copyrights - src/playlist/playlist.c: -When a user explicitely asks for an item, do play it, even if random mode -Do not stop playlist upon deletion of an autodelete item -playlist_Clear (Patch by Tong Ka Man) --- include/vlc/vlc.h | 4 ++- include/vlc_playlist.h | 3 +- src/libvlc.c | 73 ++++++++++++++++++++++++++++++++++++++- src/misc/win32_specific.c | 20 ++++++----- src/playlist/group.c | 4 +-- src/playlist/info.c | 6 ++-- src/playlist/item-ext.c | 37 ++++++++++++++++---- src/playlist/item.c | 4 +-- src/playlist/loadsave.c | 4 +-- src/playlist/playlist.c | 30 +++++++++++++--- src/playlist/sort.c | 4 +-- 11 files changed, 155 insertions(+), 34 deletions(-) diff --git a/include/vlc/vlc.h b/include/vlc/vlc.h index bf4437fb9f..fbc7dcae5b 100644 --- a/include/vlc/vlc.h +++ b/include/vlc/vlc.h @@ -2,7 +2,7 @@ * vlc.h: global header for vlc ***************************************************************************** * Copyright (C) 1998, 1999, 2000 VideoLAN - * $Id: vlc.h,v 1.28 2003/12/02 12:57:35 gbazin Exp $ + * $Id: vlc.h,v 1.29 2004/01/06 08:50:20 zorglub Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -139,6 +139,8 @@ int VLC_Play ( int ); int VLC_Pause ( int ); int VLC_Stop ( int ); int VLC_FullScreen ( int ); +int VLC_ClearPlaylist( int ); +vlc_bool_t VLC_IsPlaying ( int ); # ifdef __cplusplus } diff --git a/include/vlc_playlist.h b/include/vlc_playlist.h index 14387d0968..34bb08ffee 100644 --- a/include/vlc_playlist.h +++ b/include/vlc_playlist.h @@ -2,7 +2,7 @@ * vlc_playlist.h : Playlist functions ***************************************************************************** * Copyright (C) 1999, 2000, 2001, 2002 VideoLAN - * $Id: vlc_playlist.h,v 1.20 2004/01/06 04:57:34 rocky Exp $ + * $Id: vlc_playlist.h,v 1.21 2004/01/06 08:50:20 zorglub Exp $ * * Authors: Samuel Hocevar * @@ -157,6 +157,7 @@ VLC_EXPORT( int, playlist_Add, ( playlist_t *, const char *, const char *, i VLC_EXPORT( int, playlist_AddWDuration, ( playlist_t *, const char *, const char *, int, int, mtime_t ) ); /* For internal use. Do not use this one anymore */ VLC_EXPORT( int, playlist_AddItem, ( playlist_t *, playlist_item_t *, int, int ) ); +VLC_EXPORT( int, playlist_Clear, ( playlist_t * ) ); VLC_EXPORT( int, playlist_Delete, ( playlist_t *, int ) ); VLC_EXPORT( int, playlist_Disable, ( playlist_t *, int ) ); VLC_EXPORT( int, playlist_Enable, ( playlist_t *, int ) ); diff --git a/src/libvlc.c b/src/libvlc.c index 6c8137919a..86c259766e 100644 --- a/src/libvlc.c +++ b/src/libvlc.c @@ -2,7 +2,7 @@ * libvlc.c: main libvlc source ***************************************************************************** * Copyright (C) 1998-2002 VideoLAN - * $Id: libvlc.c,v 1.107 2004/01/05 12:59:43 zorglub Exp $ + * $Id: libvlc.c,v 1.108 2004/01/06 08:50:20 zorglub Exp $ * * Authors: Vincent Seguin * Samuel Hocevar @@ -911,6 +911,77 @@ int VLC_Get( int i_object, char const *psz_var, vlc_value_t *p_value ) /* FIXME: temporary hacks */ + +/***************************************************************************** + * VLC_IsPlaying: Query for Playlist Status + *****************************************************************************/ +vlc_bool_t VLC_IsPlaying( int i_object ) +{ + + playlist_t * p_playlist; + vlc_bool_t playing; + + vlc_t *p_vlc = vlc_current_object( i_object ); + + /* Check that the handle is valid */ + if( !p_vlc ) + { + return VLC_ENOOBJ; + } + + p_playlist = vlc_object_find( p_vlc, VLC_OBJECT_PLAYLIST, FIND_CHILD ); + + if( !p_playlist ) + { + if( i_object ) vlc_object_release( p_vlc ); + return VLC_ENOOBJ; + } + + playing = playlist_IsPlaying( p_playlist ); + + vlc_object_release( p_playlist ); + + if( i_object ) vlc_object_release( p_vlc ); + + return playing; + +} + + +/***************************************************************************** + * VLC_ClearPlaylist: Query for Playlist Status + * + * return: 0 + *****************************************************************************/ +int VLC_ClearPlaylist( int i_object ) +{ + + playlist_t * p_playlist; + vlc_t *p_vlc = vlc_current_object( i_object ); + + /* Check that the handle is valid */ + if( !p_vlc ) + { + return VLC_ENOOBJ; + } + + p_playlist = vlc_object_find( p_vlc, VLC_OBJECT_PLAYLIST, FIND_CHILD ); + + if( !p_playlist ) + { + if( i_object ) vlc_object_release( p_vlc ); + return VLC_ENOOBJ; + } + + playlist_Clear(p_playlist); + + vlc_object_release( p_playlist ); + + if( i_object ) vlc_object_release( p_vlc ); + return 0; +} + + /***************************************************************************** * VLC_Play: play *****************************************************************************/ diff --git a/src/misc/win32_specific.c b/src/misc/win32_specific.c index 7afacde49a..55fdfed1a4 100644 --- a/src/misc/win32_specific.c +++ b/src/misc/win32_specific.c @@ -2,7 +2,7 @@ * win32_specific.c: Win32 specific features ***************************************************************************** * Copyright (C) 2001 VideoLAN - * $Id: win32_specific.c,v 1.28 2003/12/09 19:18:48 gbazin Exp $ + * $Id: win32_specific.c,v 1.29 2004/01/06 08:50:20 zorglub Exp $ * * Authors: Samuel Hocevar * Gildas Bazin @@ -297,7 +297,7 @@ LRESULT CALLBACK WMCOPYWNDPROC( HWND hwnd, UINT uMsg, WPARAM wParam, if( pwm_data->lpData ) { - int i_argc, i_data, i_opt, i_options; + int i_argc, i_data, i_opt, i_options,i_id,i_pos,j; char **ppsz_argv; char *p_data = (char *)pwm_data->lpData; @@ -321,12 +321,16 @@ LRESULT CALLBACK WMCOPYWNDPROC( HWND hwnd, UINT uMsg, WPARAM wParam, { i_options++; } - - playlist_Add( p_playlist, ppsz_argv[ i_opt ], - (char const **)( i_options ? &ppsz_argv[i_opt+1] : NULL ), - i_options, PLAYLIST_APPEND | (i_opt? 0 : PLAYLIST_GO), - PLAYLIST_END ); - + i_id = playlist_Add( p_playlist, ppsz_argv[ i_opt ], + ppsz_argv[ i_opt ], + PLAYLIST_APPEND | (i_opt? 0 : PLAYLIST_GO), + PLAYLIST_END ); + i_pos = playlist_GetPositionById( p_playlist, i_id ); + for( j = 0 ; j < i_options ; j++ ) + { + playlist_AddOption( p_playlist, i_pos , + &ppsz_argv[i_opt+1+j] ); + } i_opt += i_options; } diff --git a/src/playlist/group.c b/src/playlist/group.c index feb8680433..af92592daa 100644 --- a/src/playlist/group.c +++ b/src/playlist/group.c @@ -1,8 +1,8 @@ /***************************************************************************** * playlist.c : Playlist groups management functions ***************************************************************************** - * Copyright (C) 1999-2001 VideoLAN - * $Id: group.c,v 1.5 2004/01/05 12:59:43 zorglub Exp $ + * Copyright (C) 1999-2004 VideoLAN + * $Id: group.c,v 1.6 2004/01/06 08:50:20 zorglub Exp $ * * Authors: Clément Stenac * diff --git a/src/playlist/info.c b/src/playlist/info.c index 11cdb118ba..0eef2e2728 100644 --- a/src/playlist/info.c +++ b/src/playlist/info.c @@ -1,8 +1,8 @@ /***************************************************************************** * info.c : Playlist info management ***************************************************************************** - * Copyright (C) 1999-2001 VideoLAN - * $Id: info.c,v 1.1 2004/01/05 12:59:43 zorglub Exp $ + * Copyright (C) 1999-2004 VideoLAN + * $Id: info.c,v 1.2 2004/01/06 08:50:20 zorglub Exp $ * * Authors: Clément Stenac * @@ -105,8 +105,6 @@ item_info_category_t * playlist_GetCategory( playlist_t *p_playlist, int i_item, const char * psz_cat ) { - int i; - /* Check the existence of the playlist */ if( p_playlist == NULL) { diff --git a/src/playlist/item-ext.c b/src/playlist/item-ext.c index 20f70aea25..8cfcbdd715 100644 --- a/src/playlist/item-ext.c +++ b/src/playlist/item-ext.c @@ -1,8 +1,8 @@ /***************************************************************************** * item-ext.c : Exported playlist item functions ***************************************************************************** - * Copyright (C) 1999-2001 VideoLAN - * $Id: item-ext.c,v 1.3 2004/01/06 04:57:34 rocky Exp $ + * Copyright (C) 1999-2004 VideoLAN + * $Id: item-ext.c,v 1.4 2004/01/06 08:50:20 zorglub Exp $ * * Authors: Samuel Hocevar * Clément Stenac @@ -45,8 +45,8 @@ * \return the position of the new item */ int playlist_AddWDuration( playlist_t *p_playlist, const char * psz_uri, - const char *psz_name, int i_mode, int i_pos, - mtime_t i_duration ) + const char *psz_name, int i_mode, int i_pos, + mtime_t i_duration ) { playlist_item_t * p_item; @@ -98,8 +98,8 @@ int playlist_AddWDuration( playlist_t *p_playlist, const char * psz_uri, int playlist_Add( playlist_t *p_playlist, const char * psz_uri, const char *psz_name, int i_mode, int i_pos ) { - return playlist_AddWDuration ( p_playlist, psz_uri, psz_name, i_mode, i_pos, - -1 ); + return playlist_AddWDuration ( p_playlist, psz_uri, psz_name, i_mode, i_pos, + -1 ); } /** @@ -151,7 +151,7 @@ playlist_item_t * playlist_GetItemById( playlist_t * p_playlist , int i_id ) * Set the group of a playlist item * * \param p_playlist the playlist - * \param i_item the item of which we change the group + * \param i_item the item of which we change the group (position) * \param i_group the new group * \return 0 on success, -1 on failure */ @@ -364,6 +364,29 @@ int playlist_Delete( playlist_t * p_playlist, int i_pos ) return 0; } + + +/** + * Clear all playlist items + * + * \param p_playlist the playlist to be cleared. + * \return returns 0 + */ +int playlist_Clear( playlist_t * p_playlist ) { + + while( p_playlist->i_groups > 0 ) + { + playlist_DeleteGroup( p_playlist, p_playlist->pp_groups[0]->i_id ); + } + + while( p_playlist->i_size > 0 ) + { + playlist_Delete( p_playlist, 0 ); + } + return 0; +} + + /** * Disables a playlist item * diff --git a/src/playlist/item.c b/src/playlist/item.c index 715b99fae7..e1af3ee749 100644 --- a/src/playlist/item.c +++ b/src/playlist/item.c @@ -1,8 +1,8 @@ /***************************************************************************** * item.c : Playlist item functions ***************************************************************************** - * Copyright (C) 1999-2001 VideoLAN - * $Id: item.c,v 1.10 2004/01/05 12:59:43 zorglub Exp $ + * Copyright (C) 1999-2004 VideoLAN + * $Id: item.c,v 1.11 2004/01/06 08:50:20 zorglub Exp $ * * Authors: Samuel Hocevar * diff --git a/src/playlist/loadsave.c b/src/playlist/loadsave.c index e379b1fdbb..213b269ff9 100644 --- a/src/playlist/loadsave.c +++ b/src/playlist/loadsave.c @@ -1,8 +1,8 @@ /***************************************************************************** * loadsave.c : Playlist loading / saving functions ***************************************************************************** - * Copyright (C) 1999-2001 VideoLAN - * $Id: loadsave.c,v 1.2 2004/01/05 12:59:43 zorglub Exp $ + * Copyright (C) 1999-2004 VideoLAN + * $Id: loadsave.c,v 1.3 2004/01/06 08:50:20 zorglub Exp $ * * Authors: Samuel Hocevar * diff --git a/src/playlist/playlist.c b/src/playlist/playlist.c index 3ee51a7238..1209e96475 100644 --- a/src/playlist/playlist.c +++ b/src/playlist/playlist.c @@ -1,8 +1,8 @@ /***************************************************************************** * playlist.c : Playlist management functions ***************************************************************************** - * Copyright (C) 1999-2001 VideoLAN - * $Id: playlist.c,v 1.71 2004/01/05 12:59:43 zorglub Exp $ + * Copyright (C) 1999-2004 VideoLAN + * $Id: playlist.c,v 1.72 2004/01/06 08:50:20 zorglub Exp $ * * Authors: Samuel Hocevar * @@ -82,6 +82,11 @@ playlist_t * __playlist_Create ( vlc_object_t *p_parent ) val.b_bool = VLC_TRUE; var_Set( p_playlist, "intf-show", val ); + + var_Create( p_playlist, "prevent-skip", VLC_VAR_BOOL ); + val.b_bool = VLC_FALSE; + var_Set( p_playlist, "prevent-skip", val ); + var_Create( p_playlist, "random", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); var_Create( p_playlist, "repeat", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); var_Create( p_playlist, "loop", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); @@ -127,6 +132,13 @@ void playlist_Destroy( playlist_t * p_playlist ) var_Destroy( p_playlist, "intf-change" ); var_Destroy( p_playlist, "item-change" ); + var_Destroy( p_playlist, "playlist-current" ); + var_Destroy( p_playlist, "intf-popmenu" ); + var_Destroy( p_playlist, "intf-show" ); + var_Destroy( p_playlist, "prevent-skip" ); + var_Destroy( p_playlist, "random" ); + var_Destroy( p_playlist, "repeat" ); + var_Destroy( p_playlist, "loop" ); while( p_playlist->i_groups > 0 ) { @@ -229,6 +241,8 @@ void playlist_Destroy( playlist_t * p_playlist ) { input_StopThread( p_playlist->p_input ); } + val.b_bool = VLC_TRUE; + var_Set( p_playlist, "prevent-skip", val ); p_playlist->i_status = PLAYLIST_RUNNING; } break; @@ -352,6 +366,8 @@ static void RunThread ( playlist_t *p_playlist ) { vlc_mutex_unlock( &p_playlist->object_lock ); playlist_Delete( p_playlist, p_playlist->i_index ); + p_playlist->i_index++; + p_playlist->i_status = PLAYLIST_RUNNING; } else { @@ -381,7 +397,13 @@ static void RunThread ( playlist_t *p_playlist ) } else if( p_playlist->i_status != PLAYLIST_STOPPED ) { - SkipItem( p_playlist, 0 ); + var_Get( p_playlist, "prevent-skip", &val); + if( val.b_bool == VLC_FALSE) + { + SkipItem( p_playlist, 0 ); + } + val.b_bool = VLC_TRUE; + var_Set( p_playlist, "prevent-skip", val); PlayItem( p_playlist ); } else if( p_playlist->i_status == PLAYLIST_STOPPED ) @@ -537,7 +559,7 @@ static void SkipItem( playlist_t *p_playlist, int i_arg ) /* Check that the item is enabled */ if( p_playlist->pp_items[p_playlist->i_index]->b_enabled == VLC_FALSE && p_playlist->i_enabled != 0) - { + { SkipItem( p_playlist , 1 ); } } diff --git a/src/playlist/sort.c b/src/playlist/sort.c index 511f70d6b4..1df97fbc59 100644 --- a/src/playlist/sort.c +++ b/src/playlist/sort.c @@ -1,8 +1,8 @@ /***************************************************************************** * sort.c : Playlist sorting functions ***************************************************************************** - * Copyright (C) 1999-2001 VideoLAN - * $Id: sort.c,v 1.4 2004/01/05 12:59:43 zorglub Exp $ + * Copyright (C) 1999-2004 VideoLAN + * $Id: sort.c,v 1.5 2004/01/06 08:50:20 zorglub Exp $ * * Authors: Clément Stenac * -- GitLab