Workaround for bug in RtAudio when first channel not equal to 0
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
9ec2abeced
commit
43cf2427ea
@ -1,5 +1,5 @@
|
||||
#include <mutex>
|
||||
/* #define DEBUGTRACE_ENABLED */
|
||||
#include <mutex>
|
||||
#include "debugtrace.hpp"
|
||||
#include "lasp_mathtypes.h"
|
||||
|
||||
@ -177,23 +177,22 @@ public:
|
||||
|
||||
inParams = std::make_unique<RtAudio::StreamParameters>();
|
||||
|
||||
// +1 to get the count.
|
||||
inParams->nChannels = getHighestEnabledInChannel() + 1;
|
||||
if (inParams->nChannels < 1) {
|
||||
throw rte("Invalid input number of channels");
|
||||
}
|
||||
/// RtAudio lacks good bookkeeping when the first channel is not equal to
|
||||
/// 0. For now, our fix is to shift out the channels we want, and let
|
||||
/// RtAudio pass on all channels.
|
||||
inParams->firstChannel = 0;
|
||||
inParams->nChannels = devinfo_gen.ninchannels;
|
||||
inParams->deviceId = devinfo._api_devindex;
|
||||
|
||||
} else {
|
||||
|
||||
outParams = std::make_unique<RtAudio::StreamParameters>();
|
||||
|
||||
outParams->nChannels = getHighestEnabledOutChannel() + 1;
|
||||
if (outParams->nChannels < 1) {
|
||||
throw rte("Invalid output number of channels");
|
||||
}
|
||||
/// RtAudio lacks good bookkeeping when the first channel is not equal to
|
||||
/// 0. For now, our fix is to shift out the channels we want, and let
|
||||
/// RtAudio pass on all channels.
|
||||
outParams->firstChannel = 0;
|
||||
outParams->nChannels = devinfo_gen.noutchannels;
|
||||
outParams->deviceId = devinfo._api_devindex;
|
||||
}
|
||||
|
||||
@ -355,15 +354,16 @@ public:
|
||||
|
||||
const us ch_min = getLowestEnabledInChannel();
|
||||
const us ch_max = getHighestEnabledInChannel();
|
||||
us i = 0;
|
||||
assert(ch_min < ninchannels);
|
||||
assert(ch_max < ninchannels);
|
||||
|
||||
/// Only pass on the pointers of the channels we want
|
||||
for (us ch = ch_min; ch <= ch_max; ch++) {
|
||||
if (inchannel_config.at(ch).enabled) {
|
||||
byte_t *ptr =
|
||||
static_cast<byte_t *>(inputBuffer) + sw * i * nFramesPerBlock;
|
||||
DEBUGTRACE_PRINT((us)ptr);
|
||||
static_cast<byte_t *>(inputBuffer) + sw * ch * nFramesPerBlock;
|
||||
ptrs.push_back(ptr);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
DaqData d{nFramesPerBlock, neninchannels, dtype};
|
||||
d.copyInFromRaw(ptrs);
|
||||
@ -384,14 +384,14 @@ public:
|
||||
|
||||
const us ch_min = getLowestEnabledOutChannel();
|
||||
const us ch_max = getHighestEnabledOutChannel();
|
||||
us i = 0;
|
||||
assert(ch_min < noutchannels);
|
||||
assert(ch_max < noutchannels);
|
||||
/// Only pass on the pointers of the channels we want
|
||||
for (us ch = ch_min; ch <= ch_max; ch++) {
|
||||
if (outchannel_config.at(ch).enabled) {
|
||||
|
||||
ptrs.push_back(static_cast<byte_t *>(outputBuffer) +
|
||||
sw * i * nFramesPerBlock);
|
||||
sw * ch * nFramesPerBlock);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
DaqData d{nFramesPerBlock, nenoutchannels, dtype};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user