Ejemplo n.º 1
0
 def delete(self):
     """Delete all sources and free all buffers"""
     assert context._lock.locked()
     for source, buffers in self._sources.items():
         al.alDeleteSources(1, ctypes.byref(ctypes.c_uint(source)))
         for b in buffers:
             if not al.alIsBuffer(b):
                 # Protect against implementations that DO free buffers
                 # when they delete a source - carry on.
                 if _debug_buffers:
                     print("Found a bad buffer")
                 continue
             al.alDeleteBuffers(1, ctypes.byref(b))
     for b in self._buffers:
         al.alDeleteBuffers(1, ctypes.byref(b))
     self._buffers = []
     self._sources = {}
Ejemplo n.º 2
0
 def getBuffers(self, alSource, i):
     """Returns an array containing i buffer names.  The returned list must
     not be modified in any way, and may get changed by subsequent 
     calls to getBuffers.
     """
     assert context._lock.locked()
     buffs = []
     try:
         while i > 0:
             b = self._buffers.pop()
             if not al.alIsBuffer(b):
                 # Protect against implementations that DO free buffers
                 # when they delete a source - carry on.
                 if _debug_buffers:
                     print("Found a bad buffer")
                 continue
             buffs.append(b)
             i -= 1
     except IndexError:
         while i > 0:
             buffer = al.ALuint()
             al.alGenBuffers(1, buffer)
             if _debug_buffers:
                 error = al.alGetError()
                 if error != 0:
                     print("GEN BUFFERS: " + str(error))
             buffs.append(buffer)
             i -= 1
             
     alSourceVal = alSource.value
     if alSourceVal not in self._sources:
         self._sources[alSourceVal] = buffs
     else:
         self._sources[alSourceVal].extend(buffs)
             
     return buffs
Ejemplo n.º 3
0
    def getBuffers(self, alSource, i):
        """Returns an array containing i buffer names.  The returned list must
        not be modified in any way, and may get changed by subsequent calls to
        getBuffers.
        """
        assert context._lock.locked()
        buffs = []
        try:
            while i > 0:
                b = self._buffers.pop()
                if not al.alIsBuffer(b):
                    # Protect against implementations that DO free buffers
                    # when they delete a source - carry on.
                    if _debug_buffers:
                        print("Found a bad buffer")
                    continue
                buffs.append(b)
                i -= 1
        except IndexError:
            while i > 0:
                buffer = al.ALuint()
                al.alGenBuffers(1, buffer)
                if _debug_buffers:
                    error = al.alGetError()
                    if error != 0:
                        print("GEN BUFFERS: " + str(error))
                buffs.append(buffer)
                i -= 1

        alSourceVal = alSource.value
        if alSourceVal not in self._sources:
            self._sources[alSourceVal] = buffs
        else:
            self._sources[alSourceVal].extend(buffs)

        return buffs