WinePulse – PulseAudio for Wine

Update – 25th July 2011

Audio in wine has undergone an overhaul to support the mmdevapi introduced in Windows Vista. These WinePulse patches are for the old winmm-based audio stack and are no longer relevant.

(Wine 1.3.25 released) What’s new in this release… Rewrite of the audio support, using the Win7 architecture [mmdevapi].

These winepulse patches are now no longer relevant for Wine versions ≥ 1.3.25 This page is maintained only for historical purposes.

What is It?

It’s a PulseAudio backend for WINE, an opensource implementation of the Windows API on X/Unix. PulseAudio is a modern sound system for Linux. Currently WINE applications cannot fully cooperate with pulseaudio, creating an either-or situation which is messy. WinePulse means that on a PulseAudio setup audio will always work in WINE for you. Doesn’t matter what kind of device the audio is coming out of or captured from, things will work. It also means that you get all the benefits of PulseAudio (moving streams between devices on-the-fly, network transparency… )

Why?

Firstly, while it’s true that WINE currently has many audio backends, some of which can be made to work  indirrectly with pulseaudio, no solution works well enough in my opinion. Secondly, a native interface to pulseaudio can be written as “a PCM output abstraction layer is already available in [WINE] and it thus makes sense to add an additional backend to it for PulseAudio to keep the stack of audio layers minimal.” (Lennart Poettering, http://0pointer.de/blog/projects/guide-to-sound-apis.html). Thirdly, writing such a backend seemed like a good spare time project.

So Why Isn’t This in Wine?

Audio in wine is undergoing an overhaul to support the mmdevapi introduced in Windows Vista. WinePulse will be made redundant by these changes. Thus, this patch will only be maintained only as a stopgap until the new audio system is available. Check out Maarten Lankhorst’s multimedia repository for progress at http://repo.or.cz/w/wine/multimedia.git. For historical aspects, social commentary and flames see http://bugs.winehq.org/show_bug.cgi?id=10495 .

Please note that if you use WinePulse, be it specifically compiled or provided by your distro, do not file bug reports at bugs.winehq.org. You will be either redirect here or to your distro’s bugzilla.

Getting WinePulse

For Fedora, you don’t have to do anything, they are already included!

For Gentoo, enable the pulseaudio USE flag when compiling wine. The ebuild in portage will fetch and apply the patches automatically!

For Arch, use the wine-pulse package as maintained by Sean Bogie in the ArchLinux AUR http://aur.archlinux.org/packages.php?ID=30419

For Ubuntu try looking for a PPA version of wine with winepulse. https://launchpad.net/~c-korn/+archive/ppa has been suggested.

From Git source, read on. WinePulse exists in the form of patches to the main wine git repository.

Latest Patchs

For previous versions, browse http://art.ified.ca/downloads/winepulse/

How to Build / Use Wine with PulseAudio Support

You don’t need to do this if your distro is listed in the previous section.

Clone the wine git repository and apply the winepulse patches:

git clone git://source.winehq.org/git/wine.git wine-git
cd wine-git
patch -p1 < path/to/patches/winepulse-0.40.patch
patch -p1 < path/to/patches/winepulse-configure.ac-1.3.22.patch
patch -p1 < path/to/patches/winepulse-winecfg-1.3.11.patch

The patch contains changes to configure.ac to add checks for pulesaudio, thus you must rebuild the configure script with autoreconf before building as else only a stub driver will be built.

autoreconf
./configure <optionally your configure arguments here>

After running configure if pulseaudio was not found or found to be too old configure will print a warning. If you see nothing you can double-check by running

grep HAVE_PULSEAUDIO include/config.h

from the root of the wine source. #define HAVE_PULSEAUDIO 1 should be output if pulseaudio was found. After you can build wine as normal.

make

If all goes well there should be the file dlls/winepulse.drv/winepulse.drv.so in the wine tree. If you used the winecfg patch you should be able to run winecfg and see the pulesaudio driver. To debug winepulse, compile wine with –enable-maintainer-mode and use the debug channel wave. For example;

WINEDEBUG=+wave wine <your program>

Update (20/03/10): If you get weird makefile related build failures with 1.1.41, delete dlls/winepulse.drv/Makefile and then run make clean from the wine project root, not from inside dlls or dlls/winepulse.drv. Wine changed the makefile structure and generation to compile time rather than configure time and the presence of old stale makefiles can cause errors.

Requirements

Requires pulseaudio >= 0.9.15 and a recent version of wine. Can compile and mostly work against versions 0.9.11 and up, but pulseaudio bugs (which may have been patched by your distro) could cause failures.

On 64-bit systems beware of old 32-bit libraries.

Some distributions ship old version of libpulse for the 32-bit compatibility (on gentoo be aware that your native libraries are continually updated while emul-linux packages get update less frequently). Wine compiles against the system pulse headers but links against the 32-bit libraries. If these libraries are old, there can be issues with the shared memory transport or hangs on playback/record. The trace messages (compiled with –enable-maintainer-mode and environment variable WINEDEBUG=trace+wave)

trace:wave:PULSE_WaveInit libpulse protocol version: x. API Version y
trace:wave:PULSE_WaveInit Connected to server ------ with protocol version: x.

should help to debug the problem. On a local instance both x’s should be the same version number.

Features

Support exists for the WaveIn, WaveOut APIs. DirectSound support is through internal wine emulation.

Tested with Alice (Quake 3 engine), Audacity, Civ 4, Foobar2000, Guild Wars, Max Payne 1/2, ModPlugTracker, Portal (Half Life engine), Ventrilo*, VirtualDub, WinAmp 2/5.

*Reports on Ventrilo support are not up to date.

MIDI support is not available. As PulseAudio has nothing to do with MIDI so such support is out of scope. Because of a design limitation of wine’s winmm.dll only one multi-media backend can be loaded at once meaning that you cannot use winepulse.drv for audio and winealsa.drv for MIDI at the same time.

Changelog

Version 0.40 (21/06/2011)

  • Fix from Hector Martin for a rare race condition. PulseAudio’s own threaded mainloop uses Pthreads. Unfortunately pthreads can’t be used internally in wine, so we use the Win32 api to make the mainloop instead.

Configure.ac Patch Updates

  • Updated configure.ac patch for wine release 1.3.20. Thanks Sean!
  • Updated configure.ac patch for wine release 1.3.19. Thanks John!

Winecfg update

  • New patch versioning system for the winecfg patch.
  • Translation support is currently broken, sorry. I don’t like the way wine is trying to do GetText anyways. They have a habit of tracking generated files in their source tree.

Configure.ac update (25/12/10) Merry Christmas!

  • Updated configure.ac patch to work with wine 1.3.10 again
  • New patch versioning system. The configure.ac patch is now numbered the same as the wine release version which it was first updated to work with.

Version 0.39 (24/09/10)

  • Updates to configure.ac and Makefile.in to work with newer git version of wine again. Wine 1.2 should use version 0.38 instead.

Version 0.38 (07/07/10)

  • Updates to configure.ac checks (Thanks  Sean McNamara!)
  • Use PA_STREAM_ADJUST_LATENCY for record streams (Thanks Nick)
  • Update translations to winecfg patch, again (Thanks Aaron & Oldřich)
  • Try setting buffer_attr on playback streams at connection again (please report if playback breaks.)

Version 0.36 (winecfg patch changed only) (28/06/10)

  • More changes to make the winecfg patch apply correctly.

Version 0.36 (configure.ac patch changed only) (06/03/2010)

  • Two line change to Makefile.in so it works with Wine 1.1.41

Version 0.35 (05/02/2010)

  • Device name UTF-8 fix from Oldřich Jedlička (Thanks!)
  • Update the checks in configure.ac to complain about old libraries.

Version 0.34 (26/01/2010)

  • Fixed/cleaned up capture support (finally).
  • Updated configure.ac patch to work against newer versions of wine. edit: only applied to git head.
  • Updated winecfg patch to work against newer version of wine.

Version 0.33 (23/11/2009)

  • Improvements to calculation of buffer_attr.

Version 0.32 (12/10/2009)

  • Update configure.ac patch because of changes to winehq git head.
  • Go against MSDN and use linear volume because it seems more correct.
  • Fix stalling problems

Version 0.31 (16/09/2009)

  • Update to configure.ac only to add a warning for when libpulse is not found. Aids debugging of patch application.

Version 0.30 (10/08/2009)

  • Decreased version dependency to 0.9.14.
  • Fixed a playback stall situation.
  • Fixed winecfg patch to work with latest git.

Version 0.29 (18/07/2009)

  • PulseAudio version requirement bump to 0.9.15
  • Change the way dwUser is cast to a WINE_WAVEINST.
  • Fix the winecfg patch to apply again (Thanks Neil Wilson), sort winepulse into the library list of library.c.
  • Improve latency a little, little bit in wodPlayer_CheckReleasing().
  • Remove work arounds and warnings for old PulseAudio versions.

Version 0.28 (19/06/2009)

  • Whitespace cleanup (finally).
  • Fix underrun recovery so it doesn’t cause incorrect buffer_attr request which then will cause stalls.
  • All winmm tests passed – wave: 15234 tests executed (0 marked as todo, 0 failures), 0 skipped. capture: 7513 tests executed (0 marked as todo, 0 failures), 0 skipped.
  • Removal of unnecessary or not 64-bit safe includes and dependencies.
  • Share GetPosition MMTime code between waveout and wavein.
  • Fix smtpe MMTime format.
  • Make sure WINE_WAVEINST pointers are 64-bit safe.

Version 0.27 (15/06/2009)

  • Large simplification to waveOut support.
  • Removal of specific dsound support as while it was low-latency, it was broken.
  • Removal of broken 24-bit support.
  • Small crash fix for waveIn.
  • Change in the way pa_timing_info data is used.

Todo

  • Daemon reconnection / Deal with daemon connection dying over application’s lifetime.
  • Better handling of directsound streams failing.

Contact

  • theycallhimart < at > gmail dot com.