9 #ifndef YARP_DEV_CIRCULARAUDIOBUFFER_H
10 #define YARP_DEV_CIRCULARAUDIOBUFFER_H
23 template <
typename SAMPLE>
35 return (end + 1) % maxsize.size == start;
51 end = (end + 1) % maxsize.size;
54 printf (
"ERROR: %s buffer overrun!\n", name.c_str());
55 start = (start + 1) % maxsize.size;
67 i = maxsize.size - start + end;
75 printf (
"ERROR: %s buffer underrun!\n", name.c_str());
77 SAMPLE elem = elems[start];
78 start = (start + 1) % maxsize.size;
98 elems{
static_cast<SAMPLE*
>(calloc(maxsize.size,
sizeof(
SAMPLE)))}
100 static_assert (std::is_same<unsigned char, SAMPLE>::value ||
101 std::is_same<unsigned short int, SAMPLE>::value ||
102 std::is_same<unsigned int, SAMPLE>::value,
103 "CircularAudioBuffer can be specialized only as <unsigned char>, <unsigned short int>, <unsigned int>");
124 #endif // YARP_DEV_CIRCULARAUDIOBUFFER_H