[xiph-cvs] cvs commit: ao-python/src aomodule.h

Andrew Catham Master of Python andrew at xiph.org
Sun Dec 9 11:44:51 PST 2001



andrew      01/12/09 11:44:51

  Modified:    .        ChangeLog README config_unix.py test.py
               src      aomodule.h
  Log:
  2001-12-09  Andrew H. Chatham <andrew.chatham at duke.edu>
          * README: Updated to document the "filename" keyword
  
          * config_unix.py: Updated to do logging.
  
  2001-11-25  Andrew H. Chatham <andrew.chatham at duke.edu>
          * README: Updated to match the new API. I forgot.
  
          * src/aomodule.c: Changed get_driver_info as a method to driver_info

Revision  Changes    Path
1.6       +10 -0     ao-python/ChangeLog

Index: ChangeLog
===================================================================
RCS file: /usr/local/cvsroot/ao-python/ChangeLog,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ChangeLog	2001/09/02 18:20:47	1.5
+++ ChangeLog	2001/12/09 19:44:49	1.6
@@ -1,3 +1,13 @@
+2001-12-09  Andrew H. Chatham <andrew.chatham at duke.edu>
+	* README: Updated to document the "filename" keyword
+	
+	* config_unix.py: Updated to do logging.
+	
+2001-11-25  Andrew H. Chatham <andrew.chatham at duke.edu>
+	* README: Updated to match the new API. I forgot.
+
+	* src/aomodule.c: Changed get_driver_info as a method to driver_info
+
 2001-09-02  Andrew H. Chatham <andrew.chatham at duke.edu>
         * setup.py: Bumped version number to 0.8 to match libao
 

1.4       +15 -8     ao-python/README

Index: README
===================================================================
RCS file: /usr/local/cvsroot/ao-python/README,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- README	2001/02/18 22:52:19	1.3
+++ README	2001/12/09 19:44:49	1.4
@@ -11,9 +11,11 @@
 python setup.py build
 [as root] python setup.py install
 
