]> git.sesse.net Git - vlc/commitdiff
python bindings:
authorOlivier Aubert <olivier.aubert@liris.cnrs.fr>
Tue, 6 Mar 2007 14:44:54 +0000 (14:44 +0000)
committerOlivier Aubert <olivier.aubert@liris.cnrs.fr>
Tue, 6 Mar 2007 14:44:54 +0000 (14:44 +0000)
 * use Py_ssize_t as index type (cf http://www.python.org/dev/peps/pep-0353/)
 * fix audio_[gs]et_channel parameter/return value type

bindings/python/vlc_instance.c
bindings/python/vlc_internal.c
bindings/python/vlc_mediacontrol.c
bindings/python/vlcglue.h

index fbceaf8f84bad974853814b1fa65692b2d2bbf92..e3d6f1d1b56ac41cfb75fe82042dc9dc3ef6a7e6 100644 (file)
 #include "vlcglue.h"
 
 /* Helper functions */
-static int
+static Py_ssize_t
 pyoptions_to_args(PyObject *py_options, char*** pppsz_args)
 {
-    int i_size;
-    int i_index;
+    Py_ssize_t i_size;
+    Py_ssize_t  i_index;
     char** ppsz_args = *pppsz_args;
     
     ppsz_args = NULL;
@@ -438,28 +438,25 @@ static PyObject *
 vlcInstance_audio_get_channel( PyObject *self, PyObject *args )
 {
     libvlc_exception_t ex;
-    char* psz_ret;
-    PyObject* o_ret;
+    int i_ret;
 
     LIBVLC_TRY;
-    psz_ret = libvlc_audio_get_channel( LIBVLC_INSTANCE->p_instance, &ex );
+    i_ret = libvlc_audio_get_channel( LIBVLC_INSTANCE->p_instance, &ex );
     LIBVLC_EXCEPT;
-    o_ret=Py_BuildValue( "s", psz_ret );
-    free( psz_ret );
-    return o_ret;
+    return Py_BuildValue( "i", i_ret );
 }
 
 static PyObject *
 vlcInstance_audio_set_channel( PyObject *self, PyObject *args )
 {
     libvlc_exception_t ex;
-    char* psz_channel;
+    int i_channel;
 
-    if( !PyArg_ParseTuple( args, "s", &psz_channel ) )
+    if( !PyArg_ParseTuple( args, "i", &i_channel ) )
         return NULL;
 
     LIBVLC_TRY;
-    libvlc_audio_set_channel( LIBVLC_INSTANCE->p_instance, psz_channel, &ex );
+    libvlc_audio_set_channel( LIBVLC_INSTANCE->p_instance, i_channel, &ex );
     LIBVLC_EXCEPT;
     Py_INCREF( Py_None );
     return Py_None;
index eb6e54a5a821b1b8785a7a61ad0bfc5640a3f4f4..f19d6e3c81fa28d1b887d1e028b431e0841651f1 100644 (file)
@@ -499,8 +499,8 @@ static PyObject *
 vlcObject_var_list( PyObject *self, PyObject *args )
 {
     PyObject *p_retval;
-    int i_size;
-    int i_index;
+    Py_ssize_t i_size;
+    Py_ssize_t i_index;
 
     i_size = VLCSELF->p_object->i_vars;
     p_retval = PyTuple_New( i_size );
@@ -619,8 +619,8 @@ static PyObject *
 vlcObject_children( PyObject *self, PyObject *args )
 {
     PyObject *p_retval;
-    int i_size;
-    int i_index;
+    Py_ssize_t i_size;
+    Py_ssize_t i_index;
 
     i_size = VLCSELF->p_object->i_children;
     p_retval = PyTuple_New( i_size );
index c7f22b6e3f4d8ffb8af9141becfe4cb70ddbc744..085cb854fd8f387188636baff2b12debb37e7a86 100644 (file)
@@ -36,7 +36,7 @@ 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 );
 
@@ -49,7 +49,7 @@ MediaControl_new( PyTypeObject *type, PyObject *args, PyObject *kwds )
         }
         else
         {
-            int i_index;
+            Py_ssize_t i_index;
 
             if( ! PySequence_Check( py_param ) )
             {
@@ -341,8 +341,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;
index 16f0bd47e60a3689e8fbffa1b0796068629cd737..ad5509c3ab07a4b0d6bf7fb4f2854af73e84d813 100644 (file)
 #include <vlc/mediacontrol_structures.h>
 #include <vlc/mediacontrol.h>
 
+/* Python 2.5 64-bit support compatibility define */
+#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
+typedef int Py_ssize_t;
+#define PY_SSIZE_T_MAX INT_MAX
+#define PY_SSIZE_T_MIN INT_MIN
+#endif
+
 #define SELF ((MediaControl*)self)
 
 /**********************************************************************