Changeset 1189
- Timestamp:
- 08/04/08 05:03:07 (4 months ago)
- Files:
-
- trunk/audiolab/scikits/audiolab/soundio/_alsa.pyx (modified) (2 diffs)
- trunk/audiolab/scikits/audiolab/soundio/alsa.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/audiolab/scikits/audiolab/soundio/_alsa.pyx
r1188 r1189 58 58 SND_PCM_FORMAT_FLOAT64 59 59 SND_PCM_FORMAT_IEC958_SUBFRAME 60 61 ctypedef struct snd_pcm_t 62 63 int snd_pcm_open(snd_pcm_t **, char*, int, int) 64 int snd_pcm_close(snd_pcm_t *) 65 60 66 char* snd_strerror(int error) 61 67 … … 106 112 free(sptr) 107 113 return cardname 114 115 cdef class Device: 116 cdef snd_pcm_t* pcmhdl 117 cdef public char* name 118 119 def __new__(self, device = "default", stream = SND_PCM_STREAM_PLAYBACK): 120 self.pcmhdl = NULL 121 122 st = snd_pcm_open(&self.pcmhdl, device, stream, 0) 123 if st < 0: 124 raise AlsaException("Cannot open device %s: %s" % (device, snd_strerror(st))) 125 126 def __init__(self, device = "default", stream = SND_PCM_STREAM_PLAYBACK): 127 self.name = device 128 129 def __dealloc__(self): 130 if self.pcmhdl: 131 snd_pcm_close(self.pcmhdl) trunk/audiolab/scikits/audiolab/soundio/alsa.py
r1188 r1189 1 1 from _alsa import card_name, card_indexes, asoundlib_version 2 from _alsa import Device 2 3 3 4 if __name__ == '__main__': … … 5 6 for i in card_indexes(): 6 7 print card_name(i) 8 9 dev = Device() 10 print "Device name:", dev.name
