(self)
If active, read output from the cava program.
        Make sure that the most recent frame is always fully available,
        Stores incomplete frames for the next update.
If active, read output from the cava program.
        Make sure that the most recent frame is always fully available,
        Stores incomplete frames for the next update.
If active read output from the cava program . Make sure that the most recent frame is always fully available Stores incomplete frames for the next update .
def compute(self) -> None:
        """If active, read output from the cava program.
        Make sure that the most recent frame is always fully available,
        Stores incomplete frames for the next update."""
        # do not compute if no program uses cava
        if self.consumers == 0:
            return
        # read the fifo until we get to the current frame
        while True:
            try:
                read = os.read(
                    self.cava_fifo, self.frame_length - len(self.growing_frame)
                )
                if read == b"":
                    return
                self.growing_frame += read
            except OSError as e:
                if e.errno == errno.EAGAIN or e.errno == errno.EWOULDBLOCK:
                    # there were not enough bytes for a whole frame, keep the old frame
                    return

            # we read a whole frame, update the factors
            if len(self.growing_frame) == self.frame_length:
                # vol = max(0.01, get("volume"))
                # self.current_frame = [int(b) / 255 / vol for b in self.growing_frame]
                self.current_frame = [int(b) / 255 for b in self.growing_frame]
                self.growing_frame = b""
def compute ( self ) -> None : # do not compute if no program uses cava if self . consumers == 0 : return # read the fifo until we get to the current frame while True : try : read = os . read ( self . cava_fifo , self . frame_length - len ( self . growing_frame ) ) if read == b"" : return self . growing_frame += read except OSError as e : if e . errno == errno . EAGAIN or e . errno == errno . EWOULDBLOCK : # there were not enough bytes for a whole frame, keep the old frame return # we read a whole frame, update the factors if len ( self . growing_frame ) == self . frame_length : # vol = max(0.01, get("volume")) # self.current_frame = [int(b) / 255 / vol for b in self.growing_frame] self . current_frame = [ int ( b ) / 255 for b in self . growing_frame ] self . growing_frame = b""