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