Commit b0a1ac2e authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

LibVLC media: remove exceptions

parent c8869bbd
...@@ -174,26 +174,22 @@ typedef struct libvlc_media_es_t ...@@ -174,26 +174,22 @@ typedef struct libvlc_media_es_t
* *
* \param p_instance the instance * \param p_instance the instance
* \param psz_mrl the MRL to read * \param psz_mrl the MRL to read
* \param p_e an initialized exception pointer * \return the newly created media or NULL on error
* \return the newly created media
*/ */
VLC_PUBLIC_API libvlc_media_t * libvlc_media_new( VLC_PUBLIC_API libvlc_media_t * libvlc_media_new(
libvlc_instance_t *p_instance, libvlc_instance_t *p_instance,
const char * psz_mrl, const char * psz_mrl );
libvlc_exception_t *p_e );
/** /**
* Create a media as an empty node with the passed name. * Create a media as an empty node with a given name.
* *
* \param p_instance the instance * \param p_instance the instance
* \param psz_name the name of the node * \param psz_name the name of the node
* \param p_e an initialized exception pointer * \return the new empty media or NULL on error
* \return the new empty media
*/ */
VLC_PUBLIC_API libvlc_media_t * libvlc_media_new_as_node( VLC_PUBLIC_API libvlc_media_t * libvlc_media_new_as_node(
libvlc_instance_t *p_instance, libvlc_instance_t *p_instance,
const char * psz_name, const char * psz_name );
libvlc_exception_t *p_e );
/** /**
* Add an option to the media. * Add an option to the media.
...@@ -353,12 +349,10 @@ VLC_PUBLIC_API libvlc_event_manager_t * ...@@ -353,12 +349,10 @@ VLC_PUBLIC_API libvlc_event_manager_t *
* Get duration (in ms) of media descriptor object item. * Get duration (in ms) of media descriptor object item.
* *
* \param p_md media descriptor object * \param p_md media descriptor object
* \param p_e an initialized exception object * \return duration of media item or -1 on error
* \return duration of media item
*/ */
VLC_PUBLIC_API libvlc_time_t VLC_PUBLIC_API libvlc_time_t
libvlc_media_get_duration( libvlc_media_t * p_md, libvlc_media_get_duration( libvlc_media_t * p_md );
libvlc_exception_t * p_e );
/** /**
* Get preparsed status for media descriptor object. * Get preparsed status for media descriptor object.
......
...@@ -96,7 +96,7 @@ static void input_item_subitem_added( const vlc_event_t *p_event, ...@@ -96,7 +96,7 @@ static void input_item_subitem_added( const vlc_event_t *p_event,
p_md_child = libvlc_media_new_from_input_item( p_md_child = libvlc_media_new_from_input_item(
p_md->p_libvlc_instance, p_md->p_libvlc_instance,
p_event->u.input_item_subitem_added.p_new_child, NULL ); p_event->u.input_item_subitem_added.p_new_child );
/* Add this to our media list */ /* Add this to our media list */
if( !p_md->p_subitems ) if( !p_md->p_subitems )
...@@ -240,14 +240,12 @@ static void preparse_if_needed( libvlc_media_t *p_md ) ...@@ -240,14 +240,12 @@ static void preparse_if_needed( libvlc_media_t *p_md )
**************************************************************************/ **************************************************************************/
libvlc_media_t * libvlc_media_new_from_input_item( libvlc_media_t * libvlc_media_new_from_input_item(
libvlc_instance_t *p_instance, libvlc_instance_t *p_instance,
input_item_t *p_input_item, input_item_t *p_input_item )
libvlc_exception_t *p_e )
{ {
libvlc_media_t * p_md; libvlc_media_t * p_md;
if (!p_input_item) if (!p_input_item)
{ {
libvlc_exception_raise( p_e );
libvlc_printerr( "No input item given" ); libvlc_printerr( "No input item given" );
return NULL; return NULL;
} }
...@@ -255,7 +253,6 @@ libvlc_media_t * libvlc_media_new_from_input_item( ...@@ -255,7 +253,6 @@ libvlc_media_t * libvlc_media_new_from_input_item(
p_md = calloc( 1, sizeof(libvlc_media_t) ); p_md = calloc( 1, sizeof(libvlc_media_t) );
if( !p_md ) if( !p_md )
{ {
libvlc_exception_raise( p_e );
libvlc_printerr( "Not enough memory" ); libvlc_printerr( "Not enough memory" );
return NULL; return NULL;
} }
...@@ -297,10 +294,8 @@ libvlc_media_t * libvlc_media_new_from_input_item( ...@@ -297,10 +294,8 @@ libvlc_media_t * libvlc_media_new_from_input_item(
/************************************************************************** /**************************************************************************
* Create a new media descriptor object * Create a new media descriptor object
**************************************************************************/ **************************************************************************/
libvlc_media_t * libvlc_media_new( libvlc_media_t * libvlc_media_new( libvlc_instance_t *p_instance,
libvlc_instance_t *p_instance, const char * psz_mrl )
const char * psz_mrl,
libvlc_exception_t *p_e )
{ {
input_item_t * p_input_item; input_item_t * p_input_item;
libvlc_media_t * p_md; libvlc_media_t * p_md;
...@@ -309,13 +304,11 @@ libvlc_media_t * libvlc_media_new( ...@@ -309,13 +304,11 @@ libvlc_media_t * libvlc_media_new(
if (!p_input_item) if (!p_input_item)
{ {
libvlc_exception_raise( p_e );
libvlc_printerr( "Not enough memory" ); libvlc_printerr( "Not enough memory" );
return NULL; return NULL;
} }
p_md = libvlc_media_new_from_input_item( p_instance, p_md = libvlc_media_new_from_input_item( p_instance, p_input_item );
p_input_item, p_e );
/* The p_input_item is retained in libvlc_media_new_from_input_item */ /* The p_input_item is retained in libvlc_media_new_from_input_item */
vlc_gc_decref( p_input_item ); vlc_gc_decref( p_input_item );
...@@ -326,10 +319,8 @@ libvlc_media_t * libvlc_media_new( ...@@ -326,10 +319,8 @@ libvlc_media_t * libvlc_media_new(
/************************************************************************** /**************************************************************************
* Create a new media descriptor object * Create a new media descriptor object
**************************************************************************/ **************************************************************************/
libvlc_media_t * libvlc_media_new_as_node( libvlc_media_t * libvlc_media_new_as_node( libvlc_instance_t *p_instance,
libvlc_instance_t *p_instance, const char * psz_name )
const char * psz_name,
libvlc_exception_t *p_e )
{ {
input_item_t * p_input_item; input_item_t * p_input_item;
libvlc_media_t * p_md; libvlc_media_t * p_md;
...@@ -338,13 +329,11 @@ libvlc_media_t * libvlc_media_new_as_node( ...@@ -338,13 +329,11 @@ libvlc_media_t * libvlc_media_new_as_node(
if (!p_input_item) if (!p_input_item)
{ {
libvlc_exception_raise( p_e );
libvlc_printerr( "Not enough memory" ); libvlc_printerr( "Not enough memory" );
return NULL; return NULL;
} }
p_md = libvlc_media_new_from_input_item( p_instance, p_md = libvlc_media_new_from_input_item( p_instance, p_input_item );
p_input_item, p_e );
p_md->p_subitems = libvlc_media_list_new( p_md->p_libvlc_instance ); p_md->p_subitems = libvlc_media_list_new( p_md->p_libvlc_instance );
...@@ -427,7 +416,7 @@ libvlc_media_t * ...@@ -427,7 +416,7 @@ libvlc_media_t *
libvlc_media_duplicate( libvlc_media_t *p_md_orig ) libvlc_media_duplicate( libvlc_media_t *p_md_orig )
{ {
return libvlc_media_new_from_input_item( return libvlc_media_new_from_input_item(
p_md_orig->p_libvlc_instance, p_md_orig->p_input_item, NULL ); p_md_orig->p_libvlc_instance, p_md_orig->p_input_item );
} }
/************************************************************************** /**************************************************************************
...@@ -585,13 +574,12 @@ libvlc_media_event_manager( libvlc_media_t * p_md ) ...@@ -585,13 +574,12 @@ libvlc_media_event_manager( libvlc_media_t * p_md )
* Get duration of media object (in ms) * Get duration of media object (in ms)
**************************************************************************/ **************************************************************************/
int64_t int64_t
libvlc_media_get_duration( libvlc_media_t * p_md, libvlc_exception_t *p_e ) libvlc_media_get_duration( libvlc_media_t * p_md )
{ {
assert( p_md ); assert( p_md );
if( !p_md->p_input_item ) if( !p_md->p_input_item )
{ {
libvlc_exception_raise( p_e );
libvlc_printerr( "No input item" ); libvlc_printerr( "No input item" );
return -1; return -1;
} }
......
...@@ -66,9 +66,8 @@ static void services_discovery_item_added( const vlc_event_t * p_event, ...@@ -66,9 +66,8 @@ static void services_discovery_item_added( const vlc_event_t * p_event,
libvlc_media_discoverer_t * p_mdis = user_data; libvlc_media_discoverer_t * p_mdis = user_data;
libvlc_media_list_t * p_mlist = p_mdis->p_mlist; libvlc_media_list_t * p_mlist = p_mdis->p_mlist;
p_md = libvlc_media_new_from_input_item( p_md = libvlc_media_new_from_input_item( p_mdis->p_libvlc_instance,
p_mdis->p_libvlc_instance, p_item );
p_item, NULL );
/* If we have a category, that mean we have to group the items having /* If we have a category, that mean we have to group the items having
* that category in a media_list. */ * that category in a media_list. */
...@@ -79,7 +78,7 @@ static void services_discovery_item_added( const vlc_event_t * p_event, ...@@ -79,7 +78,7 @@ static void services_discovery_item_added( const vlc_event_t * p_event,
if( p_mlist == kVLCDictionaryNotFound ) if( p_mlist == kVLCDictionaryNotFound )
{ {
libvlc_media_t * p_catmd; libvlc_media_t * p_catmd;
p_catmd = libvlc_media_new_as_node( p_mdis->p_libvlc_instance, psz_cat, NULL ); p_catmd = libvlc_media_new_as_node( p_mdis->p_libvlc_instance, psz_cat );
p_mlist = libvlc_media_subitems( p_catmd ); p_mlist = libvlc_media_subitems( p_catmd );
p_mlist->b_read_only = true; p_mlist->b_read_only = true;
......
...@@ -46,8 +46,7 @@ struct libvlc_media_t ...@@ -46,8 +46,7 @@ struct libvlc_media_t
/* Media Descriptor */ /* Media Descriptor */
libvlc_media_t * libvlc_media_new_from_input_item( libvlc_media_t * libvlc_media_new_from_input_item(
libvlc_instance_t *, input_item_t *, libvlc_instance_t *, input_item_t * );
libvlc_exception_t * );
void libvlc_media_set_state( libvlc_media_t *, libvlc_state_t ); void libvlc_media_set_state( libvlc_media_t *, libvlc_state_t );
......
...@@ -265,10 +265,8 @@ libvlc_media_list_add_file_content( libvlc_media_list_t * p_mlist, ...@@ -265,10 +265,8 @@ libvlc_media_list_add_file_content( libvlc_media_list_t * p_mlist,
return; return;
} }
p_md = libvlc_media_new_from_input_item( p_md = libvlc_media_new_from_input_item( p_mlist->p_libvlc_instance,
p_mlist->p_libvlc_instance, p_input_item );
p_input_item, p_e );
if( !p_md ) if( !p_md )
{ {
vlc_gc_decref( p_input_item ); vlc_gc_decref( p_input_item );
......
...@@ -38,12 +38,12 @@ static void test_media_list (const char ** argv, int argc) ...@@ -38,12 +38,12 @@ static void test_media_list (const char ** argv, int argc)
ml = libvlc_media_list_new (vlc); ml = libvlc_media_list_new (vlc);
assert (ml != NULL); assert (ml != NULL);
md1 = libvlc_media_new (vlc, "/dev/null", &ex); md1 = libvlc_media_new (vlc, "/dev/null");
catch (); assert (md1 != NULL);
md2 = libvlc_media_new (vlc, "/dev/null", &ex); md2 = libvlc_media_new (vlc, "/dev/null");
catch (); assert (md2 != NULL);
md3 = libvlc_media_new (vlc, "/dev/null", &ex); md3 = libvlc_media_new (vlc, "/dev/null");
catch (); assert (md3 != NULL);
libvlc_media_list_add_media (ml, md1, &ex); libvlc_media_list_add_media (ml, md1, &ex);
catch (); catch ();
...@@ -105,8 +105,8 @@ static void test_media_list (const char ** argv, int argc) ...@@ -105,8 +105,8 @@ static void test_media_list (const char ** argv, int argc)
p_non_exist = libvlc_media_list_item_at_index (ml, -1, &ex); p_non_exist = libvlc_media_list_item_at_index (ml, -1, &ex);
assert (have_exception ()); assert (have_exception ());
md4 = libvlc_media_new (vlc, "/dev/null", &ex); md4 = libvlc_media_new (vlc, "/dev/null");
catch (); assert (md4 != NULL);
/* try to find non inserted item */ /* try to find non inserted item */
int i_non_exist = 0; int i_non_exist = 0;
......
...@@ -36,8 +36,8 @@ static void test_media_player_play_stop(const char** argv, int argc) ...@@ -36,8 +36,8 @@ static void test_media_player_play_stop(const char** argv, int argc)
vlc = libvlc_new (argc, argv); vlc = libvlc_new (argc, argv);
assert (vlc != NULL); assert (vlc != NULL);
md = libvlc_media_new (vlc, file, &ex); md = libvlc_media_new (vlc, file);
catch (); assert (md != NULL);
mi = libvlc_media_player_new_from_media (md); mi = libvlc_media_player_new_from_media (md);
assert (mi != NULL); assert (mi != NULL);
...@@ -74,8 +74,8 @@ static void test_media_player_pause_stop(const char** argv, int argc) ...@@ -74,8 +74,8 @@ static void test_media_player_pause_stop(const char** argv, int argc)
vlc = libvlc_new (argc, argv); vlc = libvlc_new (argc, argv);
assert (vlc != NULL); assert (vlc != NULL);
md = libvlc_media_new (vlc, file, &ex); md = libvlc_media_new (vlc, file);
catch (); assert (md != NULL);
mi = libvlc_media_player_new_from_media (md); mi = libvlc_media_player_new_from_media (md);
assert (mi != NULL); assert (mi != NULL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment