From fa90047e522b4a46b86c3b3f8733c5caabfaa77c Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 9 Nov 2016 11:30:17 +0100 Subject: [PATCH] output/haiku: migrate from class Error to C++ exceptions Beware, this commit was not tested. I don't have Haiku, but I want to prepare an API change. --- src/output/plugins/HaikuOutputPlugin.cxx | 51 +++++------------------- 1 file changed, 9 insertions(+), 42 deletions(-) diff --git a/src/output/plugins/HaikuOutputPlugin.cxx b/src/output/plugins/HaikuOutputPlugin.cxx index a7593a1e1..2a4b70dff 100644 --- a/src/output/plugins/HaikuOutputPlugin.cxx +++ b/src/output/plugins/HaikuOutputPlugin.cxx @@ -23,7 +23,6 @@ #include "../OutputAPI.hxx" #include "../Wrapper.hxx" #include "mixer/MixerList.hxx" -#include "util/Error.hxx" #include "util/Domain.hxx" #include "Log.hxx" @@ -65,13 +64,12 @@ class HaikuOutput { unsigned buffer_delay; public: - HaikuOutput() - :base(haiku_output_plugin) {} - ~HaikuOutput(); + HaikuOutput(const ConfigBlock &block) + :base(haiku_output_plugin, block), + /* XXX: by default we should let the MediaKit propose the buffer size */ + write_size(block.GetBlockValue("write_size", 4096u)) {} - bool Initialize(const ConfigBlock &block, Error &error) { - return base.Configure(block, error); - } + ~HaikuOutput(); static HaikuOutput *Create(const ConfigBlock &block, Error &error); @@ -84,8 +82,6 @@ public: size_t Play(const void *chunk, size_t size, Error &error); void Cancel(); - bool Configure(const ConfigBlock &block, Error &error); - size_t Delay(); void FillBuffer(void* _buffer, size_t size, @@ -100,13 +96,6 @@ private: static constexpr Domain haiku_output_domain("haiku_output"); -static void -haiku_output_error(Error &error_r, status_t err) -{ - const char *error = strerror(err); - error_r.Set(haiku_output_domain, err, error); -} - static void initialize_application() { @@ -128,15 +117,6 @@ finalize_application() FormatDebug(haiku_output_domain, "deleting be_app\n"); } -inline bool -HaikuOutput::Configure(const ConfigBlock &block, Error &) -{ - /* XXX: by default we should let the MediaKit propose the buffer size */ - write_size = block.GetBlockValue("write_size", 4096u); - - return true; -} - static bool haiku_test_default_device(void) { @@ -146,23 +126,11 @@ haiku_test_default_device(void) } inline HaikuOutput * -HaikuOutput::Create(const ConfigBlock &block, Error &error) +HaikuOutput::Create(const ConfigBlock &block, Error &) { initialize_application(); - HaikuOutput *ad = new HaikuOutput(); - - if (!ad->Initialize(block, error)) { - delete ad; - return nullptr; - } - - if (!ad->Configure(block, error)) { - delete ad; - return nullptr; - } - - return ad; + return new HaikuOutput(block); } void @@ -224,7 +192,7 @@ HaikuOutput::FillBuffer(void* _buffer, size_t size, } inline bool -HaikuOutput::Open(AudioFormat &audio_format, Error &error) +HaikuOutput::Open(AudioFormat &audio_format, Error &) { status_t err; format = media_multi_audio_format::wildcard; @@ -280,8 +248,7 @@ HaikuOutput::Open(AudioFormat &audio_format, Error &error) if (err != B_OK) { delete sound_player; sound_player = NULL; - haiku_output_error(error, err); - return false; + throw MakeErrno(err, "BSoundPlayer::InitCheck() failed"); } // calculate the allowable delay for the buffer (ms)