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

Go to the source code of this file.

Functions

static void _input_helper_io_filter_blockbuffer (service_ptr_t< file > &p_file, const char *p_path, t_filesize arg, abort_callback &p_abort)
 
static void _input_helper_io_filter_fullbuffer (service_ptr_t< file > &p_file, const char *p_path, t_filesize arg, abort_callback &p_abort)
 
openAudioData_t openAudioData (playable_location const &loc, bool bSeekable, file::ptr fileHint, abort_callback &aborter)
 

Function Documentation

static void _input_helper_io_filter_blockbuffer ( service_ptr_t< file > &  p_file,
const char *  p_path,
t_filesize  arg,
abort_callback p_abort 
)
static

Definition at line 10 of file input_helpers.cpp.

10  {
11  if (arg > 0 && !filesystem::g_is_remote_or_unrecognized(p_path)) {
12  if (p_file.is_empty()) filesystem::g_open_read( p_file, p_path, p_abort );
13  if (!p_file->is_in_memory() && !p_file->is_remote() && p_file->can_seek()) {
14  file_cached::g_create( p_file, p_file, p_abort, (size_t) arg );
15  }
16  }
17 }
bool is_empty() const
Definition: service.h:120
static void _input_helper_io_filter_fullbuffer ( service_ptr_t< file > &  p_file,
const char *  p_path,
t_filesize  arg,
abort_callback p_abort 
)
static

Definition at line 3 of file input_helpers.cpp.

3  {
4  if (arg > 0 && !filesystem::g_is_remote_or_unrecognized(p_path)) {
6  p_file = a.open(p_path, p_abort, p_file, arg);
7  }
8 }
file::ptr open(const char *path, abort_callback &abort, file::ptr hint, t_filesize sizeMax=1024 *1024 *256)
Definition: fullFileBuffer.h:9
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 read the audio data stream as if it was a physical file, together with audio stream format description (sample rate, channel layout).
Please keep in mind that certain features of the returned file object are only as reliable as the underlying file format or decoder implementation allows them to be.
Reported exact file size may be either unavailable or unreliable if the file format does not let us known the exact value without decoding the whole file.
Seeking may be inaccurate with certain file formats.
In general, all file object methods will work as intended on core-supported file formats such as FLAC or WavPack.
However, if you want 100% functionality regardless of file format being worked with, mirror the content to a temp file and let go of the file object returned by openAudioData().

Definition at line 591 of file input_helpers.cpp.

591  {
593  f->init(loc, bSeekable, fileHint, aborter);
594 
595  openAudioData_t oad = {};
596  oad.audioData = f;
597  oad.audioSpec = f->get_spec();
598  return oad;
599 }
Template implementing reference-counting features of service_base. Intended for dynamic instantiation...
Definition: service_impl.h:4
file::ptr audioData
Autopointer class to be used with all services. Manages reference counter calls behind-the-scenes.
Definition: service.h:55
openAudioData return value, see openAudioData()
audio_chunk::spec_t audioSpec