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

LibVLC log: remove exceptions

parent 47f6cc9b
...@@ -339,10 +339,9 @@ VLC_PUBLIC_API void libvlc_set_log_verbosity( libvlc_instance_t *p_instance, uns ...@@ -339,10 +339,9 @@ VLC_PUBLIC_API void libvlc_set_log_verbosity( libvlc_instance_t *p_instance, uns
* Open a VLC message log instance. * Open a VLC message log instance.
* *
* \param p_instance libvlc instance * \param p_instance libvlc instance
* \param p_e an initialized exception pointer * \return log message instance or NULL on error
* \return log message instance
*/ */
VLC_PUBLIC_API libvlc_log_t *libvlc_log_open( libvlc_instance_t *, libvlc_exception_t *); VLC_PUBLIC_API libvlc_log_t *libvlc_log_open( libvlc_instance_t *);
/** /**
* Close a VLC message log instance. * Close a VLC message log instance.
...@@ -373,10 +372,9 @@ VLC_PUBLIC_API void libvlc_log_clear( libvlc_log_t *p_log ); ...@@ -373,10 +372,9 @@ VLC_PUBLIC_API void libvlc_log_clear( libvlc_log_t *p_log );
* Allocate and returns a new iterator to messages in log. * Allocate and returns a new iterator to messages in log.
* *
* \param p_log libvlc log instance * \param p_log libvlc log instance
* \param p_e an initialized exception pointer * \return log iterator object or NULL on error
* \return log iterator object
*/ */
VLC_PUBLIC_API libvlc_log_iterator_t *libvlc_log_get_iterator( const libvlc_log_t *, libvlc_exception_t *); VLC_PUBLIC_API libvlc_log_iterator_t *libvlc_log_get_iterator( const libvlc_log_t * );
/** /**
* Release a previoulsy allocated iterator. * Release a previoulsy allocated iterator.
...@@ -400,12 +398,10 @@ VLC_PUBLIC_API int libvlc_log_iterator_has_next( const libvlc_log_iterator_t *p_ ...@@ -400,12 +398,10 @@ VLC_PUBLIC_API int libvlc_log_iterator_has_next( const libvlc_log_iterator_t *p_
* *
* \param p_iter libvlc log iterator or NULL * \param p_iter libvlc log iterator or NULL
* \param p_buffer log buffer * \param p_buffer log buffer
* \param p_e an initialized exception pointer * \return log message object or NULL if none left
* \return log message object
*/ */
VLC_PUBLIC_API libvlc_log_message_t *libvlc_log_iterator_next( libvlc_log_iterator_t *p_iter, VLC_PUBLIC_API libvlc_log_message_t *libvlc_log_iterator_next( libvlc_log_iterator_t *p_iter,
libvlc_log_message_t *p_buffer, libvlc_log_message_t *p_buffer );
libvlc_exception_t *p_e );
/** @} */ /** @} */
......
...@@ -89,12 +89,14 @@ void libvlc_set_log_verbosity( libvlc_instance_t *p_instance, unsigned level ) ...@@ -89,12 +89,14 @@ void libvlc_set_log_verbosity( libvlc_instance_t *p_instance, unsigned level )
p_instance->verbosity = level; p_instance->verbosity = level;
} }
libvlc_log_t *libvlc_log_open( libvlc_instance_t *p_instance, libvlc_exception_t *p_e ) libvlc_log_t *libvlc_log_open( libvlc_instance_t *p_instance )
{ {
struct libvlc_log_t *p_log = struct libvlc_log_t *p_log = malloc(sizeof(*p_log));
(struct libvlc_log_t *)malloc(sizeof(struct libvlc_log_t)); if (unlikely(p_log == NULL))
{
if( !p_log ) RAISENULL( "Out of memory" ); libvlc_printerr ("Not enough memory");
return NULL;
}
p_log->p_instance = p_instance; p_log->p_instance = p_instance;
vlc_spin_init( &p_log->data.lock ); vlc_spin_init( &p_log->data.lock );
...@@ -105,7 +107,8 @@ libvlc_log_t *libvlc_log_open( libvlc_instance_t *p_instance, libvlc_exception_t ...@@ -105,7 +107,8 @@ libvlc_log_t *libvlc_log_open( libvlc_instance_t *p_instance, libvlc_exception_t
if( !p_log->p_messages ) if( !p_log->p_messages )
{ {
free( p_log ); free( p_log );
RAISENULL( "Out of memory" ); libvlc_printerr ("Not enough memory");
return NULL;
} }
libvlc_retain( p_instance ); libvlc_retain( p_instance );
...@@ -156,27 +159,27 @@ void libvlc_log_clear( libvlc_log_t *p_log ) ...@@ -156,27 +159,27 @@ void libvlc_log_clear( libvlc_log_t *p_log )
msg_Release (tab[i]); msg_Release (tab[i]);
} }
libvlc_log_iterator_t *libvlc_log_get_iterator( const libvlc_log_t *p_log, libvlc_log_iterator_t *libvlc_log_get_iterator( const libvlc_log_t *p_log )
libvlc_exception_t *p_e )
{ {
if( p_log ) if (p_log == NULL)
return NULL;
struct libvlc_log_iterator_t *p_iter = malloc (sizeof (*p_iter));
if (unlikely(p_iter == NULL))
{ {
struct libvlc_log_iterator_t *p_iter = libvlc_printerr ("Not enough memory");
(struct libvlc_log_iterator_t *)malloc(sizeof(struct libvlc_log_iterator_t)); return NULL;
}
/* FIXME: break constant pointer constraints */ /* FIXME: break constant pointer constraints */
msg_cb_data_t *data = &((libvlc_log_t *)p_log)->data; msg_cb_data_t *data = &((libvlc_log_t *)p_log)->data;
if( !p_iter ) RAISENULL( "Out of memory" );
vlc_spin_lock (&data->lock); vlc_spin_lock (&data->lock);
p_iter->p_data = data; p_iter->p_data = data;
p_iter->i_pos = 0; p_iter->i_pos = 0;
p_iter->i_end = data->count; p_iter->i_end = data->count;
vlc_spin_unlock (&data->lock); vlc_spin_unlock (&data->lock);
return p_iter; return p_iter;
}
RAISENULL("Invalid log object!");
} }
void libvlc_log_iterator_free( libvlc_log_iterator_t *p_iter ) void libvlc_log_iterator_free( libvlc_log_iterator_t *p_iter )
...@@ -192,14 +195,13 @@ int libvlc_log_iterator_has_next( const libvlc_log_iterator_t *p_iter ) ...@@ -192,14 +195,13 @@ int libvlc_log_iterator_has_next( const libvlc_log_iterator_t *p_iter )
} }
libvlc_log_message_t *libvlc_log_iterator_next( libvlc_log_iterator_t *p_iter, libvlc_log_message_t *libvlc_log_iterator_next( libvlc_log_iterator_t *p_iter,
libvlc_log_message_t *buffer, libvlc_log_message_t *buffer )
libvlc_exception_t *p_e )
{ {
unsigned i_pos; unsigned i_pos;
if( !p_iter ) if( !p_iter )
return NULL; return NULL;
assert( buffer ); assert (buffer != NULL);
i_pos = p_iter->i_pos; i_pos = p_iter->i_pos;
if( i_pos != p_iter->i_end ) if( i_pos != p_iter->i_end )
...@@ -217,5 +219,5 @@ libvlc_log_message_t *libvlc_log_iterator_next( libvlc_log_iterator_t *p_iter, ...@@ -217,5 +219,5 @@ libvlc_log_message_t *libvlc_log_iterator_next( libvlc_log_iterator_t *p_iter,
return buffer; return buffer;
} }
RAISENULL("No more messages"); return 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