foobar2000 SDK  2015-01-14
Functions
playlist_loader.cpp File Reference

Go to the source code of this file.

Functions

static void index_tracks_helper (const char *p_path, const service_ptr_t< file > &p_reader, const t_filestats &p_stats, playlist_loader_callback::t_entry_type p_type, playlist_loader_callback::ptr p_callback, abort_callback &p_abort, bool &p_got_input)
 
static void process_path_internal (const char *p_path, const service_ptr_t< file > &p_reader, playlist_loader_callback::ptr callback, abort_callback &abort, playlist_loader_callback::t_entry_type type, const t_filestats &p_stats)
 
static void track_indexer__g_get_tracks_wrap (const char *p_path, const service_ptr_t< file > &p_reader, const t_filestats &p_stats, playlist_loader_callback::t_entry_type p_type, playlist_loader_callback::ptr p_callback, abort_callback &p_abort)
 

Function Documentation

static void index_tracks_helper ( const char *  p_path,
const service_ptr_t< file > &  p_reader,
const t_filestats &  p_stats,
playlist_loader_callback::t_entry_type  p_type,
playlist_loader_callback::ptr  p_callback,
abort_callback p_abort,
bool &  p_got_input 
)
static

Definition at line 88 of file playlist_loader.cpp.

89 {
90  TRACK_CALL_TEXT("index_tracks_helper");
91  if (p_reader.is_empty() && filesystem::g_is_remote_safe(p_path))
92  {
93  TRACK_CALL_TEXT("remote");
94  metadb_handle_ptr handle;
95  p_callback->handle_create(handle,make_playable_location(p_path,0));
96  p_got_input = true;
97  p_callback->on_entry(handle,p_type,p_stats,true);
98  } else {
99  TRACK_CALL_TEXT("hintable");
101  input_entry::g_open_for_info_read(instance,p_reader,p_path,p_abort);
102 
103  t_filestats stats = instance->get_file_stats(p_abort);
104 
105  t_uint32 subsong,subsong_count = instance->get_subsong_count();
106  bool bInfoGetError = false;
107  for(subsong=0;subsong<subsong_count;subsong++)
108  {
109  TRACK_CALL_TEXT("subsong-loop");
110  p_abort.check();
111  metadb_handle_ptr handle;
112  t_uint32 index = instance->get_subsong(subsong);
113  p_callback->handle_create(handle,make_playable_location(p_path,index));
114 
115  p_got_input = true;
116  if (! bInfoGetError && p_callback->want_info(handle,p_type,stats,true) )
117  {
119  try {
120  TRACK_CODE("get_info",instance->get_info(index,info,p_abort));
121  } catch(...) {
122  bInfoGetError = true;
123  }
124  p_callback->on_entry_info(handle,p_type,stats,info,true);
125  }
126  else
127  {
128  p_callback->on_entry(handle,p_type,stats,true);
129  }
130  }
131  }
132 }
bool is_empty() const
Definition: service.h:120
void info(const char *p_message)
Definition: console.cpp:4
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
Implements file_info.
uint32_t t_uint32
Definition: int_types.h:5
static void process_path_internal ( const char *  p_path,
const service_ptr_t< file > &  p_reader,
playlist_loader_callback::ptr  callback,
abort_callback abort,
playlist_loader_callback::t_entry_type  type,
const t_filestats &  p_stats 
)
static

Definition at line 198 of file playlist_loader.cpp.

