ardour
audio_port.cc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2006 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 #include <cassert>
20 
21 #include "pbd/stacktrace.h"
22 
23 #include "ardour/audio_buffer.h"
24 #include "ardour/audioengine.h"
25 #include "ardour/audio_port.h"
26 #include "ardour/data_type.h"
27 #include "ardour/port_engine.h"
28 
29 using namespace ARDOUR;
30 using namespace std;
31 
32 #define port_engine AudioEngine::instance()->port_engine()
33 
34 AudioPort::AudioPort (const std::string& name, PortFlags flags)
35  : Port (name, DataType::AUDIO, flags)
36  , _buffer (new AudioBuffer (0))
37 {
38  assert (name.find_first_of (':') == string::npos);
39 }
40 
42 {
43  delete _buffer;
44 }
45 
46 void
48 {
49  /* caller must hold process lock */
50 
51  Port::cycle_start (nframes);
52 
53  if (sends_output()) {
54  _buffer->prepare ();
55  }
56 }
57 
58 void
60 {
61  if (sends_output() && !_buffer->written()) {
62  if (_buffer->capacity() >= nframes) {
63  _buffer->silence (nframes);
64  }
65  }
66 }
67 
68 void
70 {
71 }
72 
75 {
76  /* caller must hold process lock */
79  return *_buffer;
80 }
81 
82 Sample*
84 {
85  /* caller must hold process lock */
86  return (Sample *) port_engine.get_buffer (_port_handle, _cycle_nframes);
87 }
88 
89 
90 
91 
AudioBuffer & get_audio_buffer(pframes_t nframes)
Definition: audio_port.cc:74
AudioPort(std::string const &, PortFlags)
Definition: audio_port.cc:34
bool sends_output() const
Definition: port.h:74
uint32_t pframes_t
Definition: types.h:61
void cycle_end(pframes_t)
Definition: audio_port.cc:59
Definition: Beats.hpp:239
framecnt_t _port_buffer_offset
Definition: port.h:156
static pframes_t _cycle_nframes
Definition: port.h:154
float Sample
Definition: types.h:54
void silence(framecnt_t len, framecnt_t offset=0)
Definition: audio_buffer.cc:83
Sample * engine_get_whole_audio_buffer()
Definition: audio_port.cc:83
Definition: amp.h:29
virtual void cycle_start(pframes_t)
Definition: port.cc:283
PortFlags
Definition: types.h:610
PortEngine::PortHandle _port_handle
Definition: port.h:150
AudioBuffer * _buffer
Definition: audio_port.h:56
size_t capacity() const
Definition: buffer.h:51
bool written() const
Definition: audio_buffer.h:201
const char * name
#define port_engine
Definition: audio_port.cc:32
void set_data(Sample *data, size_t size)
Definition: audio_buffer.h:173
static pframes_t _global_port_buffer_offset
Definition: port.h:153
void cycle_start(pframes_t)
Definition: audio_port.cc:47