From 4dfa4e633628c251fbd981f0443760fc2edb5477 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Stenac?= Date: Sun, 29 Jan 2006 19:04:07 +0000 Subject: [PATCH] Fix a crasher in exception handling Add some playlist functions --- include/vlc/libvlc.h | 34 +++++++++++++++++++++++++++++++++- src/control/core.c | 3 ++- src/control/playlist.c | 18 +++++++++++++++++- 3 files changed, 52 insertions(+), 3 deletions(-) diff --git a/include/vlc/libvlc.h b/include/vlc/libvlc.h index 35514195e3..c2560740cc 100644 --- a/include/vlc/libvlc.h +++ b/include/vlc/libvlc.h @@ -4,7 +4,7 @@ * Copyright (C) 1998-2005 the VideoLAN team * $Id: vlc.h 13701 2005-12-12 17:58:56Z zorglub $ * - * Authors: Cl�ent Stenac + * Authors: Clément Stenac * * 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 @@ -130,6 +130,38 @@ void libvlc_destroy( libvlc_instance_t *); void libvlc_playlist_play( libvlc_instance_t*, int, char **, libvlc_exception_t * ); +/** + * Stop playing + * \param p_instance the instance to stop + * \param p_exception an initialized exception + */ +void libvlc_playlist_stop( libvlc_instance_t *, libvlc_exception_t * ); + +/** + * Remove all playlist ites + * \param p_instance the instance + * \param p_exception an initialized exception + */ +void libvlc_playlist_clear( libvlc_instance_t *, libvlc_exception_t * ); + +/** + * Go to next playlist item + * \param p_instance the instance + * \param p_exception an initialized exception + */ +void libvlc_playlist_next( libvlc_instance_t *, libvlc_exception_t * ); + +/** + * Go to Previous playlist item + * \param p_instance the instance + * \param p_exception an initialized exception + */ +void libvlc_playlist_prev( libvlc_instance_t *, libvlc_exception_t * ); + + + + + typedef struct libvlc_input_t libvlc_input_t; ///\todo document me diff --git a/src/control/core.c b/src/control/core.c index 54147eaf3c..b89911fb0b 100644 --- a/src/control/core.c +++ b/src/control/core.c @@ -54,7 +54,8 @@ inline void libvlc_exception_raise( libvlc_exception_t *p_exception, { if( p_exception == NULL ) return; p_exception->b_raised = 1; - p_exception->psz_message = strdup( psz_message ); + if( psz_message ) + p_exception->psz_message = strdup( psz_message ); } diff --git a/src/control/playlist.c b/src/control/playlist.c index 87d76efec6..7440d6d1fc 100644 --- a/src/control/playlist.c +++ b/src/control/playlist.c @@ -4,7 +4,7 @@ * Copyright (C) 2005 the VideoLAN team * $Id$ * - * Authors: Cl�ent Stenac + * Authors: Clément Stenac * * 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 @@ -40,6 +40,22 @@ void libvlc_playlist_play( libvlc_instance_t *p_instance, playlist_Play( p_instance->p_playlist ); } +void libvlc_playlist_stop( libvlc_instance_t *p_instance, + libvlc_exception_t *p_exception ) +{ + if( playlist_Stop( p_instance->p_playlist ) != VLC_SUCCESS ) + { + libvlc_exception_raise( p_exception, "Empty playlist" ); + } +} + +void libvlc_playlist_clear( libvlc_instance_t *p_instance, + libvlc_exception_t *p_exception ) +{ + playlist_Clear( p_instance->p_playlist ); +} + + libvlc_input_t * libvlc_playlist_get_input( libvlc_instance_t *p_instance, libvlc_exception_t *p_exception ) {