Opened 13 years ago

Closed 12 years ago

Last modified 12 years ago

#931 closed defect (duplicate)

[PATCH] Fix OpenAL issues on OS X

Reported by: Jan Wassenberg Owned by: stwf
Priority: Must Have Milestone:
Component: Core engine Keywords: patch
Cc: Kimball Patch:

Description (last modified by Kenny Long)

OS X CoreAudio has some trouble with our reuse of sources (see http://www.wildfiregames.com/forum/index.php?showtopic=15066). There are various bandaids such as FIFO reuse (thus giving CoreAudio more time to finish what it's doing before we reset the source properties). However, one proper fix might be to just generate/delete sources anew.

This used to be super expensive on hardware implementations, but OpenALsoft should manage much faster. I have implemented this approach (see attached patch) and run a quick test.

With the old suballocator, running -autostart="We Are Legion", sending the front middle guy forwards and waiting for the dust to clear, I see tc_OpenAL_source: 3790.03 kc (5203x) (about 0.2 us per alloc). The new patched version gets tc_OpenAL_source: 239.762 Mc (5411x). Apparently the battle went slightly differently, there were also more casualties, but the per-alloc cost is indeed higher (14 us). Still nothing to worry about; I think this approach is fine on software implementations of OpenAL.

I'd appreciate people testing this on OS X, which requires removing the little kill-switch in hwdetect.js.

Questions:

1) does this fix the issues?

2) is the per-alloc overhead [converting the above number to seconds by dividing by the CPU clock and normalizing according to the number of calls (in parentheses)] similar?

Jan - this didn't work. See my notes below. (kenny)

Attachments (2)

snd_remove_source_suballoc.patch (5.8 KB ) - added by Jan Wassenberg 13 years ago.
snd_remove_source_suballoc+disable_buf_free.patch (8.6 KB ) - added by Jan Wassenberg 13 years ago.

Download all attachments as: .zip

Change History (22)

by Jan Wassenberg, 13 years ago

comment:1 by Jan Wassenberg, 13 years ago

Here is the original analysis by mtkaz concerning these issues: http://www.wildfiregames.com/forum/index.php?showtopic=14895&st=0 Thanks for that, we are hopefully close to fixing them!

As mentioned in the meeting, the loop issue should be fixable by returning 0 from vsrc_deque_finished_bufs if vs->loop is true.

comment:2 by Kieran P, 13 years ago

Keywords: patch review added
Priority: Should HaveMust Have
Summary: Fix OpenAL issues on OS X[PATCH] Fix OpenAL issues on OS X

comment:3 by historic_bruno, 13 years ago

Keywords: review removed

comment:4 by Kieran P, 13 years ago

Milestone: Alpha 7Alpha 8
Priority: Must HaveShould Have

comment:5 by Kenny Long, 12 years ago

Cc: KennyLong removed
Owner: changed from Sound Department to Kenny Long

comment:6 by Kenny Long, 12 years ago

After a lot of testing and reading the spec I discovered that the source attribute for looping is not meant to be mixed with the streaming buffers APIs in OpenAL. For some reason this works in Win and Linux even though the spec says they are not to be mixed. This is why the OS X version tries to hold onto all the buffers when the source attribute for looping is set. If I disable looping the standard version of OpenAL on O SX works (partially - it doesn't repeat). So I think I can just change the sound update code to handle the looping and that will fix that problem.

Anyway, I think we can keep the sub allocation for sources and buffers. There does seem to be another problem with freeing the buffers on O SX that I am still looking into.

comment:7 by Kenny Long, 12 years ago

Description: modified (diff)

comment:8 by Kenny Long, 12 years ago

Description: modified (diff)

comment:9 by Kenny Long, 12 years ago

Status: newassigned

comment:10 by Kieran P, 12 years ago

Milestone: Alpha 8Alpha 9
Priority: Should HaveMust Have

Pushing to Alpha 9 and raising priority. Kenny, what's the progress on this?

comment:11 by Juicyfruit, 12 years ago

Changing the OpenAL library to OpenAL-soft post compile also fixes the issues for me.

This is trivial to do and requires no code changes whatsoever.

I used git-current from: http://repo.or.cz/w/openal-soft.git

comment:12 by historic_bruno, 12 years ago

Owner: Kenny Long removed
Status: assignednew

comment:13 by Kieran P, 12 years ago

Milestone: Alpha 9Alpha 10

comment:14 by Kieran P, 12 years ago

Milestone: Alpha 10Alpha 11

comment:15 by historic_bruno, 12 years ago

Component: Music & Sound FXCore engine

comment:16 by stwf, 12 years ago

Owner: set to stwf
Status: newassigned

comment:17 by Raymond, 12 years ago

Please increase the priority of fixing this issue. This issue is permanently moved to next alpha version :(

comment:18 by Kieran P, 12 years ago

@raymond It kept getting moved because we wanted to fix it, but had no one to do so. We have a person working on it now (stwf), so it should be fixed in Alpha 11, or Alpha 12 at the latest.

comment:19 by Kieran P, 12 years ago

Milestone: Alpha 11
Resolution: duplicate
Status: assignedclosed

Merged with #1223

comment:20 by ben, 12 years ago

In 12428:

New sound system implementation by stwf, refs #1223, #961.
Enables audio on OS X, refs #685, #931.
Fixes music not playing after a game, refs #946.

Note: See TracTickets for help on using tickets.