ardour
session_butler.cc
Go to the documentation of this file.
1 /*
2  Copyright (C) 1999-2002 Paul Davis
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 
18 */
19 
20 #include "pbd/error.h"
21 #include "pbd/pthread_utils.h"
22 #include "pbd/stacktrace.h"
23 
24 #include "ardour/butler.h"
25 #include "ardour/route.h"
26 #include "ardour/session.h"
27 #include "ardour/session_event.h"
28 #include "ardour/track.h"
29 #include "ardour/types.h"
30 
31 #include "i18n.h"
32 
33 using namespace std;
34 using namespace ARDOUR;
35 using namespace PBD;
36 
37 /*---------------------------------------------------------------------------
38  BUTLER THREAD
39  ---------------------------------------------------------------------------*/
40 
41 void
42 Session::adjust_playback_buffering ()
43 {
44  request_stop (false, false);
45  SessionEvent *ev = new SessionEvent (SessionEvent::AdjustPlaybackBuffering, SessionEvent::Add, SessionEvent::Immediate, 0, 0, 0.0);
46  queue_event (ev);
47 }
48 
49 void
50 Session::adjust_capture_buffering ()
51 {
52  request_stop (false, false);
53  SessionEvent *ev = new SessionEvent (SessionEvent::AdjustCaptureBuffering, SessionEvent::Add, SessionEvent::Immediate, 0, 0, 0.0);
54  queue_event (ev);
55 }
56 
57 void
58 Session::schedule_playback_buffering_adjustment ()
59 {
60  add_post_transport_work (PostTransportAdjustPlaybackBuffering);
61  _butler->schedule_transport_work ();
62 }
63 
64 void
65 Session::schedule_capture_buffering_adjustment ()
66 {
67  add_post_transport_work (PostTransportAdjustCaptureBuffering);
68  _butler->schedule_transport_work ();
69 }
70 
71 void
72 Session::schedule_curve_reallocation ()
73 {
74  add_post_transport_work (PostTransportCurveRealloc);
75  _butler->schedule_transport_work ();
76 }
77 
78 void
79 Session::request_overwrite_buffer (Track* t)
80 {
81  SessionEvent *ev = new SessionEvent (SessionEvent::Overwrite, SessionEvent::Add, SessionEvent::Immediate, 0, 0, 0.0);
82  ev->set_ptr (t);
83  queue_event (ev);
84 }
85 
87 void
88 Session::overwrite_some_buffers (Track* t)
89 {
90  if (actively_recording()) {
91  return;
92  }
93 
94  if (t) {
95 
96  t->set_pending_overwrite (true);
97 
98  } else {
99 
100  boost::shared_ptr<RouteList> rl = routes.reader();
101  for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
103  if (tr) {
104  tr->set_pending_overwrite (true);
105  }
106  }
107  }
108 
109  add_post_transport_work (PostTransportOverWrite);
110  _butler->schedule_transport_work ();
111 }
112 
113 uint32_t
114 Session::playback_load ()
115 {
116  return (uint32_t) g_atomic_int_get (&_playback_load);
117 }
118 
119 uint32_t
120 Session::capture_load ()
121 {
122  return (uint32_t) g_atomic_int_get (&_capture_load);
123 }
shared_ptr< T > dynamic_pointer_cast(shared_ptr< U > const &r)
Definition: shared_ptr.hpp:396
void set_ptr(void *p)
Definition: Beats.hpp:239
Definition: amp.h:29
void set_pending_overwrite(bool)
Definition: track.cc:662
Definition: debug.h:30