]> git.sesse.net Git - vlc/blobdiff - bindings/python/vlc_mediacontrol.c
Removes trailing spaces. Removes tabs.
[vlc] / bindings / python / vlc_mediacontrol.c
index bf4203688d101f5ab3b8e83b5ea20ba6fb10f311..66cc7ef6d6fffc24fb29c5f762dbc984b743e0a9 100644 (file)
@@ -2,7 +2,7 @@
  * vlc_mediacontrol.c: vlc.MediaControl binding
  *****************************************************************************
  * Copyright (C) 2006 the VideoLAN team
- * $Id$
+ * $Id$
  *
  * Authors: Olivier Aubert <oaubert at bat710.univ-lyon1.fr>
  *
@@ -36,21 +36,21 @@ MediaControl_new( PyTypeObject *type, PyObject *args, PyObject *kwds )
     PyObject* py_param = NULL;
     char** ppsz_args = NULL;
     libvlc_instance_t* p_instance = NULL;
-    int i_size = 0;
-    
+    Py_ssize_t i_size = 0;
     self = PyObject_New( MediaControl, &MediaControl_Type );
 
     if( PyArg_ParseTuple( args, "O", &py_param ) )
     {
-        Py_INCREF( py_param );
         if( PyObject_TypeCheck( py_param, &vlcInstance_Type ) == 1 )
         {
             p_instance = ((vlcInstance*)py_param)->p_instance;
         }
         else
         {
-            int i_index;
+            Py_ssize_t i_index;
 
+            Py_INCREF( py_param );
             if( ! PySequence_Check( py_param ) )
             {
                 PyErr_SetString( PyExc_TypeError, "Parameter must be a vlc.Instance or a sequence of strings." );
@@ -74,8 +74,8 @@ MediaControl_new( PyTypeObject *type, PyObject *args, PyObject *kwds )
                                                                        i_index ) ) ) );
             }
             ppsz_args[i_size] = NULL;
+            Py_DECREF( py_param );
         }
-        Py_DECREF( py_param );
     }
     else
     {
@@ -89,10 +89,14 @@ MediaControl_new( PyTypeObject *type, PyObject *args, PyObject *kwds )
     if( p_instance )
     {
         self->mc = mediacontrol_new_from_instance( p_instance, exception );
+        Py_INCREF( py_param );
+        self->vlc_instance = ( vlcInstance* ) py_param;
     }
     else
     {
         self->mc = mediacontrol_new( i_size, ppsz_args, exception );
+        self->vlc_instance = PyObject_New( vlcInstance, &vlcInstance_Type );
+        self->vlc_instance->p_instance = mediacontrol_get_libvlc_instance( SELF->mc );
     }
     MC_EXCEPT;
     Py_END_ALLOW_THREADS
@@ -104,7 +108,8 @@ MediaControl_new( PyTypeObject *type, PyObject *args, PyObject *kwds )
 static void
 MediaControl_dealloc( PyObject *self )
 {
-    PyMem_DEL( self );
+    Py_DECREF( SELF->vlc_instance );
+    PyObject_DEL( self );
 }
 
 static PyObject *
@@ -112,10 +117,8 @@ MediaControl_get_vlc_instance( PyObject *self, PyObject *args )
 {
     vlcInstance *p_ret;
 
-    p_ret = PyObject_New( vlcInstance, &vlcInstance_Type );
-    if( !p_ret )
-        return NULL;
-    p_ret->p_instance = mediacontrol_get_libvlc_instance( SELF->mc );
+    p_ret = SELF->vlc_instance;
+    Py_INCREF( p_ret );
     return ( PyObject * )p_ret;
 }
 
@@ -341,8 +344,8 @@ MediaControl_playlist_get_list( PyObject *self, PyObject *args )
     PyObject *py_retval;
     mediacontrol_Exception *exception = NULL;
     mediacontrol_PlaylistSeq* pl;
-    int i_index;
-    int i_playlist_size;
+    Py_ssize_t i_index;
+    Py_ssize_t i_playlist_size;
 
     Py_BEGIN_ALLOW_THREADS
     MC_TRY;
@@ -406,6 +409,8 @@ MediaControl_snapshot( PyObject *self, PyObject *args )
     PyDict_SetItemString( py_obj, "date",
                           Py_BuildValue( "L", p_retval->date ) );
 
+    mediacontrol_RGBPicture__free( p_retval );
+
     return py_obj;
 }
 
@@ -463,8 +468,7 @@ MediaControl_get_stream_information( PyObject *self, PyObject *args )
     PyDict_SetItemString( py_obj, "length",
                   Py_BuildValue( "L", retval->length ) );
 
-    free( retval->url );
-    free( retval );
+    mediacontrol_StreamInformation__free( retval );
 
     return py_obj;
 }