foobar2000 SDK  2015-01-14
Data Structures | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
input_helper

#include <input_helpers.h>

Data Structures

struct  decodeOpen_t
 

Public Member Functions

 input_helper ()
 
bool can_seek ()
 
void close ()
 
bool flush_on_pause ()
 
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 ()
 
bool need_file_reopen (const char *newPath) const
 
void on_idle (abort_callback &p_abort)
 
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 open (service_ptr_t< file > p_filehint, const playable_location &p_location, unsigned p_flags, abort_callback &p_abort, bool p_from_redirect=false, bool p_skip_hints=false)
 
void open (const playable_location &location, abort_callback &abort, decodeOpen_t const &other)
 
void open (metadb_handle_ptr location, abort_callback &abort, decodeOpen_t const &other)
 
void open_decoding (t_uint32 subsong, t_uint32 flags, abort_callback &p_abort)
 
bool open_path (file::ptr p_filehint, const char *path, abort_callback &p_abort, bool p_from_redirect, bool p_skip_hints)
 
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_block_buffer (size_t val)
 
void set_full_buffer (t_filesize val)
 
void set_logger (event_logger::ptr ptr)
 
void set_pause (bool state)
 

Static Public Member Functions

static void g_get_info (const playable_location &p_location, file_info &p_info, abort_callback &p_abort, bool p_from_redirect=false)
 
static bool g_mark_dead (const pfc::list_base_const_t< metadb_handle_ptr > &p_list, bit_array_var &p_mask, abort_callback &p_abort)
 
static void g_set_info (const playable_location &p_location, file_info &p_info, abort_callback &p_abort, bool p_from_redirect=false)
 

Private Member Functions

void process_fullbuffer (service_ptr_t< file > &p_file, const char *p_path, abort_callback &p_abort)
 

Private Attributes

service_ptr_t< input_decoderm_input
 
_input_helper_io_filter m_ioFilter
 
t_filesize m_ioFilterArg
 
pfc::string8 m_path
 

Detailed Description

Definition at line 6 of file input_helpers.h.

Constructor & Destructor Documentation

input_helper::input_helper ( )

Definition at line 160 of file input_helpers.cpp.

161 {
162 }
_input_helper_io_filter m_ioFilter
Definition: input_helpers.h:65
t_filesize m_ioFilterArg
Definition: input_helpers.h:66

Member Function Documentation

bool input_helper::can_seek ( )

Definition at line 123 of file input_helpers.cpp.

123  {
124  return m_input->can_seek();
125 }
service_ptr_t< input_decoder > m_input
Definition: input_helpers.h:63
void input_helper::close ( )

Definition at line 85 of file input_helpers.cpp.

85  {
86  m_input.release();
87 }
void release()
Definition: service.h:109
service_ptr_t< input_decoder > m_input
Definition: input_helpers.h:63
bool input_helper::flush_on_pause ( )

Definition at line 97 of file input_helpers.cpp.

97  {
98  input_decoder_v3::ptr v3;
99  if (m_input->service_query_t(v3)) return v3->flush_on_pause();
100  else return false;
101 }
service_ptr_t< input_decoder > m_input
Definition: input_helpers.h:63
void input_helper::g_get_info ( const playable_location p_location,
file_info p_info,
abort_callback p_abort,
bool  p_from_redirect = false 
)
static

Definition at line 165 of file input_helpers.cpp.

165  {
167  input_entry::g_open_for_info_read(instance,0,p_location.get_path(),p_abort,p_from_redirect);
168  instance->get_info(p_location.get_subsong_index(),p_info,p_abort);
169 }
virtual const char * get_path() const =0
static void g_open_for_info_read(service_ptr_t< input_info_reader > &p_instance, service_ptr_t< file > p_filehint, const char *p_path, abort_callback &p_abort, bool p_from_redirect=false)
Definition: input.cpp:175
t_uint32 get_subsong_index() const
bool input_helper::g_mark_dead ( const pfc::list_base_const_t< metadb_handle_ptr > &  p_list,
bit_array_var p_mask,
abort_callback p_abort 
)
static

Definition at line 237 of file input_helpers.cpp.

238 {
239  dead_item_filter_impl_simple filter(p_abort);
240  return filter.run(p_list,p_mask);
241 }
void input_helper::g_set_info ( const playable_location p_location,
file_info p_info,
abort_callback p_abort,
bool  p_from_redirect = false 
)
static

Definition at line 171 of file input_helpers.cpp.

171  {
173  input_entry::g_open_for_info_write(instance,0,p_location.get_path(),p_abort,p_from_redirect);
174  instance->set_info(p_location.get_subsong_index(),p_info,p_abort);
175  instance->commit(p_abort);
176 }
virtual const char * get_path() const =0
static void g_open_for_info_write(service_ptr_t< input_info_writer > &p_instance, service_ptr_t< file > p_filehint, const char *p_path, abort_callback &p_abort, bool p_from_redirect=false)
Definition: input.cpp:189
t_uint32 get_subsong_index() const
Autopointer class to be used with all services. Manages reference counter calls behind-the-scenes.
Definition: service.h:55
bool input_helper::get_dynamic_info ( file_info p_out,
double &  p_timestamp_delta 
)

Definition at line 143 of file input_helpers.cpp.

143  {
144  TRACK_CODE("input_decoder::get_dynamic_info",return m_input->get_dynamic_info(p_out,p_timestamp_delta));
145 }
service_ptr_t< input_decoder > m_input
Definition: input_helpers.h:63
bool input_helper::get_dynamic_info_track ( file_info p_out,
double &  p_timestamp_delta 
)

Definition at line 147 of file input_helpers.cpp.

147  {
148  TRACK_CODE("input_decoder::get_dynamic_info_track",return m_input->get_dynamic_info_track(p_out,p_timestamp_delta));
149 }
service_ptr_t< input_decoder > m_input
Definition: input_helpers.h:63
void input_helper::get_info ( t_uint32  p_subsong,
file_info p_info,
abort_callback p_abort 
)

Retrieves info about specific subsong of currently open file.

Definition at line 151 of file input_helpers.cpp.

151  {
152  TRACK_CODE("input_decoder::get_info",m_input->get_info(p_subsong,p_info,p_abort));
153 }
service_ptr_t< input_decoder > m_input
Definition: input_helpers.h:63
const char * input_helper::get_path ( ) const

Retrieves path of currently open file.

Definition at line 155 of file input_helpers.cpp.

155  {
156  return m_path;
157 }
pfc::string8 m_path
Definition: input_helpers.h:64
bool input_helper::is_open ( )

Definition at line 89 of file input_helpers.cpp.

89  {
90  return m_input.is_valid();
91 }
bool is_valid() const
Definition: service.h:119
service_ptr_t< input_decoder > m_input
Definition: input_helpers.h:63
bool input_helper::need_file_reopen ( const char *  newPath) const

Definition at line 28 of file input_helpers.cpp.

28  {
29  return m_input.is_empty() || metadb::path_compare(m_path, newPath) != 0;
30 }
bool is_empty() const
Definition: service.h:120
pfc::string8 m_path
Definition: input_helpers.h:64
static int path_compare(const char *p1, const char *p2)
Definition: metadb.h:245
service_ptr_t< input_decoder > m_input
Definition: input_helpers.h:63
void input_helper::on_idle ( abort_callback p_abort)

Definition at line 137 of file input_helpers.cpp.

137  {
138  if (m_input.is_valid()) {
139  TRACK_CODE("input_decoder::on_idle",m_input->on_idle(p_abort));
140  }
141 }
bool is_valid() const
Definition: service.h:119
service_ptr_t< input_decoder > m_input
Definition: input_helpers.h:63
void input_helper::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 
)

Definition at line 19 of file input_helpers.cpp.

20 {
21  open(p_filehint,p_location->get_location(),p_flags,p_abort,p_from_redirect,p_skip_hints);
22 }
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 input_helper::open ( service_ptr_t< file p_filehint,
const playable_location p_location,
unsigned  p_flags,
abort_callback p_abort,
bool  p_from_redirect = false,
bool  p_skip_hints = false 
)

Definition at line 75 of file input_helpers.cpp.

75  {
76  decodeOpen_t o;
77  o.m_hint = p_filehint;
78  o.m_flags = p_flags;
79  o.m_from_redirect = p_from_redirect;
80  o.m_skip_hints = p_skip_hints;
81  this->open( p_location, p_abort, o );
82 }
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 input_helper::open ( const playable_location location,
abort_callback abort,
decodeOpen_t const &  other 
)

Definition at line 67 of file input_helpers.cpp.

67  {
68  open_path(other.m_hint, location.get_path(), abort, other.m_from_redirect, other.m_skip_hints);
69 
70  set_logger( other.m_logger );
71 
72  open_decoding(location.get_subsong(), other.m_flags, abort);
73 }
virtual t_uint32 get_subsong() const =0
virtual const char * get_path() const =0
bool open_path(file::ptr p_filehint, const char *path, abort_callback &p_abort, bool p_from_redirect, bool p_skip_hints)
Multilevel open helpers.
void set_logger(event_logger::ptr ptr)
void open_decoding(t_uint32 subsong, t_uint32 flags, abort_callback &p_abort)
Multilevel open helpers.
void input_helper::open ( metadb_handle_ptr  location,
abort_callback abort,
decodeOpen_t const &  other 
)
inline

Definition at line 23 of file input_helpers.h.

23 {this->open(location->get_location(), abort, other);}
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 input_helper::open_decoding ( t_uint32  subsong,
t_uint32  flags,
abort_callback p_abort 
)

Multilevel open helpers.

Definition at line 63 of file input_helpers.cpp.

63  {
64  TRACK_CODE("input_decoder::initialize",m_input->initialize(subsong,flags,p_abort));
65 }
service_ptr_t< input_decoder > m_input
Definition: input_helpers.h:63
bool input_helper::open_path ( file::ptr  p_filehint,
const char *  path,
abort_callback p_abort,
bool  p_from_redirect,
bool  p_skip_hints 
)

Multilevel open helpers.

Returns
Diagnostic/helper value: true if the decoder had to be re-opened entirely, false if the instance was reused.

Definition at line 32 of file input_helpers.cpp.

32  {
33  p_abort.check();
34 
35  if (!need_file_reopen(path)) return false;
36  m_input.release();
37 
38  service_ptr_t<file> l_file = p_filehint;
39  process_fullbuffer(l_file,path,p_abort);
40 
41  TRACK_CODE("input_entry::g_open_for_decoding",
42  input_entry::g_open_for_decoding(m_input,l_file,path,p_abort,p_from_redirect)
43  );
44 
45 
46  if (!p_skip_hints) {
47  try {
48  static_api_ptr_t<metadb_io>()->hint_reader(m_input.get_ptr(),path,p_abort);
49  } catch(exception_io_data) {
50  //Don't fail to decode when this barfs, might be barfing when reading info from another subsong than the one we're trying to decode etc.
51  m_input.release();
52  if (l_file.is_valid()) l_file->reopen(p_abort);
53  TRACK_CODE("input_entry::g_open_for_decoding",
54  input_entry::g_open_for_decoding(m_input,l_file,path,p_abort,p_from_redirect)
55  );
56  }
57  }
58 
59  m_path = path;
60  return true;
61 }
T * get_ptr() const
Definition: service.h:117
bool need_file_reopen(const char *newPath) const
pfc::string8 m_path
Definition: input_helpers.h:64
bool is_valid() const
Definition: service.h:119
void release()
Definition: service.h:109
void process_fullbuffer(service_ptr_t< file > &p_file, const char *p_path, abort_callback &p_abort)
static void g_open_for_decoding(service_ptr_t< input_decoder > &p_instance, service_ptr_t< file > p_filehint, const char *p_path, abort_callback &p_abort, bool p_from_redirect=false)
Definition: input.cpp:160
service_ptr_t< input_decoder > m_input
Definition: input_helpers.h:63
Helper template used to easily access core services. Usage: static_api_ptr_t api; api->doso...
Definition: service.h:533
void input_helper::process_fullbuffer ( service_ptr_t< file > &  p_file,
const char *  p_path,
abort_callback p_abort 
)
private

