Warning: audio error: alBufferData failed: Invalid Value

Hi @hdmaster,

When dealing with audio and scenes, you must be careful about loading and disposing of it properly. One option I may suggest is that you create a “global” (but not true global) reference to the audio that’s playing for your e-book, so you can always reference it when you change scenes. By “not true global” I mean, create it as a reference within the Storyboard module that Storyboard can recognize.

Also, if your current project is early in development, I suggest that you switch to Composer which is the new incarnation of Storyboard. It’s very similar but also simplified and (I think) easier to understand. Eventually, Storyboard will be deprecated in favor of Composer, so unless you’ve deeply integrated Storyboard across many scenes, I highly recommend you use Composer instead:

http://docs.coronalabs.com/guide/system/composer/index.html

Brent

Thank you for the reply! Unfortunately, I have 28 pages that are all in Storyboard format. 

using “loadSound” instead of “loadStream” seems to have solved my immediate problem. 

I have put in a lot of time trying to understand how to load/unload audio  between Storyboard scenes but still have

problems. I am using a sfx module to play sounds that are used throughout the app.

this is how I am unloading and disposing of my narration:

[lua]

function scene:exitScene( event )

local group = self.view

audio.stop(1)

audio.dispose( narration )

narration=nil

audio.stop(2)

audio.dispose ( backgroundSound )

backgroundSound=nil

audio.stop(4)

audio.dispose ( hello )

hello=nil


transition.cancel ()

end

[/lua]

I have done this on each page. Causing problems after you go through the app twice. 

using loadSound instead of loadStream seems to have fixed it. 

I will use Composer for the next one!

Hi @hdmaster,

Where is Lua referencing the audio handles like “narration” and “backgroundSound”? You mention that you use a module somehow, but how so? A third-party offering? Something you created yourself?

Brent

I’m doing the cross scene audio with the sfx.lua module as described in this article:

http://coronalabs.com/blog/2013/06/04/tutorial-handling-cross-scene-audio/

I load and play my narration and bg sounds in enterScene. resetNarration function is to rewind

the narration and make sure it’s at full volume.

[lua]

function scene:enterScene( event )
    local group = self.view

    storyboard.removeAll()  --attempt to remove previous scenes

                
local narration = audio.loadStream( “narration/narrationPage07.mp3”  )

    

------------Reset Audio------------------------------    

local function resetNarration(event)
    if event.completed == false and event.phase == “stopped” then
        audio.setVolume ( 1, {channel=1 })
        audio.rewind (narration)
    end
        
end

    ----- Play Audio Clips --------------
    
                        
    
local function playNarration()

        audio.play(narration,
        {
        channel=1,   
        loops=0,  
        onComplete=resetNarration } )

    
end    
    
    

        

playNarration()

[/lua]

and then I stop, dispose and nil out the handle in exitScene:

[lua]

function scene:exitScene( event )
    local group = self.view

    – INSERT code here (e.g. stop timers, remove listeners, unload sounds, etc.)
    
    

-----unload Audio-------

audio.stop(1)    
audio.dispose( narration )
narration=nil

---------cancel timers and transitions-------

    
transition.cancel ()

Runtime:removeEventListener ( “enterFrame”, followCelia )

end

[/lua]

I have changed the code to load the sounds instead of trying to use audio.loadStream. That seems to have fixed the problem

I was having. It always worked the first time through the story??? That is why I don’t get it. After it would finish and go

back to the main start page, about half way through the book it stops playing the narration.

I will switch to composer after this one. It is ready to go up on the store now. Looking good! Thanks for all your help!

Just wondering how you fixed your audio.play getting called on a loadStream that had not fully loaded. I am having the same

problems.

Warning: audio error: Could not get data for streamed PlayChannel: Warning: audio error: alBufferData failed: Invalid Operation

I am trying to dispose of audio on scene changes in Storyboard

Hi @hdmaster,

When dealing with audio and scenes, you must be careful about loading and disposing of it properly. One option I may suggest is that you create a “global” (but not true global) reference to the audio that’s playing for your e-book, so you can always reference it when you change scenes. By “not true global” I mean, create it as a reference within the Storyboard module that Storyboard can recognize.

Also, if your current project is early in development, I suggest that you switch to Composer which is the new incarnation of Storyboard. It’s very similar but also simplified and (I think) easier to understand. Eventually, Storyboard will be deprecated in favor of Composer, so unless you’ve deeply integrated Storyboard across many scenes, I highly recommend you use Composer instead:

http://docs.coronalabs.com/guide/system/composer/index.html

Brent

Thank you for the reply! Unfortunately, I have 28 pages that are all in Storyboard format. 

using “loadSound” instead of “loadStream” seems to have solved my immediate problem. 

I have put in a lot of time trying to understand how to load/unload audio  between Storyboard scenes but still have

problems. I am using a sfx module to play sounds that are used throughout the app.

this is how I am unloading and disposing of my narration:

[lua]

function scene:exitScene( event )

local group = self.view

audio.stop(1)

audio.dispose( narration )

narration=nil

audio.stop(2)

audio.dispose ( backgroundSound )

backgroundSound=nil

audio.stop(4)

audio.dispose ( hello )

hello=nil


transition.cancel ()

end

[/lua]

I have done this on each page. Causing problems after you go through the app twice. 

using loadSound instead of loadStream seems to have fixed it. 

I will use Composer for the next one!

Hi @hdmaster,

Where is Lua referencing the audio handles like “narration” and “backgroundSound”? You mention that you use a module somehow, but how so? A third-party offering? Something you created yourself?

Brent

I’m doing the cross scene audio with the sfx.lua module as described in this article:

http://coronalabs.com/blog/2013/06/04/tutorial-handling-cross-scene-audio/

I load and play my narration and bg sounds in enterScene. resetNarration function is to rewind

the narration and make sure it’s at full volume.

[lua]

function scene:enterScene( event )
    local group = self.view

    storyboard.removeAll()  --attempt to remove previous scenes

                
local narration = audio.loadStream( “narration/narrationPage07.mp3”  )

    

------------Reset Audio------------------------------    

local function resetNarration(event)
    if event.completed == false and event.phase == “stopped” then
        audio.setVolume ( 1, {channel=1 })
        audio.rewind (narration)
    end
        
end

    ----- Play Audio Clips --------------
    
                        
    
local function playNarration()

        audio.play(narration,
        {
        channel=1,   
        loops=0,  
        onComplete=resetNarration } )

    
end    
    
    

        

playNarration()

[/lua]

and then I stop, dispose and nil out the handle in exitScene:

[lua]

function scene:exitScene( event )
    local group = self.view

    – INSERT code here (e.g. stop timers, remove listeners, unload sounds, etc.)
    
    

-----unload Audio-------

audio.stop(1)    
audio.dispose( narration )
narration=nil

---------cancel timers and transitions-------

    
transition.cancel ()

Runtime:removeEventListener ( “enterFrame”, followCelia )

end

[/lua]

I have changed the code to load the sounds instead of trying to use audio.loadStream. That seems to have fixed the problem

I was having. It always worked the first time through the story??? That is why I don’t get it. After it would finish and go

back to the main start page, about half way through the book it stops playing the narration.

I will switch to composer after this one. It is ready to go up on the store now. Looking good! Thanks for all your help!