foobar2000 SDK  2015-08-03
Protected Member Functions | Private Member Functions | Private Attributes
output_implabstract

#include <output.h>

+ Inheritance diagram for output_impl:

Protected Member Functions

 output_impl ()
 
virtual t_size can_write_samples ()=0
 
virtual void force_play ()=0
 
virtual t_size get_latency_samples ()=0
 
virtual void on_flush ()=0
 
virtual void on_flush_changing_track ()
 
void on_need_reopen ()
 
virtual void on_update ()=0
 
virtual void open (t_samplespec const &p_spec)=0
 
virtual void pause (bool p_state)=0
 
virtual void volume_set (double p_val)=0
 
virtual void write (const audio_chunk &p_data)=0
 
- Protected Member Functions inherited from service_base
 service_base ()
 
 ~service_base ()
 

Private Member Functions

void flush ()
 
void flush_changing_track ()
 
double get_latency ()
 
void process_samples (const audio_chunk &p_chunk)
 
void update (bool &p_ready)
 

Private Attributes

t_samplespec m_active_spec
 
pfc::array_t< audio_sample, pfc::alloc_fast_aggressivem_incoming
 
t_size m_incoming_ptr
 
t_samplespec m_incoming_spec
 

Additional Inherited Members

- Public Types inherited from service_base
typedef service_base t_interface
 
- Public Member Functions inherited from output_v2
virtual void enable_fading (bool state)
 
virtual void on_track_mark ()
 
virtual bool want_track_marks ()
 
- Public Member Functions inherited from service_base
template<typename outPtr_t >
bool cast (outPtr_t &outPtr)
 
virtual int service_add_ref ()=0 throw ()
 
virtual bool service_query (service_ptr_t< service_base > &p_out, const GUID &p_guid)
 
template<class T >
bool service_query_t (service_ptr_t< T > &p_out)
 
virtual int service_release ()=0 throw ()
 

Detailed Description

Definition at line 188 of file output.h.

Constructor & Destructor Documentation

output_impl::output_impl ( )
inlineprotected

Definition at line 190 of file output.h.

190 : m_incoming_ptr(0) {}
t_size m_incoming_ptr
Definition: output.h:213

Member Function Documentation

virtual t_size output_impl::can_write_samples ( )
protectedpure virtual
void output_impl::flush ( )
privatevirtual

Flushes queued audio data. Called after seeking.

Implements output.

Definition at line 52 of file output.cpp.

52  {
53  m_incoming_ptr = 0;
55  on_flush();
56 }
t_size m_incoming_ptr
Definition: output.h:213
virtual void on_flush()=0
void set_size(t_size p_size)
Definition: array.h:104
pfc::array_t< audio_sample, pfc::alloc_fast_aggressive > m_incoming
Definition: output.h:212
void output_impl::flush_changing_track ( )
privatevirtual

Reimplemented from output_v2.

Definition at line 57 of file output.cpp.

57  {
58  m_incoming_ptr = 0;
61 }
t_size m_incoming_ptr
Definition: output.h:213
void set_size(t_size p_size)
Definition: array.h:104
virtual void on_flush_changing_track()
Definition: output.h:197
pfc::array_t< audio_sample, pfc::alloc_fast_aggressive > m_incoming
Definition: output.h:212
virtual void output_impl::force_play ( )
protectedpure virtual

Forces playback of queued data. Called when there's no more data to send, to prevent infinite waiting if output implementation starts actually playing after amount of data in internal buffer reaches some level.

Implements output.

double output_impl::get_latency ( )
privatevirtual

Retrieves amount of audio data queued for playback, in seconds.

Implements output.

Definition at line 82 of file output.cpp.

82  {
83  double ret = 0;
84  if (m_incoming_spec.is_valid()) {
85  ret += audio_math::samples_to_time( (m_incoming.get_size() - m_incoming_ptr) / m_incoming_spec.m_channels, m_incoming_spec.m_sample_rate );
86  }
87  if (m_active_spec.is_valid()) {
88  ret += audio_math::samples_to_time( get_latency_samples() , m_active_spec.m_sample_rate );
89  }
90  return ret;
91 }
t_size m_incoming_ptr
Definition: output.h:213
bool is_valid() const
Definition: output.h:74
t_samplespec m_incoming_spec
Definition: output.h:214
t_uint32 m_channels
Definition: output.h:56
t_uint32 m_sample_rate
Definition: output.h:55
virtual t_size get_latency_samples()=0
t_size get_size() const
Definition: array.h:130
pfc::array_t< audio_sample, pfc::alloc_fast_aggressive > m_incoming
Definition: output.h:212
t_samplespec m_active_spec
Definition: output.h:214
virtual t_size output_impl::get_latency_samples ( )
protectedpure virtual
virtual void output_impl::on_flush ( )
protectedpure virtual
virtual void output_impl::on_flush_changing_track ( )
inlineprotectedvirtual

