Changeset 1360

Show
Ignore:
Timestamp:
10/19/08 02:56:16 (12 years ago)
Author:
ppalmers
Message:

temporarily fix ringbuffer thread safeness issue pointed out for jack ringbuffer on LAU/LAD

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/libffado-2.0/src/libutil/ringbuffer.c

    r864 r1360  
    188188 
    189189  memcpy (dest, &(rb->buf[rb->read_ptr]), n1); 
    190   rb->read_ptr += n1; 
    191   rb->read_ptr &= rb->size_mask; 
     190  rb->read_ptr = (rb->read_ptr + n1) & rb->size_mask; 
    192191 
    193192  if (n2) { 
    194193    memcpy (dest + n1, &(rb->buf[rb->read_ptr]), n2); 
    195     rb->read_ptr += n2; 
    196     rb->read_ptr &= rb->size_mask; 
     194    rb->read_ptr = (rb->read_ptr + n2) & rb->size_mask; 
    197195  } 
    198196 
     
    237235  if (n2) { 
    238236    memcpy (dest + n1, &(rb->buf[tmp_read_ptr]), n2); 
     237    // FIXME: tmp_read_ptr is not used anymore 
    239238    tmp_read_ptr += n2; 
    240239    tmp_read_ptr &= rb->size_mask; 
     
    273272 
    274273  memcpy (&(rb->buf[rb->write_ptr]), src, n1); 
    275   rb->write_ptr += n1; 
    276   rb->write_ptr &= rb->size_mask; 
     274  rb->write_ptr = (rb->write_ptr + n1) & rb->size_mask; 
    277275 
    278276  if (n2) { 
    279277    memcpy (&(rb->buf[rb->write_ptr]), src + n1, n2); 
    280     rb->write_ptr += n2; 
    281     rb->write_ptr &= rb->size_mask; 
     278    rb->write_ptr = (rb->write_ptr + n2) & rb->size_mask; 
    282279  } 
    283280 
     
    290287ffado_ringbuffer_read_advance (ffado_ringbuffer_t * rb, size_t cnt) 
    291288{ 
    292   rb->read_ptr += cnt; 
    293   rb->read_ptr &= rb->size_mask; 
     289  rb->read_ptr = (rb->read_ptr + cnt) & rb->size_mask; 
    294290} 
    295291 
     
    299295ffado_ringbuffer_write_advance (ffado_ringbuffer_t * rb, size_t cnt) 
    300296{ 
    301   rb->write_ptr += cnt; 
    302   rb->write_ptr &= rb->size_mask; 
     297  rb->write_ptr = (rb->write_ptr + cnt) & rb->size_mask; 
    303298} 
    304299