#include <stdarg.h>
#include <vlc/libvlc_structures.h>
-/*****************************************************************************
- * Exception handling
- *****************************************************************************/
-/** \defgroup libvlc_exception libvlc_exception
- * \ingroup libvlc_core
- * LibVLC Exceptions handling
- * @{
- */
-
-/**
- * Initialize an exception structure. This can be called several times to
- * reuse an exception structure.
- *
- * \param p_exception the exception to initialize
- */
-VLC_PUBLIC_API void libvlc_exception_init( libvlc_exception_t *p_exception );
-
-/**
- * Has an exception been raised?
- *
- * \param p_exception the exception to query
- * \return 0 if the exception was raised, 1 otherwise
- */
-VLC_PUBLIC_API int
-libvlc_exception_raised( const libvlc_exception_t *p_exception );
-
-/**
- * Raise an exception.
- *
- * \param p_exception the exception to raise
- */
-VLC_PUBLIC_API void
-libvlc_exception_raise( libvlc_exception_t *p_exception );
-
-/**
- * Clear an exception object so it can be reused.
- * The exception object must have be initialized.
- *
- * \param p_exception the exception to clear
- */
-VLC_PUBLIC_API void libvlc_exception_clear( libvlc_exception_t * );
-
-/**@} */
-
/*****************************************************************************
* Error handling
*****************************************************************************/
/** This structure is opaque. It represents a libvlc instance */
typedef struct libvlc_instance_t libvlc_instance_t;
-/*****************************************************************************
- * Exceptions
- *****************************************************************************/
-
-/** \defgroup libvlc_exception libvlc_exception
- * \ingroup libvlc_core
- * LibVLC Exceptions handling
- * @{
- */
-
-typedef struct libvlc_exception_t
-{
- int b_raised;
-} libvlc_exception_t;
-
-/**@} */
-
/*****************************************************************************
* Time
*****************************************************************************/
/*****************************************************************************
- * core.c: Core libvlc new API functions : initialization, exceptions handling
+ * core.c: Core libvlc new API functions : initialization
*****************************************************************************
* Copyright (C) 2005 the VideoLAN team
* $Id$
static const char nomemstr[] = "Insufficient memory";
-/*************************************************************************
- * Exceptions handling
- *************************************************************************/
-void libvlc_exception_init( libvlc_exception_t *p_exception )
-{
- p_exception->b_raised = 0;
-}
-
-void libvlc_exception_clear( libvlc_exception_t *p_exception )
-{
- if( NULL == p_exception )
- return;
- p_exception->b_raised = 0;
- libvlc_clearerr ();
-}
-
-int libvlc_exception_raised( const libvlc_exception_t *p_exception )
-{
- return (NULL != p_exception) && p_exception->b_raised;
-}
-
-static void libvlc_exception_not_handled( const char *psz )
-{
- fprintf( stderr, "*** LibVLC Exception not handled: %s\nSet a breakpoint in '%s' to debug.\n",
- psz, __func__ );
- abort();
-}
-
-void libvlc_exception_raise( libvlc_exception_t *p_exception )
-{
- /* Does caller care about exceptions ? */
- if( p_exception == NULL ) {
- /* Print something, so that lazy third-parties can easily
- * notice that something may have gone unnoticedly wrong */
- libvlc_exception_not_handled( libvlc_errmsg() );
- return;
- }
-
- p_exception->b_raised = 1;
-}
-
libvlc_instance_t * libvlc_new( int argc, const char *const *argv )
{
libvlc_instance_t *p_new = malloc (sizeof (*p_new));
libvlc_event_manager_release
libvlc_event_send
libvlc_event_type_name
-libvlc_exception_clear
-libvlc_exception_init
-libvlc_exception_raise
-libvlc_exception_raised
libvlc_free
libvlc_get_changeset
libvlc_get_compiler
log ("Testing core\n");
- libvlc_exception_init (&ex);
vlc = libvlc_new (argc, argv);
assert (vlc != NULL);
libvlc_media_player_t *mi;
libvlc_event_manager_t *em;
bool callback_was_called;
- libvlc_exception_t ex;
libvlc_event_type_t mi_events[] = {
libvlc_MediaPlayerPlaying,
libvlc_MediaPlayerPaused,
log ("Testing events\n");
- libvlc_exception_init (&ex);
vlc = libvlc_new (argc, argv);
assert (vlc != NULL);
libvlc_event_detach (em, mi_events[i], test_events_dummy_callback, &callback_was_called);
libvlc_media_player_release (mi);
- catch ();
-
libvlc_release (vlc);
- catch ();
}
int main (void)
static void* media_list_add_file_path(libvlc_instance_t *vlc, libvlc_media_list_t *ml, const char * file_path)
{
- libvlc_media_t *md = libvlc_media_new (vlc, file_path, &ex);
- catch ();
-
- libvlc_media_list_add_media (ml, md, &ex);
- catch ();
-
+ libvlc_media_t *md = libvlc_media_new (vlc, file_path);
+ libvlc_media_list_add_media (ml, md);
libvlc_media_release (md);
return md;
}
log ("Testing media_list\n");
- libvlc_exception_init (&ex);
vlc = libvlc_new (argc, argv);
assert (vlc != NULL);
assert ( libvlc_media_list_item_at_index (ml, 2) == md3 );
- /* test if give exceptions, when it should */
- /* have 4 items, so index 4 should give exception */
+ /* test if give errors, when it should */
+ /* have 4 items, so index 4 should give error */
ret = libvlc_media_list_remove_index (ml, 4);
assert (ret == -1);
libvlc_media_list_release (ml);
libvlc_release (vlc);
- catch ();
}
int main (void)
log ("Testing media player item queue-ing\n");
- libvlc_exception_init (&ex);
vlc = libvlc_new (argc, argv);
assert (vlc != NULL);
log ("Testing media player previous()\n");
- libvlc_exception_init (&ex);
vlc = libvlc_new (argc, argv);
assert (vlc != NULL);
log ("Testing media player next()\n");
- libvlc_exception_init (&ex);
vlc = libvlc_new (argc, argv);
assert (vlc != NULL);
log ("Testing play and pause of %s using the media list.\n", file);
- libvlc_exception_init (&ex);
vlc = libvlc_new (argc, argv);
assert (vlc != NULL);
log ("Testing play_item_at_index of %s using the media list.\n", file);
- libvlc_exception_init (&ex);
vlc = libvlc_new (argc, argv, &ex);
assert (vlc != NULL);
log ("Testing media player playback options()\n");
- libvlc_exception_init (&ex);
vlc = libvlc_new (argc, argv);
assert (vlc != NULL);
log ("Testing play and pause of %s\n", file);
- libvlc_exception_init (&ex);
vlc = libvlc_new (argc, argv);
assert (vlc != NULL);
log ("Testing pause and stop of %s\n", file);
- libvlc_exception_init (&ex);
vlc = libvlc_new (argc, argv);
assert (vlc != NULL);
libvlc_state_t state;
do {
state = libvlc_media_player_get_state (mi);
- catch ();
} while( state != libvlc_Playing &&
state != libvlc_Error &&
state != libvlc_Ended );
log ("Testing meta\n");
- libvlc_exception_init (&ex);
vlc = libvlc_new (argc, argv);
assert (vlc != NULL);
/*********************************************************************
* Some useful global var
*/
-static libvlc_exception_t ex;
static const char * test_defaults_args[] = {
"-v",
#define log( ... ) printf( "testapi: " __VA_ARGS__ );
-/* test if we have exception */
-static inline bool have_exception (void)
-{
- if (libvlc_exception_raised (&ex))
- {
- libvlc_exception_clear (&ex);
- return true;
- }
- else
- return false;
-}
-
-#define catch() catch_with_info(__FILE__, __FUNCTION__, __LINE__)
-
-static inline void catch_with_info (const char * file, const char * func, unsigned line)
-{
- if (libvlc_exception_raised (&ex))
- {
- fprintf (stderr, "%s:%s():%d Exception: %s\n", file, func, line, libvlc_errmsg ());
- abort ();
- }
- libvlc_exception_clear (&ex);
-}
-
static inline void test_init (void)
{
(void)test_default_sample; /* This one may not be used */