From 195e33efa29db8eb4c5350572b5c92394db0c4a0 Mon Sep 17 00:00:00 2001 From: Jack Jansen Date: Tue, 9 Jan 1996 17:15:57 +0000 Subject: [PATCH] - Fixed bug in getfillable() - Added setcallback() method to set a user-callback --- Mac/Lib/Audio_mac.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Mac/Lib/Audio_mac.py b/Mac/Lib/Audio_mac.py index fef7d6e7458..d64bf4dc6bf 100644 --- a/Mac/Lib/Audio_mac.py +++ b/Mac/Lib/Audio_mac.py @@ -9,9 +9,11 @@ def __init__(self): self._sampwidth = 1 self._nchannels = 1 self._gc = [] + self._usercallback = None def __del__(self): self.stop() + self._usercallback = None def wait(self): import time @@ -75,6 +77,11 @@ def writeframes(self, data): def _callback(self, *args): del self._gc[0] + if self._usercallback: + self._usercallback() + + def setcallback(self, callback): + self._usercallback = callback def getfilled(self): filled = 0 @@ -83,7 +90,7 @@ def getfilled(self): return filled / self._nchannels / self._sampwidth def getfillable(self): - return self._qsize - self.getfilled() + return (self._qsize / self._nchannels / self._sampwidth) - self.getfilled() def ulaw2lin(self, data): import audioop