summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndré Nusser <andre.nusser@googlemail.com>2016-07-13 16:33:11 +0200
committerAndré Nusser <andre.nusser@googlemail.com>2016-07-13 17:28:11 +0200
commit32606894c67e6be27ba853a8bc3e97c808c14987 (patch)
treef31c9d1bc08e2095b2cd724b5f0f0a27526c5a01
parentd71485534d3a683cae4993815f59ff68263a6751 (diff)
Introduce output engine isFreewheeling method.
-rw-r--r--drumgizmo/jackclient.cc25
-rw-r--r--drumgizmo/jackclient.h4
-rw-r--r--drumgizmo/output/alsa.cc5
-rw-r--r--drumgizmo/output/alsa.h1
-rw-r--r--drumgizmo/output/jackaudio.cc5
-rw-r--r--drumgizmo/output/jackaudio.h1
-rw-r--r--drumgizmo/output/outputdummy.cc5
-rw-r--r--drumgizmo/output/outputdummy.h1
-rw-r--r--drumgizmo/output/wavfile.cc5
-rw-r--r--drumgizmo/output/wavfile.h1
-rw-r--r--plugin/drumgizmo_plugin.cc5
-rw-r--r--plugin/drumgizmo_plugin.h1
-rw-r--r--src/audiooutputengine.h2
-rw-r--r--test/dgreftest/compareoutputengine.cc5
-rw-r--r--test/dgreftest/compareoutputengine.h1
-rw-r--r--test/dgreftest/wavfileoutputengine.cc5
-rw-r--r--test/dgreftest/wavfileoutputengine.h1
-rw-r--r--test/engine.cc1
18 files changed, 67 insertions, 7 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;
diff --git a/plugin/drumgizmo_plugin.cc b/plugin/drumgizmo_plugin.cc
index 7202770..4f3edf2 100644
--- a/plugin/drumgizmo_plugin.cc
+++ b/plugin/drumgizmo_plugin.cc
@@ -309,3 +309,8 @@ size_t DrumGizmoPlugin::Output::getBufferSize() const
{
return plugin.getFramesize();
}
+
+bool DrumGizmoPlugin::Output::isFreewheeling() const
+{
+ return plugin.getFreeWheel();
+}
diff --git a/plugin/drumgizmo_plugin.h b/plugin/drumgizmo_plugin.h
index 3508c3e..0adc240 100644
--- a/plugin/drumgizmo_plugin.h
+++ b/plugin/drumgizmo_plugin.h
@@ -143,6 +143,7 @@ private:
sample_t *getBuffer(int ch) const override;
size_t getBufferSize() const override;
+ bool isFreewheeling() const override;
protected:
DrumGizmoPlugin& plugin;
diff --git a/src/audiooutputengine.h b/src/audiooutputengine.h
index 338b5cd..19f9f44 100644
--- a/src/audiooutputengine.h
+++ b/src/audiooutputengine.h
@@ -54,8 +54,8 @@ public:
//! Overload this method to force engine to use different buffer size.
virtual std::size_t getBufferSize() const { return 1024; }
-
virtual std::size_t getSamplerate() const { return 44100; }
+ virtual bool isFreewheeling() const = 0;
//! Overload this method to get notification of latency changes.
//! \param latency The new latency in samples.
diff --git a/test/dgreftest/compareoutputengine.cc b/test/dgreftest/compareoutputengine.cc
index 4b13566..33dfe2a 100644
--- a/test/dgreftest/compareoutputengine.cc
+++ b/test/dgreftest/compareoutputengine.cc
@@ -136,3 +136,8 @@ size_t CompareOutputEngine::getSamplerate() const
{
return info.samplerate;
}
+
+bool CompareOutputEngine::isFreewheeling() const
+{
+ return true;
+}
diff --git a/test/dgreftest/compareoutputengine.h b/test/dgreftest/compareoutputengine.h
index fb610d6..a82116c 100644
--- a/test/dgreftest/compareoutputengine.h
+++ b/test/dgreftest/compareoutputengine.h
@@ -45,6 +45,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:
SF_INFO info;
diff --git a/test/dgreftest/wavfileoutputengine.cc b/test/dgreftest/wavfileoutputengine.cc
index 6f971ad..e24a315 100644
--- a/test/dgreftest/wavfileoutputengine.cc
+++ b/test/dgreftest/wavfileoutputengine.cc
@@ -123,3 +123,8 @@ size_t WavfileOutputEngine::getSamplerate() const
{
return info.samplerate;
}
+
+bool WavfileOutputEngine::isFreewheeling() const
+{
+ return true;
+}
diff --git a/test/dgreftest/wavfileoutputengine.h b/test/dgreftest/wavfileoutputengine.h
index 6937ed2..4a618ed 100644
--- a/test/dgreftest/wavfileoutputengine.h
+++ b/test/dgreftest/wavfileoutputengine.h
@@ -45,6 +45,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:
SF_INFO info;
diff --git a/test/engine.cc b/test/engine.cc
index c607ded..11fa720 100644
--- a/test/engine.cc
+++ b/test/engine.cc
@@ -43,6 +43,7 @@ public:
void pre(size_t nsamples) {}
void run(int ch, sample_t *samples, size_t nsamples) {}
void post(size_t nsamples) {}
+ bool isFreewheeling() const { return true; }
};
class AudioInputEngineDummy