#include <exception>
#include <string>
-
#include <glibmm/thread.h>
#include "pbd/rcu.h"
#include "ardour/data_type.h"
#include "ardour/session_handle.h"
#include "ardour/types.h"
+#include "ardour/chan_count.h"
#ifdef HAVE_JACK_SESSION
#include <jack/session.h>
class MidiPort;
class Port;
class Session;
+class ProcessThread;
class AudioEngine : public SessionHandlePtr
{
public:
typedef std::set<Port*> Ports;
+ class disconnected_exception : public std::exception {
+ public:
+ virtual const char *what() const throw() { return "AudioEngine is disconnected"; }
+ };
+
AudioEngine (std::string client_name, std::string session_uuid);
virtual ~AudioEngine ();
bool is_realtime () const;
+ ProcessThread* main_thread() const { return _main_thread; }
+
std::string client_name() const { return jack_client_name; }
int reconnect_to_jack ();
class PortRegistrationFailure : public std::exception {
public:
- PortRegistrationFailure (const char* why = "") {
- reason = why;
- }
- virtual const char *what() const throw() { return reason; }
+ PortRegistrationFailure (std::string const & why = "")
+ : reason (why) {}
+
+ ~PortRegistrationFailure () throw () {}
+
+ virtual const char *what() const throw () { return reason.c_str(); }
private:
- const char* reason;
+ std::string reason;
};
class NoBackendAvailable : public std::exception {
bool can_request_hardware_monitoring ();
- uint32_t n_physical_outputs (DataType type) const;
- uint32_t n_physical_inputs (DataType type) const;
+ ChanCount n_physical_outputs () const;
+ ChanCount n_physical_inputs () const;
void get_physical_outputs (DataType type, std::vector<std::string>&);
void get_physical_inputs (DataType type, std::vector<std::string>&);
- std::string get_nth_physical_output (DataType type, uint32_t n) {
- return get_nth_physical (type, n, JackPortIsInput);
- }
-
- std::string get_nth_physical_input (DataType type, uint32_t n) {
- return get_nth_physical (type, n, JackPortIsOutput);
- }
-
void update_total_latencies ();
void update_total_latency (const Port&);
Port *get_port_by_name (const std::string &);
- Port *get_port_by_name_locked (const std::string &);
enum TransportState {
TransportStopped = JackTransportStopped,
/* this signal is sent if JACK ever disconnects us */
- PBD::Signal0<void> Halted;
+ PBD::Signal1<void,const char*> Halted;
/* these two are emitted when the engine itself is
started and stopped
static AudioEngine* instance() { return _instance; }
void died ();
+ int create_process_thread (boost::function<void()>, pthread_t*, size_t stacksize);
+
private:
static AudioEngine* _instance;
Port *register_port (DataType type, const std::string& portname, bool input);
int process_callback (nframes_t nframes);
+ void* process_thread ();
+ void finish_process_cycle (int status);
void remove_all_ports ();
- std::string get_nth_physical (DataType type, uint32_t n, int flags);
+ ChanCount n_physical (unsigned long) const;
+ void get_physical (DataType, unsigned long, std::vector<std::string> &);
void port_registration_failure (const std::string& portname);
#endif
static int _graph_order_callback (void *arg);
static int _process_callback (nframes_t nframes, void *arg);
+ static void* _process_thread (void *arg);
static int _sample_rate_callback (nframes_t nframes, void *arg);
static int _bufsize_callback (nframes_t nframes, void *arg);
static void _jack_timebase_callback (jack_transport_state_t, nframes_t, jack_position_t*, int, void*);
int connect_to_jack (std::string client_name, std::string session_uuid);
static void halted (void *);
+ static void halted_info (jack_status_t,const char*,void *);
void meter_thread ();
void start_metering_thread ();
Glib::Thread* m_meter_thread;
static gint m_meter_exit;
+
+ ProcessThread* _main_thread;
+
+ struct ThreadData {
+ AudioEngine* engine;
+ boost::function<void()> f;
+ size_t stacksize;
+
+ ThreadData (AudioEngine* ae, boost::function<void()> fp, size_t stacksz)
+ : engine (ae) , f (fp) , stacksize (stacksz) {}
+ };
+
+ static void* _start_process_thread (void*);
};
} // namespace ARDOUR