OSSIA
Open Scenario System for Interactive Application
Loading...
Searching...
No Matches
audio_engine.hpp
1#pragma once
2#include <ossia/audio/audio_parameter.hpp>
3#include <ossia/audio/audio_tick.hpp>
4#include <ossia/detail/lockfree_queue.hpp>
5
6#include <smallfun.hpp>
7
8#include <atomic>
9
10#include <ossia-config.hpp>
11
12namespace ossia
13{
14class OSSIA_EXPORT audio_engine
15{
16public:
17 explicit audio_engine();
18 virtual ~audio_engine();
19
20 virtual bool running() const = 0;
21 virtual void wait(int milliseconds);
22 void stop();
23
24 void gc();
25 void sync();
26
27 using fun_type = smallfun::function<void(const ossia::audio_tick_state&), 256>;
28 void set_tick(fun_type&& t);
29 void load_audio_tick();
30
31 // From main thread to audio thread
32 ossia::spsc_queue<fun_type> tick_funlist;
33
34 // From audio thread to main thread
35 ossia::spsc_queue<fun_type> tick_gc;
36
37 fun_type audio_tick;
38
39 std::atomic_bool stop_processing{};
40 std::atomic_bool stop_received{};
41
42 int effective_sample_rate{};
43 int effective_buffer_size{};
44 int effective_inputs{};
45 int effective_outputs{};
46
47 void tick_start() { load_audio_tick(); }
48 void tick_clear() { stop_received = true; }
49 void tick_end() { }
50
51private:
52 std::shared_ptr<audio_engine> self;
53 std::atomic_int64_t request{-1};
54 std::atomic_int64_t reply{-1};
55};
56
57OSSIA_EXPORT
58ossia::audio_engine* make_audio_engine(
59 std::string proto, std::string name, std::string req_in, std::string req_out,
60 int& inputs, int& outputs, int& rate, int& bs);
61}
Definition git_info.h:7