SimpleAudioEngine bug on Samsung Galaxy S wifi

Hello everyone,

I have got a first version of my cocos2d game up and running on android and so far it works on the emulator and an HTC Desire but when I test it on a Samsung Galaxy S wifi (normally the same hardware as a Samsung Galaxy S without the phone capabilities) the game has issues with the SimpleAudioEngine.

Sometime some sounds do not play but the biggest problem is that it freezes on "SimpleAudioEngine::sharedEngine()>preloadEffect" or SimpleAudioEngine::sharedEngine>playBackgroundMusic .
Here is what happens when the game freezes on preloadEffect
I have a scene A where I preload 2 sounds in the init and start some music
I replace that scene by another one, scene B
In scene A onExit I unload the sounds
From scene B I go back to scene A and the game freezes on the “preloadEffect” in the init with scene B still visible and the music still running

if it can be of any use here is the log:

01-18 15:02:44.003: VERBOSE/PlayerDriver: HandleInformationalEvent: 23
01-18 15:02:44.027: INFO/InputReader: dispatchTouch::touch event’s action is 0
01-18 15:02:44.027: INFO/InputDispatcher: Delivering touch to current input target: action: 0, channel ‘40839900 org.cocos2dx.dcdl/org.cocos2dx.dcdl.DCDL (server)’
01-18 15:02:44.027: INFO/PowerManagerService: Ulight 3~~>7|0
01-18 15:02:44.031: DEBUG/LightsService: BUTTON : 182
01-18 15:02:44.046: WARN/SoundPool: sample 1 not READY
01-18 15:02:44.085: INFO/InputReader: dispatchTouch::touch event’s action is 1
01-18 15:02:44.089: INFO/InputDispatcher: Delivering touch to current input target: action: 1, channel ‘40839900 org.cocos2dx.dcdl/org.cocos2dx.dcdl.DCDL (server)’
01-18 15:02:44.101: WARN/SoundPool: sample 2 not READY
01-18 15:02:44.250: DEBUG/cocos2d-x debug info: MainMenuScene::onExit
01-18 15:02:44.285: ERROR/SensorManager: unregisterListener:: all sensors, listener = org.cocos2dx.lib.Cocos2dxAccelerometer@40558f08
01-18 15:02:45.003: VERBOSE/PlayerDriver: HandleInformationalEvent: 23
01-18 15:02:46.003: VERBOSE/PlayerDriver: HandleInformationalEvent: 23
01-18 15:02:46.687: DEBUG/DataRouter: fd is 22 Content read is PDA USB
01-18 15:02:46.687: DEBUG/DataRouter: length is 8
01-18 15:02:47.003: VERBOSE/PlayerDriver: HandleInformationalEvent: 23
01-18 15:02:47.089: WARN/PowerManagerService: Timer 0x7~~>0x3|0x0
01-18 15:02:47.089: INFO/PowerManagerService(118): Ulight 7~~>3|0
01-18 15:02:47.121: DEBUG/LightsService: BUTTON : 0
01-18 15:02:48.007: VERBOSE/PlayerDriver: HandleInformationalEvent: 23
01-18 15:02:49.007: VERBOSE/PlayerDriver: HandleInformationalEvent: 23
01-18 15:02:49.101: VERBOSE/AudioSink: stop
01-18 15:02:49.101: VERBOSE/AudioPolicyManager: stopOutput output 1, stream 3, session 25
01-18 15:02:49.101: VERBOSE/AudioPolicyManager: getNewDevice selected device 0
01-18 15:02:49.101: VERBOSE/AudioPolicyManager: setOutputDevice output 1 device 0 delayMs 0 force 0
01-18 15:02:49.101: VERBOSE/AudioPolicyManager: setOutputDevice setting same device 0 or null device for output 1
01-18 15:02:49.292: VERBOSE/PlayerDriver: HandleInformationalEvent: 23
01-18 15:02:49.296: VERBOSE/PlayerDriver: HandleInformationalEvent: 17
01-18 15:02:49.296: VERBOSE/PlayerDriver: CommandCompleted
01-18 15:02:49.347: VERBOSE/PlayerDriver: HandleInformationalEvent: 44
01-18 15:02:49.347: VERBOSE/PlayerDriver: HandleInformationalEvent: type=44 UNHANDLED
01-18 15:02:49.347: VERBOSE/ANDROID_DRM_TEST: notify
01-18 15:02:49.347: VERBOSE/PlayerDriver: CommandCompleted
01-18 15:02:49.347: VERBOSE/PlayerDriver: Completed command status=1
01-18 15:02:49.347: WARN/MediaPlayer: info/warning
01-18 15:02:49.347: INFO/MediaPlayer: Info
01-18 15:02:49.359: VERBOSE/AudioSink: flush
01-18 15:02:49.359: VERBOSE/AudioSink: start
01-18 15:02:49.363: VERBOSE/AudioPolicyManager: startOutput output 1, stream 3, session 25
01-18 15:02:49.363: VERBOSE/AudioPolicyManager: getDeviceForStrategy from cache strategy 0, device 2
01-18 15:02:49.363: VERBOSE/AudioPolicyManager: getDeviceForStrategy from cache strategy 0, device 2
01-18 15:02:49.363: VERBOSE/AudioPolicyManager: getNewDevice selected device 2
01-18 15:02:49.363: VERBOSE/AudioPolicyManager: setOutputDevice output 1 device 2 delayMs 0 force 0
01-18 15:02:49.363: VERBOSE/AudioPolicyManager: setOutputDevice setting same device 2 or null device for output 1
01-18 15:02:49.363: VERBOSE/AudioPolicyManager: getDeviceForStrategy strategy 0, device 2
01-18 15:02:49.363: VERBOSE/AudioPolicyManager: getNewDevice selected device 2
01-18 15:02:49.363: DEBUG/AudioPolicyManager: return MUSIC_SPK index
01-18 15:02:49.363: DEBUG/VolumeCustomizer: getVolumetableIndex XEF��dԯ�gԯ#
01-18 15:02:49.363: DEBUG/VolumeCustomizer: getVolumetableIndex mSelectindex 2, count[6]
01-18 15:02:49.562: INFO/InputReader: dispatchTouch::touch event’s action is 0
01-18 15:02:49.566: INFO/InputDispatcher: Delivering touch to current input target: action: 0, channel ‘40839900 org.cocos2dx.dcdl/org.cocos2dx.dcdl.DCDL (server)’
01-18 15:02:49.566: INFO/PowerManagerService: Ulight 3~~>7|0
01-18 15:02:49.566: DEBUG/LightsService(118): BUTTON : 182
01-18 15:02:49.574: WARN/SoundPool(2194): sample 1 not READY
01-18 15:02:49.652: INFO/InputReader(118): dispatchTouch::touch event’s action is 1
01-18 15:02:49.652: INFO/InputDispatcher(118): Delivering touch to current input target: action: 1, channel ‘40839900 org.cocos2dx.dcdl/org.cocos2dx.dcdl.DCDL (server)’
01-18 15:02:49.664: WARN/SoundPool(2194): sample 2 not READY

