summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2007-01-15 18:59:31 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2007-01-15 18:59:31 +0000
commitd3071f84e5be7d611b83ce68908da697566a9713 (patch)
treec7d249d9a7bebea5e7b8aaa2b22f064d14b68770
parent56cd926425310e5534f4a6864b296101ad0477c6 (diff)
ALSA sequencer ports are all owned by a single sequencer client, not 1 per port
git-svn-id: svn://localhost/ardour2/trunk@1329 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--libs/ardour/ardour/crossfade.h2
-rw-r--r--libs/ardour/crossfade.cc23
-rw-r--r--libs/midi++2/alsa_sequencer_midiport.cc105
-rw-r--r--libs/midi++2/midi++/alsa_sequencer.h4
4 files changed, 70 insertions, 64 deletions
diff --git a/libs/ardour/ardour/crossfade.h b/libs/ardour/ardour/crossfade.h
index 62ab1f775d..3eafed818c 100644
--- a/libs/ardour/ardour/crossfade.h
+++ b/libs/ardour/ardour/crossfade.h
@@ -167,8 +167,6 @@ class Crossfade : public PBD::StatefulDestructible, public boost::enable_shared_
void initialize ();
int compute (boost::shared_ptr<ARDOUR::AudioRegion>, boost::shared_ptr<ARDOUR::AudioRegion>, CrossfadeModel);
bool update ();
-
- void member_changed (ARDOUR::Change);
};
diff --git a/libs/ardour/crossfade.cc b/libs/ardour/crossfade.cc
index 337911d3e4..57821ca440 100644
--- a/libs/ardour/crossfade.cc
+++ b/libs/ardour/crossfade.cc
@@ -227,9 +227,6 @@ Crossfade::initialize ()
_fade_in.add (_length, 1.0);
_fade_in.thaw ();
- // _in->StateChanged.connect (sigc::mem_fun (*this, &Crossfade::member_changed));
- // _out->StateChanged.connect (sigc::mem_fun (*this, &Crossfade::member_changed));
-
overlap_type = _in->coverage (_out->position(), _out->last_frame());
layer_relation = (int32_t) (_in->layer() - _out->layer());
}
@@ -599,26 +596,6 @@ Crossfade::compute (boost::shared_ptr<AudioRegion> a, boost::shared_ptr<AudioReg
return 0;
}
-void
-Crossfade::member_changed (Change what_changed)
-{
- Change what_we_care_about = Change (Region::MuteChanged|
- Region::LayerChanged|
- BoundsChanged);
-
- if (what_changed & what_we_care_about) {
- try {
- if (what_changed & what_we_care_about) {
- refresh ();
- }
- }
-
- catch (NoCrossfadeHere& err) {
- // relax, Invalidated inside refresh()
- }
- }
-}
-
XMLNode&
Crossfade::get_state ()
{
diff --git a/libs/midi++2/alsa_sequencer_midiport.cc b/libs/midi++2/alsa_sequencer_midiport.cc
index fca6707efd..26cdb7d1fd 100644
--- a/libs/midi++2/alsa_sequencer_midiport.cc
+++ b/libs/midi++2/alsa_sequencer_midiport.cc
@@ -21,6 +21,8 @@
#include <fcntl.h>
#include <cerrno>
+#include <pbd/failed_constructor.h>
+
#include <midi++/types.h>
#include <midi++/alsa_sequencer.h>
#include <midi++/port_request.h>
@@ -35,42 +37,53 @@
#define TR_VAL(v)
#endif
-
-
-
using namespace std;
using namespace MIDI;
+snd_seq_t* ALSA_SequencerMidiPort::seq = 0;
+
ALSA_SequencerMidiPort::ALSA_SequencerMidiPort (PortRequest &req)
: Port (req)
- , seq (0)
, decoder (0)
, encoder (0)
+ , port_id (-1)
{
TR_FN();
int err;
- if (0 <= (err = CreatePorts (req)) &&
- 0 <= (err = snd_midi_event_new (1024, &decoder)) && // Length taken from ARDOUR::Session::midi_read ()
- 0 <= (err = snd_midi_event_new (64, &encoder))) { // Length taken from ARDOUR::Session::mmc_buffer
- snd_midi_event_init (decoder);
- snd_midi_event_init (encoder);
- _ok = true;
- req.status = PortRequest::OK;
- } else
- req.status = PortRequest::Unknown;
+
+ if (!seq && init_client (req.devname) < 0) {
+ _ok = false;
+
+ } else {
+
+ if (0 <= (err = CreatePorts (req)) &&
+ 0 <= (err = snd_midi_event_new (1024, &decoder)) && // Length taken from ARDOUR::Session::midi_read ()
+ 0 <= (err = snd_midi_event_new (64, &encoder))) { // Length taken from ARDOUR::Session::mmc_buffer
+ snd_midi_event_init (decoder);
+ snd_midi_event_init (encoder);
+ _ok = true;
+ req.status = PortRequest::OK;
+ } else {
+ req.status = PortRequest::Unknown;
+ }
+ }
}
ALSA_SequencerMidiPort::~ALSA_SequencerMidiPort ()
{
- if (decoder)
+ if (decoder) {
snd_midi_event_free (decoder);
- if (encoder)
+ }
+ if (encoder) {
snd_midi_event_free (encoder);
- if (seq)
- snd_seq_close (seq);
+ }
+ if (port_id >= 0) {
+ snd_seq_delete_port (seq, port_id);
+ }
}
-int ALSA_SequencerMidiPort::selectable () const
+int
+ALSA_SequencerMidiPort::selectable () const
{
struct pollfd pfd[1];
if (0 <= snd_seq_poll_descriptors (seq, pfd, 1, POLLIN | POLLOUT)) {
@@ -79,7 +92,8 @@ int ALSA_SequencerMidiPort::selectable () const
return -1;
}
-int ALSA_SequencerMidiPort::write (byte *msg, size_t msglen)
+int
+ALSA_SequencerMidiPort::write (byte *msg, size_t msglen)
{
TR_FN ();
int R;
@@ -118,7 +132,8 @@ int ALSA_SequencerMidiPort::write (byte *msg, size_t msglen)
return totwritten;
}
-int ALSA_SequencerMidiPort::read (byte *buf, size_t max)
+int
+ALSA_SequencerMidiPort::read (byte *buf, size_t max)
{
TR_FN();
int err;
@@ -142,27 +157,41 @@ int ALSA_SequencerMidiPort::read (byte *buf, size_t max)
return -ENOENT == err ? 0 : err;
}
-int ALSA_SequencerMidiPort::CreatePorts (PortRequest &req)
+int
+ALSA_SequencerMidiPort::CreatePorts (PortRequest &req)
{
int err;
- if (0 <= (err = snd_seq_open(&seq, "default", SND_SEQ_OPEN_DUPLEX,
- (req.mode & O_NONBLOCK) ? SND_SEQ_NONBLOCK : 0))) {
- snd_seq_set_client_name (seq, req.devname);
- unsigned int caps = 0;
- if (req.mode == O_WRONLY || req.mode == O_RDWR)
- caps |= SND_SEQ_PORT_CAP_WRITE | SND_SEQ_PORT_CAP_SUBS_WRITE;
- if (req.mode == O_RDONLY || req.mode == O_RDWR)
- caps |= SND_SEQ_PORT_CAP_READ | SND_SEQ_PORT_CAP_SUBS_READ;
- err = snd_seq_create_simple_port (seq, req.tagname, caps, SND_SEQ_PORT_TYPE_MIDI_GENERIC);
- if (err >= 0) {
- port_id = err;
- snd_seq_ev_clear (&SEv);
- snd_seq_ev_set_source (&SEv, port_id);
- snd_seq_ev_set_subs (&SEv);
- snd_seq_ev_set_direct (&SEv);
- } else
- snd_seq_close (seq);
+ unsigned int caps = 0;
+
+ if (req.mode == O_WRONLY || req.mode == O_RDWR)
+ caps |= SND_SEQ_PORT_CAP_WRITE | SND_SEQ_PORT_CAP_SUBS_WRITE;
+ if (req.mode == O_RDONLY || req.mode == O_RDWR)
+ caps |= SND_SEQ_PORT_CAP_READ | SND_SEQ_PORT_CAP_SUBS_READ;
+
+ if (0 <= (err = snd_seq_create_simple_port (seq, req.tagname, caps, SND_SEQ_PORT_TYPE_MIDI_GENERIC))) {
+
+ port_id = err;
+
+ snd_seq_ev_clear (&SEv);
+ snd_seq_ev_set_source (&SEv, port_id);
+ snd_seq_ev_set_subs (&SEv);
+ snd_seq_ev_set_direct (&SEv);
+
+ return 0;
}
+
return err;
}
+int
+ALSA_SequencerMidiPort::init_client (std::string name)
+{
+ int err;
+
+ if (0 <= (err = snd_seq_open (&seq, "default", SND_SEQ_OPEN_DUPLEX, 0))) {
+ snd_seq_set_client_name (seq, name.c_str());
+ return 0;
+ } else {
+ return -err;
+ }
+}
diff --git a/libs/midi++2/midi++/alsa_sequencer.h b/libs/midi++2/midi++/alsa_sequencer.h
index 8ddb2a7dd7..b76d60d05a 100644
--- a/libs/midi++2/midi++/alsa_sequencer.h
+++ b/libs/midi++2/midi++/alsa_sequencer.h
@@ -49,12 +49,14 @@ class ALSA_SequencerMidiPort : public Port
int read (byte *buf, size_t max);
private:
- snd_seq_t *seq;
snd_midi_event_t *decoder, *encoder;
int port_id;
snd_seq_event_t SEv;
+
int CreatePorts(PortRequest &req);
+ static int init_client (std::string name);
+ static snd_seq_t* seq;
};
}; /* namespace MIDI */