]> git.sesse.net Git - vlc/commitdiff
LibVLC: remove exceptions infrastructure
authorRémi Denis-Courmont <remi@remlab.net>
Sat, 6 Feb 2010 18:35:26 +0000 (20:35 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Sat, 6 Feb 2010 18:35:26 +0000 (20:35 +0200)
12 files changed:
include/vlc/libvlc.h
include/vlc/libvlc_structures.h
src/control/core.c
src/libvlc.sym
test/libvlc/core.c
test/libvlc/events.c
test/libvlc/libvlc_additions.h
test/libvlc/media_list.c
test/libvlc/media_list_player.c
test/libvlc/media_player.c
test/libvlc/meta.c
test/libvlc/test.h

index f364dab3323ec1a05cdd929077543eb76a7cd809..73c039eabc9b107cb75a7a630730759fbf081215 100644 (file)
@@ -61,50 +61,6 @@ extern "C" {
 #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
  *****************************************************************************/
index 4e5e1c5d4d40f83e741a83b8bdb53382c85d34e0..44a3718671cef48780b0f5be2990a2490f270949 100644 (file)
@@ -38,23 +38,6 @@ extern "C" {
 /** 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
  *****************************************************************************/
index 5131ab3c0b67f72737b4e22bf97cbf3e0caf3562..8bc7fd12ad319aac6db94c7bfa3f87f136488a74 100644 (file)
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * 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));
index 88ce19f7e88c7ab232f9c53ed02b74af3200f91a..d0a21c4252e1debc0b003ecf9786cc26bffd0f01 100644 (file)
@@ -30,10 +30,6 @@ libvlc_event_manager_register_event_type
 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
index fe274a7cb354b78c13f14bd1b808d76ad76ec9da..3871e5e8197e01e052674a9fe025eabb1a9f00b4 100644 (file)
@@ -29,7 +29,6 @@ static void test_core (const char ** argv, int argc)
 
     log ("Testing core\n");
 
-    libvlc_exception_init (&ex);
     vlc = libvlc_new (argc, argv);
     assert (vlc != NULL);
 
index 17d5a8aedd23091720b539c696d4a9fedd1d4d80..2c613216fc5acd2205690621a48a02116882119a 100644 (file)
@@ -61,7 +61,6 @@ static void test_events (const char ** argv, int argc)
     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,
@@ -74,7 +73,6 @@ static void test_events (const char ** argv, int argc)
 
     log ("Testing events\n");
 
-    libvlc_exception_init (&ex);
     vlc = libvlc_new (argc, argv);
     assert (vlc != NULL);
 
@@ -125,10 +123,7 @@ static void test_events (const char ** argv, int argc)
         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)
index e029ad748b30e14196e0e5a5a02b1b7071923f45..c3f33dd0b2977fe36d70dcdd0a2784f06aa25859 100644 (file)
 
 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;
 }
index a8e5f024937ba06177db49c17f7c9c9592b1ce74..9d1399c1b262934342bed48beb207dc6e0a90ad6 100644 (file)
@@ -32,7 +32,6 @@ static void test_media_list (const char ** argv, int argc)
 
     log ("Testing media_list\n");
 
-    libvlc_exception_init (&ex);
     vlc = libvlc_new (argc, argv);
     assert (vlc != NULL);
 
@@ -82,8 +81,8 @@ static void test_media_list (const char ** argv, int argc)
 
     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);
 
@@ -120,7 +119,6 @@ static void test_media_list (const char ** argv, int argc)
     libvlc_media_list_release (ml);
 
     libvlc_release (vlc);
-    catch ();
 }
 
 int main (void)
index 7e0717ac3577c534300ca81c055cb12dcebee00d..cebaefc6857c7668be4bd26d948b6ac0fda3438f 100644 (file)
@@ -100,7 +100,6 @@ static void test_media_list_player_items_queue(const char** argv, int argc)
 
     log ("Testing media player item queue-ing\n");
 
-    libvlc_exception_init (&ex);
     vlc = libvlc_new (argc, argv);
     assert (vlc != NULL);
 
@@ -171,7 +170,6 @@ static void test_media_list_player_previous(const char** argv, int argc)
 
     log ("Testing media player previous()\n");
 
-    libvlc_exception_init (&ex);
     vlc = libvlc_new (argc, argv);
     assert (vlc != NULL);
 
@@ -248,7 +246,6 @@ static void test_media_list_player_next(const char** argv, int argc)
 
     log ("Testing media player next()\n");
 
-    libvlc_exception_init (&ex);
     vlc = libvlc_new (argc, argv);
     assert (vlc != NULL);
 
@@ -324,7 +321,6 @@ static void test_media_list_player_pause_stop(const char** argv, int argc)
 
     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);
 
@@ -371,7 +367,6 @@ static void test_media_list_player_play_item_at_index(const char** argv, int arg
 
     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);
 
@@ -427,7 +422,6 @@ static void test_media_list_player_playback_options (const char** argv, int argc
 
     log ("Testing media player playback options()\n");
 
-    libvlc_exception_init (&ex);
     vlc = libvlc_new (argc, argv);
     assert (vlc != NULL);
 
index cec2cb938893d16f54684e6a0851544ba8c9c4cb..8df6b10311a032688785b3a00827e2ed51c5ef54 100644 (file)
@@ -32,7 +32,6 @@ static void test_media_player_play_stop(const char** argv, int argc)
 
     log ("Testing play and pause of %s\n", file);
 
-    libvlc_exception_init (&ex);
     vlc = libvlc_new (argc, argv);
     assert (vlc != NULL);
 
@@ -70,7 +69,6 @@ static void test_media_player_pause_stop(const char** argv, int argc)
 
     log ("Testing pause and stop of %s\n", file);
 
-    libvlc_exception_init (&ex);
     vlc = libvlc_new (argc, argv);
     assert (vlc != NULL);
 
@@ -90,7 +88,6 @@ static void test_media_player_pause_stop(const char** argv, int argc)
     libvlc_state_t state;
     do {
         state = libvlc_media_player_get_state (mi);
-        catch ();
     } while( state != libvlc_Playing &&
              state != libvlc_Error &&
              state != libvlc_Ended );
index c4131ebbb9ebbf323b9e40b3882ecf2798d39f64..49403e2d61039d6ce3c95f20c412e2aba43c85d9 100644 (file)
@@ -34,7 +34,6 @@ static void test_meta (const char ** argv, int argc)
 
     log ("Testing meta\n");
 
-    libvlc_exception_init (&ex);
     vlc = libvlc_new (argc, argv);
     assert (vlc != NULL);
 
index f706d3ea2b95596eb5cda3662fc4cfd11a6ca613..2a6c84b6e85b6fa48dcca730075998b4ddf9727e 100644 (file)
@@ -46,7 +46,6 @@
 /*********************************************************************
  * Some useful global var
  */
-static libvlc_exception_t ex;
 
 static const char * test_defaults_args[] = {
     "-v",
@@ -72,30 +71,6 @@ static const char test_default_sample[] = SRCDIR"/samples/empty.voc";
 
 #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 */