summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibAudio/Loader.h
diff options
context:
space:
mode:
authorkleines Filmröllchen <malu.bertsch@gmail.com>2021-06-24 23:56:28 +0200
committerAli Mohammad Pur <Ali.mpfard@gmail.com>2021-06-25 20:48:14 +0430
commit488de12ed406faf90481e477eb7121218359d2fe (patch)
treed10bb846b28bafad1cef94aebc82b0dab469d139 /Userland/Libraries/LibAudio/Loader.h
parentd599a14545ffda1fa538efcb9fed67c8e569bc58 (diff)
downloadserenity-488de12ed406faf90481e477eb7121218359d2fe.zip
LibAudio: Make LoaderPlugin::error_string return String&
Previously, error_string() returned char* which is bad Serenity style and caused issues when other error handling methods were tried. As both WavLoader and (future) FLAC loader store a String internally for the error message, it makes sense to return a String reference instead.
Diffstat (limited to 'Userland/Libraries/LibAudio/Loader.h')
-rw-r--r--Userland/Libraries/LibAudio/Loader.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/Userland/Libraries/LibAudio/Loader.h b/Userland/Libraries/LibAudio/Loader.h
index 5075b0062a..a4bad829c1 100644
--- a/Userland/Libraries/LibAudio/Loader.h
+++ b/Userland/Libraries/LibAudio/Loader.h
@@ -15,6 +15,9 @@
namespace Audio {
+static const String empty_string = "";
+static String no_plugin_error = "No loader plugin available";
+
class LoaderPlugin {
public:
virtual ~LoaderPlugin() { }
@@ -22,7 +25,7 @@ public:
virtual bool sniff() = 0;
virtual bool has_error() { return false; }
- virtual const char* error_string() { return ""; }
+ virtual const String& error_string() { return empty_string; }
virtual RefPtr<Buffer> get_more_samples(size_t max_bytes_to_read_from_input = 128 * KiB) = 0;
@@ -52,7 +55,7 @@ public:
static NonnullRefPtr<Loader> create(const ByteBuffer& buffer) { return adopt_ref(*new Loader(buffer)); }
bool has_error() const { return m_plugin ? m_plugin->has_error() : true; }
- const char* error_string() const { return m_plugin ? m_plugin->error_string() : "No loader plugin available"; }
+ const String& error_string() const { return m_plugin ? m_plugin->error_string() : no_plugin_error; }
RefPtr<Buffer> get_more_samples(size_t max_bytes_to_read_from_input = 128 * KiB) const { return m_plugin ? m_plugin->get_more_samples(max_bytes_to_read_from_input) : nullptr; }