New audio API issues

Using the latest build I’m trying to play a single, large MP3 using loadStream. I’ll post the code at the end, but when I first Play, Pause, Stop and then Play again, I get no audio. I usually get this error from the dispose() call thrown in the console:

[lua]ALmixer_FreeData: alDeleteBuffers failed. Invalid Operation[/lua]

I should note that I am not using the Stop() function and wonder if I should.

When I restart the simulator, I get this upon exit, as long as music has played:

[lua]Copyright © 2009-2010 A n s c a , I n c .
Version: 2.0.0
Build: 2010.243
The file sandbox for this project is located at the following folder:
(/Users/eudoxus/Library/Application Support/Corona Simulator/SBiPhone2-6E0352BFCB68434713694818FC028F80)
Corona Simulator(28551,0xa0bff540) malloc: *** error for object 0x5a61f4: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
Corona Simulator(28551,0xa0bff540) malloc: *** error for object 0x59d084: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
Corona Simulator(28551,0xa0bff540) malloc: *** error for object 0x59d080: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
Corona Simulator(28551,0xa0bff540) malloc: *** error for object 0x5e9fa4: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
Corona Simulator(28551,0xa0bff540) malloc: *** error for object 0x5e9fa0: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
Corona Simulator(28551,0xa0bff540) malloc: *** error for object 0x5a6284: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
Corona Simulator(28551,0xa0bff540) malloc: *** error for object 0x5a63b4: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
/Applications/Corona.243/Corona Terminal: line 9: 28551 Bus error “$path/Corona Simulator.app/Contents/MacOS/Corona Simulator” $*
logout

[Process completed][/lua]

[lua]module(…, package.seeall)
– shows and manages the main menu
function newOptions( controller, gamestate )
local options = {}
options.class = “options”
options.controller = controller
options.gamestate = gamestate

– option values
options.sound = true
options.music = true
options.mode = true
options.help = true

– the music being played, nil if none
options.backgroundmusic = nil
options.FadeTime = 500

– music files
options.tunes = {
“align.mp3”,
“frog.mp3”,
“inawhile.mp3”,
“lull.mp3”
}

– load options from state file
– TODO

– save options to state file
– TODO

– music file completion listener
function musicFinished( event )
print(‘complete music’)
– start a different tune if necessary
if (options.gamestate.playState and options.music) then
options:start()
end
end

– music controls, not game controls
function options:start()
print(‘options start’)
– if music is on then choose a tune and play it
options:play()
end

function stopped( event )
print(‘options stopped’,1)
– cleanup
print(options.backgroundmusic)
audio.dispose( options.backgroundmusic )
print(‘options stopped’,2)
options.backgroundmusic = nil
print(‘options stopped’,3)
end

function options:stop()
print(‘options stop’)
– stop the music playing
if (options.music and options.backgroundmusic) then
– fade out and stop
audio.fadeOut( { channel=1, time=options.FadeTime } )
timer.performWithDelay( options.FadeTime, stopped, 1 )
end
end

function options:play()
print(‘options play’,options.music,options.backgroundmusic)
– is music allowed
if (options.gamestate.playState and options.music) then
– is music already playing
if (options.backgroundmusic) then
– play and fade in
print(‘options fade in’)
audio.resume( options.backgroundmusic )
audio.fade( { channel=1, time=options.FadeTime, volume=1 } )
else
– select tune, stream and fade in
options.backgroundmusic = audio.loadStream( options.tunes[math.random(1, #options.tunes)] )
– play the music
audio.play( options.backgroundmusic, { channel=1, fadein=options.FadeTime, onComplete=musicFinished } )
end
else
– music not allowed, stop if playing
options:stop()
end
end

function paused( event )
print(‘options paused’)
audio.pause( options.backgroundmusic )
end

function options:pause()
print(‘options pause’,options.music)
– pause the music
if (options.music) then
audio.fade( { channel=1, time=options.FadeTime, volume=0 } )
timer.performWithDelay( options.FadeTime, paused, 1 )
end
end

return options
end[/lua]

matt [import]uid: 8271 topic_id: 5067 reply_id: 305067[/import]

I’ve noticed that audio.play() does not necessarily fade up the volume. I can show this in the following code - if line 46 is removed the music will not appear to play when the music is stopped and then restarted, because the volume does not come back up, though it is actually playing…

[lua]local tune = “lull.mp3”
local backgroundmusic = nil
local fadeTime = 500

function musicFinished( event )
print(’\n\n\ncomplete music’, event.completed)
if (event.completed) then
start()
end
end

function start()
print(’\n\n\n\noptions start’)
play()
end

function stopped( event )
print(’\noptions stopped’,1)
print(backgroundmusic)
audio.stop( 1 )
print(‘options stopped’,2)
audio.dispose( backgroundmusic )
print(‘options stopped’,3)
backgroundmusic = nil
print(‘options stopped’,4)
end

function stop()
print(’\noptions stop’)
if (backgroundmusic) then
pause()
timer.performWithDelay( fadeTime, stopped, 1 )
end
end

function play()
print(’\noptions play’,backgroundmusic)
if (backgroundmusic) then
print(‘options fade in’)
audio.resume( backgroundmusic )
audio.fade( { channel=1, time=fadeTime, volume=1 } )
else
print(‘options loadstream’)
backgroundmusic = audio.loadStream( tune )
audio.play( backgroundmusic, { channel=1, fadein=fadeTime, onComplete=musicFinished } )
audio.fade( { channel=1, time=fadeTime, volume=1 } )
end
end

function paused( event )
print(’\noptions paused’,backgroundmusic)
if (backgroundmusic) then
audio.pause( backgroundmusic )
end
end

function pause()
print(’\noptions pause’)
audio.fade( { channel=1, time=fadeTime, volume=0 } )
timer.performWithDelay( fadeTime, paused, 1 )
end
timer.performWithDelay( 2000, start, 1 )
timer.performWithDelay( 4000, pause, 1 )
timer.performWithDelay( 6000, play, 1 )
timer.performWithDelay( 8000, stop, 1 )
timer.performWithDelay( 10000, start, 1 )
timer.performWithDelay( 12000, pause, 1 )
timer.performWithDelay( 14000, play, 1 )
timer.performWithDelay( 16000, stop, 1 )[/lua]

matt. [import]uid: 8271 topic_id: 5067 reply_id: 16691[/import]

I’m also getting this error:

ALmixer_FreeData: alDeleteBuffers failed. Invalid Operation

But it’s strange… I had 7 sounds loaded and played, then when I exit the screen, I do this for each of them:
audio.dispose(snd)
snd=nil

Only one sound triggers the error. If I comment it out, there is no error. Order makes no difference.


Update: Thanks to Ansca Staff, the problem was that this particular sound wasn’t finished playing yet. So either have to wait for it to finish, or audio.stop(snd) before disposing of it. [import]uid: 9905 topic_id: 5067 reply_id: 19175[/import]

Hello,

I was get same error iOS with CoronaSDK-2011.318

[import]uid: 11749 topic_id: 5067 reply_id: 29208[/import]

I’m also getting this error using build 494 [import]uid: 14018 topic_id: 5067 reply_id: 34074[/import]