-The config script is new and still pretty weak. If you have any
-problems let me know. Access the module by using "import ao" in your
-Python code.
+Use the config_unix.py script to configure the build first. You can
+pass a --prefix argument to tell the script where you have the ao
+files installed. If you have problems, check the file config.log for
+specifics. If you have any problems let me know. Access the module by
+using "import ao" in your Python code.
 
 Here's an interactive session of just playing with the module, until I
 create better documentation (there should be docstrings for
@@ -22,22 +24,20 @@
 
 >>> import ao
 
->>> myoptions = {'file': 'myoutput.wav'}
+>>> dev = ao.AudioDevice('wav', filename = 'myoutput.wav')
 
->>> dev = ao.AudioDevice('wav', options = myoptions)
-
 >>> f = open('/dev/urandom', 'r') #that's some good stuff
 
 >>> print dev
 <AudioDevice object at 0x812ac28>
 
->>> print dev.get_driver_info()
+>>> print dev.driver_info()
 {'author': 'Aaron Holtzman <aholtzma at ess.engr.uvic.ca>', 
  'short_name': 'wav', 
  'name': 'WAV file output', 
  'comment': 'Sends output to a .wav file'}
 
->>> print ao.get_driver_info('oss')
+>>> print ao.driver_info('oss')
 {'author': 'Aaron Holtzman <aholtzma at ess.engr.uvic.ca>', 
  'short_name': 'oss', 
  'name': 'OSS audio driver output ', 
@@ -50,6 +50,13 @@
 >>> <control-d>
 
 And now I have a file myoutput.wav with random noise in it.
+
+A note: Because of the way the AO API works, if you are opening a
+device that outputs to a file (like raw or wav), then you HAVE to pass
+the filename as a keyword parameter to the constructor (like
+above). It can't just be an option (you used to be able to do
+that). Opening a "live" device (e.g. oss or alsa), you obviously don't
+have to worry about the filename.
 
 
 Andrew Chatham <andrew.chatham at duke.edu>

1.3       +32 -14    ao-python/config_unix.py

Index: config_unix.py
===================================================================
RCS file: /usr/local/cvsroot/ao-python/config_unix.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- config_unix.py	2001/09/02 18:20:47	1.2
+++ config_unix.py	2001/12/09 19:44:49	1.3
@@ -4,13 +4,26 @@
 import os
 import sys
 
+log_name = 'config.log'
+if os.path.isfile(log_name):
+    os.unlink(log_name)
+
+def write_log(msg):
+    log_file = open(log_name, 'a')
+    log_file.write(msg)
+    log_file.write('\n')
+    log_file.close()
+
+def exit(code=0):
+    sys.exit(code)
+
 def msg_checking(msg):
     print "Checking", msg, "...",
 
-def execute(cmd, display = 0):
-    if display:
-        print cmd
-    return os.system(cmd)
+def execute(cmd):
+    write_log("Execute: %s" % cmd)
+    full_cmd = '%s 1>>%s 2>&1' % (cmd, log_name)
+    return os.system(full_cmd)
 
 def run_test(input, flags = ''):
     try:
@@ -19,6 +32,7 @@
         f.close()
         compile_cmd = '%s -o _temp _temp.c %s' % (os.environ.get('CC', 'cc'),
                                                   flags)
+        write_log("executing test: %s" % compile_cmd)
         if not execute(compile_cmd):
             execute('./_temp')
     finally:
@@ -50,13 +64,13 @@
     msg_checking('for Ao')
 
     if enable_aotest:
-        execute('rm -f conf.aotest', 0)
+        execute('rm -f conf.aotest')
 
         try:
             run_test(ao_test_program, "-I" + ao_include_dir)
             if not os.path.isfile('conf.aotest'):
                 raise RuntimeError, "Did not produce output"
-            execute('rm conf.aotest', 0)
+            execute('rm conf.aotest')
             
         except Exception, e:
             print "test program failed"
@@ -77,10 +91,18 @@
             
 def print_help():
     print '''%s
-    --prefix      Give the prefix in which ao was installed.''' % sys.argv[0]
-    sys.exit(0)
+    --prefix                 Give the prefix in which ao was installed
+                               (separated by a space)''' % sys.argv[0]
+    exit()
 
 def parse_args():
+    def arg_check(data, argv, pos, arg_type, key):
+        "Register an command line arg which takes an argument"
+        if len(argv) == pos:
+            print arg_type, "needs an argument"
+            exit(1)
+        data[key] = argv[pos]
+        
     data = {}
     argv = sys.argv
     for pos in range(len(argv)):
@@ -88,11 +110,7 @@
             print_help()
         if argv[pos] == '--prefix':
             pos = pos + 1
-            if len(argv) == pos:
-                print "Prefix needs an argument"
-                sys.exit(1)
-            data['prefix'] = argv[pos]
-
+            arg_check(data, argv, pos, "Ao Prefix", 'prefix')
     return data
     
 def main():
@@ -102,7 +120,7 @@
     data = find_ao(ao_prefix = prefix)
     if not data:
         print "Config failure"
-        sys.exit(1)
+        exit(1)
     write_data(data)
 
 if __name__ == '__main__':

1.3       +1 -1      ao-python/test.py

Index: test.py
===================================================================
RCS file: /usr/local/cvsroot/ao-python/test.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- test.py	2001/08/31 02:02:10	1.2
+++ test.py	2001/12/09 19:44:49	1.3
@@ -2,7 +2,7 @@
 
 import ao
 
-dev = ao.AudioDevice('wav', bits=16)
+dev = ao.AudioDevice('wav', filename='foo.wav', bits=16)
 f = open('test.wav', 'r')
 data = f.read()
 dev.play(data, len(data))

1.5       +3 -3      ao-python/src/aomodule.h

Index: aomodule.h
===================================================================
RCS file: /usr/local/cvsroot/ao-python/src/aomodule.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- aomodule.h	2001/08/31 02:02:11	1.4
+++ aomodule.h	2001/12/09 19:44:50	1.5
@@ -37,9 +37,9 @@
 "Return a dictionary of information about a driver.\n\
 \n\
 It can either be called as a member function of an AudioDevice object:\n\
-   x.get_driver_info()\n\
+   x.driver_info()\n\
 or as a standalone function which takes the integer id of the driver:\n\
-   get_driver_info(1)";
+   driver_info(1)";
 static PyObject *py_ao_driver_info(PyObject *, PyObject *);
 
 static char py_ao_is_big_endian_doc[] =
@@ -88,7 +88,7 @@
 
 
 struct PyMethodDef ao_Object_methods[] = {
-  {"get_driver_info", py_ao_driver_info, 
+  {"driver_info", py_ao_driver_info, 
    METH_VARARGS, py_ao_driver_info_doc},
   {"play", py_ao_play, 
    METH_VARARGS, py_ao_play_doc},

--- >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