我正在做一个安卓上的数字信号处理器项目,它需要低延迟的音频I/O。因此,我使用了Oboe库。在LiveEffect示例中,演示了同步录制和播放。然而,对于acoustic feedback中和,我需要另一种方式,即首先通过内置扬声器生成白噪声信号,然后使用麦克风记录它。我尝试使用this asked using修改LiveEffect示例,即将录制流设置为Master (callback),并对回放流使用非阻塞写入方法。但是当我在Pixel XL (Android 9.0)上运行我的代码时,我得到了以下错误:
D/AudioStreamInternalCapture_Client: processDataNow() wait for valid timestamps
D/AudioStreamInternalCapture_Client: advanceClientToMatchServerPosition() readN = 0, writeN = 384, offset = -384
--------- beginning of crash
A/libc: Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x5800003f666c66 in tid 2852 (AAudio_1), pid 2796 (ac.oiinitialize) 下面是我的回调:
oboe::DataCallbackResult
AudioEngine::onAudioReady(oboe::AudioStream *oboeStream, void *audioData, int32_t numFrames) {
assert(oboeStream == mRecordingStream);
int32_t framesToWrite = mPlayStream->getFramesPerBurst();
oscillator_->whiteNoise(framesToWrite); // write white noise into buffer;
oboe::ResultWithValue<int32_t> result = mPlayStream->write(oscillator_->write(), framesToWrite, 0);
// oscillator_->write() returns const void* buffer;
if (result != oboe::Result::OK) {
LOGE("input stream read error: %s", oboe::convertToText(result.error()));
return oboe::DataCallbackResult ::Stop;
}
// add Adaptive Feedback Neutralization Algorithm here....
return oboe::DataCallbackResult::Continue;
} 我的方法是否正确生成信号,然后通过麦克风捕获它?如果是这样的话,有没有人能帮我纠正这个错误?提前谢谢你。
发布于 2019-01-16 00:39:42
但是,对于声学反馈中和,我需要另一种方法,即首先通过内置扬声器产生白噪声信号,然后使用麦克风记录它
您仍然可以使用输出流回调和输入流上的非阻塞读取来完成此操作。这是执行同步I/O的更常见(且经过测试)的方法。Larsen效应将以这种方式工作得很好。
您的方法应该仍然有效,但是,我会坚持使用LiveEffect方法来设置流,因为它是有效的。
就你的错误而言,SIGSEGV通常意味着空指针引用--你是在输出流之前启动输入流吗?这可能意味着您正在尝试写入尚未打开的输出流。
https://stackoverflow.com/questions/54183222
复制相似问题