Anklang-0.3.0.dev797+g4e3241f3 anklang-0.3.0.dev797+g4e3241f3
ASE — Anklang Sound Engine (C++)

« « « Anklang Documentation
Loading...
Searching...
No Matches
server.hh
Go to the documentation of this file.
1 // This Source Code Form is licensed MPL-2.0: http://mozilla.org/MPL/2.0
2#pragma once
3
4#include <ase/gadget.hh>
5#include <ase/memory.hh>
6
7namespace Ase {
8
9class ServerImpl : public GadgetImpl, public virtual Server {
10 FastMemory::Arena telemetry_arena;
11public:
12 static ServerImplP instancep ();
13 explicit ServerImpl ();
14 virtual ~ServerImpl ();
15 bool set_data (const String &key, const Value &v) override;
16 Value get_data (const String &key) const override;
17 String get_version () override;
18 String get_build_id () override;
19 String get_opus_version () override;
20 String get_flac_version () override;
21 String get_sndfile_version () override;
22 String error_blurb (Error error) const override;
23 String musical_tuning_label (MusicalTuning musicaltuning) const override;
24 String musical_tuning_blurb (MusicalTuning musicaltuning) const override;
25 uint64 user_note (const String &text, const String &channel = "misc", UserNote::Flags flags = UserNote::TRANSIENT, const String &rest = "") override;
26 bool user_reply (uint64 noteid, uint r) override;
27 bool broadcast_telemetry (const TelemetrySegmentS &plan, int32 interval_ms) override;
28 void shutdown () override;
29 ProjectP last_project () override;
30 ProjectP create_project (String projectname) override;
31 PropertyP access_preference (const String &ident) override;
32 StringS list_preferences () override;
34 Block telemem_allocate (uint32 length) const;
35 void telemem_release (Block telememblock) const;
36 ptrdiff_t telemem_start () const;
37};
38extern ServerImpl *SERVER;
39
40// static constexpr const char* telemetry_type (const int64 &field) { return "i64"; }
41static constexpr const char* telemetry_type (const int8 &field) { return "i8"; }
42static constexpr const char* telemetry_type (const int32 &field) { return "i32"; }
43static constexpr const char* telemetry_type (const float &field) { return "f32"; }
44static constexpr const char* telemetry_type (const double &field) { return "f64"; }
45
46template<class T> inline TelemetryField
47telemetry_field (const String &name, const T *field)
48{
49 auto start = ServerImpl::instancep()->telemem_start();
50 const ptrdiff_t offset = ptrdiff_t (field) - start;
51 ASE_ASSERT_RETURN (offset >= 0 && offset < 2147483647, {}); // INT_MAX
52 TelemetryField tfield { name, telemetry_type (*field), int32 (offset), sizeof (*field) };
53 return tfield;
54}
55
56} // Ase
Base type for classes that have a Property.
Definition gadget.hh:12
String get_flac_version() override
Retrieve FLAC handler version.
Definition server.cc:69
String get_build_id() override
Retrieve ASE build id.
Definition server.cc:57
Value get_data(const String &key) const override
Retrieve session data.
Definition server.cc:134
ProjectP last_project() override
Retrieve the last created project.
Definition server.cc:88
PropertyP access_preference(const String &ident) override
Retrieve property handle for a Preference identifier.
Definition server.cc:107
StringS list_preferences() override
Retrieve a list of all preference identifiers.
Definition server.cc:100
ProjectP create_project(String projectname) override
Create a new project (name is modified to be unique if necessary.
Definition server.cc:94
String get_version() override
Retrieve ASE version.
Definition server.cc:51
void shutdown() override
Shutdown ASE.
Definition server.cc:81
String get_sndfile_version() override
Retrieve libsndfile support version.
Definition server.cc:75
bool broadcast_telemetry(const TelemetrySegmentS &plan, int32 interval_ms) override
Broadcast telemetry memory segments to the current Jsonipc connection.
Definition server.cc:474
String get_opus_version() override
Retrieve Opus handler version.
Definition server.cc:63
bool set_data(const String &key, const Value &v) override
Assign session data, prefix ephemerals with '_'.
Definition server.cc:120
Central singleton, serves as API entry point.
Definition api.hh:392
#define ASE_ASSERT_RETURN(expr,...)
Return from the current function if expr evaluates to false and issue an assertion warning.
Definition cxxaux.hh:82
The Anklang C++ API namespace.
Definition api.hh:9
uint64_t uint64
A 64-bit unsigned integer, use PRI*64 in format strings.
Definition cxxaux.hh:25
int32_t int32
A 32-bit signed integer.
Definition cxxaux.hh:28
int8_t int8
An 8-bit signed integer.
Definition cxxaux.hh:26
Error
Enum representing Error states.
Definition api.hh:22
std::string String
Convenience alias for std::string.
Definition cxxaux.hh:35
uint32_t uint32
A 32-bit unsigned integer.
Definition cxxaux.hh:24
uint32_t uint
Provide 'uint' as convenience type.
Definition cxxaux.hh:18
MusicalTuning
Musical tunings, see: http://en.wikipedia.org/wiki/Musical_tuning.
Definition api.hh:83
Memory area (over-)aligned to cache size and utilizing huge pages.
Definition memory.hh:100
Reference for an allocated memory block.
Definition memory.hh:90
Value type used to interface with various property types.
Definition value.hh:54