1. 用sdk里面的 emulator 启动的 模拟器没有声音。
2. 源码下的 emulator 启动的模拟器也没有声音。
有重新生成新的 模拟器,也没有解决。
AudioTrack 不断输出log:
W/AudioTrack( 152): obtainBuffer timed out (is the CPU pegged?) 0x2a202578 name=0x10user=00001000, server=00000000
是在 AudioTrack.cpp的 obtainBuffer()中输出的log。
代码:
因为对这部分代码不熟悉,不过我想还是模拟器的原因。想知道具体是什么原因,怎么解决?
obtainBuffer代码:
status_t AudioTrack::obtainBuffer(Buffer* audioBuffer, int32_t waitCount)
{
AutoMutex lock(mLock);
bool active;
status_t result = NO_ERROR;
audio_track_cblk_t* cblk = mCblk;
uint32_t framesReq = audioBuffer->frameCount;
uint32_t waitTimeMs = (waitCount < 0) ? cblk->bufferTimeoutMs : WAIT_PERIOD_MS;
audioBuffer->frameCount = 0;
audioBuffer->size = 0;
uint32_t framesAvail = cblk->framesAvailable();
cblk->lock.lock();
if (cblk->flags & CBLK_INVALID_MSK) {
goto create_new_track;
}
cblk->lock.unlock();
if (framesAvail == 0) {
cblk->lock.lock();
goto start_loop_here;
while (framesAvail == 0) {
active = mActive;
if (CC_UNLIKELY(!active)) {
ALOGV("Not active and NO_MORE_BUFFERS");
cblk->lock.unlock();
return NO_MORE_BUFFERS;
}
if (CC_UNLIKELY(!waitCount)) {
cblk->lock.unlock();
return WOULD_BLOCK;
}
if (!(cblk->flags & CBLK_INVALID_MSK)) {
mLock.unlock();
result = cblk->cv.waitRelative(cblk->lock, milliseconds(waitTimeMs));
cblk->lock.unlock();
mLock.lock();
if (!mActive) {