summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2011-01-02 12:45:20 +0000
committerCarl Hetherington <carl@carlh.net>2011-01-02 12:45:20 +0000
commite4d960b71f78f7460c56c7e4a7d325cb650502bb (patch)
tree8f5c08fb44e05e3cbbf42a826dd2bc4593f2c980 /libs
parent2cd8a5a752b19e2d529e0b52f3fba6824c5558e2 (diff)
Allow AudioDiskstream to have 0 channels without crashing. Fixes crash on record with a track with no inputs.
git-svn-id: svn://localhost/ardour2/branches/3.0@8408 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/audio_diskstream.cc31
1 files changed, 24 insertions, 7 deletions
diff --git a/libs/ardour/audio_diskstream.cc b/libs/ardour/audio_diskstream.cc
index 5abdb97b33..8428e05b39 100644
--- a/libs/ardour/audio_diskstream.cc
+++ b/libs/ardour/audio_diskstream.cc
@@ -114,9 +114,6 @@ AudioDiskstream::init ()
set_block_size (_session.get_block_size());
allocate_temporary_buffers ();
-
- add_channel (1);
- assert(_n_channels == ChanCount(DataType::AUDIO, 1));
}
AudioDiskstream::~AudioDiskstream ()
@@ -410,8 +407,7 @@ AudioDiskstream::prepare_record_status(framepos_t capture_start_frame)
transvec.buf[0]->type = CaptureStart;
transvec.buf[0]->capture_val = capture_start_frame;
(*chan)->capture_transition_buf->increment_write_ptr(1);
- }
- else {
+ } else {
// bad!
fatal << X_("programming error: capture_transition_buf is full on rec start! inconceivable!")
<< endmsg;
@@ -708,7 +704,11 @@ AudioDiskstream::commit (framecnt_t /* nframes */)
capture_captured += adjust_capture_position;
adjust_capture_position = 0;
}
-
+
+ if (c->empty()) {
+ return false;
+ }
+
if (_slaved) {
if (_io && _io->active()) {
need_butler = c->front()->playback_buf->write_space() >= c->front()->playback_buf->bufsize() / 2;
@@ -735,13 +735,22 @@ AudioDiskstream::set_pending_overwrite (bool yn)
_pending_overwrite = yn;
overwrite_frame = playback_sample;
- overwrite_offset = channels.reader()->front()->playback_buf->get_read_ptr();
+
+ boost::shared_ptr<ChannelList> c = channels.reader ();
+ if (!c->empty ()) {
+ overwrite_offset = c->front()->playback_buf->get_read_ptr();
+ }
}
int
AudioDiskstream::overwrite_existing_buffers ()
{
boost::shared_ptr<ChannelList> c = channels.reader();
+ if (c->empty ()) {
+ _pending_overwrite = false;
+ return 0;
+ }
+
Sample* mixdown_buffer;
float* gain_buffer;
int ret = -1;
@@ -2137,6 +2146,10 @@ AudioDiskstream::playback_buffer_load () const
{
boost::shared_ptr<ChannelList> c = channels.reader();
+ if (c->empty ()) {
+ return 0;
+ }
+
return (float) ((double) c->front()->playback_buf->read_space()/
(double) c->front()->playback_buf->bufsize());
}
@@ -2146,6 +2159,10 @@ AudioDiskstream::capture_buffer_load () const
{
boost::shared_ptr<ChannelList> c = channels.reader();
+ if (c->empty ()) {
+ return 0;
+ }
+
return (float) ((double) c->front()->capture_buf->write_space()/
(double) c->front()->capture_buf->bufsize());
}