summaryrefslogtreecommitdiff
path: root/Libraries
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-09-04 20:13:32 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-09-04 20:13:32 +0200
commit6693e56603888fcfe29a669acc24bd21079f33d2 (patch)
treeecaee70be031c47ea7fd9d1d50f330fc62418cb8 /Libraries
parenta98de0b6eea3e5671ad767a6b6f434232f1b7a17 (diff)
downloadserenity-6693e56603888fcfe29a669acc24bd21079f33d2.zip
LibAudio: Allow tweaking how much get_more_samples() reads from file
Diffstat (limited to 'Libraries')
-rw-r--r--Libraries/LibAudio/AWavLoader.cpp4
-rw-r--r--Libraries/LibAudio/AWavLoader.h5
2 files changed, 5 insertions, 4 deletions
diff --git a/Libraries/LibAudio/AWavLoader.cpp b/Libraries/LibAudio/AWavLoader.cpp
index f1a1fe5553..f241cfe134 100644
--- a/Libraries/LibAudio/AWavLoader.cpp
+++ b/Libraries/LibAudio/AWavLoader.cpp
@@ -16,13 +16,13 @@ AWavLoader::AWavLoader(const StringView& path)
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
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
- 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())
return nullptr;
diff --git a/Libraries/LibAudio/AWavLoader.h b/Libraries/LibAudio/AWavLoader.h
index 43d24657fe..0734774e73 100644
--- a/Libraries/LibAudio/AWavLoader.h
+++ b/Libraries/LibAudio/AWavLoader.h
@@ -15,10 +15,11 @@ class ByteBuffer;
class AWavLoader {
public:
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(); }
- 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 total_samples() const { return m_total_samples; }