20 #ifndef __ardour_audioengine_h__
21 #define __ardour_audioengine_h__
24 #include "libardour-config.h"
34 #include <glibmm/threads.h>
58 struct AudioBackendInfo;
68 int discover_backends();
69 std::vector<const AudioBackendInfo*> available_backends()
const;
70 std::string current_backend_name ()
const;
74 bool setup_required ()
const;
84 int start (
bool for_latency_measurement=
false);
85 int stop (
bool for_latency_measurement=
false);
86 int freewheel (
bool start_stop);
87 float get_dsp_load()
const ;
88 void transport_start ();
89 void transport_stop ();
95 int usecs_per_cycle ()
const;
100 bool get_sync_offset (
pframes_t& offset)
const;
102 int create_process_thread (boost::function<
void()> func);
103 int join_process_threads ();
104 bool in_process_thread ();
105 uint32_t process_thread_count ();
107 int backend_reset_requested();
108 void request_backend_reset();
109 void request_device_list_update();
110 void launch_device_control_app();
112 bool is_realtime()
const;
113 bool connected()
const;
116 bool is_reset_requested()
const {
return g_atomic_int_get(const_cast<gint*>(&_hw_reset_request_count)); }
118 int set_device_name (
const std::string&);
119 int set_sample_rate (
float);
120 int set_buffer_size (uint32_t);
121 int set_interleaved (
bool yn);
122 int set_input_channels (uint32_t);
123 int set_output_channels (uint32_t);
124 int set_systemic_input_latency (uint32_t);
125 int set_systemic_output_latency (uint32_t);
133 Glib::Threads::RecMutex&
state_lock() {
return _state_lock; }
136 return set_buffer_size (samples);
142 void remove_session ();
145 void reconnect_session_routes (
bool reconnect_inputs =
true,
bool reconnect_outputs =
true);
149 virtual const char *
what()
const throw() {
return "could not connect to engine backend"; }
154 int reset_timebase ();
156 void update_latencies ();
197 static void destroy();
202 int process_callback (
pframes_t nframes);
203 int buffer_size_change (
pframes_t nframes);
204 int sample_rate_change (
pframes_t nframes);
205 void freewheel_callback (
bool);
208 int port_registration_callback ();
209 void latency_callback (
bool for_playback);
210 void halted_callback (
const char* reason);
213 static void thread_init_callback (
void *);
220 int prepare_for_latency_measurement ();
221 int start_latency_detection (
bool);
222 void stop_latency_detection ();
223 void set_latency_input_port (
const std::string&);
224 void set_latency_output_port (
const std::string&);
243 void reset_silence_countdown ();
291 void start_hw_event_processing();
292 void stop_hw_event_processing();
293 void do_reset_backend();
294 void do_devicelist_update();
299 void drop_backend ();
303 uint32_t _silence_hit_cnt;
framecnt_t _latency_signal_latency
gain_t session_removal_gain
Glib::Threads::Mutex _devicelist_update_lock
Glib::Threads::Cond session_removed
PBD::Signal1< int, pframes_t > Freewheel
PBD::Signal0< void > Xrun
int request_buffer_size(pframes_t samples)
bool _started_for_latency
Glib::Threads::Thread * _hw_reset_event_thread
Glib::Threads::RecMutex _state_lock
Glib::Threads::Thread * m_meter_thread
std::string _latency_output_name
boost::shared_ptr< AudioBackend > current_backend() const
bool _stopped_for_latency
gint _stop_hw_devicelist_processing
framecnt_t last_monitor_check
time of the last monitor check in frames
framecnt_t _processed_frames
the number of frames processed since start() was called
PBD::Signal0< void > DeviceListChanged
static AudioEngine * _instance
LatencyMeasurement measuring_latency() const
LIBARDOUR_API PBD::PropertyDescriptor< framepos_t > start
framecnt_t monitor_check_interval
number of frames between each check for changes in monitor input
static AudioEngine * instance()
bool is_reset_requested() const
PBD::Signal0< void > DeviceResetFinished
gint _hw_devicelist_update_count
frameoffset_t session_removal_countdown
ProcessThread * main_thread() const
framecnt_t processed_frames() const
ProcessThread * _main_thread
framecnt_t _latency_flush_frames
std::map< std::string, AudioBackendInfo * > BackendMap
Glib::Threads::Cond _hw_reset_condition
Glib::Threads::Thread * _hw_devicelist_update_thread
gint _stop_hw_reset_processing
Glib::Threads::Mutex _process_lock
PortEngine::PortHandle _latency_input_port
PBD::Signal1< void, framecnt_t > SampleRateChanged
gint _hw_reset_request_count
PBD::Signal0< void > BecameSilent
Glib::Threads::Mutex _reset_request_lock
PBD::Signal0< void > Running
PBD::Signal0< void > DeviceResetStarted
Session * session() const
Glib::Threads::Mutex & process_lock()
bool freewheeling() const
PortEngine::PortHandle _latency_output_port
Glib::Threads::RecMutex & state_lock()
Glib::Threads::Cond _hw_devicelist_update_condition
LIBARDOUR_API PBD::PropertyDescriptor< framepos_t > position
PBD::Signal0< void > DeviceError
PBD::Signal1< void, pframes_t > BufferSizeChanged
virtual const char * what() const
std::string _latency_input_name
PBD::Signal1< void, const char * > Halted
PBD::Signal0< void > Stopped
LIBARDOUR_API uint64_t AudioEngine
bool session_remove_pending
LatencyMeasurement _measuring_latency
uint32_t latency_signal_delay() const
gain_t session_removal_gain_step