I got a very strange alignment exception, which only occurs on certain hardware combinations.
(我遇到了一个非常奇怪的对齐异常,该异常仅在某些硬件组合上发生。)
I have implemented a bluetooth audio sink, which get its data fed from a unix file descriptor. (我已经实现了一个蓝牙音频接收器,该音频接收器的数据从unix文件描述符中获取。)
When i combine a Macbook Pro (as bluetooth source) and a raspberry pi (as bluetooth sink), i get an alignment exception at the following point: (当我将Macbook Pro(作为蓝牙源)和树莓派(作为蓝牙接收器)结合使用时,在以下几点出现对齐异常:)
void process(uint8_t* inData, uint32_t size, float* outData)
{
int16_t* from = (int16_t*)inData;
float* to = outData;
for (size_t i = 0; i < size/2; ++i) {
*to = *from/32767.0;
++to;
++from; // Crashes on MacbookPro/RasPi combination
}
}
How comes?
(怎么会?)
My sink obviously does not know about my source. (我的水槽显然不知道我的来源。)
And this works for other platforms (combinations)? (这适用于其他平台(组合)吗?)
I also tried this snippet, however, also no success.
(我也尝试过此代码段,但是也没有成功。)
int8_t* from = (int8_t*)inData;
float* to = outData;
for (size_t i = 0; i < size/2; ++i) {
int16_t tmp;
std::memcpy(&tmp, from, 2);
*to = tmp/32767.0;
++to;
from += 2; // This crashes
}
I guess a running example would not help here, since the exact same code works, when using another data (bluetooth) source.
(我猜正在运行的示例在这里无济于事,因为当使用另一个数据(蓝牙)源时,完全相同的代码可以工作。)
ask by mincequi translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…