Logo Search packages:      
Sourcecode: blender version File versions

int fifo_read ( FifoBuffer *  f,
uint8_t *  buf,
int  buf_size,
uint8_t **  rptr_ptr 
)

Get data from the fifo (returns -1 if not enough data).

Definition at line 291 of file utils.c.

{
    uint8_t *rptr;
    int size, len;

    if(!rptr_ptr)
        rptr_ptr= &f->rptr;
    rptr = *rptr_ptr;

    if (f->wptr >= rptr) {
        size = f->wptr - rptr;
    } else {
        size = (f->end - rptr) + (f->wptr - f->buffer);
    }

    if (size < buf_size)
        return -1;
    while (buf_size > 0) {
        len = f->end - rptr;
        if (len > buf_size)
            len = buf_size;
        memcpy(buf, rptr, len);
        buf += len;
        rptr += len;
        if (rptr >= f->end)
            rptr = f->buffer;
        buf_size -= len;
    }
    *rptr_ptr = rptr;
    return 0;
}


Generated by  Doxygen 1.6.0   Back to index