2 * Copyright (C) 1999-2019 Paul Davis <paul@linuxaudiosystems.com>
3 * Copyright (C) 2005-2006 Taybin Rutkin <taybin@taybin.com>
4 * Copyright (C) 2006-2014 David Robillard <d@drobilla.net>
5 * Copyright (C) 2006 Jesse Chappell <jesse@essej.net>
6 * Copyright (C) 2010-2012 Carl Hetherington <carl@carlh.net>
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.
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.
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.
23 #include "pbd/error.h"
24 #include "pbd/pthread_utils.h"
25 #include "pbd/stacktrace.h"
27 #include "ardour/butler.h"
28 #include "ardour/disk_reader.h"
29 #include "ardour/route.h"
30 #include "ardour/session.h"
31 #include "ardour/session_event.h"
32 #include "ardour/track.h"
33 #include "ardour/types.h"
38 using namespace ARDOUR;
41 /*---------------------------------------------------------------------------
43 ---------------------------------------------------------------------------*/
46 Session::adjust_playback_buffering ()
48 request_stop (false, false);
49 SessionEvent *ev = new SessionEvent (SessionEvent::AdjustPlaybackBuffering, SessionEvent::Add, SessionEvent::Immediate, 0, 0, 0.0);
54 Session::adjust_capture_buffering ()
56 request_stop (false, false);
57 SessionEvent *ev = new SessionEvent (SessionEvent::AdjustCaptureBuffering, SessionEvent::Add, SessionEvent::Immediate, 0, 0, 0.0);
62 Session::schedule_playback_buffering_adjustment ()
64 add_post_transport_work (PostTransportAdjustPlaybackBuffering);
65 DiskReader::inc_no_disk_output ();
66 _butler->schedule_transport_work ();
70 Session::schedule_capture_buffering_adjustment ()
72 add_post_transport_work (PostTransportAdjustCaptureBuffering);
73 _butler->schedule_transport_work ();
77 Session::request_overwrite_buffer (boost::shared_ptr<Route> r)
79 boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track> (r);
84 SessionEvent *ev = new SessionEvent (SessionEvent::Overwrite, SessionEvent::Add, SessionEvent::Immediate, 0, 0, 0.0);
85 ev->set_ptr (t.get());
89 /** Process thread. */
91 Session::overwrite_some_buffers (Track* t)
93 if (actively_recording()) {
99 t->set_pending_overwrite ();
103 boost::shared_ptr<RouteList> rl = routes.reader();
104 for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
105 boost::shared_ptr<Track> tr = boost::dynamic_pointer_cast<Track> (*i);
107 tr->set_pending_overwrite ();
112 add_post_transport_work (PostTransportOverWrite);
114 _butler->schedule_transport_work ();
118 Session::playback_load ()
120 return (uint32_t) g_atomic_int_get (&_playback_load);
124 Session::capture_load ()
126 return (uint32_t) g_atomic_int_get (&_capture_load);