Android Soundpool problems

我们两清 提交于 2019-12-01 05:19:11

It seems AudioFlinger can have up to 1 Mb worth of audio going on at any given time. The heap errors occur if this limit is exceeded. This guess is based on some code I found in AudioFlinger source code:

AudioFlinger::Client::Client(const sp<AudioFlinger>& audioFlinger, pid_t pid) 
     :   RefBase(), 
         mAudioFlinger(audioFlinger), 
         mMemoryDealer(new MemoryDealer(1024*1024)), 
         mPid(pid) 
{ 
     // 1 MB of address space is good for 32 tracks, 8 buffers each, 4 KB/buffer 
} 

And this:

size_t size = sizeof(audio_track_cblk_t); 
size_t bufferSize = frameCount*channelCount*sizeof(int16_t); 
if (sharedBuffer == 0) { 
    size += bufferSize; 
} 
mCblkMemory = client->heap()->allocate(size); 
if (mCblkMemory != 0) {
    ...
} else {
    LOGE("not enough memory for AudioTrack size=%u", size); 
    client->heap()->dump("AudioTrack"); 
}

Anyone else better informed?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!