summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-10-03 04:09:37 +0000
committerDavid Robillard <d@drobilla.net>2011-10-03 04:09:37 +0000
commit990007a6c0317aa0cce97f4e095bc98745c60c4d (patch)
treee5e3010b83ff525b900adf8096556984e0feacf7 /src
parent8768c927968c2541bcac763d9a4f237081eaca4b (diff)
downloadingen-990007a6c0317aa0cce97f4e095bc98745c60c4d.tar.gz
ingen-990007a6c0317aa0cce97f4e095bc98745c60c4d.tar.bz2
ingen-990007a6c0317aa0cce97f4e095bc98745c60c4d.zip
Use port type instead of buffer type where appropriate.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@3524 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/server/InputPort.cpp4
-rw-r--r--src/server/JackDriver.cpp14
-rw-r--r--src/server/PortImpl.cpp8
-rw-r--r--src/server/PortImpl.hpp11
-rw-r--r--src/server/ingen_lv2.cpp8
5 files changed, 18 insertions, 27 deletions
diff --git a/src/server/InputPort.cpp b/src/server/InputPort.cpp
index 2abd17eb..98922b07 100644
--- a/src/server/InputPort.cpp
+++ b/src/server/InputPort.cpp
@@ -83,7 +83,7 @@ InputPort::get_buffers(BufferFactory& bufs,
size_t num_connections = (ThreadManager::thread_is(THREAD_PROCESS))
? _connections.size() : _num_connections;
- if (buffer_type() == PortType::AUDIO && num_connections == 0) {
+ if (is_a(PortType::AUDIO) && num_connections == 0) {
// Audio input with no connections, use shared zero buffer
for (uint32_t v = 0; v < poly; ++v)
buffers->at(v) = bufs.silent_buffer();
@@ -216,7 +216,7 @@ void
InputPort::post_process(Context& context)
{
if (_set_by_user) {
- if (buffer_type() == PortType::EVENTS) {
+ if (is_a(PortType::EVENTS)) {
// Clear events received via a SetPortValue
for (uint32_t v = 0; v < _poly; ++v) {
buffer(v)->clear();
diff --git a/src/server/JackDriver.cpp b/src/server/JackDriver.cpp
index 42e9f78a..246d6fdb 100644
--- a/src/server/JackDriver.cpp
+++ b/src/server/JackDriver.cpp
@@ -85,7 +85,7 @@ JackPort::create()
_jack_port = jack_port_register(
_driver->jack_client(),
ingen_jack_port_name(_patch_port->path()).c_str(),
- (_patch_port->buffer_type() == PortType::AUDIO)
+ (_patch_port->is_a(PortType::AUDIO))
? JACK_DEFAULT_AUDIO_TYPE : JACK_DEFAULT_MIDI_TYPE,
(_patch_port->is_input())
? JackPortIsInput : JackPortIsOutput,
@@ -120,13 +120,13 @@ JackPort::pre_process(ProcessContext& context)
const SampleCount nframes = context.nframes();
- if (_patch_port->buffer_type() == PortType::AUDIO) {
+ if (_patch_port->is_a(PortType::AUDIO)) {
jack_sample_t* jack_buf = (jack_sample_t*)jack_port_get_buffer(_jack_port, nframes);
AudioBuffer* patch_buf = (AudioBuffer*)_patch_port->buffer(0).get();
patch_buf->copy(jack_buf, 0, nframes - 1);
- } else if (_patch_port->buffer_type() == PortType::EVENTS) {
+ } else if (_patch_port->is_a(PortType::EVENTS)) {
void* jack_buf = jack_port_get_buffer(_jack_port, nframes);
EventBuffer* patch_buf = (EventBuffer*)_patch_port->buffer(0).get();
@@ -155,13 +155,13 @@ JackPort::post_process(ProcessContext& context)
const SampleCount nframes = context.nframes();
- if (_patch_port->buffer_type() == PortType::AUDIO) {
+ if (_patch_port->is_a(PortType::AUDIO)) {
jack_sample_t* jack_buf = (jack_sample_t*)jack_port_get_buffer(_jack_port, nframes);
AudioBuffer* patch_buf = (AudioBuffer*)_patch_port->buffer(0).get();
memcpy(jack_buf, patch_buf->data(), nframes * sizeof(Sample));
- } else if (_patch_port->buffer_type() == PortType::EVENTS) {
+ } else if (_patch_port->is_a(PortType::EVENTS)) {
void* jack_buf = jack_port_get_buffer(_jack_port, context.nframes());
EventBuffer* patch_buf = (EventBuffer*)_patch_port->buffer(0).get();
@@ -386,8 +386,8 @@ DriverPort*
JackDriver::create_port(DuplexPort* patch_port)
{
try {
- if (patch_port->buffer_type() == PortType::AUDIO
- || patch_port->buffer_type() == PortType::EVENTS)
+ if (patch_port->is_a(PortType::AUDIO)
+ || patch_port->is_a(PortType::EVENTS))
return new JackPort(this, patch_port);
else
return NULL;
diff --git a/src/server/PortImpl.cpp b/src/server/PortImpl.cpp
index ce75321d..d4d947d1 100644
--- a/src/server/PortImpl.cpp
+++ b/src/server/PortImpl.cpp
@@ -53,7 +53,7 @@ PortImpl::PortImpl(BufferFactory& bufs,
, _index(index)
, _poly(poly)
, _buffer_size(buffer_size)
- , _buffer_type(type)
+ , _type(type)
, _value(value)
, _min(0.0f)
, _max(1.0f)
@@ -64,7 +64,6 @@ PortImpl::PortImpl(BufferFactory& bufs,
, _broadcast(false)
, _set_by_user(false)
{
- _types.insert(type);
assert(node != NULL);
assert(_poly > 0);
@@ -200,7 +199,7 @@ void
PortImpl::broadcast_value(Context& context, bool force)
{
Raul::Atom val;
- switch (buffer_type().symbol()) {
+ switch (_type.symbol()) {
case PortType::UNKNOWN:
break;
case PortType::AUDIO:
@@ -255,8 +254,7 @@ PortImpl::set_context(Context::ID c)
PortType
PortImpl::buffer_type() const
{
- // TODO: multiple types
- return *_types.begin();
+ return _type;
}
} // namespace Server
diff --git a/src/server/PortImpl.hpp b/src/server/PortImpl.hpp
index 7baaf089..2316a1d9 100644
--- a/src/server/PortImpl.hpp
+++ b/src/server/PortImpl.hpp
@@ -20,7 +20,6 @@
#include <cstdlib>
#include <string>
-#include <set>
#include "raul/Array.hpp"
#include "raul/Atom.hpp"
@@ -123,11 +122,7 @@ public:
uint32_t index() const { return _index; }
- typedef std::set<PortType> PortTypes;
-
- const PortTypes& types() const { return _types; }
-
- inline bool is_a(PortType type) const { return _types.find(type) != _types.end(); }
+ inline bool is_a(PortType type) const { return _type == type; }
PortType buffer_type() const;
@@ -143,7 +138,6 @@ public:
}
void set_buffer_size(Context& context, BufferFactory& bufs, size_t size);
- void set_buffer_type(PortType type);
void broadcast(bool b) { _broadcast = b; }
bool broadcast() { return _broadcast; }
@@ -171,8 +165,7 @@ protected:
uint32_t _index;
uint32_t _poly;
uint32_t _buffer_size;
- PortType _buffer_type;
- std::set<PortType> _types;
+ PortType _type;
Raul::Atom _value;
Raul::Atom _min;
Raul::Atom _max;
diff --git a/src/server/ingen_lv2.cpp b/src/server/ingen_lv2.cpp
index 700c2a72..c8ea9fbe 100644
--- a/src/server/ingen_lv2.cpp
+++ b/src/server/ingen_lv2.cpp
@@ -93,10 +93,10 @@ public:
if (!is_input() || !_buffer)
return;
- if (_patch_port->buffer_type() == PortType::AUDIO) {
+ if (_patch_port->is_a(PortType::AUDIO)) {
AudioBuffer* patch_buf = (AudioBuffer*)_patch_port->buffer(0).get();
patch_buf->copy((Sample*)_buffer, 0, context.nframes() - 1);
- } else if (_patch_port->buffer_type() == PortType::EVENTS) {
+ } else if (_patch_port->is_a(PortType::EVENTS)) {
//Raul::warn << "TODO: LV2 event I/O" << std::endl;
}
}
@@ -105,10 +105,10 @@ public:
if (is_input() || !_buffer)
return;
- if (_patch_port->buffer_type() == PortType::AUDIO) {
+ if (_patch_port->is_a(PortType::AUDIO)) {
AudioBuffer* patch_buf = (AudioBuffer*)_patch_port->buffer(0).get();
memcpy((Sample*)_buffer, patch_buf->data(), context.nframes() * sizeof(Sample));
- } else if (_patch_port->buffer_type() == PortType::EVENTS) {
+ } else if (_patch_port->is_a(PortType::EVENTS)) {
//Raul::warn << "TODO: LV2 event I/O" << std::endl;
}
}