01-18 15:02:49.667: DEBUG/cocos2d-x debug info(2194): MainMenuScene::init()

01-18 15:02:49.687: DEBUG/DataRouter(74): fd is 22 Content read is PDA USB
01-18 15:02:49.687: DEBUG/DataRouter(74): length is 8

01-18 15:02:49.769: DEBUG/cocos2d-x debug info(2194): preload Menu Effects

01-18 15:02:50.289: VERBOSE/PlayerDriver(76): HandleInformationalEvent: 23
01-18 15:02:51.292: VERBOSE/PlayerDriver(76): HandleInformationalEvent: 23
01-18 15:02:52.292: VERBOSE/PlayerDriver(76): HandleInformationalEvent: 23
01-18 15:02:52.656: WARN/PowerManagerService(118): Timer 0x7~~>0x3|0x0
01-18 15:02:52.656: INFO/PowerManagerService: Ulight 7~~>3|0
01-18 15:02:52.691: DEBUG/DataRouter(74): fd is 22 Content read is PDA USB
01-18 15:02:52.691: DEBUG/DataRouter(74): length is 8
01-18 15:02:52.726: DEBUG/LightsService(118): BUTTON : 0
01-18 15:02:53.292: VERBOSE/PlayerDriver(76): HandleInformationalEvent: 23
01-18 15:02:54.292: VERBOSE/PlayerDriver(76): HandleInformationalEvent: 23
01-18 15:02:55.296: VERBOSE/PlayerDriver(76): HandleInformationalEvent: 23
01-18 15:02:55.691: DEBUG/DataRouter(74): fd is 22 Content read is PDA USB
01-18 15:02:55.691: DEBUG/DataRouter(74): length is 8
01-18 15:02:56.300: VERBOSE/PlayerDriver(76): HandleInformationalEvent: 23
01-18 15:02:57.300: VERBOSE/PlayerDriver(76): HandleInformationalEvent: 23
01-18 15:02:58.304: VERBOSE/PlayerDriver(76): HandleInformationalEvent: 23
01-18 15:02:58.695: DEBUG/DataRouter(74): fd is 22 Content read is PDA USB
01-18 15:02:58.695: DEBUG/DataRouter(74): length is 8
01-18 15:02:59.308: VERBOSE/PlayerDriver(76): HandleInformationalEvent: 23

