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

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]

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]

We are releasing an app next week. The phone call audio bug also occurs in our app. What should we do? Is there still no workaround? [import]uid: 101722 topic_id: 31242 reply_id: 140315[/import]

For me this was fixed in iOS 6.1.
Have you confirmed that it’s OK with the 6.1 beta? [import]uid: 70847 topic_id: 31242 reply_id: 140317[/import]

At the moment we don’t have a tester with 6.1 beta device. It would be great, if I could say with certainty that the sound problem will be fixed with the official 6.1 update.

But still, users don’t have 6.1 beta, they have 6.0 on their iOS devices. When is the 6.1 update scheduled? [import]uid: 101722 topic_id: 31242 reply_id: 140341[/import]

All the signs are pointing to a 6.1 release next week or maybe very early February. I’m holding onto some app updates until it’s released so I can confirm the audio issue is fixed and my new versions don’t get slammed with bad reviews. [import]uid: 84258 topic_id: 31242 reply_id: 140345[/import]

It seems like this isn’t a bug on apples side, rather a event that needs to be handled in AlMixer/OpenAL on sound interruptions :

http://benbritten.com/2009/02/02/restarting-openal-after-application-interruption-on-the-iphone/

Is there a way to access those properties mentioned in that blog post? I’v having the same problem with my game and most of the games on appStore seem to have fixed that issue somehow.

[import]uid: 103182 topic_id: 31242 reply_id: 140755[/import]

Oh my! That’s a 4-year old post you found there when *iOS 2.2.1* was king :slight_smile:

The issues the OP was talking about were Apple bugs in iOS6.
I can confirm myself that as of iOS 6.1 (released today) that the audio issues I was experiencing in my apps are fixed (without having to submit a new release).

Also, Eric Wing, who is nothing less than an OpenAL guru and has written books on the subject of OpenAL, was certain that it was an Apple bug. (read post #15 above)
[import]uid: 70847 topic_id: 31242 reply_id: 140759[/import]

oops! sorry about that. I was just a little stressy about fixing the problem for my game, so i guess i missed that particular part =)
I have now updated and tried it on 6.1 and it seems to work fine! Thanks! [import]uid: 103182 topic_id: 31242 reply_id: 140783[/import]

We are releasing an app next week. The phone call audio bug also occurs in our app. What should we do? Is there still no workaround? [import]uid: 101722 topic_id: 31242 reply_id: 140315[/import]

For me this was fixed in iOS 6.1.
Have you confirmed that it’s OK with the 6.1 beta? [import]uid: 70847 topic_id: 31242 reply_id: 140317[/import]

At the moment we don’t have a tester with 6.1 beta device. It would be great, if I could say with certainty that the sound problem will be fixed with the official 6.1 update.

But still, users don’t have 6.1 beta, they have 6.0 on their iOS devices. When is the 6.1 update scheduled? [import]uid: 101722 topic_id: 31242 reply_id: 140341[/import]

All the signs are pointing to a 6.1 release next week or maybe very early February. I’m holding onto some app updates until it’s released so I can confirm the audio issue is fixed and my new versions don’t get slammed with bad reviews. [import]uid: 84258 topic_id: 31242 reply_id: 140345[/import]

It seems like this isn’t a bug on apples side, rather a event that needs to be handled in AlMixer/OpenAL on sound interruptions :

http://benbritten.com/2009/02/02/restarting-openal-after-application-interruption-on-the-iphone/

Is there a way to access those properties mentioned in that blog post? I’v having the same problem with my game and most of the games on appStore seem to have fixed that issue somehow.

[import]uid: 103182 topic_id: 31242 reply_id: 140755[/import]

Oh my! That’s a 4-year old post you found there when *iOS 2.2.1* was king :slight_smile:

The issues the OP was talking about were Apple bugs in iOS6.
I can confirm myself that as of iOS 6.1 (released today) that the audio issues I was experiencing in my apps are fixed (without having to submit a new release).

Also, Eric Wing, who is nothing less than an OpenAL guru and has written books on the subject of OpenAL, was certain that it was an Apple bug. (read post #15 above)
[import]uid: 70847 topic_id: 31242 reply_id: 140759[/import]