diff options
author | André Nusser <andre.nusser@googlemail.com> | 2016-07-13 16:33:11 +0200 |
---|---|---|
committer | André Nusser <andre.nusser@googlemail.com> | 2016-07-13 17:28:11 +0200 |
commit | 32606894c67e6be27ba853a8bc3e97c808c14987 (patch) | |
tree | f31c9d1bc08e2095b2cd724b5f0f0a27526c5a01 /drumgizmo | |
parent | d71485534d3a683cae4993815f59ff68263a6751 (diff) |
Introduce output engine isFreewheeling method.
Diffstat (limited to 'drumgizmo')
-rw-r--r-- | drumgizmo/jackclient.cc | 25 | ||||
-rw-r--r-- | drumgizmo/jackclient.h | 4 | ||||
-rw-r--r-- | drumgizmo/output/alsa.cc | 5 | ||||
-rw-r--r-- | drumgizmo/output/alsa.h | 1 | ||||
-rw-r--r-- | drumgizmo/output/jackaudio.cc | 5 | ||||
-rw-r--r-- | drumgizmo/output/jackaudio.h | 1 | ||||
-rw-r--r-- | drumgizmo/output/outputdummy.cc | 5 | ||||
-rw-r--r-- | drumgizmo/output/outputdummy.h | 1 | ||||
-rw-r--r-- | drumgizmo/output/wavfile.cc | 5 | ||||
-rw-r--r-- | drumgizmo/output/wavfile.h | 1 |
10 files changed, 47 insertions, 6 deletions
diff --git a/drumgizmo/jackclient.cc b/drumgizmo/jackclient.cc index fb71b1b..8bf0939 100644 --- a/drumgizmo/jackclient.cc +++ b/drumgizmo/jackclient.cc @@ -63,6 +63,11 @@ void JackClient::latencyCallback(jack_latency_callback_mode_t mode, static_cast<JackClient*>(arg)->jackLatencyCallback(mode); } +void JackClient::freewheelCallback(int is_freewheeling, void* arg) +{ + static_cast<JackClient*>(arg)->jackFreewheelCallback(is_freewheeling); +} + JackClient::JackClient() : client{nullptr} , processes{} @@ -70,13 +75,11 @@ JackClient::JackClient() { jack_status_t status; client = jack_client_open("DrumGizmo", JackNullOption, &status); - jack_set_process_callback(client, JackClient::wrapJackProcess, this); - // Register callback which is called by jack when it wants to know about the - // current port latency. - jack_set_latency_callback(client, - JackClient::latencyCallback, - this); + // Register callbacks + jack_set_process_callback(client, JackClient::wrapJackProcess, this); + jack_set_latency_callback(client, JackClient::latencyCallback, this); + jack_set_freewheel_callback(client, JackClient::freewheelCallback, this); } JackClient::~JackClient() @@ -123,6 +126,11 @@ void JackClient::jackLatencyCallback(jack_latency_callback_mode_t mode) } } +void JackClient::jackFreewheelCallback(bool is_freewheeling) +{ + this->is_freewheeling = is_freewheeling; +} + std::size_t JackClient::getBufferSize() const { return jack_get_buffer_size(client); @@ -132,3 +140,8 @@ std::size_t JackClient::getSampleRate() const { return jack_get_sample_rate(client); } + +bool JackClient::isFreewheeling() const +{ + return is_freewheeling; +} diff --git a/drumgizmo/jackclient.h b/drumgizmo/jackclient.h index 83e5339..f769ab4 100644 --- a/drumgizmo/jackclient.h +++ b/drumgizmo/jackclient.h @@ -72,15 +72,19 @@ public: std::size_t getBufferSize() const; std::size_t getSampleRate() const; + bool isFreewheeling() const; private: jack_client_t* client; std::set<JackProcess*> processes; bool is_active; + bool is_freewheeling; int process(jack_nframes_t num_frames); void jackLatencyCallback(jack_latency_callback_mode_t mode); + void jackFreewheelCallback(bool is_freewheeling); static int wrapJackProcess(jack_nframes_t nframes, void* arg); static void latencyCallback(jack_latency_callback_mode_t mode, void* arg); + static void freewheelCallback(int is_freewheeling, void* arg); }; diff --git a/drumgizmo/output/alsa.cc b/drumgizmo/output/alsa.cc index aea80a6..1241cad 100644 --- a/drumgizmo/output/alsa.cc +++ b/drumgizmo/output/alsa.cc @@ -191,3 +191,8 @@ size_t AlsaOutputEngine::getSamplerate() const { return srate; } + +bool AlsaOutputEngine::isFreewheeling() const +{ + return false; +} diff --git a/drumgizmo/output/alsa.h b/drumgizmo/output/alsa.h index cc28f94..56011b6 100644 --- a/drumgizmo/output/alsa.h +++ b/drumgizmo/output/alsa.h @@ -50,6 +50,7 @@ public: void run(int ch, sample_t* samples, size_t nsamples) override; void post(size_t nsamples) override; size_t getSamplerate() const override; + bool isFreewheeling() const override; private: snd_pcm_t* handle; diff --git a/drumgizmo/output/jackaudio.cc b/drumgizmo/output/jackaudio.cc index 75766d1..2274bea 100644 --- a/drumgizmo/output/jackaudio.cc +++ b/drumgizmo/output/jackaudio.cc @@ -123,6 +123,11 @@ size_t JackAudioOutputEngine::getSamplerate() const return client.getSampleRate(); } +bool JackAudioOutputEngine::isFreewheeling() const +{ + return client.isFreewheeling(); +} + void JackAudioOutputEngine::onLatencyChange(std::size_t latency) { this->latency = latency; diff --git a/drumgizmo/output/jackaudio.h b/drumgizmo/output/jackaudio.h index b8fbcab..ce18f6f 100644 --- a/drumgizmo/output/jackaudio.h +++ b/drumgizmo/output/jackaudio.h @@ -49,6 +49,7 @@ public: void post(size_t nsamples) override; size_t getBufferSize() const override; size_t getSamplerate() const override; + bool isFreewheeling() const override; void onLatencyChange(std::size_t latency) override; // based on JackProcess diff --git a/drumgizmo/output/outputdummy.cc b/drumgizmo/output/outputdummy.cc index 4ff0816..3cb3ac4 100644 --- a/drumgizmo/output/outputdummy.cc +++ b/drumgizmo/output/outputdummy.cc @@ -63,3 +63,8 @@ void DummyOutputEngine::run(int ch, sample_t* samples, size_t nsamples) void DummyOutputEngine::post(size_t nsamples) { } + +bool DummyOutputEngine::isFreewheeling() const +{ + return false; +} diff --git a/drumgizmo/output/outputdummy.h b/drumgizmo/output/outputdummy.h index 5a1b2fa..3e24495 100644 --- a/drumgizmo/output/outputdummy.h +++ b/drumgizmo/output/outputdummy.h @@ -42,4 +42,5 @@ public: void pre(size_t nsamples) override; void run(int ch, sample_t* samples, size_t nsamples) override; void post(size_t nsamples) override; + bool isFreewheeling() const override; }; diff --git a/drumgizmo/output/wavfile.cc b/drumgizmo/output/wavfile.cc index 20b63bd..c82a365 100644 --- a/drumgizmo/output/wavfile.cc +++ b/drumgizmo/output/wavfile.cc @@ -152,3 +152,8 @@ void WavfileOutputEngine::onLatencyChange(std::size_t latency) { this->latency = latency; } + +bool WavfileOutputEngine::isFreewheeling() const +{ + return true; +} diff --git a/drumgizmo/output/wavfile.h b/drumgizmo/output/wavfile.h index 656c0cd..63bf0e4 100644 --- a/drumgizmo/output/wavfile.h +++ b/drumgizmo/output/wavfile.h @@ -51,6 +51,7 @@ public: void post(std::size_t nsamples) override; std::size_t getSamplerate() const override; void onLatencyChange(std::size_t latency) override; + bool isFreewheeling() const override; private: SF_INFO info; |