foobar2000 SDK  2015-01-14
Public Member Functions | Private Member Functions | Private Attributes
input_helper_cue

#include <input_helpers.h>

Public Member Functions

bool can_seek ()
 
void close ()
 
bool get_dynamic_info (file_info &p_out, double &p_timestamp_delta)
 
bool get_dynamic_info_track (file_info &p_out, double &p_timestamp_delta)
 
void get_info (t_uint32 p_subsong, file_info &p_info, abort_callback &p_abort)
 
const char * get_path () const
 
bool is_open ()
 
void on_idle (abort_callback &p_abort)
 
void open (service_ptr_t< file > p_filehint, const playable_location &p_location, unsigned p_flags, abort_callback &p_abort, double p_start, double p_length)
 
bool run (audio_chunk &p_chunk, abort_callback &p_abort)
 
bool run_raw (audio_chunk &p_chunk, mem_block_container &p_raw, abort_callback &p_abort)
 
void seek (double seconds, abort_callback &p_abort)
 
void set_full_buffer (t_filesize val)
 
void set_logger (event_logger::ptr ptr)
 

Private Member Functions

bool _m_input_run (audio_chunk &p_chunk, mem_block_container *p_raw, abort_callback &p_abort)
 
bool _run (audio_chunk &p_chunk, mem_block_container *p_raw, abort_callback &p_abort)
 

Private Attributes

bool m_dynamic_info_track_trigger
 
bool m_dynamic_info_trigger
 
input_helper m_input
 
double m_length
 
double m_position
 
double m_start
 

Detailed Description

Definition at line 90 of file input_helpers.h.

Member Function Documentation

bool input_helper_cue::_m_input_run ( audio_chunk p_chunk,
mem_block_container p_raw,
abort_callback p_abort 
)
private

Definition at line 309 of file input_helpers.cpp.

309  {
310  if (p_raw == NULL) {
311  return m_input.run(p_chunk, p_abort);
312  } else {
313  return m_input.run_raw(p_chunk, *p_raw, p_abort);
314  }
315 }
bool run(audio_chunk &p_chunk, abort_callback &p_abort)
bool run_raw(audio_chunk &p_chunk, mem_block_container &p_raw, abort_callback &p_abort)
input_helper m_input
bool input_helper_cue::_run ( audio_chunk p_chunk,
mem_block_container p_raw,
abort_callback p_abort 
)
private

Definition at line 316 of file input_helpers.cpp.

316  {
317  p_abort.check();
318 
319  if (m_length > 0) {
320  if (m_position >= m_length) return false;
321 
322  if (!_m_input_run(p_chunk, p_raw, p_abort)) return false;
323 
324  m_dynamic_info_trigger = true;
326 
328  if (max == 0)
329  {//handle rounding accidents, this normally shouldn't trigger
331  return false;
332  }
333 
334  t_size samples = p_chunk.get_sample_count();
335  if ((t_uint64)samples > max)
336  {
337  p_chunk.set_sample_count((unsigned)max);
338  if (p_raw != NULL) {
339  const t_size rawSize = p_raw->get_size();
340  PFC_ASSERT( rawSize % samples == 0 );
341  p_raw->set_size( (t_size) ( (t_uint64) rawSize * max / samples ) );
342  }
344  }
345  else
346  {
347  m_position += p_chunk.get_duration();
348  }
349  return true;
350  }
351  else
352  {
353  if (!_m_input_run(p_chunk, p_raw, p_abort)) return false;
354  m_position += p_chunk.get_duration();
355  return true;
356  }
357 }
virtual void set_size(t_size p_size)=0
uint64_t t_uint64
Definition: int_types.h:3
unsigned get_sample_rate() const
Helper, same as get_srate().
Definition: audio_chunk.h:103
bool m_dynamic_info_track_trigger
size_t t_size
Definition: int_types.h:48
bool _m_input_run(audio_chunk &p_chunk, mem_block_container *p_raw, abort_callback &p_abort)
double get_duration() const
Retrieves duration of contained audio data, in seconds.
Definition: audio_chunk.h:116
t_uint64 time_to_samples(double p_time, t_uint32 p_sample_rate)
Definition: audio_sample.h:33
virtual t_size get_sample_count() const =0
Retrieves number of valid samples in the buffer. Note that a "sample" means a unit of interleaved PC...
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...
virtual t_size get_size() const =0
bool input_helper_cue::can_seek ( )

Definition at line 378 of file input_helpers.cpp.

378 {return true;}
void input_helper_cue::close ( )

Definition at line 306 of file input_helpers.cpp.

306 {m_input.close();}
input_helper m_input
bool input_helper_cue::get_dynamic_info ( file_info p_out,
double &  p_timestamp_delta 
)

Definition at line 384 of file input_helpers.cpp.

384  {
386  m_dynamic_info_trigger = false;
387  return m_input.get_dynamic_info(p_out,p_timestamp_delta);
388  } else {
389  return false;
390  }
391 }
bool get_dynamic_info(file_info &p_out, double &p_timestamp_delta)
input_helper m_input
bool input_helper_cue::get_dynamic_info_track ( file_info p_out,
double &  p_timestamp_delta 
)

Definition at line 393 of file input_helpers.cpp.

