Ardour  9.0-pre0-350-gf17a656217
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 #pragma once
24 
25 #include <atomic>
26 
27 #include <pthread.h>
28 
29 #include <glibmm/threads.h>
30 
31 #include "pbd/crossthread.h"
32 #include "pbd/pool.h"
33 #include "pbd/ringbuffer.h"
34 #include "pbd/mpmc_queue.h"
35 
37 #include "ardour/session_handle.h"
38 #include "ardour/types.h"
39 
40 namespace ARDOUR
41 {
50 {
51 public:
53  ~Butler ();
54 
55  int start_thread ();
58  void summon ();
59  void stop ();
61  bool transport_work_requested () const;
62  void drop_references ();
63 
64  void map_parameters ();
65 
66  bool delegate (sigc::slot<void> const& work) {
67  bool rv = _delegated_work.push_back (work);
68  summon ();
69  return rv;
70  }
72  {
73  return _audio_capture_buffer_size;
74  }
76  {
77  return _audio_playback_buffer_size;
78  }
79  uint32_t midi_buffer_size () const
80  {
81  return _midi_buffer_size;
82  }
83 
84  mutable std::atomic<int> should_do_transport_work;
85 
86 private:
87  struct Request {
88  enum Type {
89  Run,
91  Quit
92  };
93  };
94 
95 
96  static void* _thread_work (void* arg);
97 
98  void* thread_work ();
99 
102  void config_changed (std::string);
103  bool flush_tracks_to_disk_normal (std::shared_ptr<RouteList const>, uint32_t& errors);
105 
106  pthread_t thread;
108 
109  Glib::Threads::Mutex request_lock;
110  Glib::Threads::Cond paused;
112 
116 
120 };
121 
122 } // namespace ARDOUR
123 
pthread_t thread
Definition: butler.h:106
void terminate_thread()
uint32_t _midi_buffer_size
Definition: butler.h:115
PBD::MPMCQueue< sigc::slot< void > > _delegated_work
Definition: butler.h:119
void schedule_transport_work()
void wait_until_finished()
bool transport_work_requested() const
bool should_run
Definition: butler.h:111
void drop_references()
static void * _thread_work(void *arg)
void process_delegated_work()
void * thread_work()
bool have_thread
Definition: butler.h:107
void empty_pool_trash()
void map_parameters()
Glib::Threads::Mutex request_lock
Definition: butler.h:109
samplecnt_t _audio_capture_buffer_size
Definition: butler.h:113
Butler(Session &session)
void config_changed(std::string)
samplecnt_t audio_capture_buffer_size() const
Definition: butler.h:71
uint32_t midi_buffer_size() const
Definition: butler.h:79
bool flush_tracks_to_disk_normal(std::shared_ptr< RouteList const >, uint32_t &errors)
samplecnt_t audio_playback_buffer_size() const
Definition: butler.h:75
samplecnt_t _audio_playback_buffer_size
Definition: butler.h:114
Glib::Threads::Cond paused
Definition: butler.h:110
std::atomic< int > should_do_transport_work
Definition: butler.h:84
bool delegate(sigc::slot< void > const &work)
Definition: butler.h:66
CrossThreadChannel _xthread
Definition: butler.h:118
PBD::RingBuffer< PBD::CrossThreadPool * > pool_trash
Definition: butler.h:117
void queue_request(Request::Type r)
#define LIBARDOUR_API
void session(lua_State *L)
Temporal::samplecnt_t samplecnt_t