Audio sounds/streams not working after invoking siri or getting phone call

hi Ernest i am facing the same problems. my audio channels have no volume after a phone call one iphone 4g whit iOS 6 and i check if the application was resumed ore not, whit the fallowing code

[lua]local function onSystemEvent( event )
print( "System event name and type: " … event.name, event.type )
if event.type==“applicationResume” then
audio.resume( gameMusicChannel )
end
end

Runtime:addEventListener( “system”, onSystemEvent )[/lua]
but stuck at this issue.
i am currently using corona 894 public build
dos some one know a solution? [import]uid: 169726 topic_id: 31242 reply_id: 130914[/import]

Are there any other ways forward here? A good percentage of my customers complain that the audio has gone out. I’ve tried posting a bug with Apple, but they revoked it, saying it was a duplicate of the current bug. [import]uid: 122310 topic_id: 31242 reply_id: 131094[/import]

This is a problem with iOS 6, lots of games have this problem, and not just Corona Games

Have to wait for Apple

E [import]uid: 88628 topic_id: 31242 reply_id: 131095[/import]

The only current solution (that I’m aware of) is to hold down the home button, and remove the app from memory and restart it [import]uid: 88628 topic_id: 31242 reply_id: 131098[/import]

Here are some suggested workarounds that other frameworks have used when dealing with this OpenAL issue. There must be a way to restore the context when the app comes back.

One of these threads says “The interruption methods were deprecated in iOS 6.0 and replaced with notifications. Seems like the deprecated methods don’t work (at least in some circumstances).”

They might never fix them if they were in fact depreciated and Corona is using the AVAudioSessionDelegate.

http://www.cocos2d-iphone.org/forum/topic/67872

http://www.cocos2d-iphone.org/forum/topic/49956

https://groups.google.com/forum/m/?fromgroups#!topic/objectal-for-iphone/uYy0COTZFu0 [import]uid: 122310 topic_id: 31242 reply_id: 131109[/import]

Are there any other ways forward here? A good percentage of my customers complain that the audio has gone out. I’ve tried posting a bug with Apple, but they revoked it, saying it was a duplicate of the current bug. [import]uid: 122310 topic_id: 31242 reply_id: 131094[/import]

This is a problem with iOS 6, lots of games have this problem, and not just Corona Games

Have to wait for Apple

E [import]uid: 88628 topic_id: 31242 reply_id: 131095[/import]

The only current solution (that I’m aware of) is to hold down the home button, and remove the app from memory and restart it [import]uid: 88628 topic_id: 31242 reply_id: 131098[/import]

Here are some suggested workarounds that other frameworks have used when dealing with this OpenAL issue. There must be a way to restore the context when the app comes back.

One of these threads says “The interruption methods were deprecated in iOS 6.0 and replaced with notifications. Seems like the deprecated methods don’t work (at least in some circumstances).”

They might never fix them if they were in fact depreciated and Corona is using the AVAudioSessionDelegate.

http://www.cocos2d-iphone.org/forum/topic/67872

http://www.cocos2d-iphone.org/forum/topic/49956

https://groups.google.com/forum/m/?fromgroups#!topic/objectal-for-iphone/uYy0COTZFu0 [import]uid: 122310 topic_id: 31242 reply_id: 131109[/import]

Trust me. Our code is correct. (You can verify some it via my open source ALmixer, and my publicly posted reproducible test cases on Open Radar/GitHub.) On our side, the code appears to call correctly and we get no errors so we can’t detect the problem. The problem is inside Apple’s implementation where things are breaking. This is an Apple bug that only Apple can fix.

We are not touching AVAudioSession. Everything is done at the C level directly through Core Audio and OpenAL.

[import]uid: 7563 topic_id: 31242 reply_id: 131192[/import]

Trust me. Our code is correct. (You can verify some it via my open source ALmixer, and my publicly posted reproducible test cases on Open Radar/GitHub.) On our side, the code appears to call correctly and we get no errors so we can’t detect the problem. The problem is inside Apple’s implementation where things are breaking. This is an Apple bug that only Apple can fix.

We are not touching AVAudioSession. Everything is done at the C level directly through Core Audio and OpenAL.

[import]uid: 7563 topic_id: 31242 reply_id: 131192[/import]

Is there a way we can force restart the audio? Recreate the whole audio system on a resume, or perhaps if the user goes into options and toggles sound off and back on? This would be more user friendly than having them force quit the app. Maybe you just expose this via an additional audio function, so its only something that people would use in rare conditions, not just an automatic part of the Corona subsystem? [import]uid: 122310 topic_id: 31242 reply_id: 131592[/import]

aisaksen:

There is a secret audio API called audio.quit(). This shuts down the entire audio system. It is very dangerous to use because if you do it wrong, you will crash the program, which is why we don’t talk about it. We don’t support this API and don’t encourage its use.

But to use:

  1. Stop all audio (audio.stop())
  2. Unload all audio handles (audio.dispose(handle))
  3. Call audio.quit()

To start back up, load your audio files again and play like you normally do.

Note that this is not guaranteed to help with certain types of Apple bugs. When their own internal audio system gets hosed, the behavior is sometimes unpredictable. I can’t remember if this is one of them.

So you might try this shutdown sequence on suspend. And restart everything on resume. Note that because loading files can be slow, doing this every time you resume can be slow/painful. Depending on your app, you might be better off simply making your app exit on suspend via build.settings/plist.

[import]uid: 7563 topic_id: 31242 reply_id: 131620[/import]

