/[svn]/linuxsampler/trunk/src/common/RingBuffer.h
ViewVC logotype

Diff of /linuxsampler/trunk/src/common/RingBuffer.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 970 by schoenebeck, Wed Dec 6 22:28:17 2006 UTC revision 1479 by senoner, Wed Nov 14 15:06:48 2007 UTC
# Line 24  Line 24 
24  #ifndef RINGBUFFER_H  #ifndef RINGBUFFER_H
25  #define RINGBUFFER_H  #define RINGBUFFER_H
26    
27  #define DEFAULT_WRAP_ELEMENTS 1024  #define DEFAULT_WRAP_ELEMENTS 0
28    
29  #include <string.h>  #include <string.h>
30    
# Line 94  public: Line 94  public:
94      inline void fill_write_space_with_null() {      inline void fill_write_space_with_null() {
95               int w = atomic_read(&write_ptr),               int w = atomic_read(&write_ptr),
96                   r = atomic_read(&read_ptr);                   r = atomic_read(&read_ptr);
97               memset(get_write_ptr(), 0, write_space_to_end());               memset(get_write_ptr(), 0, sizeof(T)*write_space_to_end());
98               if (r && w >= r) {               if (r && w >= r) {
99                 memset(get_buffer_begin(), 0, r - 1);                 memset(get_buffer_begin(), 0, sizeof(T)*(r - 1));
100               }               }
101    
102               // set the wrap space elements to null               // set the wrap space elements to null
103               if (wrap_elements) memset(&buf[size], 0, wrap_elements);               if (wrap_elements) memset(&buf[size], 0, sizeof(T)*wrap_elements);
104             }             }
105    
106      __inline int  read (T *dest, int cnt);      __inline int  read (T *dest, int cnt);
# Line 301  public: Line 301  public:
301               */               */
302              inline void operator--() {              inline void operator--() {
303                  if (read_ptr == atomic_read(&pBuf->read_ptr)) return; //TODO: or should we react oh this case (e.g. force segfault), as this is a very odd case?                  if (read_ptr == atomic_read(&pBuf->read_ptr)) return; //TODO: or should we react oh this case (e.g. force segfault), as this is a very odd case?
304                  --read_ptr & pBuf->size_mask;                  read_ptr = (read_ptr-1) & pBuf->size_mask;
305              }              }
306    
307              /**              /**

Legend:
Removed from v.970  
changed lines
  Added in v.1479

  ViewVC Help
Powered by ViewVC