Revision 870a12d1 libavutil/fifo.c

View differences:

libavutil/fifo.c
90 90

  
91 91
void av_fifo_write(AVFifoBuffer *f, const uint8_t *buf, int size)
92 92
{
93
    int len;
94

  
95 93
    while (size > 0) {
96
        len = FFMIN(f->end - f->wptr, size);
94
        int len = FFMIN(f->end - f->wptr, size);
97 95
        memcpy(f->wptr, buf, len);
98 96
        f->wptr += len;
99 97
        if (f->wptr >= f->end)
......
107 105
/* get data from the fifo (return -1 if not enough data) */
108 106
int av_fifo_generic_read(AVFifoBuffer *f, int buf_size, void (*func)(void*, void*, int), void* dest)
109 107
{
110
    int len;
111
    int size = f->wptr - f->rptr;
112
    if (size < 0)
113
        size += f->end - f->buffer;
108
    int size = av_fifo_size(f);
114 109

  
115 110
    if (size < buf_size)
116 111
        return -1;
117 112
    while (buf_size > 0) {
118
        len = FFMIN(f->end - f->rptr, buf_size);
113
        int len = FFMIN(f->end - f->rptr, buf_size);
119 114
        func(dest, f->rptr, len);
120 115
        f->rptr += len;
121 116
        if (f->rptr >= f->end)

Also available in: Unified diff