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

#include <dsp.h>

+ Inheritance diagram for dsp_chunk_list_impl:

Public Member Functions

t_size get_count () const
 
audio_chunkget_item (t_size n) const
 
audio_chunkinsert_item (t_size idx, t_size hint_size=0)
 
void remove_by_idx (t_size idx)
 
void remove_mask (const bit_array &mask)
 
- Public Member Functions inherited from dsp_chunk_list
void add_chunk (const audio_chunk *chunk)
 
audio_chunkadd_item (t_size hint_size=0)
 
double get_duration ()
 
void remove_all ()
 
void remove_bad_chunks ()
 

Private Attributes

pfc::list_t< pfc::rcptr_t< audio_chunk > > m_data
 
pfc::list_t< pfc::rcptr_t< audio_chunk > > m_recycled
 

Additional Inherited Members

- Protected Member Functions inherited from dsp_chunk_list
 dsp_chunk_list ()
 
 ~dsp_chunk_list ()
 

Detailed Description

Definition at line 32 of file dsp.h.

Member Function Documentation

t_size dsp_chunk_list_impl::get_count ( ) const
virtual

Implements dsp_chunk_list.

Definition at line 4 of file dsp.cpp.

4 {return m_data.get_count();}
pfc::list_t< pfc::rcptr_t< audio_chunk > > m_data
Definition: dsp.h:34
t_size get_count() const
Definition: list.h:365
audio_chunk * dsp_chunk_list_impl::get_item ( t_size  n) const
virtual

Implements dsp_chunk_list.

Definition at line 6 of file dsp.cpp.

6 {return n<m_data.get_count() ? &*m_data[n] : 0;}
pfc::list_t< pfc::rcptr_t< audio_chunk > > m_data
Definition: dsp.h:34
t_size get_count() const
Definition: list.h:365
audio_chunk * dsp_chunk_list_impl::insert_item ( t_size  idx,
t_size  hint_size = 0 
)
virtual

Implements dsp_chunk_list.

Definition at line 23 of file dsp.cpp.

24 {
25  t_size max = get_count();
26  if (idx>max) idx = max;
28  if (m_recycled.get_count()>0)
29  {
30  t_size best;
31  if (hint_size>0)
32  {
33  best = 0;
34  t_size best_found = m_recycled[0]->get_data_size(), n, total = m_recycled.get_count();
35  for(n=1;n<total;n++)
36  {
37  if (best_found==hint_size) break;
38  t_size size = m_recycled[n]->get_data_size();
39  int delta_old = abs((int)best_found - (int)hint_size), delta_new = abs((int)size - (int)hint_size);
40  if (delta_new < delta_old)
41  {
42  best_found = size;
43  best = n;
44  }
45  }
46  }
47  else best = m_recycled.get_count()-1;
48 
49  ret = m_recycled.remove_by_idx(best);
50  ret->set_sample_count(0);
51  ret->set_channels(0);
52  ret->set_srate(0);
53  }
54  else ret = pfc::rcnew_t<audio_chunk_impl>();
55  if (idx==max) m_data.add_item(ret);
56  else m_data.insert_item(ret,idx);
57  return &*ret;
58 }
virtual void set_srate(unsigned val)=0
Sets sample rate of contained audio data.
pfc::list_t< pfc::rcptr_t< audio_chunk > > m_data
Definition: dsp.h:34
pfc::list_t< pfc::rcptr_t< audio_chunk > > m_recycled
Definition: dsp.h:34
t_size get_count() const
Definition: list.h:365
t_size get_count() const
Definition: dsp.cpp:4
size_t t_size
Definition: int_types.h:48
t_size add_item(const T &item)
Definition: list.h:522
T remove_by_idx(t_size idx)
Definition: list.h:331
virtual void set_channels(unsigned p_count, unsigned p_config)=0
Sets channel count / channel map.
t_size insert_item(const t_in &item, t_size idx)
Definition: list.h:323
virtual void set_sample_count(t_size val)=0
Sets number of valid samples in the buffer. WARNING: sample count * channel count should never be abo...
void dsp_chunk_list_impl::remove_by_idx ( t_size  idx)
virtual

Implements dsp_chunk_list.

Definition at line 8 of file dsp.cpp.

9 {
10  if (idx<m_data.get_count())
12 }
pfc::list_t< pfc::rcptr_t< audio_chunk > > m_data
Definition: dsp.h:34
pfc::list_t< pfc::rcptr_t< audio_chunk > > m_recycled
Definition: dsp.h:34
t_size get_count() const
Definition: list.h:365
t_size add_item(const T &item)
Definition: list.h:522
T remove_by_idx(t_size idx)
Definition: list.h:331
void dsp_chunk_list_impl::remove_mask ( const bit_array mask)
virtual

Implements dsp_chunk_list.

Definition at line 14 of file dsp.cpp.

15 {
16  t_size n, m = m_data.get_count();
17  for(n=0;n<m;n++)
18  if (mask[m])
20  m_data.remove_mask(mask);
21 }
pfc::list_t< pfc::rcptr_t< audio_chunk > > m_data
Definition: dsp.h:34
pfc::list_t< pfc::rcptr_t< audio_chunk > > m_recycled
Definition: dsp.h:34
t_size get_count() const
Definition: list.h:365
void remove_mask(const bit_array &mask)
Definition: list.h:517
size_t t_size
Definition: int_types.h:48
t_size add_item(const T &item)
Definition: list.h:522

Field Documentation

pfc::list_t<pfc::rcptr_t<audio_chunk> > dsp_chunk_list_impl::m_data
private

Definition at line 34 of file dsp.h.

pfc::list_t<pfc::rcptr_t<audio_chunk> > dsp_chunk_list_impl::m_recycled
private

Definition at line 34 of file dsp.h.


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