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
This commit is contained in:
parent
56cd926425
commit
d3071f84e5
@ -167,8 +167,6 @@ class Crossfade : public PBD::StatefulDestructible, public boost::enable_shared_
|
|||||||
void initialize ();
|
void initialize ();
|
||||||
int compute (boost::shared_ptr<ARDOUR::AudioRegion>, boost::shared_ptr<ARDOUR::AudioRegion>, CrossfadeModel);
|
int compute (boost::shared_ptr<ARDOUR::AudioRegion>, boost::shared_ptr<ARDOUR::AudioRegion>, CrossfadeModel);
|
||||||
bool update ();
|
bool update ();
|
||||||
|
|
||||||
void member_changed (ARDOUR::Change);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -227,9 +227,6 @@ Crossfade::initialize ()
|
|||||||
_fade_in.add (_length, 1.0);
|
_fade_in.add (_length, 1.0);
|
||||||
_fade_in.thaw ();
|
_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());
|
overlap_type = _in->coverage (_out->position(), _out->last_frame());
|
||||||
layer_relation = (int32_t) (_in->layer() - _out->layer());
|
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;
|
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&
|
XMLNode&
|
||||||
Crossfade::get_state ()
|
Crossfade::get_state ()
|
||||||
{
|
{
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
|
|
||||||
|
#include <pbd/failed_constructor.h>
|
||||||
|
|
||||||
#include <midi++/types.h>
|
#include <midi++/types.h>
|
||||||
#include <midi++/alsa_sequencer.h>
|
#include <midi++/alsa_sequencer.h>
|
||||||
#include <midi++/port_request.h>
|
#include <midi++/port_request.h>
|
||||||
@ -35,20 +37,25 @@
|
|||||||
#define TR_VAL(v)
|
#define TR_VAL(v)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace MIDI;
|
using namespace MIDI;
|
||||||
|
|
||||||
|
snd_seq_t* ALSA_SequencerMidiPort::seq = 0;
|
||||||
|
|
||||||
ALSA_SequencerMidiPort::ALSA_SequencerMidiPort (PortRequest &req)
|
ALSA_SequencerMidiPort::ALSA_SequencerMidiPort (PortRequest &req)
|
||||||
: Port (req)
|
: Port (req)
|
||||||
, seq (0)
|
|
||||||
, decoder (0)
|
, decoder (0)
|
||||||
, encoder (0)
|
, encoder (0)
|
||||||
|
, port_id (-1)
|
||||||
{
|
{
|
||||||
TR_FN();
|
TR_FN();
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
if (!seq && init_client (req.devname) < 0) {
|
||||||
|
_ok = false;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
if (0 <= (err = CreatePorts (req)) &&
|
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 (1024, &decoder)) && // Length taken from ARDOUR::Session::midi_read ()
|
||||||
0 <= (err = snd_midi_event_new (64, &encoder))) { // Length taken from ARDOUR::Session::mmc_buffer
|
0 <= (err = snd_midi_event_new (64, &encoder))) { // Length taken from ARDOUR::Session::mmc_buffer
|
||||||
@ -56,21 +63,27 @@ ALSA_SequencerMidiPort::ALSA_SequencerMidiPort (PortRequest &req)
|
|||||||
snd_midi_event_init (encoder);
|
snd_midi_event_init (encoder);
|
||||||
_ok = true;
|
_ok = true;
|
||||||
req.status = PortRequest::OK;
|
req.status = PortRequest::OK;
|
||||||
} else
|
} else {
|
||||||
req.status = PortRequest::Unknown;
|
req.status = PortRequest::Unknown;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ALSA_SequencerMidiPort::~ALSA_SequencerMidiPort ()
|
ALSA_SequencerMidiPort::~ALSA_SequencerMidiPort ()
|
||||||
{
|
{
|
||||||
if (decoder)
|
if (decoder) {
|
||||||
snd_midi_event_free (decoder);
|
snd_midi_event_free (decoder);
|
||||||
if (encoder)
|
}
|
||||||
|
if (encoder) {
|
||||||
snd_midi_event_free (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];
|
struct pollfd pfd[1];
|
||||||
if (0 <= snd_seq_poll_descriptors (seq, pfd, 1, POLLIN | POLLOUT)) {
|
if (0 <= snd_seq_poll_descriptors (seq, pfd, 1, POLLIN | POLLOUT)) {
|
||||||
@ -79,7 +92,8 @@ int ALSA_SequencerMidiPort::selectable () const
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ALSA_SequencerMidiPort::write (byte *msg, size_t msglen)
|
int
|
||||||
|
ALSA_SequencerMidiPort::write (byte *msg, size_t msglen)
|
||||||
{
|
{
|
||||||
TR_FN ();
|
TR_FN ();
|
||||||
int R;
|
int R;
|
||||||
@ -118,7 +132,8 @@ int ALSA_SequencerMidiPort::write (byte *msg, size_t msglen)
|
|||||||
return totwritten;
|
return totwritten;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ALSA_SequencerMidiPort::read (byte *buf, size_t max)
|
int
|
||||||
|
ALSA_SequencerMidiPort::read (byte *buf, size_t max)
|
||||||
{
|
{
|
||||||
TR_FN();
|
TR_FN();
|
||||||
int err;
|
int err;
|
||||||
@ -142,27 +157,41 @@ int ALSA_SequencerMidiPort::read (byte *buf, size_t max)
|
|||||||
return -ENOENT == err ? 0 : err;
|
return -ENOENT == err ? 0 : err;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ALSA_SequencerMidiPort::CreatePorts (PortRequest &req)
|
int
|
||||||
|
ALSA_SequencerMidiPort::CreatePorts (PortRequest &req)
|
||||||
{
|
{
|
||||||
int err;
|
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;
|
unsigned int caps = 0;
|
||||||
|
|
||||||
if (req.mode == O_WRONLY || req.mode == O_RDWR)
|
if (req.mode == O_WRONLY || req.mode == O_RDWR)
|
||||||
caps |= SND_SEQ_PORT_CAP_WRITE | SND_SEQ_PORT_CAP_SUBS_WRITE;
|
caps |= SND_SEQ_PORT_CAP_WRITE | SND_SEQ_PORT_CAP_SUBS_WRITE;
|
||||||
if (req.mode == O_RDONLY || req.mode == O_RDWR)
|
if (req.mode == O_RDONLY || req.mode == O_RDWR)
|
||||||
caps |= SND_SEQ_PORT_CAP_READ | SND_SEQ_PORT_CAP_SUBS_READ;
|
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) {
|
if (0 <= (err = snd_seq_create_simple_port (seq, req.tagname, caps, SND_SEQ_PORT_TYPE_MIDI_GENERIC))) {
|
||||||
|
|
||||||
port_id = err;
|
port_id = err;
|
||||||
|
|
||||||
snd_seq_ev_clear (&SEv);
|
snd_seq_ev_clear (&SEv);
|
||||||
snd_seq_ev_set_source (&SEv, port_id);
|
snd_seq_ev_set_source (&SEv, port_id);
|
||||||
snd_seq_ev_set_subs (&SEv);
|
snd_seq_ev_set_subs (&SEv);
|
||||||
snd_seq_ev_set_direct (&SEv);
|
snd_seq_ev_set_direct (&SEv);
|
||||||
} else
|
|
||||||
snd_seq_close (seq);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return err;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -49,12 +49,14 @@ class ALSA_SequencerMidiPort : public Port
|
|||||||
int read (byte *buf, size_t max);
|
int read (byte *buf, size_t max);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
snd_seq_t *seq;
|
|
||||||
snd_midi_event_t *decoder, *encoder;
|
snd_midi_event_t *decoder, *encoder;
|
||||||
int port_id;
|
int port_id;
|
||||||
snd_seq_event_t SEv;
|
snd_seq_event_t SEv;
|
||||||
|
|
||||||
int CreatePorts(PortRequest &req);
|
int CreatePorts(PortRequest &req);
|
||||||
|
|
||||||
|
static int init_client (std::string name);
|
||||||
|
static snd_seq_t* seq;
|
||||||
};
|
};
|
||||||
|
|
||||||
}; /* namespace MIDI */
|
}; /* namespace MIDI */
|
||||||
|
Loading…
Reference in New Issue
Block a user