foobar2000 SDK  2015-08-03
Public Member Functions | Private Attributes
seekabilizer_backbuffer

#include <seekabilizer.h>

Public Member Functions

t_size get_depth () const
 
t_size get_max_depth () const
 
void initialize (t_size p_size)
 
void read (t_size p_backlogdepth, void *p_buffer, t_size p_bytes) const
 
void reset ()
 
void write (const void *p_buffer, t_size p_bytes)
 

Private Attributes

pfc::array_t< t_uint8m_buffer
 
t_size m_cursor
 
t_size m_depth
 

Detailed Description

Definition at line 1 of file seekabilizer.h.

Member Function Documentation

t_size seekabilizer_backbuffer::get_depth ( ) const

Definition at line 64 of file seekabilizer.cpp.

65 {
66  return m_depth;
67 }
t_size seekabilizer_backbuffer::get_max_depth ( ) const

Definition at line 69 of file seekabilizer.cpp.

70 {
71  return m_buffer.get_size();
72 }
pfc::array_t< t_uint8 > m_buffer
Definition: seekabilizer.h:11
t_size get_size() const
Definition: array.h:130
void seekabilizer_backbuffer::initialize ( t_size  p_size)

Definition at line 5 of file seekabilizer.cpp.

6 {
7  m_depth = m_cursor = 0;
8 
9  m_buffer.set_size(p_size);
10 }
pfc::array_t< t_uint8 > m_buffer
Definition: seekabilizer.h:11
void set_size(t_size p_size)
Definition: array.h:104
void seekabilizer_backbuffer::read ( t_size  p_backlogdepth,
void *  p_buffer,
t_size  p_bytes 
) const

Definition at line 41 of file seekabilizer.cpp.

42 {
43  assert(p_backlogdepth <= m_depth);
44  assert(p_backlogdepth >= p_bytes);
45 
46 
47  t_uint8* targetptr = (t_uint8*) p_buffer;
48  t_size remaining = p_bytes;
49  t_size cursor = (m_cursor + m_buffer.get_size() - p_backlogdepth) % m_buffer.get_size();
50 
51  while(remaining > 0)
52  {
53  t_size delta = m_buffer.get_size() - cursor;
54  if (delta > remaining) delta = remaining;
55 
56  memcpy(targetptr,m_buffer.get_ptr() + cursor,delta);
57 
58  targetptr += delta;
59  remaining -= delta;
60  cursor = (cursor + delta) % m_buffer.get_size();
61  }
62 }
const t_item * get_ptr() const
Definition: array.h:213
uint8_t t_uint8
Definition: int_types.h:9
pfc::array_t< t_uint8 > m_buffer
Definition: seekabilizer.h:11
size_t t_size
Definition: int_types.h:48
t_size get_size() const
Definition: array.h:130
void seekabilizer_backbuffer::reset ( )

Definition at line 74 of file seekabilizer.cpp.

75 {
76  m_depth = m_cursor = 0;
77 }
void seekabilizer_backbuffer::write ( const void *  p_buffer,
t_size  p_bytes 
)

Definition at line 12 of file seekabilizer.cpp.

13 {
14  if (p_bytes >= m_buffer.get_size())
15  {
16  memcpy(m_buffer.get_ptr(),(const t_uint8*)p_buffer + p_bytes - m_buffer.get_size(),m_buffer.get_size());
17  m_cursor = 0;
19  }
20  else
21  {
22  const t_uint8* sourceptr = (const t_uint8*) p_buffer;
23  t_size remaining = p_bytes;
24  while(remaining > 0)
25  {
26  t_size delta = m_buffer.get_size() - m_cursor;
27  if (delta > remaining) delta = remaining;
28 
29  memcpy(m_buffer.get_ptr() + m_cursor,sourceptr,delta);
30 
31  sourceptr += delta;
32  remaining -= delta;
33  m_cursor = (m_cursor + delta) % m_buffer.get_size();
34 
35  m_depth = pfc::min_t<t_size>(m_buffer.get_size(),m_depth + delta);
36 
37  }
38  }
39 }
const t_item * get_ptr() const
Definition: array.h:213
uint8_t t_uint8
Definition: int_types.h:9
pfc::array_t< t_uint8 > m_buffer
Definition: seekabilizer.h:11
size_t t_size
Definition: int_types.h:48
t_size get_size() const
Definition: array.h:130

Field Documentation

pfc::array_t<t_uint8> seekabilizer_backbuffer::m_buffer
private

Definition at line 11 of file seekabilizer.h.

t_size seekabilizer_backbuffer::m_cursor
private

Definition at line 12 of file seekabilizer.h.

t_size seekabilizer_backbuffer::m_depth
private

Definition at line 12 of file seekabilizer.h.


The documentation for this class was generated from the following files: