foobar2000 SDK  2015-08-03
input_helpers.h
Go to the documentation of this file.
1 #ifndef _INPUT_HELPERS_H_
2 #define _INPUT_HELPERS_H_
3 
4 typedef void (* _input_helper_io_filter)(service_ptr_t<file> & p_file,const char * p_path, t_filesize arg,abort_callback & p_abort);
5 
6 class input_helper {
7 public:
8  input_helper();
9 
10  struct decodeOpen_t {
12  event_logger::ptr m_logger;
15  unsigned m_flags;
16  file::ptr m_hint;
17  };
18 
19  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);
20  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);
21 
22  void open(const playable_location & location, abort_callback & abort, decodeOpen_t const & other);
23  void open(metadb_handle_ptr location, abort_callback & abort, decodeOpen_t const & other) {this->open(location->get_location(), abort, other);}
24 
25 
28  bool open_path(file::ptr p_filehint,const char * path,abort_callback & p_abort,bool p_from_redirect,bool p_skip_hints);
30  void open_decoding(t_uint32 subsong, t_uint32 flags, abort_callback & p_abort);
31 
32  bool need_file_reopen(const char * newPath) const;
33 
34  void close();
35  bool is_open();
36  bool run(audio_chunk & p_chunk,abort_callback & p_abort);
37  bool run_raw(audio_chunk & p_chunk, mem_block_container & p_raw, abort_callback & p_abort);
38  void seek(double seconds,abort_callback & p_abort);
39  bool can_seek();
40  void set_full_buffer(t_filesize val);
41  void set_block_buffer(size_t val);
42  void on_idle(abort_callback & p_abort);
43  bool get_dynamic_info(file_info & p_out,double & p_timestamp_delta);
44  bool get_dynamic_info_track(file_info & p_out,double & p_timestamp_delta);
45  void set_logger(event_logger::ptr ptr);
46  void set_pause(bool state);
47  bool flush_on_pause();
48 
50  const char * get_path() const;
51 
53  void get_info(t_uint32 p_subsong,file_info & p_info,abort_callback & p_abort);
54 
55  static void g_get_info(const playable_location & p_location,file_info & p_info,abort_callback & p_abort,bool p_from_redirect = false);
56  static void g_set_info(const playable_location & p_location,file_info & p_info,abort_callback & p_abort,bool p_from_redirect = false);
57 
58 
59  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);
60 
61 private:
62  void process_fullbuffer(service_ptr_t<file> & p_file,const char * p_path,abort_callback & p_abort);
67 };
68 
69 class NOVTABLE dead_item_filter : public abort_callback {
70 public:
71  virtual void on_progress(t_size p_position,t_size p_total) = 0;
72 
73  bool run(const pfc::list_base_const_t<metadb_handle_ptr> & p_list,bit_array_var & p_mask);
74 };
75 
77 public:
79  void get_info(const playable_location & p_location,file_info & p_info,t_filestats & p_stats,abort_callback & p_abort);
80  void get_info_check(const playable_location & p_location,file_info & p_info,t_filestats & p_stats,bool & p_reloaded,abort_callback & p_abort);
81 private:
82  void open(const char * p_path,abort_callback & p_abort);
83 
86 };
87 
88 
89 
91 public:
92  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);
93 
94  void close();
95  bool is_open();
96  bool run(audio_chunk & p_chunk,abort_callback & p_abort);
97  bool run_raw(audio_chunk & p_chunk, mem_block_container & p_raw, abort_callback & p_abort);
98  void seek(double seconds,abort_callback & p_abort);
99  bool can_seek();
100  void set_full_buffer(t_filesize val);
101  void on_idle(abort_callback & p_abort);
102  bool get_dynamic_info(file_info & p_out,double & p_timestamp_delta);
103  bool get_dynamic_info_track(file_info & p_out,double & p_timestamp_delta);
104  void set_logger(event_logger::ptr ptr) {m_input.set_logger(ptr);}
105 
106  const char * get_path() const;
107 
108  void get_info(t_uint32 p_subsong,file_info & p_info,abort_callback & p_abort);
109 
110 private:
111  bool _run(audio_chunk & p_chunk, mem_block_container * p_raw, abort_callback & p_abort);
112  bool _m_input_run(audio_chunk & p_chunk, mem_block_container * p_raw, abort_callback & p_abort);
114  double m_start,m_length,m_position;
115  bool m_dynamic_info_trigger,m_dynamic_info_track_trigger;
116 };
117 
120  file::ptr audioData; // audio data stream
121  audio_chunk::spec_t audioSpec; // format description (sample rate, channel layout).
122 };
123 
131 openAudioData_t openAudioData(playable_location const & loc, bool bSeekable, file::ptr fileHint, abort_callback & aborter);
132 
133 #endif
openAudioData_t openAudioData(playable_location const &loc, bool bSeekable, file::ptr fileHint, abort_callback &aborter)
Opens the specified location as a stream of audio_samples. Returns a file object that allows you to ...
void(* _input_helper_io_filter)(service_ptr_t< file > &p_file, const char *p_path, t_filesize arg, abort_callback &p_abort)
Definition: input_helpers.h:4
static void g_get_info(const playable_location &p_location, file_info &p_info, abort_callback &p_abort, bool p_from_redirect=false)
static void g_set_info(const playable_location &p_location, file_info &p_info, abort_callback &p_abort, bool p_from_redirect=false)
bool need_file_reopen(const char *newPath) const
void set_pause(bool state)
pfc::string8 m_path
Definition: input_helpers.h:64
Interface to container of a chunk of audio data. See audio_chunk_impl for an implementation.
Definition: audio_chunk.h:5
bool run(audio_chunk &p_chunk, abort_callback &p_abort)
void set_block_buffer(size_t val)
service_ptr_t< input_info_reader > m_input
Definition: input_helpers.h:85
bool flush_on_pause()
_input_helper_io_filter m_ioFilter
Definition: input_helpers.h:65
Main interface class for information about some playable object.
Definition: file_info.h:73
file::ptr audioData
bool get_dynamic_info_track(file_info &p_out, double &p_timestamp_delta)
bool run_raw(audio_chunk &p_chunk, mem_block_container &p_raw, abort_callback &p_abort)
event_logger::ptr m_logger
Definition: input_helpers.h:12
size_t t_size
Definition: int_types.h:48
void process_fullbuffer(service_ptr_t< file > &p_file, const char *p_path, 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)
t_filesize m_ioFilterArg
Definition: input_helpers.h:66
Bit array interface class, variable version (you can both set and retrieve values). As with the constant version, valid index range depends on the context.
Definition: bit_array.h:40
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 seek(double seconds, abort_callback &p_abort)
void set_logger(event_logger::ptr ptr)
bool get_dynamic_info(file_info &p_out, double &p_timestamp_delta)
t_uint64 t_filesize
Type used for file size related variables.
Definition: filesystem.h:8
const char * get_path() const
Retrieves path of currently open file.
void get_info(t_uint32 p_subsong, file_info &p_info, abort_callback &p_abort)
Retrieves info about specific subsong of currently open file.
openAudioData return value, see openAudioData()
void set_logger(event_logger::ptr ptr)
void on_idle(abort_callback &p_abort)
Generic interface for a memory block; used by various other interfaces to return memory blocks while ...
service_ptr_t< input_decoder > m_input
Definition: input_helpers.h:63
void open_decoding(t_uint32 subsong, t_uint32 flags, abort_callback &p_abort)
Multilevel open helpers.
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)
audio_chunk::spec_t audioSpec
void set_full_buffer(t_filesize val)
void open(metadb_handle_ptr location, abort_callback &abort, decodeOpen_t const &other)
Definition: input_helpers.h:23
input_helper m_input
uint32_t t_uint32
Definition: int_types.h:5