[xiph-cvs] cvs commit: ogg-python2/src pyoggpage.c pyoggstreamstate.c pyoggsyncstate.c

Arc arc at xiph.org
Sat Nov 29 22:33:12 PST 2003



arc         03/11/30 01:33:12

  Modified:    src      pyoggpage.c pyoggstreamstate.c pyoggsyncstate.c
  Log:
  Numerous bugfixes

Revision  Changes    Path
1.3       +11 -40    ogg-python2/src/pyoggpage.c

Index: pyoggpage.c
===================================================================
RCS file: /usr/local/cvsroot/ogg-python2/src/pyoggpage.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- pyoggpage.c	29 Nov 2003 18:49:20 -0000	1.2
+++ pyoggpage.c	30 Nov 2003 06:33:11 -0000	1.3
@@ -46,14 +46,10 @@
 
 static PyMethodDef PyOggPage_methods[] = {
   {"__len__", PyOggPage_Size, METH_VARARGS, NULL},
-/*  {"__getattr__", PyOggPage_Getattr, METH_VARARGS, NULL},
-  {"__setattr__", PyOggPage_Setattr, METH_VARARGS, NULL}, */
-  {"bos", NULL, NULL, "The BOS (Beginning-Of-Stream) flag."},
-  {"body", NULL, NULL, NULL},
+  {"bos", NULL, NULL, NULL},
   {"continued", NULL, NULL, NULL},
   {"eos", NULL, NULL, NULL},
   {"granulepos", NULL, NULL, NULL},
-  {"header", NULL, NULL, NULL},
   {"packets", NULL, NULL, NULL},
   {"pageno", NULL, NULL, NULL},
   {"serialno", NULL, NULL, NULL},
@@ -105,39 +101,12 @@
 PyOggPage_Getattr(PyObject *self, char *name) {
   ogg_page *page = PyOggPage_AsOggPage(self);
 
-  if (strcmp(name, "body") == 0) 
-    return PyString_FromStringAndSize((char *) page->body, page->body_len);
-
-  if (strcmp(name, "bos") == 0) {
-    if (ogg_page_bos(page)) {
-      Py_INCREF(Py_True);
-      return Py_True;
-    }
-    else {
-      Py_INCREF(Py_False);
-      return Py_False;
-    }
-  }
-  if (strcmp(name, "continued") == 0) {
-    if (ogg_page_continued(page)) {
-      Py_INCREF(Py_True);
-      return Py_True;
-    }
-    else {
-      Py_INCREF(Py_False);
-      return Py_False;
-    }
-  }
-  if (strcmp(name, "eos") == 0) {
-    if (ogg_page_eos(page)) {
-      Py_INCREF(Py_True);
-      return Py_True;
-    }
-    else {
-      Py_INCREF(Py_False);
-      return Py_False;
-    }
-  }
+  if (strcmp(name, "bos") == 0) 
+    return Py_TrueFalse(ogg_page_bos(page));
+  if (strcmp(name, "continued") == 0) 
+    return Py_TrueFalse(ogg_page_continued(page));
+  if (strcmp(name, "eos") == 0) 
+    return Py_TrueFalse(ogg_page_eos(page));
   if (strcmp(name, "granulepos") == 0)
     return PyLong_FromLongLong(ogg_page_granulepos(page));
   if (strcmp(name, "packets") == 0) 
@@ -151,6 +120,8 @@
   return Py_FindMethod(PyOggPage_methods, self, name);
 }
 
+/* These are all horribly broken. Needs to be upgraded for libogg2. */
+
 static int
 PyOggPage_Setattr(PyObject *self, char *name, PyObject *value)
 {
@@ -278,7 +249,7 @@
   char *cont = ogg_page_continued(PyOggPage_AsOggPage(self)) ? "CONT, " : "";
   sprintf(buf, "<OggPage, %s%s%spageno = %ld, granulepos = %lld,"
           " packets = %d, serialno = %d, version = %d," 
-          " head length = %ld, body length = %ld, at %p>",
+          " head length = %ld, body length = %ld, at %p (%p)>",
           cont, bos, eos, ogg_page_pageno(PyOggPage_AsOggPage(self)),
           ogg_page_granulepos(PyOggPage_AsOggPage(self)),
           ogg_page_packets(PyOggPage_AsOggPage(self)),
@@ -286,6 +257,6 @@
           ogg_page_version(PyOggPage_AsOggPage(self)), 
           PyOggPage_AsOggPage(self)->header_len, 
           PyOggPage_AsOggPage(self)->body_len,
-          PyOggPage_AsOggPage(self)); 
+          self, PyOggPage_AsOggPage(self)); 
   return PyString_FromString(buf);
 }

<p><p>1.3       +1 -1      ogg-python2/src/pyoggstreamstate.c

Index: pyoggstreamstate.c
===================================================================
RCS file: /usr/local/cvsroot/ogg-python2/src/pyoggstreamstate.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- pyoggstreamstate.c	29 Nov 2003 18:49:20 -0000	1.2
+++ pyoggstreamstate.c	30 Nov 2003 06:33:11 -0000	1.3
@@ -189,7 +189,7 @@
   PyOggPageObject *page;
   
   if (!PyArg_ParseTuple(args, "O!", &PyOggPage_Type,
-			(PyObject *) page))
+			(PyObject *) &page))
     return NULL;
   
   ret = ogg_stream_pagein(PyOggStreamState_AsOggStreamState(self), 

<p><p>1.3       +8 -6      ogg-python2/src/pyoggsyncstate.c

Index: pyoggsyncstate.c
===================================================================
RCS file: /usr/local/cvsroot/ogg-python2/src/pyoggsyncstate.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- pyoggsyncstate.c	29 Nov 2003 18:49:20 -0000	1.2
+++ pyoggsyncstate.c	30 Nov 2003 06:33:11 -0000	1.3
@@ -107,7 +107,7 @@
   PyOggPageObject *page;
 
   if (!PyArg_ParseTuple(args, "O!", &PyOggPage_Type,
-                        (PyObject *) page))
+                        (PyObject *) &page))
     return NULL;
   
   ret = ogg_sync_pagein(PyOggSyncState_AsOggSyncState(self),
@@ -163,12 +163,15 @@
 
   if (!PyArg_ParseTuple(args, "O!|i", &PyFile_Type, &pyfile, &ask_bytes))
     return NULL;
-  
-  fp = PyFile_AsFile(pyfile);
+
+  if ( ask_bytes < 0 ) ask_bytes = 4096;
+    fp = PyFile_AsFile(pyfile);
   
   got_bytes = ogg_sync_bufferout(PyOggSyncState_AsOggSyncState(self),
                                  &ogg_buffer);
-  if ( ask_bytes < 0 || got_bytes < ask_bytes ) ask_bytes = got_bytes;
+
+  if ( got_bytes == 0 ) return PyInt_FromLong(0);    
+  if ( got_bytes < ask_bytes ) ask_bytes = got_bytes;
   fwrite(ogg_buffer, 1, ask_bytes, fp);
 
   ret = ogg_sync_read(PyOggSyncState_AsOggSyncState(self), ask_bytes);
@@ -241,8 +244,7 @@
   ret = ogg_sync_wrote(PyOggSyncState_AsOggSyncState(self),
                        bytes);
   if ( ret == OGG_SUCCESS ) {
-    Py_INCREF(Py_None);
-    return Py_None;
+    return PyLong_FromLong(bytes);
   }
   PyErr_SetString(PyOggError, "Unknown error from ogg_sync_wrote.");
   return NULL;

<p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list