summaryrefslogtreecommitdiff
path: root/drumgizmo/jackclient.cc
diff options
context:
space:
mode:
Diffstat (limited to 'drumgizmo/jackclient.cc')
-rw-r--r--drumgizmo/jackclient.cc62
1 files changed, 34 insertions, 28 deletions
diff --git a/drumgizmo/jackclient.cc b/drumgizmo/jackclient.cc
index 3d1a836..eb35bf6 100644
--- a/drumgizmo/jackclient.cc
+++ b/drumgizmo/jackclient.cc
@@ -28,19 +28,22 @@
#include "jackclient.h"
-JackProcess::~JackProcess() {
-}
+JackProcess::~JackProcess() {}
// --------------------------------------------------------------------
-JackPort::JackPort(JackClient& client, std::string const & name, const char * type, JackPortFlags flags)
- : client{client.client}
- // register jack port for given client
- , port{jack_port_register(this->client, name.c_str(), type, flags, 0)} {
+JackPort::JackPort(JackClient &client, std::string const &name,
+ const char *type, JackPortFlags flags)
+ : client{client.client} // register jack port for given client
+ ,
+ port{jack_port_register(this->client, name.c_str(), type, flags, 0)}
+{
}
-JackPort::~JackPort() {
- if (port != nullptr) {
+JackPort::~JackPort()
+{
+ if (port != nullptr)
+ {
assert(client != nullptr);
jack_port_unregister(client, port);
}
@@ -48,51 +51,54 @@ JackPort::~JackPort() {
// --------------------------------------------------------------------
-int _wrap_jack_process(jack_nframes_t nframes, void* arg){
- return static_cast<JackClient*>(arg)->process(nframes);
+int _wrap_jack_process(jack_nframes_t nframes, void *arg)
+{
+ return static_cast<JackClient *>(arg)->process(nframes);
}
-JackClient::JackClient()
- : client{nullptr}
- , processes{}
- , is_active{false} {
+JackClient::JackClient() : client{nullptr}, processes{}, is_active{false}
+{
jack_status_t status;
client = jack_client_open("DrumGizmo", JackNullOption, &status);
jack_set_process_callback(client, _wrap_jack_process, this);
}
-JackClient::~JackClient() {
- if (client != nullptr) {
+JackClient::~JackClient()
+{
+ if (client != nullptr)
+ {
jack_client_close(client);
}
}
-void JackClient::add(JackProcess& process) {
- processes.insert(&process);
-}
+void JackClient::add(JackProcess &process) { processes.insert(&process); }
-void JackClient::remove(JackProcess& process) {
- processes.erase(&process);
-}
+void JackClient::remove(JackProcess &process) { processes.erase(&process); }
-void JackClient::activate() {
- if (!is_active) {
+void JackClient::activate()
+{
+ if (!is_active)
+ {
jack_activate(client);
}
is_active = true;
}
-int JackClient::process(jack_nframes_t num_frames) {
- for (auto& ptr: processes) {
+int JackClient::process(jack_nframes_t num_frames)
+{
+ for (auto &ptr : processes)
+ {
ptr->process(num_frames);
}
return 0;
}
-std::size_t JackClient::getBufferSize() const {
+std::size_t JackClient::getBufferSize() const
+{
return jack_get_buffer_size(client);
}
-std::size_t JackClient::getSampleRate() const {
+std::size_t JackClient::getSampleRate() const
+{
return jack_get_sample_rate(client);
}