]> git.sesse.net Git - vlc/commitdiff
mediacontrol API: split old mediacontrol_exception_init behaviour into mediacontrol_e...
authorOlivier Aubert <olivier.aubert@liris.cnrs.fr>
Thu, 3 May 2007 20:02:34 +0000 (20:02 +0000)
committerOlivier Aubert <olivier.aubert@liris.cnrs.fr>
Thu, 3 May 2007 20:02:34 +0000 (20:02 +0000)
include/vlc/mediacontrol.h
src/control/mediacontrol_audio_video.c
src/control/mediacontrol_core.c
src/control/mediacontrol_util.c

index 76efb0a3c3d4f19a78b6fdc86972bf4defd7dfda..3c53a3e9acca55a741863238f39bc0b5fee81fe5 100644 (file)
@@ -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 );
 
 /**
index b39db5a7cfdfe615e4699c6147ac5adda00e6b35..f3a0be529f328abbbe736a3e5eb3913d3ad65e21 100644 (file)
@@ -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" );
 }
index a072bd83d163a65eedf876a9a1b1a895534b9d47..e561b60e558a2cc276f335d8df270d42c6c8091a 100644 (file)
@@ -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 );
 
index 2c0d44bd5b480846ec649f9ae35052597e94be4a..0bc8f08da8c2ac0725748b1d4b88bbdfda408648 100644 (file)
@@ -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