Has anyone had similar issues on android devices or any ideas how to solve them?

Which version of cocos2dx did you test?
Could you paste a demo to reproduce the bug?

Sorry I forgot to say that I updated cocos2d-X to the latest version (0.11.0) to see if that would resolve the issue.
I am currently trying to reproduce the bug with the minimum amount of code starting from the project template but so far no success.
Afterwards if still no bug, I shall try the opposite, start from my project and work down to the code that can reproduce the bug.

I have managed to get my test project to not play sound any more (but not freeze) but only after it stops working in my original project.
I had to restart the device to get the sound back.

Here is the Error log :

01-19 14:08:36.933: ERROR/OsclAsyncFile(76): OsclAsyncFile::ConstructL
01-19 14:08:36.945: ERROR/SoundBooster(76): readSBTable: file open error!
01-19 14:08:36.945: ERROR/SoundBooster(76): readSBTable: file open error!
01-19 14:08:36.968: ERROR/OsclAsyncFile(76): OsclAsyncFile::ConstructL
01-19 14:08:36.988: ERROR/OsclAsyncFile(76): OsclAsyncFile::ConstructL
01-19 14:08:37.003: ERROR/PlayerDriver(76): Command PLAYER_PREPARE completed with an error or info - 17
01-19 14:08:37.007: ERROR/AudioCache(76): Error 1, - 17 occurred
01-19 14:08:37.011: WARN/PlayerDriver(76): PVMFInfoErrorHandlingComplete
01-19 14:08:37.039: ERROR/SoundPool(5680): Unable to load sample: (null)
01-19 14:08:37.074: ERROR/OsclAsyncFile(76): OsclAsyncFile::ConstructL
01-19 14:08:37.101: ERROR/OsclAsyncFile(76): OsclAsyncFile::ConstructL
01-19 14:08:37.128: WARN/MediaPlayer(5680): info/warning (1, 26)
01-19 14:08:37.132: ERROR/PlayerDriver(76): Command PLAYER_PREPARE completed with an error or info - 17
01-19 14:08:37.132: ERROR/MediaPlayer(5680): error (1, - 17)
01-19 14:08:37.136: WARN/PlayerDriver(76): PVMFInfoErrorHandlingComplete
01-19 14:08:37.144: ERROR/OsclAsyncFile(76): OsclAsyncFile::ConstructL
01-19 14:08:37.156: ERROR/Cocos2dxMusic(5680): error: Prepare failed.: status=0x1
01-19 14:08:37.156: ERROR/Cocos2dxMusic(5680): java.io.IOException: Prepare failed.: status=0x1
01-19 14:08:37.156: ERROR/Cocos2dxMusic(5680): at android.media.MediaPlayer.prepare(Native Method)
01-19 14:08:37.156: ERROR/Cocos2dxMusic(5680): at org.cocos2dx.lib.Cocos2dxMusic.createMediaplayerFromAssets(Cocos2dxMusic.java:214)
01-19 14:08:37.156: ERROR/Cocos2dxMusic(5680): at org.cocos2dx.lib.Cocos2dxMusic.playBackgroundMusic(Cocos2dxMusic.java:71)
01-19 14:08:37.156: ERROR/Cocos2dxMusic(5680): at org.cocos2dx.lib.Cocos2dxActivity.playBackgroundMusic(Cocos2dxActivity.java:106)
01-19 14:08:37.156: ERROR/Cocos2dxMusic(5680): at org.cocos2dx.lib.Cocos2dxRenderer.nativeTouchesEnd(Native Method)
01-19 14:08:37.156: ERROR/Cocos2dxMusic(5680): at org.cocos2dx.lib.Cocos2dxRenderer.handleActionUp(Cocos2dxRenderer.java:79)
01-19 14:08:37.156: ERROR/Cocos2dxMusic(5680): at org.cocos2dx.lib.Cocos2dxGLSurfaceView$10.run(Cocos2dxGLSurfaceView.java:342)
01-19 14:08:37.156: ERROR/Cocos2dxMusic(5680): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1346)
01-19 14:08:37.156: ERROR/Cocos2dxMusic(5680): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1138)
01-19 14:08:37.164: ERROR/PlayerDriver(76): Command PLAYER_PREPARE completed with an error or info - 17
01-19 14:08:37.167: ERROR/AudioCache(76): Error 1, - 17 occurred
01-19 14:08:37.171: WARN/PlayerDriver(76): PVMFInfoErrorHandlingComplete
01-19 14:08:37.187: ERROR/SoundPool(5680): Unable to load sample: (null)
01-19 14:08:37.199: ERROR/Cocos2dxMusic(5680): playBackgroundMusic: background media player is null
01-19 14:08:37.343: WARN/SoundPool(5680): sample 1 not READY
01-19 14:08:37.343: WARN/SoundPool(5680): sample 2 not READY
01-19 14:08:39.792: WARN/PowerManagerService(118): Timer 0x7~~>0x3|0x0
01-19 14:08:42.011: ERROR/VolumePanel: onShowVolumeChanged40
01-19 14:08:47.468: WARN/PowerManagerService: Timer 0x7~~>0x3|0x0
01-19 14:08:51.644: ERROR/Cocos2dxMusic(5680): playBackgroundMusic: background media player is null
01-19 14:08:51.769: WARN/SoundPool(5680): sample 1 not READY
01-19 14:08:51.792: WARN/SoundPool(5680): sample 2 not READY
01-19 14:08:52.332: ERROR/Cocos2dxMusic(5680): playBackgroundMusic: background media player is null
01-19 14:08:52.453: WARN/SoundPool(5680): sample 1 not READY
01-19 14:08:52.472: WARN/SoundPool(5680): sample 2 not READY

I am still trying to find out how to exactly reproduce the error.

Same issue here ! My program works perfectly on Samsung Galaxy tablet 10.1 (running Android 3.1) but get the bug “W/SoundPool(4349): sample 14 not READY” when running on Samsung S2 (running Android 2.3.3). Bug occurs with SDK 0.10.0 and 0.11.0 ; NDK r6b and r7b (didn’t try other SDK/NDK combinations).

Did you find a solution to fix this bug ?

Thanks !

Sorry I have not got round to finding a solution yet and am currently concentrating my efforts on the iOS version right now.
When I get back round to it and if I find a solution or anything I will give you an update.

I faced with this bug.
It starts with log messages
Sample 257 not ready
and continues with log messages like
Unable to load sample: (null)

It occurs on one of test devices - LG P500 (low end android 2.3.3)

I fixed it by calling Cocos2dxSound.end() while level loading - it itakes some time, but it fixes the problem.

This link helped me https://groups.google.com/forum/?fromgroups#!topic/android-developers/cWA7DWXKPzw