move ChannelInfo structure from DiskReader into DiskIOProcessor

This commit is contained in:
Paul Davis 2017-03-08 19:46:24 +01:00
parent 7fb6807ed3
commit bcd7a21510
4 changed files with 97 additions and 91 deletions

View file

@ -24,6 +24,10 @@
#include <string>
#include <exception>
#include "pbd/ringbufferNPT.h"
#include "pbd/rcu.h"
#include "ardour/interpolation.h"
#include "ardour/processor.h"
namespace ARDOUR {
@ -85,6 +89,9 @@ class LIBARDOUR_API DiskIOProcessor : public Processor
int set_state (const XMLNode&, int version);
int add_channel (uint32_t how_many);
int remove_channel (uint32_t how_many);
protected:
friend class Auditioner;
virtual int seek (framepos_t which_sample, bool complete_refill = false) = 0;
@ -115,6 +122,43 @@ class LIBARDOUR_API DiskIOProcessor : public Processor
framecnt_t& write_buffer_size);
virtual void allocate_temporary_buffers () = 0;
/** Information about one audio channel, playback or capture
* (depending on the derived class)
*/
struct ChannelInfo : public boost::noncopyable {
ChannelInfo (framecnt_t buffer_size,
framecnt_t speed_buffer_size,
framecnt_t wrap_buffer_size);
~ChannelInfo ();
Sample *wrap_buffer;
Sample *speed_buffer;
Sample *current_buffer;
/** A ringbuffer for data to be played back, written to in the
butler thread, read from in the process thread.
*/
PBD::RingBufferNPT<Sample>* buf;
Sample* scrub_buffer;
Sample* scrub_forward_buffer;
Sample* scrub_reverse_buffer;
PBD::RingBufferNPT<Sample>::rw_vector read_vector;
void resize (framecnt_t);
};
typedef std::vector<ChannelInfo*> ChannelList;
SerializedRCUManager<ChannelList> channels;
int add_channel_to (boost::shared_ptr<ChannelList>, uint32_t how_many);
int remove_channel_from (boost::shared_ptr<ChannelList>, uint32_t how_many);
CubicInterpolation interpolation;
};
} // namespace ARDOUR

View file

