Ardour  8.12
butler.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2009-2011 David Robillard <d@drobilla.net>
3  * Copyright (C) 2009-2017 Paul Davis <paul@linuxaudiosystems.com>
4  * Copyright (C) 2010-2012 Carl Hetherington <carl@carlh.net>
5  * Copyright (C) 2013 John Emmas <john@creativepost.co.uk>
6  * Copyright (C) 2015-2017 Robin Gareus <robin@gareus.org>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22 
23 #ifndef __ardour_butler_h__
24 #define __ardour_butler_h__
25 
26 #include <atomic>
27 
28 #include <pthread.h>
29 
30 #include <glibmm/threads.h>
31 
32 #include "pbd/crossthread.h"
33 #include "pbd/pool.h"
34 #include "pbd/ringbuffer.h"
35 #include "pbd/mpmc_queue.h"
36 
38 #include "ardour/session_handle.h"
39 #include "ardour/types.h"
40 
41 namespace ARDOUR
42 {
51 {
52 public:
54  ~Butler ();
55 
56  int start_thread ();
59  void summon ();
60  void stop ();
62  bool transport_work_requested () const;
63  void drop_references ();
64 
65  void map_parameters ();
66 
67  bool delegate (sigc::slot<void> const& work) {
68  bool rv = _delegated_work.push_back (work);
69  summon ();
70  return rv;
71  }
73  {
74  return _audio_capture_buffer_size;
75  }
77  {
78  return _audio_playback_buffer_size;
79  }
80  uint32_t midi_buffer_size () const
81  {
82  return _midi_buffer_size;
83  }
84 
85  mutable std::atomic<int> should_do_transport_work;
86 
87 private:
88  struct Request {
89  enum Type {
90  Run,
92  Quit
93  };
94  };
95 
96 
97  static void* _thread_work (void* arg);
98 
99  void* thread_work ();
100 
103  void config_changed (std::string);
104  bool flush_tracks_to_disk_normal (std::shared_ptr<RouteList const>, uint32_t& errors);
106 
107  pthread_t thread;
109 
110  Glib::Threads::Mutex request_lock;
111  Glib::Threads::Cond paused;
113 
117 
121 };
122 
123 } // namespace ARDOUR
124 
125 #endif // __ardour_butler_h__
pthread_t thread
Definition: butler.h:107
void terminate_thread()
uint32_t _midi_buffer_size
Definition: butler.h:116
PBD::MPMCQueue< sigc::slot< void > > _delegated_work
Definition: butler.h:120
void schedule_transport_work()
void wait_until_finished()
bool transport_work_requested() const
bool should_run
Definition: butler.h:112
void drop_references()
static void * _thread_work(void *arg)
void process_delegated_work()
void * thread_work()
bool have_thread
Definition: butler.h:108
void empty_pool_trash()
void map_parameters()
Glib::Threads::Mutex request_lock
Definition: butler.h:110
samplecnt_t _audio_capture_buffer_size
Definition: butler.h:114
Butler(Session &session)
void config_changed(std::string)
samplecnt_t audio_capture_buffer_size() const
Definition: butler.h:72
uint32_t midi_buffer_size() const
Definition: butler.h:80
bool flush_tracks_to_disk_normal(std::shared_ptr< RouteList const >, uint32_t &errors)
samplecnt_t audio_playback_buffer_size() const
Definition: butler.h:76
samplecnt_t _audio_playback_buffer_size
Definition: butler.h:115
Glib::Threads::Cond paused
Definition: butler.h:111
std::atomic< int > should_do_transport_work
Definition: butler.h:85
bool delegate(sigc::slot< void > const &work)
Definition: butler.h:67
CrossThreadChannel _xthread
Definition: butler.h:119
PBD::RingBuffer< PBD::CrossThreadPool * > pool_trash
Definition: butler.h:118
void queue_request(Request::Type r)
#define LIBARDOUR_API
void session(lua_State *L)
Temporal::samplecnt_t samplecnt_t