From 742bc3ffc34fe4b7e9738d5ad31b93e68aa3f25e Mon Sep 17 00:00:00 2001 From: David Ludwig Date: Sat, 17 Aug 2019 13:19:06 -0400 Subject: [PATCH] fix build errors when using 'null' backend --- include/audio_backend/__null_backend.h | 27 +++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/include/audio_backend/__null_backend.h b/include/audio_backend/__null_backend.h index 2f5530b..a03ca7b 100644 --- a/include/audio_backend/__null_backend.h +++ b/include/audio_backend/__null_backend.h @@ -11,6 +11,12 @@ _LIBSTDAUDIO_NAMESPACE_BEGIN +struct audio_device_exception : public runtime_error { + explicit audio_device_exception(const char* what) + : runtime_error(what) { + } +}; + class audio_device { public: audio_device() = delete; @@ -74,7 +80,22 @@ class audio_device { return false; } - bool start() { + template &>, int> = 0> + void connect(_CallbackType callback) + { + throw audio_device_exception("cannot connect to a null-backend audio_device"); + } + + // TODO: remove std::function as soon as C++20 default-ctable lambda and lambda in unevaluated contexts become available + using no_op_t = std::function; + + template && is_invocable_v<_StopCallbackType, audio_device&>>> + bool start(_StartCallbackType&& start_callback = [](audio_device&) noexcept {}, + _StopCallbackType&& stop_callback = [](audio_device&) noexcept {}) { return false; } @@ -138,4 +159,8 @@ audio_device_list get_audio_output_device_list() { return {}; } +template > */> +void set_audio_device_list_callback(audio_device_list_event event, F &&callback) { +} + _LIBSTDAUDIO_NAMESPACE_END \ No newline at end of file