[xiph-cvs] cvs commit: ao-python/src aomodule.c aomodule.h
Andrew Chatham Master of Python
andrew at xiph.org
Wed Jan 14 21:49:43 PST 2004
andrew 04/01/15 00:49:43
Modified: . ChangeLog setup.py test.py
src aomodule.c aomodule.h
Log:
2004-1-13 Andrew H. Chatham <pyogg at andrewchatham.com>
* aomodule.c: Add a patch from Roel Schroeven to add
ao.default_driver_id()
Revision Changes Path
1.9 +10 -0 ao-python/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /usr/local/cvsroot/ao-python/ChangeLog,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- ChangeLog 16 Dec 2002 09:34:56 -0000 1.8
+++ ChangeLog 15 Jan 2004 05:49:42 -0000 1.9
@@ -1,3 +1,13 @@
+2004-1-13 Andrew H. Chatham <pyogg at andrewchatham.com>
+ * aomodule.c: Add a patch from Roel Schroeven to add
+ ao.default_driver_id()
+
+2003-07-23 Andrew H. Chatham <pyogg at andrewchatham.com>
+ * aomodule.c: (parse_args) and (py_ao_new) Apply patch from Joerg
+ Lehmann to fix some segfaults.
+ * aomodule.h: Apply patch from Klaus Harke to so things will
+ compile on Suse properly.
+
2002-12-15 Andrew H. Chatham <pyogg at andrewchatham.com>
* aomodule.c: ao_driver_id no longer accepts NULL as a default
* aomodule.c: fixed some compiler warnings with gcc 3.2
<p><p>1.7 +1 -1 ao-python/setup.py
Index: setup.py
===================================================================
RCS file: /usr/local/cvsroot/ao-python/setup.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- setup.py 16 Dec 2002 09:34:56 -0000 1.6
+++ setup.py 15 Jan 2004 05:49:42 -0000 1.7
@@ -38,7 +38,7 @@
setup (# Distribution meta-data
name = "pyao",
- version = "0.81",
+ version = "0.82",
description = "A wrapper for the ao library",
author = "Andrew Chatham",
author_email = "andrew.chatham at duke.edu",
<p><p>1.4 +3 -1 ao-python/test.py
Index: test.py
===================================================================
RCS file: /usr/local/cvsroot/ao-python/test.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- test.py 9 Dec 2001 19:44:49 -0000 1.3
+++ test.py 15 Jan 2004 05:49:42 -0000 1.4
@@ -2,7 +2,9 @@
import ao
-dev = ao.AudioDevice('wav', filename='foo.wav', bits=16)
+print "Default driver id:", ao.default_driver_id()
+print "Bigendian?", ao.is_big_endian()
+dev = ao.AudioDevice(ao.default_driver_id(), bits=16)
f = open('test.wav', 'r')
data = f.read()
dev.play(data, len(data))
<p><p>1.5 +16 -10 ao-python/src/aomodule.c
Index: aomodule.c
===================================================================
RCS file: /usr/local/cvsroot/ao-python/src/aomodule.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- aomodule.c 16 Dec 2002 09:34:57 -0000 1.4
+++ aomodule.c 15 Jan 2004 05:49:43 -0000 1.5
@@ -41,7 +41,7 @@
*/
static int
parse_args(PyObject *args, PyObject *kwargs,
- ao_sample_format * format, PyObject **py_options,
+ ao_sample_format *format, PyObject **py_options,
const char **filename,
uint_32 *driver_id,
uint_32 *overwrite)
@@ -69,7 +69,7 @@
format->channels = 2;
format->byte_format = 1; /* What should this be by default? Anyone? */
- overwrite = 0;
+ *overwrite = 0;
if(PyArg_ParseTupleAndKeywords(args, kwargs, "s|llllO!sl",
(char **) driver_name_kwlist,
@@ -107,7 +107,7 @@
py_ao_new(PyObject *self, PyObject *args, PyObject *kwargs)
{
uint_32 overwrite, driver_id;
- const char * filename = NULL;
+ const char *filename = NULL;
PyObject *py_options = NULL;
ao_option *c_options = NULL;
ao_device *dev;
@@ -128,16 +128,13 @@
return NULL;
}
}
-
- if (py_options) {
- Py_DECREF(py_options);
- }
-
- if (filename == NULL)
+
+ if (filename == NULL) {
dev = ao_open_live(driver_id, &sample_format, c_options);
- else
+ } else {
dev = ao_open_file(driver_id, filename, overwrite,
&sample_format, c_options);
+ }
ao_free_options(c_options);
if (dev == NULL) {
@@ -259,9 +256,18 @@
static PyObject*
py_ao_is_big_endian(PyObject *self, PyObject *args)
{
+ if (!PyArg_ParseTuple(args, ""))
+ return NULL;
return PyInt_FromLong(ao_is_big_endian());
}
+static PyObject*
+py_ao_default_driver_id(PyObject *self, PyObject *args)
+{
+ /* Passed with METH_NOARGS */
+ return PyInt_FromLong(ao_default_driver_id());
+}
+
#define AddInt(x) PyDict_SetItemString(dict, #x, PyInt_FromLong(x))
void
<p><p>1.7 +32 -14 ao-python/src/aomodule.h
Index: aomodule.h
===================================================================
RCS file: /usr/local/cvsroot/ao-python/src/aomodule.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- aomodule.h 16 Dec 2002 09:34:57 -0000 1.6
+++ aomodule.h 15 Jan 2004 05:49:43 -0000 1.7
@@ -21,10 +21,11 @@
static PyObject* py_ao_getattr(PyObject *, char *);
static char py_ao_play_doc[] =
-"Play the contents of a given audio buffer.\n\n"
-"Arguments:\n"\
-"buff : Buffer or string containing audio data\n"\
-"n : Number of bytes to play (defaults to len(buff))";
+"Play the contents of a given audio buffer.\n\
+\n\
+Arguments:\n\
+buff : Buffer or string containing audio data\n\
+n : Number of bytes to play (defaults to len(buff))";
static PyObject *py_ao_play(PyObject *, PyObject *);
@@ -46,16 +47,31 @@
static PyObject *py_ao_is_big_endian(PyObject *, PyObject *);
static char py_ao_doc[] =
-"AudioDevice(driverid, bits=16, rate=44100, channels=2, byte_format=1,\n"
-" options=[], filename='', overwrite=0)\n"
-"OR\n"
-"AudioDevice(drivername, bits=16, rate=44100, channels=2, byte_format=1,\n"
-" options=[], filename='', overwrite=0)\n\n"
-"An AudioDevice object is an interface to a sound device. You can either\n"
-"pass an id of a specific type of device or the name of that device type.\n"
-"If filename is passed, the module will try to open an output file as the\n"
-"audio device. In this case, overwrite indicates whether to overwrite an\n"
-"existing file\n";
+"AudioDevice(driverid, bits=16, rate=44100, channels=2, byte_format=1, options=[], filename='', overwrite=0)\n\
+OR\
+AudioDevice(drivername, bits=16, rate=44100, channels=2, byte_format=1, options=[], filename='', overwrite=0)\n\
+\n\
+An AudioDevice object is an interface to a sound device. You can either pass\n\
+an id of a specific type of device or the name of that device type.\n\
+If filename is passed, the module will try to open an output file as the\n\
+audio device. In this case, overwrite indicates whether to overwrite an\n\
+existing file\n";
+
+static PyObject *py_ao_default_driver_id(PyObject *self, PyObject *args);
+static char py_ao_default_driver_id_doc[] ="Returns the ID number of the default live output driver.\n\
+\n\
+If the configuration files specify a default driver, its ID is returned,\n\
+otherwise the library tries to pick a live output driver that will work\n\
+on the host platform.\n\
+\n\
+Return values:\n\
+ . a non-negative value is the ID number of the default driver\n\
+ . -1 indicates failure to find a usable audio output device\n\
+\n\
+Notes:\n\
+ If no default device is available, you may still use the \n\
+ null device to test your application.";
+
static PyTypeObject ao_Type = {
PyObject_HEAD_INIT(&PyType_Type)
@@ -103,6 +119,8 @@
METH_VARARGS, py_ao_driver_info_doc},
{"is_big_endian", py_ao_is_big_endian,
METH_VARARGS, py_ao_is_big_endian_doc},
+ {"default_driver_id", py_ao_default_driver_id,
+ METH_NOARGS, py_ao_default_driver_id_doc},
{NULL, 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