X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=bindings%2Fpython%2Fvlc_position.c;h=e2e736be7f811e0e15a5dad18edc6b29f5ec586c;hb=9589813471d0f5525789b7cf7165e48d177cbad6;hp=4e330c8d6dbfcbbb84b391320c96b23908398dff;hpb=18959e10b702b913c0e9461518d34c4bb160e77b;p=vlc diff --git a/bindings/python/vlc_position.c b/bindings/python/vlc_position.c index 4e330c8d6d..e2e736be7f 100644 --- a/bindings/python/vlc_position.c +++ b/bindings/python/vlc_position.c @@ -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