2008-06-02 17:41:35 -04:00
|
|
|
/*
|
2009-10-14 12:10:01 -04:00
|
|
|
Copyright (C) 2006 Paul Davis
|
2008-06-02 17:41:35 -04:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <cassert>
|
2011-03-07 14:06:42 -05:00
|
|
|
|
|
|
|
#include "pbd/stacktrace.h"
|
|
|
|
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "ardour/audio_port.h"
|
|
|
|
#include "ardour/audioengine.h"
|
|
|
|
#include "ardour/data_type.h"
|
|
|
|
#include "ardour/audio_buffer.h"
|
2008-06-02 17:41:35 -04:00
|
|
|
|
|
|
|
using namespace ARDOUR;
|
|
|
|
using namespace std;
|
|
|
|
|
2009-02-10 19:58:24 -05:00
|
|
|
AudioPort::AudioPort (const std::string& name, Flags flags)
|
|
|
|
: Port (name, DataType::AUDIO, flags)
|
|
|
|
, _buffer (new AudioBuffer (0))
|
2008-06-02 17:41:35 -04:00
|
|
|
{
|
2009-01-20 21:27:21 -05:00
|
|
|
assert (name.find_first_of (':') == string::npos);
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
|
2009-02-10 19:58:24 -05:00
|
|
|
AudioPort::~AudioPort ()
|
2008-06-02 17:41:35 -04:00
|
|
|
{
|
2009-01-20 21:27:21 -05:00
|
|
|
delete _buffer;
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-12-03 17:26:29 -05:00
|
|
|
AudioPort::cycle_start (pframes_t nframes)
|
2008-06-02 17:41:35 -04:00
|
|
|
{
|
|
|
|
/* caller must hold process lock */
|
|
|
|
|
2011-03-10 21:55:52 -05:00
|
|
|
Port::cycle_start (nframes);
|
|
|
|
|
2009-04-23 13:48:37 -04:00
|
|
|
if (sends_output()) {
|
|
|
|
_buffer->prepare ();
|
2009-01-30 02:40:13 -05:00
|
|
|
}
|
2009-04-23 13:48:37 -04:00
|
|
|
}
|
2009-01-30 02:40:13 -05:00
|
|
|
|
2009-04-23 13:48:37 -04:00
|
|
|
void
|
2011-09-30 13:55:14 -04:00
|
|
|
AudioPort::cycle_end (pframes_t)
|
2009-04-23 13:48:37 -04:00
|
|
|
{
|
2011-03-07 14:06:42 -05:00
|
|
|
if (sends_output() && !_buffer->written()) {
|
2011-06-01 12:50:12 -04:00
|
|
|
/* we can't use nframes here because the current buffer capacity may
|
2011-03-07 17:13:53 -05:00
|
|
|
be shorter than the full buffer size if we split the cycle.
|
|
|
|
*/
|
2011-03-14 14:41:35 -04:00
|
|
|
if (_buffer->capacity () > 0) {
|
|
|
|
_buffer->silence (_buffer->capacity());
|
|
|
|
}
|
2009-01-20 21:27:21 -05:00
|
|
|
}
|
2008-10-08 16:14:22 -04:00
|
|
|
}
|
|
|
|
|
2009-04-23 13:48:37 -04:00
|
|
|
void
|
|
|
|
AudioPort::cycle_split ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
AudioBuffer&
|
2011-03-10 21:55:52 -05:00
|
|
|
AudioPort::get_audio_buffer (pframes_t nframes)
|
2009-01-20 21:27:21 -05:00
|
|
|
{
|
|
|
|
/* caller must hold process lock */
|
2011-06-01 12:50:12 -04:00
|
|
|
_buffer->set_data ((Sample *) jack_port_get_buffer (_jack_port, _cycle_nframes) +
|
2011-03-10 21:55:52 -05:00
|
|
|
_global_port_buffer_offset + _port_buffer_offset, nframes);
|
2008-10-08 16:14:22 -04:00
|
|
|
return *_buffer;
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
|
2011-05-29 13:33:41 -04:00
|
|
|
|
2009-05-04 11:50:51 -04:00
|
|
|
|