summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibAudio
diff options
context:
space:
mode:
authorKarol Kosek <krkk@krkk.ct8.pl>2021-07-22 15:41:18 +0200
committerAndreas Kling <kling@serenityos.org>2021-07-22 22:57:05 +0200
commit8c2be4b3dc31d0e900cc16631b381217cf093c22 (patch)
tree61720a666c878623a97065866c89a80d1369484f /Userland/Libraries/LibAudio
parent01e1e2c2c5f8eceb322682a7122796e4e86d5bc6 (diff)
downloadserenity-8c2be4b3dc31d0e900cc16631b381217cf093c22.zip
LibAudio: Implement loaded_samples() in the FLAC Loader
This makes aplay show current playback position.
Diffstat (limited to 'Userland/Libraries/LibAudio')
-rw-r--r--Userland/Libraries/LibAudio/FlacLoader.cpp1
-rw-r--r--Userland/Libraries/LibAudio/FlacLoader.h4
2 files changed, 3 insertions, 2 deletions
diff --git a/Userland/Libraries/LibAudio/FlacLoader.cpp b/Userland/Libraries/LibAudio/FlacLoader.cpp
index 2cb2898111..08e32ba7ad 100644
--- a/Userland/Libraries/LibAudio/FlacLoader.cpp
+++ b/Userland/Libraries/LibAudio/FlacLoader.cpp
@@ -235,6 +235,7 @@ RefPtr<Buffer> FlacLoaderPlugin::get_more_samples([[maybe_unused]] size_t max_by
--samples_to_read;
}
+ m_loaded_samples += samples.size();
return Buffer::create_with_samples(move(samples));
}
diff --git a/Userland/Libraries/LibAudio/FlacLoader.h b/Userland/Libraries/LibAudio/FlacLoader.h
index 693146c5c7..0b75ff5dfd 100644
--- a/Userland/Libraries/LibAudio/FlacLoader.h
+++ b/Userland/Libraries/LibAudio/FlacLoader.h
@@ -67,8 +67,7 @@ public:
virtual void reset() override;
virtual void seek(const int position) override;
- // FIXME
- virtual int loaded_samples() override { return 0; }
+ virtual int loaded_samples() override { return m_loaded_samples; }
virtual int total_samples() override { return m_total_samples; }
virtual u32 sample_rate() override { return m_sample_rate; }
virtual u16 num_channels() override { return m_num_channels; }
@@ -119,6 +118,7 @@ private:
u32 m_max_frame_size { 0 }; // 24 bit
u64 m_total_samples { 0 }; // 36 bit
u8 m_md5_checksum[128 / 8]; // 128 bit (!)
+ size_t m_loaded_samples { 0 };
// keep track of the start of the data in the FLAC stream to seek back more easily
u64 m_data_start_location { 0 };