涉及soundpool的应用程序的BpMemoryHeap问题

时间:2013-02-27 02:06:30

标签: android soundpool

我创建了一个涉及大约600个小ogg文件的应用。总计约15MB。每个文件都有avg。 6秒的声音。这不是游戏应用程序,而是为儿童学习应用程序。

我尝试在媒体播放器上加载声音。它工作正常一次,当连续播放时,我最终没有声音。它是空白的。

所以我尝试了声音池选项。声音仅在加载到soundpool加载器后播放。因此我尝试在应用程序的开头加载声音。所以加载声音大约需要30秒,然后主屏幕出现(我在后台使用Async加载声音,前面显示进度条)。

当我添加一个超过450的声音时,此设置适用于大约450个ogg文件我在加载几个声音时出现堆错误并且app force关闭时出现以下错误:

 02-27 07:13:02.614: I/Choreographer(27172): Skipped 35 frames!  The application may be doing too much work on its main thread.
 02-27 07:13:11.012: E/IMemory(27172): binder=0x56f0c430 transaction failed fd=-2147483647, size=0, err=-2147483646 (Unknown error 2147483646)
 02-27 07:13:11.012: E/IMemory(27172): cannot dup fd=-2147483647, size=0, err=-2147483646 (Bad file number)
 02-27 07:13:11.012: E/IMemory(27172): cannot map BpMemoryHeap (binder=0x56f0c430), size=0, fd=-1 (Bad file number)
 02-27 07:13:11.020: W/dalvikvm(27172): threadid=37: thread exiting with uncaught exception (group=0x40d75930)
 02-27 07:13:11.153: E/IMemory(27172): cannot dup fd=818, size=1048576, err=0 (Too many open files)
 02-27 07:13:11.153: E/IMemory(27172): cannot map BpMemoryHeap (binder=0x56f09e80), size=1048576, fd=-1 (Bad file number)
 02-27 07:13:11.403: E/IMemory(27172): cannot dup fd=972, size=1048576, err=0 (Too many open files)
 02-27 07:13:11.403: E/IMemory(27172): cannot map BpMemoryHeap (binder=0x56f09988), size=1048576, fd=-1 (Bad file number)
 02-27 07:13:11.450: E/IMemory(27172): cannot dup fd=873, size=1048576, err=0 (Too many open files)
 02-27 07:13:11.450: E/IMemory(27172): cannot map BpMemoryHeap (binder=0x56f0a500), size=1048576, fd=-1 (Bad file number)
 02-27 07:13:11.520: E/IMemory(27172): cannot dup fd=954, size=1048576, err=0 (Too many open files)
 02-27 07:13:11.520: E/IMemory(27172): cannot map BpMemoryHeap (binder=0x56efbde8), size=1048576, fd=-1 (Bad file number)
 02-27 07:13:11.614: W/dalvikvm(27172): threadid=35: thread exiting with uncaught exception (group=0x40d75930)
 02-27 07:13:11.677: E/IMemory(27172): cannot dup fd=903, size=1048576, err=0 (Too many open files)
 02-27 07:13:11.677: E/IMemory(27172): cannot map BpMemoryHeap (binder=0x56f09b30), size=1048576, fd=-1 (Bad file number)
 02-27 07:13:11.716: E/IMemory(27172): cannot dup fd=978, size=1048576, err=0 (Too many open files)
 02-27 07:13:11.716: E/IMemory(27172): cannot map BpMemoryHeap (binder=0x5d99add0), size=1048576, fd=-1 (Bad file number) 
 02-27 07:13:11.747: E/IMemory(27172): cannot dup fd=941, size=1048576, err=0 (Too many open files)
 02-27 07:13:11.747: E/IMemory(27172): cannot map BpMemoryHeap (binder=0x56efb710), size=1048576, fd=-1 (Bad file number)
 02-27 07:13:11.809: E/IMemory(27172): cannot dup fd=991, size=1048576, err=0 (Too many open files)
 02-27 07:13:11.809: E/IMemory(27172): cannot map BpMemoryHeap (binder=0x56efaa90), size=1048576, fd=-1 (Bad file number)

如何解决此问题?关于Heap的大部分问题是关于数据库游标而不是soundpool。

如果无法解决这个问题,那么当我要加载600个声音时,使用soundpool的工作是什么?

谢谢!

1 个答案:

答案 0 :(得分:2)

有了这么多文件,你就会想要延迟加载它们并转储那些暂时没用的文件。

Android中有LruCache可以帮助您。