Skip to content

Commit 508e916

Browse files
committed
Add the Terf SOundPlugin for win32, minus the AEC code (cuz this requires
boost). Add a Makefile to disable the failing CameraPlugin build on cygwin.
1 parent 252be09 commit 508e916

File tree

10 files changed

+1394
-278
lines changed

10 files changed

+1394
-278
lines changed

build.win32x86/common/Makefile.msvc.tools

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ DL:=/DEFAULTLIB:
8787
NDL:=/NODEFAULTLIB:
8888

8989
STDLIBS:=$(STDLIBS) $(NDL)libc $(NDL)libcmt $(DL)msvcrt \
90-
dinput8.lib ws2_32.lib comdlg32.lib ole32.lib winmm.lib \
90+
dinput8.lib dsound.lib ws2_32.lib comdlg32.lib ole32.lib winmm.lib \
9191
version.lib wininet.lib user32.lib gdi32.lib psapi.lib \
9292
advapi32.lib kernel32.lib secur32.lib shell32.lib shfolder.lib
9393

build.win64x64/common/Makefile.msvc.tools

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ DL:=/DEFAULTLIB:
9797
NDL:=/NODEFAULTLIB:
9898

9999
STDLIBS:=$(STDLIBS) $(NDL)libc $(NDL)libcmt $(DL)msvcrt \
100-
dinput8.lib ws2_32.lib comdlg32.lib ole32.lib winmm.lib \
100+
dinput8.lib dsound.lib ws2_32.lib comdlg32.lib ole32.lib winmm.lib \
101101
version.lib wininet.lib user32.lib gdi32.lib psapi.lib \
102102
advapi32.lib kernel32.lib secur32.lib shell32.lib shfolder.lib
103103

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# CameraPlugin build assumes it's external.
2+
# Further it must be built using the MSVC++ toolchain because of lack of COM
3+
# support in the mingw toolchain. Hence this Makefile.plugin exists only to
4+
# exclude CameraPlugin on the cygwin/mingw build (sadly).
5+
6+
EXTRALIBS:=strmbase.lib strmiids.lib
7+
8+
PREREQUISITES:=$(WIN32MISCDIR)/atlbase.h # no atlbase.h for cygwin
9+
10+
include ../common/Makefile.plugin
11+
12+
INCLUDES:=-I$(WIN32MISCDIR) $(INCLUDES)
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#include "sqDSoundClassFactory.h"
2+
#include "sq.h"
3+
#include <tchar.h>
4+
5+
#include "sqWin32DPRINTF.h"
6+
7+
typedef HRESULT (CALLBACK * GETCLASSOBJECTPROC)(REFCLSID, REFIID, LPVOID *);
8+
static HMODULE hDSoundDLL = NULL;
9+
static GETCLASSOBJECTPROC fProc = NULL;
10+
11+
12+
int dsound_InitClassFactory()
13+
{
14+
hDSoundDLL = LoadLibraryA("dsound.dll");
15+
if (hDSoundDLL == NULL) {
16+
DPRINTF(("ERROR dsound_InitClassFactory(): cannot load 'dsound.dll'\n"));
17+
return 0;
18+
}
19+
if (fProc) {
20+
DPRINTF(("WARNING dsound_InitClassFactory(): 'fProc' already non-NULL\n"));
21+
}
22+
fProc = (GETCLASSOBJECTPROC)GetProcAddress(hDSoundDLL, "DllGetClassObject");
23+
if (fProc == NULL) {
24+
DPRINTF(("ERROR dsound_InitClassFactory(): cannot load 'DllGetClassObject()'\n"));
25+
return 0;
26+
}
27+
return 1;
28+
}
29+
30+
31+
int
32+
dsound_ShutdownClassFactory()
33+
{
34+
if (hDSoundDLL)
35+
FreeLibrary(hDSoundDLL);
36+
hDSoundDLL = NULL;
37+
fProc = NULL;
38+
return 1;
39+
}
40+
41+
42+
IClassFactory* dsound_GetClassFactory(REFCLSID classID)
43+
{
44+
IClassFactory* factory;
45+
46+
// For some reason, IID_IClassFactory isn't available to the cygwin linker (although
47+
// it compiles/links fine for MSVC). Instead, I manually construct the IID for
48+
// IClassFactory.
49+
//HRESULT hr = fProc(classID, IID_IClassFactory, (void**)&factory);
50+
IID iid = {NULL};
51+
HRESULT hr = IIDFromString((LPOLESTR)(L"{00000001-0000-0000-C000-000000000046}"), &iid);
52+
if (FAILED(hr)) {
53+
DPRINTF(("ERROR dsound_GetClassFactory(): failed to initialize IID for IClassFactory\n"));
54+
return NULL;
55+
}
56+
hr = fProc(classID, iid, (void**)&factory);
57+
if (FAILED(hr)) {
58+
DPRINTF(("ERROR dsound_GetClassFactory(): failed to obtain class-factory\n"));
59+
return NULL;
60+
}
61+
return factory;
62+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#ifndef __SQ_DSOUND_CLASS_FACTORY_H__
2+
#define __SQ_DSOUND_CLASS_FACTORY_H__
3+
4+
#include <dsound.h>
5+
#include <dsconf.h>
6+
7+
#ifdef __cplusplus
8+
extern "C" {
9+
#endif
10+
11+
int dsound_InitClassFactory(void);
12+
int dsound_ShutdownClassFactory(void);
13+
IClassFactory* dsound_GetClassFactory(REFCLSID classID);
14+
15+
#ifdef __cplusplus
16+
}
17+
#endif
18+
19+
#endif /* #ifndef __SQ_DSOUND_CLASS_FACTORY_H__ */
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/* Declare/define the necessary GUIDs */
2+
3+
#include <initguid.h>
4+
5+
/* Including <initguid.h> above results in INITGUID being #defined.
6+
The files below include macros which declare/define GUID values.
7+
Since INITGUID is defined, these macros actually define and
8+
initialize the GUIDs; if INITGUID is not defined, these same
9+
macros simply declare an extern reference to the GUID.
10+
11+
Therefore, we must #include the GUID-defining header files below
12+
exactly once while INITGUID is defined (we can #include them
13+
as often as we want when INITGUID is not defined). Otherwise,
14+
we will fail with either multiply-defined or undefined symbols.
15+
16+
For further discussion, see http://support.microsoft.com/kb/130869,
17+
or Google for "INITGUID".
18+
*/
19+
20+
/* If we're built as an internal plugin, the sqWin32GUID.c takes care
21+
of these definitions. */
22+
#ifndef SQUEAK_BUILTIN_PLUGIN
23+
#include <dsound.h>
24+
#include <dsconf.h>
25+
#endif
26+
27+
#include <mmdeviceapi.h>
28+
#include <wmcodecdsp.h>
29+
#include <uuids.h>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include "sqWin32.h"
2+
3+
/* Need separate cases for GNU C and MSVC. */
4+
#ifdef DEBUG
5+
#warning "DEBUG printing enabled"
6+
#define DPRINTF(x) warnPrintf x
7+
#define CRASH(x) warnPrintf x
8+
#elif defined(_DEBUG)
9+
#pragma message ( "DEBUG printing enabled" )
10+
#define DPRINTF(x) { warnPrintf x; fflush(stdout); }
11+
#define CRASH(x) { int *foo = NULL; warnPrintf x; fflush(stdout); foo[10] = 20; }
12+
#else
13+
#define DPRINTF(x)
14+
#define CRASH(x)
15+
#endif

0 commit comments

Comments
 (0)