[PATCH] Revamped support for Microsoft Windows
I've put together a patch to Libao, against Git master (currently 97c0dea6
), that fixes and simplifies the support for Windows.
First, I've added an NMAKE makefile that can be used with Microsoft Visual Studio. I have tested the build with the following versions:
- Microsoft Visual C++ 6.0 (does not build due to missing APIs)
- Microsoft Visual Studio 2003 .NET
- Microsoft Visual Studio 2005
- Intel ICC 11.1 + MSVC9 Platform SDK
This is accompanied by a small batch file that handles the instantiation of os_types.h
from os_types.h.in
. Together, these allow building Libao using only Microsoft tools.
(I have further tested the linking of a small sound application with the built library, and confirmed that it works correctly.)
I've tweaked things so that on Windows, the system config for Libao is at
C:\Program Files\Common Files\Xiph.Org\libao.conf
and the user config is at
${LOCALAPPDATA}\Xiph.Org\libao.conf
This follows Windows conventions reasonably well without resorting to the Registry.
In ao_private.h
, I've added two new sets of logging macros. One uses C99 syntax for variadic macros, supported by Visual Studio 2005 and later. The other is for older systems that do not support variadic macros at all. It's a hack, and has the shortcoming that messages are written to stdout
instead of stderr
, but it's better than nothing.
The remainder are small changes, which I'll describe below:
-
Makefile.am
: Added the two new Windows build files toEXTRA_DIST
-
include/ao/Makefile.am
: Don't includeos_types.h
(generated file) in the distribution tarball -
include/ao/ao_private.h
: Usestrdup()
with an underscore prefix to keep the Microsoft compiler happy -
src/ao_wmm.c
: Moved-D_CRT_SECURE_NO_DEPRECATE
out to the makefile, because it also quashes warnings in the other source files -
src/ao_wmm.c
: Use#pragma comment(lib)
directives to bake in a reference to the two Windows libraries required by this code; this simplifies application linking later -
src/ao_wmm.c
: Must#include<ks.h>
or else you get this error:
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\KsMedia.h(16) : fatal error C1189: #error : KS.H must be included before KSMEDIA.H
(Also, you must still #include<ksmedia.h>
, or else you don't get a usable definition of KSDATAFORMAT_SUBTYPE_PCM
)
-
src/ao_wmm.c
: Add missing newlines to various logging macros -
src/ao_wmm.c
: Check thatmax
is greater than zero, because otherwise the system has no sound devices (saw this on a Windows VM) -
src/ao_wmm.c
: Properly ignore unsupported options -
src/audio_out.c
:dirent.h
does not exist in Microsoft-land -
src/audio_out.c
: Don't#include"ao_private.h"
; this is #included fromao.h
-
src/audio_out.c
: Removed unused variable, flattened needless block -
src/config.c
: Corrected AO header #including -
src/config.c
: Removed unused variable