Definition at line 197 of file output.h.

197 {on_flush();}
virtual void on_flush()=0
void output_impl::on_need_reopen ( )
inlineprotected

Definition at line 204 of file output.h.

t_samplespec m_active_spec
Definition: output.h:214
virtual void output_impl::on_update ( )
protectedpure virtual
virtual void output_impl::open ( t_samplespec const &  p_spec)
protectedpure virtual
virtual void output_impl::pause ( bool  p_state)
protectedpure virtual

Pauses/unpauses playback.

Implements output.

void output_impl::process_samples ( const audio_chunk p_chunk)
privatevirtual

Sends new samples to the device. Allowed to be called only when update() indicates that the device is ready.

Implements output.

Definition at line 92 of file output.cpp.

92  {
94  t_samplespec spec;
95  spec.fromchunk(p_chunk);
96  if (!spec.is_valid()) pfc::throw_exception_with_message< exception_io_data >("Invalid audio stream specifications");
97  m_incoming_spec = spec;
98  t_size length = p_chunk.get_used_size();
99  m_incoming.set_data_fromptr(p_chunk.get_data(),length);
100  m_incoming_ptr = 0;
101 }
t_size m_incoming_ptr
Definition: output.h:213
t_samplespec m_incoming_spec
Definition: output.h:214
void fromchunk(const audio_chunk &p_chunk)
Definition: output.h:82
void dynamic_assert(bool p_condition, const char *p_msg)
Definition: primitives.h:239
size_t t_size
Definition: int_types.h:48
virtual audio_sample * get_data()=0
Retrieves audio data buffer pointer (non-const version). Returned pointer is for temporary use only; ...
void set_data_fromptr(const t_source *p_buffer, t_size p_count)
Warning: buffer pointer must not point to buffer allocated by this array (fixme). ...
Definition: array.h:139
t_size get_size() const
Definition: array.h:130
size_t get_used_size() const
Returns actual amount of audio data contained in the buffer (sample count * channel count)...
Definition: audio_chunk.h:134
pfc::array_t< audio_sample, pfc::alloc_fast_aggressive > m_incoming
Definition: output.h:212
void output_impl::update ( bool &  p_ready)
privatevirtual

Updates playback; queries whether the device is ready to receive new data.

Parameters
p_readyOn success, receives value indicating whether the device is ready for next process_samples() call.

Implements output.

Definition at line 62 of file output.cpp.

62  {
63  on_update();
65  if (get_latency_samples() == 0) {
68  } else {
69  force_play();
70  }
71  }
75  if (delta > 0) {
77  m_incoming_ptr += delta;
78  }
79  }
80  p_ready = (m_incoming_ptr == m_incoming.get_size());
81 }
t_size m_incoming_ptr
Definition: output.h:213
const t_item * get_ptr() const
Definition: array.h:213
T min_t(const T &item1, const T &item2)
Definition: primitives.h:556
t_samplespec m_incoming_spec
Definition: output.h:214
audio_chunk_memref_impl audio_chunk_temp_impl
Definition: audio_chunk.h:310
t_uint32 m_channels
Definition: output.h:56
virtual t_size can_write_samples()=0
virtual void on_update()=0
virtual void force_play()=0
Forces playback of queued data. Called when there&#39;s no more data to send, to prevent infinite waiting...
virtual void open(t_samplespec const &p_spec)=0
t_uint32 m_sample_rate
Definition: output.h:55
size_t t_size
Definition: int_types.h:48
t_uint32 m_channel_config
Definition: output.h:56
virtual t_size get_latency_samples()=0
virtual void write(const audio_chunk &p_data)=0
Will never get more input than as returned by can_write_samples().
t_size get_size() const
Definition: array.h:130
pfc::array_t< audio_sample, pfc::alloc_fast_aggressive > m_incoming
Definition: output.h:212
t_samplespec m_active_spec
Definition: output.h:214
virtual void output_impl::volume_set ( double  p_val)
protectedpure virtual

Sets playback volume. Volume level in dB. Value of 0 indicates full ("100%") volume, negative values indciate different attenuation levels.

Implements output.

virtual void output_impl::write ( const audio_chunk p_data)
protectedpure virtual

Will never get more input than as returned by can_write_samples().

Field Documentation

t_samplespec output_impl::m_active_spec
private

Definition at line 214 of file output.h.

pfc::array_t<audio_sample,pfc::alloc_fast_aggressive> output_impl::m_incoming
private

Definition at line 212 of file output.h.

t_size output_impl::m_incoming_ptr
private

Definition at line 213 of file output.h.

t_samplespec output_impl::m_incoming_spec
private

Definition at line 214 of file output.h.


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