replace BUFFER_SIZE with fifo->ring_size