JörgHöhle

Jörg-Cyril Höhle

Email: <you AT SPAMFREE example DOT com>

Elements of a talk on concurrency issues in audio applications

Proposed for WineConf2010

What's typically missing from documentation?

  • Thread-safety, reentrancy properties
  • In what order can methods be called?

  • What method is called at what time (internally)?
  • Where's timing described?
  • Generate tick messages at what rate?
  • Fill buffers (how large?) at what rate?

How long does a function take to execute and how does it influence code?

Nasty timing examples

PlaySound(...,SND_ASYNC) - apps may hang for a couple of seconds while trying to draw menus.

Quartz -Morrowind stucks for 3-5 seconds during background music change (in combat) #14186.

MCI Stop - Heroes of Might and Magic II "freezes for a few seconds every time the track changes."

Dirty callbacks - HOMM bug #3930 MSDN says "... as doing so can cause a deadlock".

  • midiOutUnprepare + HeapFree are called from within the MOM_DONE function callback.

  • midiStreamClose is called from the MOM_DONE callback.

Asynchronous Notification - In Chip's Challenge #22880 the MCI player sent DONE notification before setting MCI_MODE_STOP. This fails in Wine when executed too early (would work in native).

Where's robust code?

How to safely implement concurrency, e.g. Pause/Stop command while playing?

  1. Program to the UNIX or MS-Windows APIs?
  2. Ring buffer (as in winealsa.drv) is frowned upon? Gimme Erlang!

  3. Critical Section is no silver bullet. It raises more problems than it solves.

  4. InterlockedExchange & InterlockedCompareExchange are good.

  5. Events & WaitForObject* too - WaitForObject(threadobject) waits until it dies!

  6. Condition Variables?


CategoryHomepage

JörgHöhle (last edited 2010-11-19 10:04:01 by JörgHöhle)