Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion examples/melody.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include <cmath>
#include <array>
#include <atomic>
#include <thread>
#include <audio>

Expand Down Expand Up @@ -99,4 +100,4 @@ int main() {
while (!stop.load()) {
std::this_thread::sleep_for(std::chrono::milliseconds(50));
}
}
}
42 changes: 20 additions & 22 deletions include/audio_backend/__null_backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include <string_view>
#include <chrono>
#include <cassert>
#include <forward_list>
#include <functional>

_LIBSTDAUDIO_NAMESPACE_BEGIN

Expand Down Expand Up @@ -74,7 +76,14 @@ class audio_device {
return false;
}

bool start() {
using no_op_t = std::function<void(audio_device&)>;

template <typename _StartCallbackType = no_op_t,
typename _StopCallbackType = no_op_t,
// TODO: is_nothrow_invocable_t does not compile, temporarily replaced with is_invocable_t
typename = enable_if_t<is_invocable_v<_StartCallbackType, audio_device&> && is_invocable_v<_StopCallbackType, audio_device&>>>
bool start(_StartCallbackType&& start_callback = [](audio_device&) noexcept {},
_StopCallbackType&& stop_callback = [](audio_device&) noexcept {}) {
return false;
}

Expand All @@ -98,28 +107,13 @@ class audio_device {
constexpr bool has_unprocessed_io() const noexcept {
return false;
}
};

class audio_device_list
{
private:
class iterator {
public:
auto operator==(const iterator&) const noexcept { return true; }
auto operator!=(const iterator&) const noexcept { return false; }
auto operator++() -> const iterator& { assert(false); return *this; }
auto operator*() -> audio_device& {
assert(false); static audio_device device{};
return device;
}
};
template <typename _CallbackType>
void connect(_CallbackType callback) {
}
};

public:
auto begin() -> iterator { return {}; }
auto end() -> iterator { return {}; }
auto begin() const -> iterator { return {}; }
auto end() const -> iterator { return {}; }
auto empty() const -> bool { return true; }
class audio_device_list : public forward_list<audio_device> {
};

optional<audio_device> get_default_audio_input_device() {
Expand All @@ -138,4 +132,8 @@ audio_device_list get_audio_output_device_list() {
return {};
}

_LIBSTDAUDIO_NAMESPACE_END
template <typename F, typename /* = enable_if_t<is_nothrow_invocable_v<F>> */ >
void set_audio_device_list_callback(audio_device_list_event event, F&& cb) {
}

_LIBSTDAUDIO_NAMESPACE_END