summaryrefslogtreecommitdiff
path: root/libs/ardour/audio_unit.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2019-09-11 02:40:57 +0200
committerRobin Gareus <robin@gareus.org>2019-09-11 02:56:08 +0200
commit9f668ceed29b1a3b79636a8767dca36c4e1ca307 (patch)
tree837a835c27f49c34125c560f43971640144ebf68 /libs/ardour/audio_unit.cc
parent8dc0c84ba40e2cf06e487939d5860989da9ef474 (diff)
AU: fix optional buffers
The spec [1] says: "If the mData pointers are null, the audio unit can provide pointers to its own buffers. In this case, the audio unit must keep those buffers valid for the duration of the calling thread’s I/O cycle." A plugin *can* do this, but it does not need to. An extra NULL test is required. furthermore [2] specifies "mDataByteSize - The number of bytes in the buffer pointed at by the mData field." In case the host does not provide any buffers, this is obviously zero. [1] https://developer.apple.com/documentation/audiotoolbox/1438430-audiounitrender?language=objc [2] https://developer.apple.com/documentation/coreaudiotypes/audiobuffer?language=objc
Diffstat (limited to 'libs/ardour/audio_unit.cc')
-rw-r--r--libs/ardour/audio_unit.cc13
1 files changed, 10 insertions, 3 deletions
diff --git a/libs/ardour/audio_unit.cc b/libs/ardour/audio_unit.cc
index e1ef883747..46b7c6746d 100644
--- a/libs/ardour/audio_unit.cc
+++ b/libs/ardour/audio_unit.cc
@@ -1667,17 +1667,19 @@ AUPlugin::connect_and_run (BufferSet& bufs,
for (uint32_t i = 0; i < cnt; ++i) {
buffers->mBuffers[i].mNumberChannels = 1;
- buffers->mBuffers[i].mDataByteSize = nframes * sizeof (Sample);
- /* setting this to 0 indicates to the AU that it can provide buffers here
+ /* setting this to 0 indicates to the AU that it *can* provide buffers here
* if necessary. if it can process in-place, it will use the buffers provided
* as input by ::render_callback() above.
*
* a non-null values tells the plugin to render into the buffer pointed
* at by the value.
+ * https://developer.apple.com/documentation/audiotoolbox/1438430-audiounitrender?language=objc
*/
if (inplace) {
+ buffers->mBuffers[i].mDataByteSize = 0;
buffers->mBuffers[i].mData = 0;
} else {
+ buffers->mBuffers[i].mDataByteSize = nframes * sizeof (Sample);
bool valid = false;
uint32_t idx = out_map.get (DataType::AUDIO, i + busoff, &valid);
if (valid) {
@@ -1704,7 +1706,12 @@ AUPlugin::connect_and_run (BufferSet& bufs,
for (uint32_t i = 0; i < limit; ++i) {
bool valid = false;
uint32_t idx = out_map.get (DataType::AUDIO, i + busoff, &valid);
- if (!valid) continue;
+ if (!valid) {
+ continue;
+ }
+ if (buffers->mBuffers[i].mData == 0 || buffers->mBuffers[i].mNumberChannels != 1) {
+ continue
+ }
used_outputs.set (i + busoff);
Sample* expected_buffer_address = bufs.get_audio (idx).data (offset);
if (expected_buffer_address != buffers->mBuffers[i].mData) {