If anyone is interested. I have been recently getting this error. By using audio.loadStream it helps a lot. Almost error free unless you go really crazy.
Oh and all you need to for the error is using a performWithDelay of around 140 milliseconds infinite repeating trigger on an audio.loadSound
Hi Rob
Could you explain more your solution with some code example?
Thanks!
Best
Olivier
We would still love to have a bug report on this.
Rob
Hi Oliver. All I did was change any loading of sounds which normally go like blah=audio.loadSound to blah=audio.loadStream. I’m not saying it will definitely fix your issue but it fixed the issue I had that was more problematic on Apple systems. It will be interesting to see if this helps you.
Thanks Rob
Olivier
No more errors even if I go really crazy!
Here my code
local wordsTab = {"word1","word2",....,"wordn"} --your word list, each word has a mp3 file associated local currentIndex = 1 local soundFile local soundHandler local function onNext() audio.stop() audio.dispose(soundFile) soundFile = nil soundHandler = nil local word = wordsTab[currentIndex] local soundFileName = "sounds/words/"..word..".mp3" --your mp3 directory soundFile = audio.loadStream(soundFileName) soundHandler = audio.play(soundFile) currentIndex = currentIndex + 1 end local nextButton = widget.newButton { label = "NEXT", onRelease = onNext, } nextButton.x = display.contentCenterX nextButton.y = display.contentCenterY
Hope this helps
Thanks again
Olivier
That’s great to hear. On a side note I personally wouldn’t even bother disposing audio unless it’s a game and leaving a level which never uses the audio again. I would have assumed disposing and loading might give a delay but maybe it’s not noticeable enough. I would have stuck all the load.streams in the table then just play the table and index. That’s just me though
This bug seems to have been introduced somewhere between Corona build 2692 and 2731, as I didn´t get it before when I was using 2692; however I get it constantly now on 2731
Hi @license,
At the very minimum, we’ll need some very specific system/OS details on which this is occurring, along with the line(s) of code which are causing it. Once we have that, we can attempt to reproduce it on our side.
Thanks,
Brent
Loading a stream is great and all, but you can’t play the sound repeatedly at the same time, so it’s useless. I constantly get “Warning: audio error: Could not bind data to source: Invalid Operation” as I play any random sound and it often loops. Fortunately this does not occur on iOS or Android devices though and seems to be solely on my Mac (Yosemite), but it gets annoying
This bug seems to have been introduced somewhere between Corona build 2692 and 2731, as I didn´t get it before when I was using 2692; however I get it constantly now on 2731
Hi @license,
At the very minimum, we’ll need some very specific system/OS details on which this is occurring, along with the line(s) of code which are causing it. Once we have that, we can attempt to reproduce it on our side.
Thanks,
Brent
@Brent Sorrentino and @Rob Miracle
I have attached a project that helps replicate the issue. Mash the button and you should eventually see the error in the terminal.
I’m getting the error when I’m using the sound module described here https://coronalabs.com/blog/2013/06/04/tutorial-handling-cross-scene-audio/ in a second scene.
It’s like this: Module is working fine in one scene when required at the top of the scene file. Then when moving to the next scene in composer I remove the sounds and I require the same module in the next scene and get the following error, when trying to use a sound there: “audio error: Could not bind data to source: Invalid Value” “Error: Over-disposing of the same audio data”. BTW: I’m using the normal Corona version and not the enterprise one.
If you’re just playing another sound on the same channel, why not just play it instead of stopping it first? The new instance should just play over top the previous instance.
Daniela,
Why are you removing sounds between scenes? Isn’t the goal for this module to use a common set of sounds across multiple scenes?
Brent
Brent,
I right now using the module in each scene by adding
local SM = require ("soundmodule")
at the top of each scene where I have to use the sounds.
But I thought it should be possible to dispose the sounds in the composer function scene:destroy anyway to save memory… and later the module is “loaded again” in a new scene where sound is needed. Isn’t this how it should work?
Right now I can’t dispose the sound in a scene without getting the error above when trying to use the sound in a “new” scene, after I have used dispose sound in the old scene.
How can I dispose the sounds from the module correctly and use the module again in a new scene when I need the sound?
Hi Daniela,
If, for example, you’re loading an audio file from the module like this (from the tutorial):
[lua]
sfx.boomSound = audio.loadSound( “audio/explosion2.wav” )
[/lua]
I would think you should just use a call like this to dispose of it, when you exit the scene you were using it in:
[lua]
audio.dispose( sfx.boomSound )
[/lua]
Are you doing something similar to that already?
Brent
Yes, and it seems like this disposal is causing the problem and the sound in a new scene is not loaded again when requiring the module again. Is there an example somewhere how to handle sound disposal and scene changes correctly somewhere. This is really stuff causing headaches
Hi Daniela
When you require a module it is executed only the first time you require it.
Requiring the same module again in another scene will not “reset” the module or execute it’s code again. It will just make the module available “as it was left the last time you used it”.
So in the first scene your module loads the sound and assigns it to sfx.boomSound
Then, when exiting the scene, you dispose the sound and sfx.boomSound becomes nil
Requiring the module again in the new scene will not load the sound again. you have to reload it explicitly.
You might have something like that in your module
sfx.loadBoomSound = function () sfx.boomSound = audio.loadSound( "audio/explosion2.wav" ) end
and call it when you enter the new scene to reload the sound again.