Jump to content

[SOLVED] OpenAL: AL_INVALID_OPERATION


Aaron Symons
 Share

Recommended Posts

Hey guys!

 

I'm experiencing an issue when I try to switch maps: "OpenAL: AL_INVALID_OPERATION".

 

I have many small audio samples loaded as a Source in one map (each 1 second long), each being played whenever the player triggers them through interaction. I've noticed that if none of the samples are played the map will switch just fine, but if one or more are played the map switch will fail with the above error.

 

I've tried explicitly telling each sample to stop playing right before the map switch, just to make sure, but this didn't work. I've also combined this with releasing each Source, again with no luck.

 

What could this invalid operation be, and how do I solve it?

 

Many thanks in advance!

Win7 64-bit | Intel i7-3770 3.40GHz | NVIDIA GeForce GTX 660

Link to comment
Share on other sites

Well, it sounds like a bug, but try to do release the Sources before changing maps (rather than just stopping).

 

So, if you have a Source called Source1, do:

Source1:Release()

 

If that doesn't work, then also release the Sound objects.

 

Finally, if that doesn't work, then this is some massive bug!

Link to comment
Share on other sites

I added this function to Noise.Lua

 

function Script:CleanUp()

if self.source ~= nil then

self.source:Stop()

end

 

end

 

and before reloading maps in app.lua i make sure my sound (music and announcements), which are not part of the map, but have been added to a pivot created in App.Lua, are cleared up.

 

--Handle map change

if changemapname~=nil then

 

--Clear all entities

if self.my1a ~= nil then

if self.my1a.script ~= nil then

self.my1a.script:CleanUp()

end

self.my1a = nil

end

if self.crawlerbetplaced ~= nil then

if self.crawlerbetplaced.script ~= nil then

self.crawlerbetplaced.script:CleanUp()

end

self.crawlerbetplaced = nil

end

if self.zombiebetplaced ~= nil then

if self.zombiebetplaced.script ~= nil then

self.zombiebetplaced.script:CleanUp()

end

self.zombiebetplaced = nil

end

self.world:Clear()

 

 

I then reload the next map and re-create the pivots and attach the sounds like this.

 

if self.my1a == nil then

self.my1a = Pivot:Create()

end

self.my1a:SetScript("Scripts/Objects/Sound/Noise.lua")

self.my1a.script:SetSoundFile("Sound/Music/my1a.wav")

self.my1a.script:SetUp() -- complete initialisation and play.

 

 

 

I had to make some more functions in noise.lua

 

function Script:Start()

end

function Script:Initialise()

self.source = Source:Create()

self.source:SetVolume(self.volume/100)

self.source:SetPitch(self.pitch)

self.source:SetLoopMode(self.loop)

self.source:SetRange(self.range)

self.source:SetPosition(self.entity:GetPosition(true))

 

end

 

function Script:SetUp()

local sound = Sound:Load(self.setsoundfile)

if sound~=nil then

self.source:SetSound(sound)

if self.playing==true and self.enabled==true then

if App:GetMusic() then

self.source:Play()

else

self.playing=false

end

 

end

sound:Release()

sound=nil

end

end

function Script:Play()--in

if self.enabled and self.playing == false then

 

self.source:Play()

self.playing = true

 

end

self.component:CallOutputs("Play")

end

function Script:Enable()--in

self.enabled=true

end

function Script:Disable()--in

self.enabled=false

end

function Script:UpdatePhysics()

if self.loop then

if App:GetMusic() then

self:Play()

else

self:Pause()

end

else

self:Play()

end

end

function Script:Pause()--in

self.source:Pause()

self.playing = false

end

function Script:SetSoundFile(soundpath)

self.setsoundfile = soundpath

self:Initialise()

end

function Script:OneHit()

self.playing=false

self.loop=false

end

 

 

OneHit stops the sound looping.

The code in Start() has been split in 2 and the first part put in an Initialise function.

The second half put in SetUp()

This gives me the control to make the sound occur when other functions of app.lua are being processed.

 

I also avoid using the flowgraph editor, relying on code and calls to App: functions.

I can now add more maps without having to add the music and announcer sounds or pivots to each map.

Link to comment
Share on other sites

Thank you for your replies guys!

 

I reworked my audio managment after being inspired by Gonan's reply and changing maps no longer causes errors. It's a good thing too because I've simplified everything and it's far easier to manage. :)

 

I'm still not sure whether my previous way of managing the audio was the problem or if I did indeed encounter a bug. I may look into that again in an attempt to figure it out.

 

Thanks again!

Win7 64-bit | Intel i7-3770 3.40GHz | NVIDIA GeForce GTX 660

Link to comment
Share on other sites

  • 2 weeks later...

Hi there!

 

Just a quick update, I think I found the original problem: originally, I was rushing through the scene quite fast (far faster than a player would) and triggered many sound sources to play at once. I'm guessing OpenAL doesn't like this, and must "overload" somehow. I have stopped rushing around since. :)

 

I know it may seem silly running through the scene that fast, but I did have an excuse.

 

Word to the wise: don't trigger loads of sound sources at once. Not good! :)

  • Upvote 1

Win7 64-bit | Intel i7-3770 3.40GHz | NVIDIA GeForce GTX 660

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...