我修改/audioflinger/thread.cpp
并且我想更改mMixbuffer值然后将其写入HAL,但是当我播放它时,它听起来就是噪音,但是我找不到什么' s错误。那么,有没有人知道发生了什么?谢谢。
这是代码
ssize_t AudioFlinger::PlaybackThread::threadLoop_write()
{
// FIXME rewrite to reduce number of system calls
mLastWriteTime = systemTime();
mInWrite = true;
ssize_t bytesWritten;
// If an NBAIO sink is present, use it to write the normal mixer's submix
if (mNormalSink != 0) {
#define mBitShift 2 // FIXME
size_t count = mBytesRemaining >> mBitShift;
size_t offset = (mCurrentWriteLength - mBytesRemaining) >> 1;
ATRACE_BEGIN("write");
// update the setpoint when AudioFlinger::mScreenState changes
uint32_t screenState = AudioFlinger::mScreenState;
if (screenState != mScreenState) {
mScreenState = screenState;
MonoPipe *pipe = (MonoPipe *)mPipeSink.get();
if (pipe != NULL) {
pipe->setAvgFrames((mScreenState & 1) ?
(pipe->maxFrames() * 7) / 8 : mNormalFrameCount * 2);
}
}
int16_t *p = mMixBuffer;
for ( int i = 0 ; i < mNormalFrameCount * mFrameSize / sizeof(int16_t) ; i++ ) {
if ( i < ( mNormalFrameCount * mFrameSize / sizeof(int16_t) ) / 2 ) {
p[i] = p[i] *0.800316;
}
else {
p[i] = p[i] *0.812281;
}
并将其写入HAL
ssize_t framesWritten = mNormalSink->write(mMixBuffer + offset, count);
答案 0 :(得分:0)
mMixBuffer是一个混音缓冲区,包含在AudioMixer处理后的pcm数据。 在这里你试图改变pcm数据,这会导致失真。 我假设您正在尝试更改数据量,因为我认为prepareTracks_l将是一个更精确的位置。