mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:07:46 +00:00
LibAudio: Allow tweaking how much get_more_samples() reads from file
This commit is contained in:
parent
a98de0b6ee
commit
6693e56603
2 changed files with 5 additions and 4 deletions
|
@ -16,13 +16,13 @@ AWavLoader::AWavLoader(const StringView& path)
|
||||||
parse_header();
|
parse_header();
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<ABuffer> AWavLoader::get_more_samples()
|
RefPtr<ABuffer> AWavLoader::get_more_samples(size_t max_bytes_to_read_from_input)
|
||||||
{
|
{
|
||||||
#ifdef AWAVLOADER_DEBUG
|
#ifdef AWAVLOADER_DEBUG
|
||||||
dbgprintf("Read WAV of format PCM with num_channels %u sample rate %u, bits per sample %u\n", m_num_channels, m_sample_rate, m_bits_per_sample);
|
dbgprintf("Read WAV of format PCM with num_channels %u sample rate %u, bits per sample %u\n", m_num_channels, m_sample_rate, m_bits_per_sample);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto raw_samples = m_file.read(128 * KB);
|
auto raw_samples = m_file.read(max_bytes_to_read_from_input);
|
||||||
if (raw_samples.is_empty())
|
if (raw_samples.is_empty())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
|
|
@ -15,10 +15,11 @@ class ByteBuffer;
|
||||||
class AWavLoader {
|
class AWavLoader {
|
||||||
public:
|
public:
|
||||||
explicit AWavLoader(const StringView& path);
|
explicit AWavLoader(const StringView& path);
|
||||||
RefPtr<ABuffer> load_wav(const StringView& path);
|
|
||||||
|
bool has_error() const { return !m_error_string.is_null(); }
|
||||||
const char* error_string() { return m_error_string.characters(); }
|
const char* error_string() { return m_error_string.characters(); }
|
||||||
|
|
||||||
RefPtr<ABuffer> get_more_samples();
|
RefPtr<ABuffer> get_more_samples(size_t max_bytes_to_read_from_input = 128 * KB);
|
||||||
|
|
||||||
int loaded_samples() const { return m_loaded_samples; }
|
int loaded_samples() const { return m_loaded_samples; }
|
||||||
int total_samples() const { return m_total_samples; }
|
int total_samples() const { return m_total_samples; }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue