Hi,
We sporadically get that message sporadically in a game we are currently working on. I’m not 100% on the exact steps to reproduce this, but I’ve been able to make it reproduce just by stopping and starting audio on the same channel.
The code below is a pared down example of something similar that happens in the game we’re currently working on. It can be difficult to reproduce, but it does happen. If you make the right sequence of calls with the correct timing, you’ll get the following output:
17dTesting Error with clearing buffer from source: Invalid OperationWarning: audio error: Failed to clear buffer from source: Invalid Operation
Any subsequent attempts to play audio on that channel (source?) fails, with this trace:
Warning: audio error: Could not bind data to source: Invalid OperationWarning: audio error: Could not bind data to source: Invalid
It’s not a Lua error either, so it appears to be coming from within the audio API. What does this message mean, and how do we prevent it from happening? We filed a ticket but haven’t received any comments on progress towards addressing this issue. Is this being addressed? If it can’t be addressed in a timely manner, are there any workarounds that we can use?
Here is sample code:
local audio = require "audio" local sample, channel local sounds = {"drum\_1.wav", "drum\_3.wav"} local currentIndex = 1 function onTouch(event) if event.phase == "began" then stopAudio() end end function replayAudio() stopAudio() playAudio() end function stopAudio() audio.stop(channel) end function playAudio() if sample then audio.dispose(sample) sample = nil end currentIndex = currentIndex + 1 if currentIndex \> #sounds then currentIndex = 1 end sample = audio.loadSound(sounds[currentIndex]) channel = audio.findFreeChannel() audio.play(sample, { loops = 0, channel = audio.findFreeChannel(), onComplete = replayAudio, }) end playAudio() display.getCurrentStage():addEventListener("touch", onTouch)