summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorkleines Filmröllchen <filmroellchen@serenityos.org>2022-01-14 12:32:42 +0100
committerAndreas Kling <kling@serenityos.org>2022-01-14 21:37:23 +0100
commit54ac4ba8cc2b2a27620b0bd13c556ede7257c12d (patch)
treebea3a9041dede7250fcb7cc269babdb9caa966e5 /Userland
parentdc89ac1463c8693c1493c5472c33568b81950a66 (diff)
downloadserenity-54ac4ba8cc2b2a27620b0bd13c556ede7257c12d.zip
LibAudio: Expose the format name from the loader plugins
The format of these names is "Full Abbreviation (.fileformat)". For example: "FLAC (.flac)", "RIFF WAVE (.wav)", "MPEG Layer III (.mp3)", "Vorbis (.ogg)" The reasoning is that the container and therefore the file ending may differ significantly from the actual format, and the format should be given as unambiguously as possible and necessary.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibAudio/FlacLoader.h1
-rw-r--r--Userland/Libraries/LibAudio/Loader.h3
-rw-r--r--Userland/Libraries/LibAudio/WavLoader.h1
3 files changed, 5 insertions, 0 deletions
diff --git a/Userland/Libraries/LibAudio/FlacLoader.h b/Userland/Libraries/LibAudio/FlacLoader.h
index ed4f65cd4c..4ea284f831 100644
--- a/Userland/Libraries/LibAudio/FlacLoader.h
+++ b/Userland/Libraries/LibAudio/FlacLoader.h
@@ -100,6 +100,7 @@ public:
virtual int total_samples() override { return static_cast<int>(m_total_samples); }
virtual u32 sample_rate() override { return m_sample_rate; }
virtual u16 num_channels() override { return m_num_channels; }
+ virtual String format_name() override { return "FLAC (.flac)"; }
virtual PcmSampleFormat pcm_format() override { return m_sample_format; }
virtual RefPtr<Core::File> file() override { return m_file; }
diff --git a/Userland/Libraries/LibAudio/Loader.h b/Userland/Libraries/LibAudio/Loader.h
index 596dd5d08c..30efc60088 100644
--- a/Userland/Libraries/LibAudio/Loader.h
+++ b/Userland/Libraries/LibAudio/Loader.h
@@ -50,6 +50,8 @@ public:
virtual u32 sample_rate() = 0;
virtual u16 num_channels() = 0;
+ // Human-readable name of the file format, of the form <full abbreviation> (.<ending>)
+ virtual String format_name() = 0;
virtual PcmSampleFormat pcm_format() = 0;
virtual RefPtr<Core::File> file() = 0;
};
@@ -68,6 +70,7 @@ public:
int total_samples() const { return m_plugin->total_samples(); }
u32 sample_rate() const { return m_plugin->sample_rate(); }
u16 num_channels() const { return m_plugin->num_channels(); }
+ String format_name() const { return m_plugin->format_name(); }
u16 bits_per_sample() const { return pcm_bits_per_sample(m_plugin->pcm_format()); }
RefPtr<Core::File> file() const { return m_plugin->file(); }
diff --git a/Userland/Libraries/LibAudio/WavLoader.h b/Userland/Libraries/LibAudio/WavLoader.h
index 39b045a4c3..40d7f098ca 100644
--- a/Userland/Libraries/LibAudio/WavLoader.h
+++ b/Userland/Libraries/LibAudio/WavLoader.h
@@ -52,6 +52,7 @@ public:
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; }
+ virtual String format_name() override { return "RIFF WAVE (.wav)"; }
virtual PcmSampleFormat pcm_format() override { return m_sample_format; }
virtual RefPtr<Core::File> file() override { return m_file; }