Playing with pyesd.
Aaron Berg
shuzt at yahoo.com
Tue Aug 1 16:46:43 EDT 2000
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20000801/6ae81082/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: esdtest.tar.gz
Type: application/x-gzip
Size: 419 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20000801/6ae81082/attachment.bin>
-------------- next part --------------
Index: esd.swig
===================================================================
RCS file: /usr/local/cvsroot/pyesd/esd.swig,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 esd.swig
--- esd.swig 1999/07/23 16:07:44 1.1.1.1
+++ esd.swig 2000/08/01 00:49:16
@@ -43,6 +43,12 @@
} esd_sample_info_list_t;
static int has_error;
+
+int esd_open_sound_local()
+ {
+ return esd_open_sound(NULL);
+ }
+
%}
%except(python)
@@ -166,6 +172,12 @@
rate, format = (bits | channels | stream | func)
*/
int esd_open_sound( const char *host );
+
+/*
+ Like esd_open_sound(), but does not require the specification of server,
+ automatically connects to the server on the local system.
+*/
+int esd_open_sound_local();
/* lock/unlock will disable/enable foreign clients from connecting */
Index: esd_class.py
===================================================================
RCS file: /usr/local/cvsroot/pyesd/esd_class.py,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 esd_class.py
--- esd_class.py 1999/07/23 16:07:44 1.1.1.1
+++ esd_class.py 2000/08/01 00:50:47
@@ -35,6 +35,11 @@
from StringIO import StringIO
from types import StringType
+class ComError(Exception):
+ """
+ Raised when unable to connect to the ESD server.
+ """
+
class Sample:
"""
@@ -112,9 +117,10 @@
typically consisting of `ESD_STEREO` or `ESD_MONO`, `ESD_BITS8` or
`ESD_BITS16` or'd together.
"""
- ServerConnection.__init__(self,
- esd_play_stream(format, rate, host, name)
- )
+ sock = esd_play_stream(format, rate, host, name)
+ if sock < 0:
+ raise ComError('Unable to c5onnect to ESD server on %s' % host)
+ ServerConnection.__init__(self, sock)
class ServerSession(ServerConnection):
@@ -123,8 +129,17 @@
Allows you to query server information and manage samples.
"""
- def __init__(self, host):
- ServerConnection.__init__(self, esd_open_sound(host))
+ def __init__(self, host = None):
+ if host:
+ sock = esd_open_sound(host)
+ else:
+ sock = esd_open_sound_local()
+
+ if sock < 0:
+ raise ComError('Unable to connect to ESD server on %s' %
+ host and host or '<local>'
+ )
+ ServerConnection.__init__(self, sock)
def lock(self):
"""
Index: esdtest
===================================================================
RCS file: /usr/local/cvsroot/pyesd/esdtest,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 esdtest
--- esdtest 1999/07/23 16:07:44 1.1.1.1
+++ esdtest 2000/08/01 00:51:05
@@ -50,7 +50,7 @@
)
print 'connecting to daemon'
-s = esd.ServerSession('localhost')
+s = esd.ServerSession()
print 'caching bell sample in server'
sampleId = s.cacheSample(bellwave, 'pyesd bell sample')
More information about the Python-list
mailing list