Definition at line 24 of file input_helpers.cpp.

24  {
25  if (m_ioFilter != NULL) m_ioFilter(p_file, p_path, m_ioFilterArg, p_abort);
26 }
_input_helper_io_filter m_ioFilter
Definition: input_helpers.h:65
t_filesize m_ioFilterArg
Definition: input_helpers.h:66
bool input_helper::run ( audio_chunk p_chunk,
abort_callback p_abort 
)

Definition at line 115 of file input_helpers.cpp.

115  {
116  TRACK_CODE("input_decoder::run",return m_input->run(p_chunk,p_abort));
117 }
service_ptr_t< input_decoder > m_input
Definition: input_helpers.h:63
bool input_helper::run_raw ( audio_chunk p_chunk,
mem_block_container p_raw,
abort_callback p_abort 
)

Definition at line 109 of file input_helpers.cpp.

109  {
110  input_decoder_v2::ptr v2;
111  if (!m_input->service_query_t(v2)) throw pfc::exception_not_implemented();
112  return v2->run_raw(p_chunk, p_raw, p_abort);
113 }
service_ptr_t< input_decoder > m_input
Definition: input_helpers.h:63
void input_helper::seek ( double  seconds,
abort_callback p_abort 
)

Definition at line 119 of file input_helpers.cpp.

119  {
120  TRACK_CODE("input_decoder::seek",m_input->seek(seconds,p_abort));
121 }
service_ptr_t< input_decoder > m_input
Definition: input_helpers.h:63
void input_helper::set_block_buffer ( size_t  val)

Definition at line 132 of file input_helpers.cpp.

132  {
134  m_ioFilterArg = val;
135 }
_input_helper_io_filter m_ioFilter
Definition: input_helpers.h:65
t_filesize m_ioFilterArg
Definition: input_helpers.h:66
static void _input_helper_io_filter_blockbuffer(service_ptr_t< file > &p_file, const char *p_path, t_filesize arg, abort_callback &p_abort)
void input_helper::set_full_buffer ( t_filesize  val)

Definition at line 127 of file input_helpers.cpp.

127  {
129  m_ioFilterArg = val;
130 }
static void _input_helper_io_filter_fullbuffer(service_ptr_t< file > &p_file, const char *p_path, t_filesize arg, abort_callback &p_abort)
_input_helper_io_filter m_ioFilter
Definition: input_helpers.h:65
t_filesize m_ioFilterArg
Definition: input_helpers.h:66
void input_helper::set_logger ( event_logger::ptr  ptr)

Definition at line 104 of file input_helpers.cpp.

104  {
105  input_decoder_v2::ptr v2;
106  if (m_input->service_query_t(v2)) v2->set_logger(ptr);
107 }
service_ptr_t< input_decoder > m_input
Definition: input_helpers.h:63
void input_helper::set_pause ( bool  state)

Definition at line 93 of file input_helpers.cpp.

93  {
94  input_decoder_v3::ptr v3;
95  if (m_input->service_query_t(v3)) v3->set_pause(state);
96 }
service_ptr_t< input_decoder > m_input
Definition: input_helpers.h:63

Field Documentation

service_ptr_t<input_decoder> input_helper::m_input
private

Definition at line 63 of file input_helpers.h.

_input_helper_io_filter input_helper::m_ioFilter
private

Definition at line 65 of file input_helpers.h.

t_filesize input_helper::m_ioFilterArg
private

Definition at line 66 of file input_helpers.h.

pfc::string8 input_helper::m_path
private

Definition at line 64 of file input_helpers.h.


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