summaryrefslogtreecommitdiffstats
path: root/src/libs
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-01-08 17:56:50 +0000
committerDavid Robillard <d@drobilla.net>2007-01-08 17:56:50 +0000
commit641923335b88ddd8ca3df176f42810d8cea30685 (patch)
tree9a52bd2b40e2e58ec410617aa3e9e7c721bef3d5 /src/libs
parentfa8c25fd08953b6b14b22faa807a5446cec7294c (diff)
downloadingen-641923335b88ddd8ca3df176f42810d8cea30685.tar.gz
ingen-641923335b88ddd8ca3df176f42810d8cea30685.tar.bz2
ingen-641923335b88ddd8ca3df176f42810d8cea30685.zip
Alsa MIDI fixed.
git-svn-id: http://svn.drobilla.net/lad/ingen@244 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs')
-rw-r--r--src/libs/client/Loader.cpp2
-rw-r--r--src/libs/client/PortModel.h2
-rw-r--r--src/libs/client/Serializer.cpp3
-rw-r--r--src/libs/engine/AlsaMidiDriver.cpp62
-rw-r--r--src/libs/engine/AlsaMidiDriver.h10
5 files changed, 42 insertions, 37 deletions
diff --git a/src/libs/client/Loader.cpp b/src/libs/client/Loader.cpp
index af51d4c8..4ceb34d2 100644
--- a/src/libs/client/Loader.cpp
+++ b/src/libs/client/Loader.cpp
@@ -174,6 +174,7 @@ Loader::load(const Glib::ustring& filename,
}
}
+
/* Load connections */
// FIXME: path?
@@ -206,6 +207,7 @@ Loader::load(const Glib::ustring& filename,
_engine->connect(src_port, dst_port);
}
+
// Set passed metadata last to override any loaded values
for (MetadataMap::const_iterator i = data.begin(); i != data.end(); ++i)
_engine->set_metadata(patch_path, i->first, i->second);
diff --git a/src/libs/client/PortModel.h b/src/libs/client/PortModel.h
index 1dc68ccd..adaaf803 100644
--- a/src/libs/client/PortModel.h
+++ b/src/libs/client/PortModel.h
@@ -58,7 +58,7 @@ public:
inline bool operator==(const PortModel& pm) const { return (_path == pm._path); }
// Signals
- sigc::signal<void, float> control_change_sig; ///< "Control" ports only
+ sigc::signal<void, float> control_change_sig; ///< "Control" ports only
sigc::signal<void, SharedPtr<PortModel> > connection_sig;
sigc::signal<void, SharedPtr<PortModel> > disconnection_sig;
diff --git a/src/libs/client/Serializer.cpp b/src/libs/client/Serializer.cpp
index 3a417a48..5ce2674a 100644
--- a/src/libs/client/Serializer.cpp
+++ b/src/libs/client/Serializer.cpp
@@ -301,6 +301,9 @@ Serializer::serialize_port(SharedPtr<PortModel> port, unsigned depth)
_writer.write(port_id, NS_INGEN("name"), Atom(port->path().name().c_str()));
_writer.write(port_id, NS_INGEN("dataType"), Atom(port->type()));
+
+ if (port->is_control() && port->is_input())
+ _writer.write(port_id, NS_INGEN("value"), Atom(port->value()));
if (port->metadata().size() > 0) {
for (MetadataMap::const_iterator m = port->metadata().begin(); m != port->metadata().end(); ++m) {
diff --git a/src/libs/engine/AlsaMidiDriver.cpp b/src/libs/engine/AlsaMidiDriver.cpp
index c8b2b906..3d1ebbd2 100644
--- a/src/libs/engine/AlsaMidiDriver.cpp
+++ b/src/libs/engine/AlsaMidiDriver.cpp
@@ -19,8 +19,8 @@
#include <cstdlib>
#include <pthread.h>
#include "types.h"
-//#include "Engine.h"
#include "Maid.h"
+#include "ThreadManager.h"
#include "AudioDriver.h"
#include "MidiMessage.h"
#include "DuplexPort.h"
@@ -34,20 +34,19 @@ namespace Ingen {
//// AlsaMidiPort ////
-AlsaMidiPort::AlsaMidiPort(AlsaMidiDriver* driver, DuplexPort<MidiMessage>* port)
-: DriverPort(),
+AlsaMidiPort::AlsaMidiPort(AlsaMidiDriver* driver, DuplexPort<MidiMessage>* patch_port)
+: DriverPort(patch_port->is_input()),
ListNode<AlsaMidiPort*>(this),
_driver(driver),
- _patch_port(port),
+ _patch_port(patch_port),
_port_id(0),
- _midi_pool(new unsigned char*[port->buffer_size()]),
+ _midi_pool(new unsigned char*[patch_port->buffer_size()]),
_events(1024)
{
- assert(port->parent() != NULL);
- assert(port->poly() == 1);
+ assert(patch_port->poly() == 1);
- if (port->is_input()) {
- if ((_port_id = snd_seq_create_simple_port(driver->seq_handle(), port->path().c_str(),
+ if (patch_port->is_input()) {
+ if ((_port_id = snd_seq_create_simple_port(driver->seq_handle(), patch_port->path().c_str(),
SND_SEQ_PORT_CAP_WRITE | SND_SEQ_PORT_CAP_SUBS_WRITE,
SND_SEQ_PORT_TYPE_APPLICATION)) < 0)
{
@@ -55,7 +54,7 @@ AlsaMidiPort::AlsaMidiPort(AlsaMidiDriver* driver, DuplexPort<MidiMessage>* port
exit(EXIT_FAILURE);
}
} else {
- if ((_port_id = snd_seq_create_simple_port(driver->seq_handle(), port->path().c_str(),
+ if ((_port_id = snd_seq_create_simple_port(driver->seq_handle(), patch_port->path().c_str(),
SND_SEQ_PORT_CAP_READ | SND_SEQ_PORT_CAP_SUBS_READ,
SND_SEQ_PORT_TYPE_APPLICATION)) < 0)
{
@@ -68,11 +67,11 @@ AlsaMidiPort::AlsaMidiPort(AlsaMidiDriver* driver, DuplexPort<MidiMessage>* port
* of Alsa events. The buffer member of the MidiMessage's in the patch port's
* buffer will be set directly to an element in this pool, then next cycle they
* will be overwritten (eliminating the need for any allocation/freeing). */
- for (size_t i=0; i < port->buffer_size(); ++i)
+ for (size_t i=0; i < patch_port->buffer_size(); ++i)
_midi_pool[i] = new unsigned char[MAX_MIDI_EVENT_SIZE];
- port->buffer(0)->clear();
- port->fixed_buffers(true);
+ patch_port->buffer(0)->clear();
+ patch_port->fixed_buffers(true);
}
@@ -293,12 +292,15 @@ AlsaMidiDriver::prepare_block(const SampleCount block_start, const SampleCount b
* See create_port() and remove_port().
*/
void
-AlsaMidiDriver::add_port(AlsaMidiPort* port)
+AlsaMidiDriver::add_port(DriverPort* port)
{
- if (port->patch_port()->is_input())
- _in_ports.push_back(port);
+ assert(ThreadManager::current_thread_id() == THREAD_PROCESS);
+ assert(dynamic_cast<AlsaMidiPort*>(port));
+
+ if (port->is_input())
+ _in_ports.push_back((AlsaMidiPort*)port);
else
- _out_ports.push_back(port);
+ _out_ports.push_back((AlsaMidiPort*)port);
}
@@ -310,20 +312,22 @@ AlsaMidiDriver::add_port(AlsaMidiPort* port)
*
* It is the callers responsibility to delete the returned port.
*/
-AlsaMidiPort*
-AlsaMidiDriver::remove_port(AlsaMidiPort* port)
+DriverPort*
+AlsaMidiDriver::remove_port(const Path& path)
{
- if (port->patch_port()->is_input()) {
- for (List<AlsaMidiPort*>::iterator i = _in_ports.begin(); i != _in_ports.end(); ++i)
- if ((*i) == (AlsaMidiPort*)port)
- return _in_ports.remove(i)->elem();
- } else {
- for (List<AlsaMidiPort*>::iterator i = _out_ports.begin(); i != _out_ports.end(); ++i)
- if ((*i) == port)
- return _out_ports.remove(i)->elem();
- }
+ assert(ThreadManager::current_thread_id() == THREAD_PROCESS);
+
+ // FIXME: duplex?
- cerr << "[AlsaMidiDriver::remove_input] WARNING: Failed to find Jack port to remove!" << endl;
+ for (List<AlsaMidiPort*>::iterator i = _in_ports.begin(); i != _in_ports.end(); ++i)
+ if ((*i)->patch_port()->path() == path)
+ return _in_ports.remove(i)->elem();
+
+ for (List<AlsaMidiPort*>::iterator i = _out_ports.begin(); i != _out_ports.end(); ++i)
+ if ((*i)->patch_port()->path() == path)
+ return _out_ports.remove(i)->elem();
+
+ cerr << "[AlsaMidiDriver::remove_port] WARNING: Failed to find Jack port to remove!" << endl;
return NULL;
}
diff --git a/src/libs/engine/AlsaMidiDriver.h b/src/libs/engine/AlsaMidiDriver.h
index 9309a05b..8de2feba 100644
--- a/src/libs/engine/AlsaMidiDriver.h
+++ b/src/libs/engine/AlsaMidiDriver.h
@@ -87,6 +87,9 @@ public:
DriverPort* create_port(DuplexPort<MidiMessage>* patch_port)
{ return new AlsaMidiPort(this, patch_port); }
+
+ void add_port(DriverPort* port);
+ DriverPort* remove_port(const Path& path);
snd_seq_t* seq_handle() const { return _seq_handle; }
snd_midi_event_t* event_coder() const { return _event_coder; }
@@ -97,13 +100,6 @@ private:
friend class AlsaMidiPort;
- // Functions for AlsaMidiPort
- void add_port(AlsaMidiPort* port);
- AlsaMidiPort* remove_port(AlsaMidiPort* port);
-
- void add_output(ListNode<AlsaMidiPort*>* port);
- ListNode<AlsaMidiPort*>* remove_output(AlsaMidiPort* port);
-
// MIDI thread
static void* process_midi_in(void* me);