]> git.sesse.net Git - vlc/blobdiff - bindings/python/vlc_position.c
Removes trailing spaces. Removes tabs.
[vlc] / bindings / python / vlc_position.c
index 4e330c8d6dbfcbbb84b391320c96b23908398dff..8cf6efabd69af92807895c5d1c8ef34513d0f8b9 100644 (file)
@@ -31,25 +31,39 @@ PyPosition_new( PyTypeObject *type, PyObject *args, PyObject *kwds )
 {
     PyPosition *self;
     static char *kwlist[] = { "value", "origin", "key", NULL};
-    
     self = PyObject_New( PyPosition, &PyPosition_Type );
 
     self->value=0;
     self->origin=mediacontrol_AbsolutePosition;
     self->key=mediacontrol_MediaTime;
 
-    /* We do not care about the return value, since it will leave the fields
-       with their default value. */
     if(! PyArg_ParseTupleAndKeywords( args, kwds, "|lii", kwlist,
                                       &(self->value),
                                       &(self->origin),
                                       &(self->key) ) )
     {
-        return NULL;        
+        return NULL;
+    }
+
+    if( self->key != mediacontrol_MediaTime
+    && self->key != mediacontrol_ByteCount
+    && self->key != mediacontrol_SampleCount )
+    {
+        PyErr_SetString ( MediaControl_InternalException, "Invalid key value" );
+        return NULL;
     }
-       
+
+    if( self->origin != mediacontrol_AbsolutePosition
+    && self->origin != mediacontrol_RelativePosition
+    && self->origin != mediacontrol_ModuloPosition )
+    {
+        PyErr_SetString ( MediaControl_InternalException, "Invalid origin value" );
+        return NULL;
+    }
+
     Py_INCREF( self );
-    return ( PyObject * )self;    
+    return ( PyObject * )self;
 }
 
 mediacontrol_PositionKey