2008-06-02 17:41:35 -04:00
|
|
|
/*
|
|
|
|
Copyright (C) 2006 Paul Davis
|
|
|
|
Written by Dave Robillard
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
$Id: jack.h 4 2005-05-13 20:47:18Z taybin $
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __jack_midiport_h__
|
|
|
|
#define __jack_midiport_h__
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include <glibmm/thread.h>
|
|
|
|
|
|
|
|
#include <jack/jack.h>
|
|
|
|
#include <jack/midiport.h>
|
2009-12-08 22:05:14 -05:00
|
|
|
|
|
|
|
#include "pbd/ringbuffer.h"
|
2009-12-29 16:31:14 -05:00
|
|
|
#include "pbd/signals.h"
|
2009-12-08 22:05:14 -05:00
|
|
|
#include "pbd/crossthread.h"
|
|
|
|
#include "evoral/EventRingBuffer.hpp"
|
|
|
|
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "midi++/port.h"
|
|
|
|
#include "midi++/event.h"
|
2008-06-02 17:41:35 -04:00
|
|
|
|
|
|
|
namespace MIDI
|
|
|
|
{
|
|
|
|
|
|
|
|
class JACK_MidiPort : public Port
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
JACK_MidiPort (const XMLNode& node, jack_client_t* jack_client);
|
|
|
|
virtual ~JACK_MidiPort ();
|
|
|
|
|
|
|
|
int write(byte *msg, size_t msglen, timestamp_t timestamp);
|
|
|
|
int read(byte *buf, size_t max);
|
|
|
|
|
2009-12-08 22:05:14 -05:00
|
|
|
int selectable() const { return xthread.selectable(); }
|
|
|
|
bool must_drain_selectable() const { return true; }
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2009-12-08 22:05:14 -05:00
|
|
|
void cycle_start(nframes_t nframes);
|
|
|
|
void cycle_end();
|
2008-06-02 17:41:35 -04:00
|
|
|
|
|
|
|
static std::string typestring;
|
|
|
|
|
2009-12-08 22:05:14 -05:00
|
|
|
XMLNode& get_state () const;
|
|
|
|
void set_state (const XMLNode&);
|
2008-06-02 17:41:35 -04:00
|
|
|
|
|
|
|
static void set_process_thread (pthread_t);
|
2008-10-25 04:28:10 -04:00
|
|
|
static pthread_t get_process_thread () { return _process_thread; }
|
|
|
|
static bool is_process_thread();
|
|
|
|
|
2008-11-29 00:40:17 -05:00
|
|
|
nframes_t nframes_this_cycle() const { return _nframes_this_cycle; }
|
2009-12-29 16:31:14 -05:00
|
|
|
|
|
|
|
static PBD::Signal0<void> MakeConnections;
|
|
|
|
static PBD::Signal0<void> JackHalted;
|
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
protected:
|
|
|
|
std::string get_typestring () const {
|
|
|
|
return typestring;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
int create_ports(const XMLNode&);
|
|
|
|
|
|
|
|
jack_client_t* _jack_client;
|
|
|
|
jack_port_t* _jack_input_port;
|
|
|
|
jack_port_t* _jack_output_port;
|
|
|
|
nframes_t _last_read_index;
|
|
|
|
timestamp_t _last_write_timestamp;
|
2009-12-08 22:05:14 -05:00
|
|
|
CrossThreadChannel xthread;
|
2009-12-29 16:31:14 -05:00
|
|
|
std::string _inbound_connections;
|
|
|
|
std::string _outbound_connections;
|
|
|
|
PBD::Connection connect_connection;
|
|
|
|
PBD::Connection halt_connection;
|
2008-06-02 17:41:35 -04:00
|
|
|
void flush (void* jack_port_buffer);
|
2009-12-29 16:31:14 -05:00
|
|
|
void jack_halted ();
|
|
|
|
void make_connections();
|
2008-06-02 17:41:35 -04:00
|
|
|
|
|
|
|
static pthread_t _process_thread;
|
|
|
|
|
2009-12-08 22:05:14 -05:00
|
|
|
RingBuffer< Evoral::Event<double> > output_fifo;
|
|
|
|
Evoral::EventRingBuffer<timestamp_t> input_fifo;
|
|
|
|
|
|
|
|
Glib::Mutex output_fifo_lock;
|
2008-06-02 17:41:35 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} /* namespace MIDI */
|
|
|
|
|
|
|
|
#endif // __jack_midiport_h__
|
|
|
|
|