The sad state of audio GetPosition

Joerg-Cyril.Hoehle at Joerg-Cyril.Hoehle at
Thu Aug 18 07:04:10 CDT 2011


the good news first: I've some code which seems to return the "position
of the sample that is currently playing through the speakers" that MSDN
requires GetPosition to return. It passes my mmdevapi rendering tests when
used with ALSA's dmix and hw:0 devices.

The new WinMM over mmdevapi depends on GetPosition for its buffer
management.  Hence a correct GetPosition seems essential for Wine.

The bad news: I've logs which unambiguously prove that at least in
Ubuntu Lucid (2010), PulseAudio yields values of snd_pcm_avail_update
and snd_pcm_delay that are completely inadequate to compute what
GetPosition should return. I'll write more about that in the ALSA or PA mailing list.

Before doing that, I'd like to sample the behaviour of my rendering tests on a few machines.

You'll find the executable at

I'm interested in results from:

- Linux, esp. with something newer than Ubuntu Lucid, or different sound cards.

- Native, because testbot shows some failures and I'd like to see results from real machines, not vmware.

- Ignore the test failures about IsFormatSupported/Initialize. I'm misusing ok() for reporting.

- Please send the complete log, not the short form with failures only, because the test now
  loops twice: once for SHARED mode, once for EXCLUSIVE. Without the complete log, it's
  not possible to tell from the line number only which mode is in use.

- The test may crash in Wine, after my loop, in test_session, because sometimes
  Initialize fails and the test doesn't catch that.

Testbot shows failures such as:
render.c:1034: Test failed: Position 56880 too far after 1070ms
render.c:1035: Test failed: Position delta 5712 not regular

I've yet to analyse testbot's logs in detail.
- "Position delta" means that after 100ms, one expects the speaker position
  to advance by ~4800 (or 48000) positions. How come it can be 5712?
- "Position too far" means that after 1000ms of playing, the speaker position
   cannot be larger than FramesPerSecond (modulo Frequency).
   How can it be 56880 when I expect 48000? (modulo some period increments)

 Jörg Höhle

More information about the wine-devel mailing list