[xiph-commits] r7233 - in trunk/py-ogg2: examples src
arc at dactyl.lonelymoon.com
arc
Wed Jul 21 11:55:44 PDT 2004
Author: arc
Date: Wed Jul 21 11:55:44 2004
New Revision: 7233
Modified:
trunk/py-ogg2/examples/writ_encoder.py
trunk/py-ogg2/src/general.h
trunk/py-ogg2/src/pyoggstreamstate.c
Log:
Upgraded to use the work from my libogg2 branch in svn:
http://svn.xiph.org/branches/ogg2-arc
Added setmode() to OggStreamState objects to set discontinuous mode.
Removed temporary include in general.h.
Made a small fix in examples/writ_encoder.py, as it was previously
attempting to use a packet after it had been passed into the
OggStreamState object (I believe this is not legal, and made this an
error in py-ogg2 with an earlier commit).
Modified: trunk/py-ogg2/examples/writ_encoder.py
===================================================================
--- trunk/py-ogg2/examples/writ_encoder.py 2004-07-21 18:07:01 UTC (rev 7232)
+++ trunk/py-ogg2/examples/writ_encoder.py 2004-07-21 18:55:43 UTC (rev 7233)
@@ -65,12 +65,13 @@
if self.pn == 0 :
packet.bos = 1
else :
+ packetno = self.packet.packetno
self.os.packetin(self.packet)
if self.pn != 2 :
- print "Flushing: %d" % (self.packet.packetno)
+ print "Flushing: %d" % (packetno)
self.flush()
else :
- print "Skipping: %d" % (self.packet.packetno)
+ print "Skipping: %d" % (packetno)
self.packet = packet
self.pn = self.pn + 1
Modified: trunk/py-ogg2/src/general.h
===================================================================
--- trunk/py-ogg2/src/general.h 2004-07-21 18:07:01 UTC (rev 7232)
+++ trunk/py-ogg2/src/general.h 2004-07-21 18:55:43 UTC (rev 7233)
@@ -9,7 +9,7 @@
#define PY_UNICODE (PY_VERSION_HEX >= 0x01060000)
-#define FDEF(x) static PyObject *##x(PyObject *self, PyObject *args); \
+#define FDEF(x) static PyObject *x(PyObject *self, PyObject *args); \
static char x##_Doc[] =
int arg_to_int64(PyObject *longobj, ogg_int64_t *val);
@@ -17,8 +17,4 @@
PyObject * Py_TrueFalse(int value);
-/* This is temporary, until libogg2 is more complete */
-ogg_buffer_state *ogg_buffer_create(void);
-
-
#endif /* __GENERAL_H__ */
Modified: trunk/py-ogg2/src/pyoggstreamstate.c
===================================================================
--- trunk/py-ogg2/src/pyoggstreamstate.c 2004-07-21 18:07:01 UTC (rev 7232)
+++ trunk/py-ogg2/src/pyoggstreamstate.c 2004-07-21 18:55:43 UTC (rev 7233)
@@ -23,6 +23,7 @@
FDEF(PyOggStreamState_Packetpeek) "Extract a packet from the stream";
FDEF(PyOggStreamState_Reset) "Reset the stream state";
FDEF(PyOggStreamState_Eos) "Return whether the end of the stream is reached.";
+FDEF(PyOggStreamState_Setmode) "Set stream mode for (dis)continuous.";
PyTypeObject PyOggStreamState_Type = {
PyObject_HEAD_INIT(NULL)
@@ -70,6 +71,8 @@
METH_VARARGS, PyOggStreamState_Reset_Doc},
{"eos", PyOggStreamState_Eos,
METH_VARARGS, PyOggStreamState_Eos_Doc},
+ {"setmode", PyOggStreamState_Setmode,
+ METH_VARARGS, PyOggStreamState_Setmode_Doc},
{NULL, NULL}
};
@@ -106,6 +109,7 @@
PyOggStreamState_New(PyObject *self, PyObject *args)
{
int serialno;
+
if (!PyArg_ParseTuple(args, "i", &serialno))
return NULL;
return PyOggStreamState_FromSerialno(serialno);
@@ -329,7 +333,30 @@
return Py_True;
}
+static PyObject*
+PyOggStreamState_Setmode(PyObject *self, PyObject *args)
+{
+ int mode;
+ int ret;
+ if (!PyArg_ParseTuple(args, "i", &mode))
+ return NULL;
+
+ ret = ogg_stream_setmode(PyOggStreamState_AsOggStreamState(self), mode);
+
+ if ( ret == OGG_SUCCESS ) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+ if ( ret == OGG_EMODE ) {
+ PyErr_SetString(PyOgg_Error, "Cannot set this stream mode at this time.");
+ return NULL;
+ }
+ PyErr_SetString(PyOgg_Error, "Unknown error while setting stream mode");
+ return NULL;
+}
+
+
static PyObject *
PyOggStreamState_Repr(PyObject *self)
{
More information about the commits
mailing list