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