Commit a79c62a4 authored by Olivier Aubert's avatar Olivier Aubert

mediacontrol API: split old mediacontrol_exception_init behaviour into...

mediacontrol API: split old mediacontrol_exception_init behaviour into mediacontrol_exception_create/mediacontrol_exception_init
parent a58e289a
......@@ -135,11 +135,17 @@ mediacontrol_PlaylistSeq *mediacontrol_PlaylistSeq__alloc( int size );
VLC_PUBLIC_API void mediacontrol_PlaylistSeq__free( mediacontrol_PlaylistSeq *ps );
/**
* Initialize an exception structure.
* \param p_exception the exception to initialize. If NULL, a new exception will be created.
* Instanciate and initialize an exception structure.
* \return the exception
*/
VLC_PUBLIC_API mediacontrol_Exception *
mediacontrol_exception_create( void );
/**
* Initialize an existing exception structure.
* \param p_exception the exception to initialize.
*/
VLC_PUBLIC_API void
mediacontrol_exception_init( mediacontrol_Exception *exception );
/**
......
......@@ -61,7 +61,7 @@ mediacontrol_snapshot( mediacontrol_Instance *self,
char path[256];
snapshot_t *p_snapshot;
exception=mediacontrol_exception_init( exception );
mediacontrol_exception_init( exception );
p_vout = vlc_object_find( self->p_playlist, VLC_OBJECT_VOUT, FIND_CHILD );
if( ! p_vout )
......@@ -112,7 +112,7 @@ mediacontrol_RGBPicture **
mediacontrol_all_snapshots( mediacontrol_Instance *self,
mediacontrol_Exception *exception )
{
exception=mediacontrol_exception_init( exception );
mediacontrol_exception_init( exception );
RAISE_NULL( mediacontrol_InternalException, "unsupported method" );
}
......
......@@ -58,7 +58,7 @@ mediacontrol_Instance* mediacontrol_new( int argc, char** argv, mediacontrol_Exc
int i_index;
libvlc_exception_init( &ex );
exception=mediacontrol_exception_init( exception );
mediacontrol_exception_init( exception );
retval = ( mediacontrol_Instance* )malloc( sizeof( mediacontrol_Instance ) );
if( !retval )
......@@ -126,7 +126,7 @@ mediacontrol_get_media_position( mediacontrol_Instance *self,
vlc_int64_t pos;
libvlc_input_t * p_input;
exception = mediacontrol_exception_init( exception );
mediacontrol_exception_init( exception );
libvlc_exception_init( &ex );
retval = ( mediacontrol_Position* )malloc( sizeof( mediacontrol_Position ) );
......@@ -207,7 +207,7 @@ mediacontrol_start( mediacontrol_Instance *self,
{
playlist_t * p_playlist = self->p_playlist;
exception = mediacontrol_exception_init( exception );
mediacontrol_exception_init( exception );
if( ! p_playlist )
{
RAISE( mediacontrol_PlaylistException, "No available playlist" );
......@@ -249,7 +249,7 @@ mediacontrol_pause( mediacontrol_Instance *self,
input_thread_t *p_input = self->p_playlist->p_input;
/* FIXME: use the a_position parameter */
exception=mediacontrol_exception_init( exception );
mediacontrol_exception_init( exception );
if( p_input != NULL )
{
var_SetInteger( p_input, "state", PAUSE_S );
......@@ -268,7 +268,7 @@ mediacontrol_resume( mediacontrol_Instance *self,
input_thread_t *p_input = self->p_playlist->p_input;
/* FIXME: use the a_position parameter */
exception=mediacontrol_exception_init( exception );
mediacontrol_exception_init( exception );
if( p_input != NULL )
{
var_SetInteger( p_input, "state", PAUSE_S );
......@@ -285,7 +285,7 @@ mediacontrol_stop( mediacontrol_Instance *self,
mediacontrol_Exception *exception )
{
/* FIXME: use the a_position parameter */
exception=mediacontrol_exception_init( exception );
mediacontrol_exception_init( exception );
if( !self->p_playlist )
{
RAISE( mediacontrol_PlaylistException, "No playlist" );
......@@ -347,7 +347,7 @@ mediacontrol_playlist_get_list( mediacontrol_Instance *self,
playlist_t * p_playlist = self->p_playlist;
int i_playlist_size;
exception=mediacontrol_exception_init( exception );
mediacontrol_exception_init( exception );
if( !p_playlist )
{
RAISE( mediacontrol_PlaylistException, "No playlist" );
......@@ -355,13 +355,13 @@ mediacontrol_playlist_get_list( mediacontrol_Instance *self,
}
vlc_mutex_lock( &p_playlist->object_lock );
i_playlist_size = p_playlist->items.i_size;
i_playlist_size = p_playlist->current.i_size;
retval = mediacontrol_PlaylistSeq__alloc( i_playlist_size );
for( i_index = 0 ; i_index < i_playlist_size ; i_index++ )
{
retval->data[i_index] = strdup( ARRAY_VAL(p_playlist->items, i_index)->p_input->psz_uri );
retval->data[i_index] = strdup( ARRAY_VAL(p_playlist->current, i_index)->p_input->psz_uri );
}
vlc_mutex_unlock( &p_playlist->object_lock );
......
......@@ -49,9 +49,6 @@
# include <sys/types.h>
#endif
#define RAISE( c, m ) exception->code = c; \
exception->message = strdup(m);
/* FIXME: Need to stop accessing private input structures !! */
#include "input/input_internal.h"
......@@ -250,31 +247,24 @@ mediacontrol_PlaylistSeq__free( mediacontrol_PlaylistSeq* ps )
free( ps );
}
/**
* Initialize a VLC exception.
*
* If given a NULL pointer, it will instanciate a new exception, which
* should be later freed by the caller. If given an existing
* exception, it will reset its code and message fields. In both
* cases, the exception pointer is returned.
*
* \param exception a pointer on a mediacontrol_Exception
* \return a pointer on a mediacontrol_Exception.
*/
mediacontrol_Exception*
mediacontrol_exception_create( void )
{
mediacontrol_Exception* exception;
exception = ( mediacontrol_Exception* )malloc( sizeof( mediacontrol_Exception ) );
mediacontrol_exception_init( exception );
return exception;
}
void
mediacontrol_exception_init( mediacontrol_Exception *exception )
{
if( !exception )
if( exception )
{
exception = ( mediacontrol_Exception* )malloc( sizeof( mediacontrol_Exception ) );
if( !exception )
{
return NULL;
}
exception->code = 0;
exception->message = NULL;
}
exception->code = 0;
exception->message = NULL;
return exception;
}
void
......
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