base.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:FightstickDisplay 作者: calexil 项目源码 文件源码
def consume(self, bytes, audio_format):
        """Remove some data from beginning of packet.  All events are
        cleared."""
        self.events = ()
        if bytes >= self.length:
            self.data = None
            self.length = 0
            self.timestamp += self.duration
            self.duration = 0.
            return
        elif bytes == 0:
            return

        if not isinstance(self.data, str):
            # XXX Create a string buffer for the whole packet then
            #     chop it up.  Could do some pointer arith here and
            #     save a bit of data pushing, but my guess is this is
            #     faster than fudging aruond with ctypes (and easier).
            data = ctypes.create_string_buffer(self.length)
            ctypes.memmove(data, self.data, self.length)
            self.data = data
        self.data = self.data[bytes:]
        self.length -= bytes
        self.duration -= bytes / float(audio_format.bytes_per_second)
        self.timestamp += bytes / float(audio_format.bytes_per_second)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号