393  {
396  return m_input.get_dynamic_info_track(p_out,p_timestamp_delta);
397  } else {
398  return false;
399  }
400 }
bool m_dynamic_info_track_trigger
bool get_dynamic_info_track(file_info &p_out, double &p_timestamp_delta)
input_helper m_input
void input_helper_cue::get_info ( t_uint32  p_subsong,
file_info p_info,
abort_callback p_abort 
)

Definition at line 404 of file input_helpers.cpp.

404 {m_input.get_info(p_subsong,p_info,p_abort);}
void get_info(t_uint32 p_subsong, file_info &p_info, abort_callback &p_abort)
Retrieves info about specific subsong of currently open file.
input_helper m_input
const char * input_helper_cue::get_path ( ) const

Definition at line 402 of file input_helpers.cpp.

402 {return m_input.get_path();}
const char * get_path() const
Retrieves path of currently open file.
input_helper m_input
bool input_helper_cue::is_open ( )

Definition at line 307 of file input_helpers.cpp.

307 {return m_input.is_open();}
input_helper m_input
void input_helper_cue::on_idle ( abort_callback p_abort)

Definition at line 382 of file input_helpers.cpp.

382 {m_input.on_idle(p_abort);}
void on_idle(abort_callback &p_abort)
input_helper m_input
void input_helper_cue::open ( service_ptr_t< file p_filehint,
const playable_location p_location,
unsigned  p_flags,
abort_callback p_abort,
double  p_start,
double  p_length 
)

Definition at line 278 of file input_helpers.cpp.

278  {
279  p_abort.check();
280 
281  m_start = p_start;
282  m_position = 0;
283  m_dynamic_info_trigger = false;
285 
286  m_input.open(p_filehint,p_location,p_flags,p_abort,true,true);
287 
288  if (!m_input.can_seek()) throw exception_io_object_not_seekable();
289 
290  if (m_start > 0) {
291  m_input.seek(m_start,p_abort);
292  }
293 
294  if (p_length > 0) {
295  m_length = p_length;
296  } else {
297  file_info_impl temp;
298  m_input.get_info(0,temp,p_abort);
299  double ref_length = temp.get_length();
300  if (ref_length <= 0) throw exception_io_data();
301  m_length = ref_length - m_start + p_length /* negative or zero */;
302  if (m_length <= 0) throw exception_io_data();
303  }
304 }
double get_length() const
Retrieves audio duration, in seconds. Note that the reported duration should not be assumed to be th...
bool m_dynamic_info_track_trigger
void open(service_ptr_t< file > p_filehint, metadb_handle_ptr p_location, unsigned p_flags, abort_callback &p_abort, bool p_from_redirect=false, bool p_skip_hints=false)
void seek(double seconds, abort_callback &p_abort)
void get_info(t_uint32 p_subsong, file_info &p_info, abort_callback &p_abort)
Retrieves info about specific subsong of currently open file.
Implements file_info.
input_helper m_input
bool input_helper_cue::run ( audio_chunk p_chunk,
abort_callback p_abort 
)

Definition at line 362 of file input_helpers.cpp.

362  {
363  return _run(p_chunk, NULL, p_abort);
364 }
bool _run(audio_chunk &p_chunk, mem_block_container *p_raw, abort_callback &p_abort)
bool input_helper_cue::run_raw ( audio_chunk p_chunk,
mem_block_container p_raw,
abort_callback p_abort 
)

Definition at line 358 of file input_helpers.cpp.

358  {
359  return _run(p_chunk, &p_raw, p_abort);
360 }
bool _run(audio_chunk &p_chunk, mem_block_container *p_raw, abort_callback &p_abort)
void input_helper_cue::seek ( double  seconds,
abort_callback p_abort 
)

Definition at line 366 of file input_helpers.cpp.

367 {
368  m_dynamic_info_trigger = false;
370  if (m_length <= 0 || p_seconds < m_length) {
371  m_input.seek(p_seconds + m_start,p_abort);
372  m_position = p_seconds;
373  } else {
375  }
376 }
bool m_dynamic_info_track_trigger
void seek(double seconds, abort_callback &p_abort)
input_helper m_input
void input_helper_cue::set_full_buffer ( t_filesize  val)

Definition at line 380 of file input_helpers.cpp.

380 {m_input.set_full_buffer(val);}
void set_full_buffer(t_filesize val)
input_helper m_input
void input_helper_cue::set_logger ( event_logger::ptr  ptr)
inline

Definition at line 104 of file input_helpers.h.

104 {m_input.set_logger(ptr);}
void set_logger(event_logger::ptr ptr)
input_helper m_input

Field Documentation

bool input_helper_cue::m_dynamic_info_track_trigger
private

Definition at line 115 of file input_helpers.h.

bool input_helper_cue::m_dynamic_info_trigger
private

Definition at line 115 of file input_helpers.h.

input_helper input_helper_cue::m_input
private

Definition at line 113 of file input_helpers.h.

double input_helper_cue::m_length
private

Definition at line 114 of file input_helpers.h.

double input_helper_cue::m_position
private

Definition at line 114 of file input_helpers.h.

double input_helper_cue::m_start
private

Definition at line 114 of file input_helpers.h.


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