@ -20,11 +20,7 @@
#ifndef __ardour_disk_reader_h__
#define __ardour_disk_reader_h__
#include "pbd/ringbufferNPT.h"
#include "pbd/rcu.h"
#include "ardour/disk_io.h"
#include "ardour/interpolation.h"
#include "ardour/midi_buffer.h"
namespace ARDOUR
@ -110,9 +106,6 @@ class LIBARDOUR_API DiskReader : public DiskIOProcessor
int can_internal_playback_seek (framecnt_t distance);
int seek (framepos_t frame, bool complete_refill = false);
int add_channel (uint32_t how_many);
int remove_channel (uint32_t how_many);
bool need_butler() const { return _need_butler; }
PBD::Signal0<void> Underrun;
@ -166,36 +159,6 @@ class LIBARDOUR_API DiskReader : public DiskIOProcessor
gint _frames_written_to_ringbuffer;
gint _frames_read_from_ringbuffer;
/** Information about one of our channels */
struct ChannelInfo : public boost::noncopyable {
ChannelInfo (framecnt_t buffer_size,
framecnt_t speed_buffer_size,
framecnt_t wrap_buffer_size);
~ChannelInfo ();
Sample *wrap_buffer;
Sample *speed_buffer;
Sample *current_buffer;
/** A ringbuffer for data to be played back, written to in the
butler thread, read from in the process thread.
*/
PBD::RingBufferNPT<Sample>* buf;
Sample* scrub_buffer;
Sample* scrub_forward_buffer;
Sample* scrub_reverse_buffer;
PBD::RingBufferNPT<Sample>::rw_vector read_vector;
void resize (framecnt_t);
};
typedef std::vector<ChannelInfo*> ChannelList;
SerializedRCUManager<ChannelList> channels;
CubicInterpolation interpolation;
int audio_read (Sample* buf, Sample* mixdown_buffer, float* gain_buffer,
framepos_t& start, framecnt_t cnt,
@ -209,9 +172,6 @@ class LIBARDOUR_API DiskReader : public DiskIOProcessor
int refill_audio (Sample *mixdown_buffer, float *gain_buffer, framecnt_t fill_level);
int refill_midi ();
int add_channel_to (boost::shared_ptr<ChannelList>, uint32_t how_many);
int remove_channel_from (boost::shared_ptr<ChannelList>, uint32_t how_many);
int internal_playback_seek (framecnt_t distance);
frameoffset_t calculate_playback_distance (pframes_t);

View file

@ -20,11 +20,12 @@
#include "pbd/error.h"
#include "pbd/i18n.h"
#include "ardour/rc_configuration.h"
#include "ardour/butler.h"
#include "ardour/disk_io.h"
#include "ardour/disk_reader.h"
#include "ardour/disk_writer.h"
#include "ardour/location.h"
#include "ardour/rc_configuration.h"
#include "ardour/session.h"
using namespace ARDOUR;
@ -51,6 +52,7 @@ DiskIOProcessor::DiskIOProcessor (Session& s, string const & str, Flag f)
, in_set_state (false)
, wrap_buffer_size (0)
, speed_buffer_size (0)
, channels (new ChannelList)
{
}
@ -203,3 +205,53 @@ DiskIOProcessor::set_state (const XMLNode& node, int version)
}
return 0;
}
int
DiskIOProcessor::add_channel_to (boost::shared_ptr<ChannelList> c, uint32_t how_many)
{
while (how_many--) {
c->push_back (new ChannelInfo(
_session.butler()->audio_diskstream_playback_buffer_size(),
speed_buffer_size, wrap_buffer_size));
interpolation.add_channel_to (
_session.butler()->audio_diskstream_playback_buffer_size(),
speed_buffer_size);
}
_n_channels.set (DataType::AUDIO, c->size());
return 0;
}
int
DiskIOProcessor::add_channel (uint32_t how_many)
{
RCUWriter<ChannelList> writer (channels);
boost::shared_ptr<ChannelList> c = writer.get_copy();
return add_channel_to (c, how_many);
}
int
DiskIOProcessor::remove_channel_from (boost::shared_ptr<ChannelList> c, uint32_t how_many)
{
while (how_many-- && !c->empty()) {
delete c->back();
c->pop_back();
interpolation.remove_channel_from ();
}
_n_channels.set(DataType::AUDIO, c->size());
return 0;
}
int
DiskIOProcessor::remove_channel (uint32_t how_many)
{
RCUWriter<ChannelList> writer (channels);
boost::shared_ptr<ChannelList> c = writer.get_copy();
return remove_channel_from (c, how_many);
}

View file

@ -54,7 +54,6 @@ DiskReader::DiskReader (Session& s, string const & str, DiskIOProcessor::Flag f)
, _gui_feed_buffer (AudioEngine::instance()->raw_buffer_size (DataType::MIDI))
, _frames_written_to_ringbuffer (0)
, _frames_read_from_ringbuffer (0)
, channels (new ChannelList)
{
}
@ -232,55 +231,6 @@ DiskReader::set_loop (Location *location)
return 0;
}
int
DiskReader::add_channel_to (boost::shared_ptr<ChannelList> c, uint32_t how_many)
{
while (how_many--) {
c->push_back (new ChannelInfo(
_session.butler()->audio_diskstream_playback_buffer_size(),
speed_buffer_size, wrap_buffer_size));
interpolation.add_channel_to (
_session.butler()->audio_diskstream_playback_buffer_size(),
speed_buffer_size);
}
_n_channels.set (DataType::AUDIO, c->size());
return 0;
}
int
DiskReader::add_channel (uint32_t how_many)
{
RCUWriter<ChannelList> writer (channels);
boost::shared_ptr<ChannelList> c = writer.get_copy();
return add_channel_to (c, how_many);
}
int
DiskReader::remove_channel_from (boost::shared_ptr<ChannelList> c, uint32_t how_many)
{
while (how_many-- && !c->empty()) {
delete c->back();
c->pop_back();
interpolation.remove_channel_from ();
}
_n_channels.set(DataType::AUDIO, c->size());
return 0;
}
int
DiskReader::remove_channel (uint32_t how_many)
{
RCUWriter<ChannelList> writer (channels);
boost::shared_ptr<ChannelList> c = writer.get_copy();
return remove_channel_from (c, how_many);
}
float
DiskReader::buffer_load () const
{