diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2019-12-05 15:34:51 -0700 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2019-12-07 10:30:38 -0700 |
commit | 1008ac20ffcf4a88420c5c5a9a0b2396cca04f20 (patch) | |
tree | 213f108dca423b4618fcd20f0428c355ad5e1252 /libs/ardour/disk_io.cc | |
parent | 8d05f6d4b788d2f100eb309965d398adc4198045 (diff) |
a few parameter changes, and flesh out code to switch rbufs in DiskReader
Diffstat (limited to 'libs/ardour/disk_io.cc')
-rw-r--r-- | libs/ardour/disk_io.cc | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/libs/ardour/disk_io.cc b/libs/ardour/disk_io.cc index cd41f78505..9ac0d58750 100644 --- a/libs/ardour/disk_io.cc +++ b/libs/ardour/disk_io.cc @@ -324,8 +324,8 @@ DiskIOProcessor::use_playlist (DataType dt, boost::shared_ptr<Playlist> playlist } DiskIOProcessor::ChannelInfo::ChannelInfo (samplecnt_t bufsize) - : current_rbuf (0) - , read_switch_rbuf (0) + : _process_rbuf (0) + , _switch_rbuf (0) , wbuf (0) , capture_transition_buf (0) , curr_capture_cnt (0) @@ -347,11 +347,41 @@ DiskIOProcessor::ChannelInfo::~ChannelInfo () } PlaybackBuffer<Sample>* -DiskIOProcessor::ChannelInfo::rbuf() +DiskIOProcessor::ChannelInfo::process_rbuf() { - return _rbuf[0]; + return _rbuf[g_atomic_int_get (&_process_rbuf)]; } +PlaybackBuffer<Sample>* +DiskIOProcessor::ChannelInfo::other_rbuf() +{ + return _rbuf[!g_atomic_int_get (&_process_rbuf)]; +} + +void +DiskIOProcessor::ChannelInfo::maybe_switch_rbuf () +{ + if (!g_atomic_int_get (&_switch_rbuf)) { + return; + } + + while (true) { + gint current_process_rbuf = g_atomic_int_get (&_process_rbuf); + + if (g_atomic_int_compare_and_exchange (&_process_rbuf, current_process_rbuf, !_process_rbuf)) { + g_atomic_int_set (&_switch_rbuf, 0); + break; + } + } +} + +void +DiskIOProcessor::ChannelInfo::queue_switch_rbuf () +{ + g_atomic_int_set (&_switch_rbuf, 1); +} + + void DiskIOProcessor::drop_track () { |