199 {
200  //p_path must be canonical
201 
202  abort.check();
203 
204  callback->on_progress(p_path);
205 
206 
207  {
208  if (p_reader.is_empty() && type != playlist_loader_callback::entry_directory_enumerated) {
209  directory_callback_impl2 directory_results(true);
210  try {
211  filesystem::g_list_directory(p_path,directory_results,abort);
212  for(t_size n=0;n<directory_results.get_count();n++) {
213  process_path_internal(directory_results.get_item(n),0,callback,abort,playlist_loader_callback::entry_directory_enumerated,directory_results.get_item_stats(n));
214  }
215  return;
216  } catch(exception_aborted) {throw;}
217  catch(...) {
218  //do nothing, fall thru
219  //fixme - catch only filesystem exceptions?
220  }
221  }
222 
223  bool found = false;
224 
225 
226  {
227  archive_callback_impl archive_results(callback, abort);
230  while(e.next(f)) {
231  abort.check();
233  if (f->service_query_t(arch)) {
234  if (p_reader.is_valid()) p_reader->reopen(abort);
235 
236  try {
237  TRACK_CODE("archive::archive_list",arch->archive_list(p_path,p_reader,archive_results,true));
238  return;
239  } catch(exception_aborted) {throw;}
240  catch(...) {}
241  }
242  }
243  }
244  }
245 
246 
247 
248  {
250  if (link_resolver::g_find(ptr,p_path))
251  {
252  if (p_reader.is_valid()) p_reader->reopen(abort);
253 
254  pfc::string8 temp;
255  try {
256  TRACK_CODE("link_resolver::resolve",ptr->resolve(p_reader,p_path,temp,abort));
257 
258  track_indexer__g_get_tracks_wrap(temp,0,filestats_invalid,playlist_loader_callback::entry_from_playlist,callback, abort);
259  return;//success
260  } catch(exception_aborted) {throw;}
261  catch(...) {}
262  }
263  }
264 
265  if (callback->is_path_wanted(p_path,type)) {
266  track_indexer__g_get_tracks_wrap(p_path,p_reader,p_stats,type,callback, abort);
267  }
268 }
bool is_empty() const
Definition: service.h:120
static const t_filestats filestats_invalid
Invalid/unknown file stats constant. See: t_filestats.
Definition: filesystem.h:75
bool is_valid() const
Definition: service.h:119
size_t t_size
Definition: int_types.h:48
static void process_path_internal(const char *p_path, const service_ptr_t< file > &p_reader, playlist_loader_callback::ptr callback, abort_callback &abort, playlist_loader_callback::t_entry_type type, const t_filestats &p_stats)
Autopointer class to be used with all services. Manages reference counter calls behind-the-scenes.
Definition: service.h:55
static void track_indexer__g_get_tracks_wrap(const char *p_path, const service_ptr_t< file > &p_reader, const t_filestats &p_stats, playlist_loader_callback::t_entry_type p_type, playlist_loader_callback::ptr p_callback, abort_callback &p_abort)
bool next(service_ptr_t< t_query > &p_out)
Definition: service.h:587
static void track_indexer__g_get_tracks_wrap ( const char *  p_path,
const service_ptr_t< file > &  p_reader,
const t_filestats &  p_stats,
playlist_loader_callback::t_entry_type  p_type,
playlist_loader_callback::ptr  p_callback,
abort_callback p_abort 
)
static

Definition at line 134 of file playlist_loader.cpp.

134  {
135  bool got_input = false;
136  bool fail = false;
137  try {
138  index_tracks_helper(p_path,p_reader,p_stats,p_type,p_callback,p_abort, got_input);
139  } catch(exception_aborted) {
140  throw;
141  } catch(exception_io_unsupported_format) {
142  fail = true;
143  } catch(std::exception const & e) {
144  fail = true;
145  console::formatter() << "could not enumerate tracks (" << e << ") on:\n" << file_path_display(p_path);
146  }
147  if (fail) {
148  if (!got_input && !p_abort.is_aborting()) {
149  if (p_type == playlist_loader_callback::entry_user_requested)
150  {
151  metadb_handle_ptr handle;
152  p_callback->handle_create(handle,make_playable_location(p_path,0));
153  p_callback->on_entry(handle,p_type,p_stats,true);
154  }
155  }
156  }
157 }
Usage: console::formatter() << "blah " << somenumber << " asdf" << somestring;.
Definition: console.h:17
static void fail(completion_notify_ptr p_notify)
static void index_tracks_helper(const char *p_path, const service_ptr_t< file > &p_reader, const t_filestats &p_stats, playlist_loader_callback::t_entry_type p_type, playlist_loader_callback::ptr p_callback, abort_callback &p_abort, bool &p_got_input)
std::exception exception
Definition: primitives.h:193