Is there a way we can force restart the audio? Recreate the whole audio system on a resume, or perhaps if the user goes into options and toggles sound off and back on? This would be more user friendly than having them force quit the app. Maybe you just expose this via an additional audio function, so its only something that people would use in rare conditions, not just an automatic part of the Corona subsystem? [import]uid: 122310 topic_id: 31242 reply_id: 131592[/import]

aisaksen:

There is a secret audio API called audio.quit(). This shuts down the entire audio system. It is very dangerous to use because if you do it wrong, you will crash the program, which is why we don’t talk about it. We don’t support this API and don’t encourage its use.

But to use:

  1. Stop all audio (audio.stop())
  2. Unload all audio handles (audio.dispose(handle))
  3. Call audio.quit()

To start back up, load your audio files again and play like you normally do.

Note that this is not guaranteed to help with certain types of Apple bugs. When their own internal audio system gets hosed, the behavior is sometimes unpredictable. I can’t remember if this is one of them.

So you might try this shutdown sequence on suspend. And restart everything on resume. Note that because loading files can be slow, doing this every time you resume can be slow/painful. Depending on your app, you might be better off simply making your app exit on suspend via build.settings/plist.

[import]uid: 7563 topic_id: 31242 reply_id: 131620[/import]

In the following post it was stated that this may be fixed in iOS 6.1 beta 3. Can anyone else confirm?

http://developer.coronalabs.com/forum/2012/07/25/sounds-still-stops-randomly-ios#comment-134451 [import]uid: 84258 topic_id: 31242 reply_id: 134580[/import]

In the following post it was stated that this may be fixed in iOS 6.1 beta 3. Can anyone else confirm?

http://developer.coronalabs.com/forum/2012/07/25/sounds-still-stops-randomly-ios#comment-134451 [import]uid: 84258 topic_id: 31242 reply_id: 134580[/import]

Hi

I do not belive this bug has anything to do with Siri, here just run this code it will mute the app even in corona simulator on Mac.

Is this still Apple’s issue when the bug is reproducible even in simulator. It seems to me as Corona SDK bug since looping for ca 90-100 times sound dies.

local text1  
count = 0  
  
function playSound()  
 count = count + 1  
 local click = audio.loadStream("test.mp3")  
 audio.play(click, {loops=0, channel=1 })  
 text1.text = "count: "..count  
end  
  
text1 = display.newText( "count: 0", 0, 0, native.systemFontBold, 34 )  
text1:setTextColor( 255 )  
text1:setReferencePoint( display.CenterReferencePoint )  
text1.x, text1.y = display.contentWidth \* 0.5, display.contentHeight \* 0.5  
  
timer.performWithDelay( 100, playSound, 0 )  

[import]uid: 13099 topic_id: 31242 reply_id: 135811[/import]

We’re talking about different issues here.
The Siri and lock-screen issues are/were real issues that appeared in iOS6, and appear to be fixed in iOS 6.1. I still haven’t been able to reproduce *those* audio issues in the 6.1 betas.

Your issue is completely different, and has to do with audio management. There are 2 problems with the code above:

  1. You’re loading audio upon every invocation of playSound()
  2. You’re using loadStream to play what I assume is a short audio effect.

1 comment) Audio should only be loaded once, and then reused. If you’re game requires different sound-sets in different levels, you should only load the sounds required for the current level in the beginning of game-play, and then unload those sounds when switching levels.

2 comment) loadStream should only be used for long sounds (think background music and narration) where you only have a few running at any one time during game-play. This is due to the fact that these audio-handles cannot be shared across multiple channels.
For shorter audio effects where you need multiple audio effects running at the same time you should use loadSound().

I could easily reproduce your issue in the Corona Simulator, as you mentioned.
The problem is not a Corona or Apple bug. In the terminal output after about 90 iterations you get the following error:

WARNING: Failed to create audio sound(loaded.wav), and the sound stops.

The issue was solved by moving one line of code.

-- main.lua  
  
local text1  
local count = 0  
local click = audio.loadStream("loaded.wav")  
   
function playSound()  
 count = count + 1  
 audio.play(click, {loops=0, channel=1 })  
 text1.text = "count: "..count  
end  
   
text1 = display.newText( "count: 0", 0, 0, native.systemFontBold, 34 )  
text1:setTextColor( 255 )  
text1:setReferencePoint( display.CenterReferencePoint )  
text1.x, text1.y = display.contentWidth \* 0.5, display.contentHeight \* 0.5  
   
timer.performWithDelay( 100, playSound, 0 )  

Even though loadStream() handles is something that shouldn’t be used with short invocations like this, I moved the loadStream() out of playSound() so that it’s only loaded once. By doing that I haven’t had any problems in the Simulator even after 5000+ iterations.
I would still highly recommend using loadSound() in this kind of scenario. [import]uid: 70847 topic_id: 31242 reply_id: 135825[/import]

Hi

I do not belive this bug has anything to do with Siri, here just run this code it will mute the app even in corona simulator on Mac.

Is this still Apple’s issue when the bug is reproducible even in simulator. It seems to me as Corona SDK bug since looping for ca 90-100 times sound dies.

local text1  
count = 0  
  
function playSound()  
 count = count + 1  
 local click = audio.loadStream("test.mp3")  
 audio.play(click, {loops=0, channel=1 })  
 text1.text = "count: "..count  
end  
  
text1 = display.newText( "count: 0", 0, 0, native.systemFontBold, 34 )  
text1:setTextColor( 255 )  
text1:setReferencePoint( display.CenterReferencePoint )  
text1.x, text1.y = display.contentWidth \* 0.5, display.contentHeight \* 0.5  
  
timer.performWithDelay( 100, playSound, 0 )  

[import]uid: 13099 topic_id: 31242 reply_id: 135811[/import]