By and large everything is fine in my game, sounds are played and what not. Every once in a while though, about half of the sounds stop working. There is no crash, or anything to that effect, just some sounds play and some don't. They are all .caf files. Have any of you guys or girls experienced this?
Simple Audio Engine half working
(8 posts) (7 voices)-
Posted 1 year ago #
-
Well I had a similar problem.
I have a song that plays while the level you're playing is active. If you lose the music stops and if you click "restart" the music starts again.
My problem was that the music didn't play again, ever. The song file was .mp3 and I changed it to .wav and now it works fine.
I don't think that .mp3 is the problem but that the song file itself had an error or something. You could try changing the file extensions. I hope it helps.
Posted 1 year ago # -
We have a similar problem with a very small portion of our customers.
I've only ever seen it once in hundreds (thousands?) of plays myself, but we get 1-2 support emails a week describing the problem. It's always the same, some seemingly random portion of our sound files just don't play at all. Once it happens, it's broken until the device is fully restarted. Bizarre, right?
Not sure if it's the same issue you are dealing with, but we're in the midst of switching to a new sound engine since we can't figure it out.
Posted 1 year ago # -
To the original poster, you may want to upgrade your code to interact with CDAudioManager rather than SimpleAudioEngine. If you have lots of sounds effects that are fired frequently, the SimpleAudioEngine doesn't prioritize some sounds over others and you may eventually exceed 32 voices and something gets dropped. If you instead code for CDAudioManger (of which SimpleAudioEngine uses itself), you can control which sounds are highest priority that never get dropped.
I had this problem you describe when I used SimpleAudioEngine; even some sounds that were repeated many times would eventually cause other sounds to stop. I have since not had this problem now that I am using CDAudioManager.
Posted 1 year ago # -
I have had this issue surface rarely (as described by malphigian where players complain that sound stopped in the game) with numerous apps too and I have finally found a reproducible way that this can occur, and it makes sense why it is rare. Not sure how to fix it yet.
I have submitted this as a bug/issue.
My idea for a workaround solution is to somehow figure out how to detect AURemoteIO::Initialize failed: -12985 in Cocos Dension and to then reinitialize Cocos Dension. That failure seems to be the cause.
I have not looked to deep into Dension to figure out how this could be fixed, but one thing to note is that many of the objects in Dension seem to be valid objects even after the initialization fails. So no runtime errors occur but SimpleAudioEngine will not play sound effects.
The following will still work after this failure.
'[SimpleAudioEngine sharedEngine] playBackgroundMusic:@"effectName.m4a"]'The following will not work after this failure, but no errors occur.
[[SimpleAudioEngine sharedEngine] playEffect:@"mySound.m4a" pitch:1 pan:0 gain:1];Currently users can restart their device or kill and restart the app to get a successful initialization and then sound effect audio will return.
Steps to reproduce:
1) Launch your app for the first time (NOT resume from background) on a device.2) While the splash screen is showing, press the home button to exit the app BEFORE the app fully launches. The app will still be in the process of launching, will finish launching but will not be visible, and then will resign active.
3) Relaunch the app after a short wait of maybe 10-15 seconds. This step is crucial because if the app did not finish launching and then resign while not visible, then the bug will not occur. I call it 'not visible' because the app is in a state where it has been exited but since iOS has not finished launching it yet, it first finishes launching, but is not visible since you will see home screen app icons, and then the app resigns active.
If I do these three steps, then resume the app and use SimpleAudioEngine to play an effect as shown below, then the selector is called, the soundId is retrieved from the buffer manager and soundEngine playSound is called, but no sound is played.
[[SimpleAudioEngine sharedEngine] playEffect:@"mySound.m4a" pitch:1 pan:0 gain:1];-- DEBUG LOG FOR THE CASE WHEN EXITING THE APP SPLASH SCREEN BEFORE APP FINISHES LAUNCHING --
Here is the debug log with #define CD_DEBUG 10.
Note the AURemoteIO::Initialize failed: -12985.2012-05-24 11:31:36.010 APP_NAME[3131:607] Denshion::CDAudioManager - Other audio is not playing audio will be exclusive 2012-05-24 11:31:36.018 APP_NAME[3131:607] Denshion::CDAudioManager - Audio session set category AVAudioSessionCategorySoloAmbient succeeded 2012-05-24 11:31:36.020 APP_NAME[3131:607] Denshion::CDSoundEngine - mixer output rate set to 44100.00 AudioStreamBasicDescription: 2 ch, 44100 Hz, 'lpcm' (0x00000C2C) 8.24-bit little-endian signed integer, deinterleaved 2012-05-24 11:31:36.032 APP_NAME[3131:607] 11:31:36.032 <0x3ede1d98> AURemoteIO::Initialize failed: -12985 (enable 2, outf< 2 ch, 44100 Hz, Int8.24, non-inter> inf< 2 ch, 0 Hz, Float32, non-inter>) 2012-05-24 11:31:36.036 APP_NAME[3131:607] 11:31:36.036 <0x3ede1d98> AURemoteIO::Initialize failed: -12985 (enable 2, outf< 2 ch, 44100 Hz, Int8.24, non-inter> inf< 2 ch, 0 Hz, Float32, non-inter>) 2012-05-24 11:31:36.229 APP_NAME[3131:607] Denshion::CDBufferManager generating new buffer id 0 2012-05-24 11:31:36.232 APP_NAME[3131:607] Denshion::CDSoundEngine - Loading openAL buffer 0 atv.m4a 2012-05-24 11:31:36.446 APP_NAME[3131:607] Denshion::CDSoundEngine Buffer 0 loaded format:4355 freq:44100 size:1172752 2012-05-24 11:31:36.452 APP_NAME[3131:607] Denshion::CDBufferManager buffer loaded 0 atv.m4a 2012-05-24 11:31:36.456 APP_NAME[3131:607] Denshion::SimpleAudioEngine sound source created for atv.m4a 2012-05-24 11:31:36.459 APP_NAME[3131:607] Denshion::CDBufferManager generating new buffer id 1 2012-05-24 11:31:36.463 APP_NAME[3131:607] Denshion::CDSoundEngine - Loading openAL buffer 1 engine1.m4a 2012-05-24 11:31:36.490 APP_NAME[3131:607] Denshion::CDSoundEngine Buffer 1 loaded format:4353 freq:44100 size:176672 2012-05-24 11:31:36.493 APP_NAME[3131:607] Denshion::CDBufferManager buffer loaded 1 engine1.m4a 2012-05-24 11:31:36.497 APP_NAME[3131:607] Denshion::SimpleAudioEngine sound source created for engine1.m4a 2012-05-24 11:31:36.501 APP_NAME[3131:607] Denshion::CDLongAudioSource - Loading new audio source race9.m4a 2012-05-24 11:31:36.560 APP_NAME[3131:607] gameApplicationDidBecomeActive 2012-05-24 11:31:36.563 APP_NAME[3131:607] CDAudioManager:applicationDidBecomeActive 2012-05-24 11:31:36.601 APP_NAME[3131:607] gameApplicationWillResignActive 2012-05-24 11:31:36.607 APP_NAME[3131:607] CDAudioManager:applicationWillResignActive 2012-05-24 11:31:36.611 APP_NAME[3131:607] Denshion::CDAudioManager - Audio session set category AVAudioSessionCategoryAmbient succeeded 2012-05-24 11:31:36.613 APP_NAME[3131:607] Denshion::CDAudioManager - handled resign active 2012-05-24 11:31:36.616 APP_NAME[3131:607] gameApplicationDidEnterBackground-- DEBUG LOG SHOWING APP FULLY LAUNCHING NORMALLY i.e. NOT PRESSING HOME BUTTON DURING SPLASH SCREEN --
AUDIO WORKS NORMALLY AS EXPECTED IN THIS CASE
Note there is no AURemoteIO::Initialize failed in this case.2012-05-24 11:39:50.117 APP_NAME[3131:607]] Denshion::CDAudioManager - Other audio is not playing audio will be exclusive 2012-05-24 11:39:50.125 APP_NAME[3131:607]] Denshion::CDAudioManager - Audio session set category AVAudioSessionCategorySoloAmbient succeeded 2012-05-24 11:39:50.135 APP_NAME[3131:607]] Denshion::CDSoundEngine - mixer output rate set to 44100.00 AudioStreamBasicDescription: 2 ch, 44100 Hz, 'lpcm' (0x00000C2C) 8.24-bit little-endian signed integer, deinterleaved 2012-05-24 11:39:51.137 APP_NAME[3131:607]] Denshion::CDBufferManager generating new buffer id 0 2012-05-24 11:39:51.138 APP_NAME[3131:607]] Denshion::CDSoundEngine - Loading openAL buffer 0 atv.m4a 2012-05-24 11:39:51.443 APP_NAME[3131:607]] Denshion::CDSoundEngine Buffer 0 loaded format:4355 freq:44100 size:1172752 2012-05-24 11:39:51.445 APP_NAME[3131:607]] Denshion::CDBufferManager buffer loaded 0 atv.m4a 2012-05-24 11:39:51.447 APP_NAME[3131:607]] Denshion::SimpleAudioEngine sound source created for atv.m4a 2012-05-24 11:39:51.449 APP_NAME[3131:607]] Denshion::CDBufferManager generating new buffer id 1 2012-05-24 11:39:51.451 APP_NAME[3131:607]] Denshion::CDSoundEngine - Loading openAL buffer 1 engine1.m4a 2012-05-24 11:39:51.476 APP_NAME[3131:607]] Denshion::CDSoundEngine Buffer 1 loaded format:4353 freq:44100 size:176672 2012-05-24 11:39:51.477 APP_NAME[3131:607]] Denshion::CDBufferManager buffer loaded 1 engine1.m4a 2012-05-24 11:39:51.480 APP_NAME[3131:607]] Denshion::SimpleAudioEngine sound source created for engine1.m4a 2012-05-24 11:39:51.487 APP_NAME[3131:607]] Denshion::CDLongAudioSource - Loading new audio source race9.m4a 2012-05-24 11:39:51.718 APP_NAME[3131:607]] gameApplicationDidBecomeActive 2012-05-24 11:39:51.723 APP_NAME[3131:607]] CDAudioManager:applicationDidBecomeActiveUsing Cocos Dension that is included in cocos2d v2.0-rc1.
I am running iOS 5.1 on an iPhone 4s.
On first launch, I set CDAudioManager resign behavior like this
[[CDAudioManager sharedManager] setResignBehavior:kAMRBStopPlay autoHandle:YES];Posted 12 months ago # -
We had the same problem and we fixed it by increasing the CD_SOURCE_LIMIT in CocosDenshion.h.
Posted 12 months ago # -
@Studder, did you test the specific case I mentioned above when the app is first launched and then exited out of while the splash screen is showing.
That specific situation results in the Audio Unit initialization error of AURemoteIO::Initialize failed: -12985 and doesn't seem to be related to CD_SOURCE_LIMIT.
For my case, all audio functions normally as long as the app is not exited out of while the splash screen is showing on first launch of the app.
Posted 12 months ago # -
If you want a quick and dirty solution to reset the audio after a point where it might have started working, here's what I did:
Like the others here I found that after a while with too many voices at once, some sound effects would stop playing. To restore those voices I added this line at the end of each level:
[SimpleAudioEngine end];
This clears out SimpleAudioEngine completely, thereby resetting it and allowing all the sound effects to play once again.
Posted 6 months ago #
Reply
You must log in to post.