Jump to content

OpenAL: AL_INVALID_OPERATION


Recommended Posts

Based on this forum post where an error was occurring during switching of maps:

http://www.leadwerks.com/werkspace/topic/10459-load-map-error/#entry76909

 

It appears that using Release() on a sound that has been played will cause the OpenAl error. If you release the sound before being played, then no issues.

 

example script to show the problem:

function App:Start()

self.window=Window:Create("Sound Bug Example",0,0,200,150,Window.Titlebar+Window.Center)

self.context=Context:Create(self.window)

self.world=World:Create()

self.camera = Camera:Create()

 

--import "Scripts/Functions/ReleaseTableObjects.lua"

sound = {}

sound[1] = Sound:Load("Sound/Footsteps/Concrete/step1.wav")

sound[2] = Sound:Load("Sound/Footsteps/Concrete/step2.wav")

 

return true

end

 

function App:Loop()

if self.window:Closed() or self.window:KeyDown(Key.Escape) then return false end

 

if self.window:KeyHit(Key.Space) then

local r = math.random(1,2)

if sound~=nil then

if sound[r]~=nil then sound[r]:Play() end

end

end

 

if self.window:KeyHit(Key.Up) then

if sound~=nil then

--ReleaseTableObjects(sound)

sound[1]:Release()

sound[2]:Release()

sound = nil

end

end

 

Time:Update()

self.world:Update()

self.world:Render()

 

self.context:Sync()

 

return true

end

 

If you press the Up arrow key prior to playing the sounds then there are no issues. If you hit the Space key and play a sound then try to release the sound it will cause the error.

 

Since the fpsplayer script uses the 'ReleasetableObjects' function, it causes this same error when switching maps and the player has been released.

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Thanks, I got that fixed. Freeing up a channel is a rather complicated series of events! (Engine code):

       	 //Free channels that are no longer playing
           if (source->channel)
           {
               alGetSourcei(((OpenALChannel*)source->channel)->source,AL_SOURCE_STATE,&state);
               if (state != AL_PLAYING)
               {
                   bool cleanup = false;
                   source->state = Source::Stopped;
                   if (source->owner)
                   {
                       source->owner->activesources.remove(source);
                       cleanup=true;
                   }
                   if (source->autorelease) cleanup = true;
                   source->channel->available = true;
                   if (cleanup)
                   {
                       source->Release();
                       source = NULL;
                       continue;
                   }                    
                   source->channel = NULL;
               }
           }

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...