Framework for the doppler effect.
[wine] / dlls / dmusic / dmusic.c
1 /* IDirectMusic Implementation
2  *
3  * Copyright (C) 2003 Rok Mandeljc
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  */
19
20 #include "windef.h"
21 #include "winbase.h"
22 #include "winuser.h"
23 #include "wingdi.h"
24 #include "wine/debug.h"
25
26 #include "dmusic_private.h"
27
28 WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
29
30 /* for ClassFactory */
31 HRESULT WINAPI DMUSIC_CreateDirectMusic (LPCGUID lpcGUID, LPDIRECTMUSIC *ppDM, LPUNKNOWN pUnkOuter)
32 {
33         IDirectMusicImpl *dmusic;
34
35         TRACE("(%p,%p,%p)\n",lpcGUID, ppDM, pUnkOuter);
36
37
38         dmusic = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicImpl));
39         if (NULL == dmusic)
40         {
41                 *ppDM = (LPDIRECTMUSIC)NULL;
42                 return E_OUTOFMEMORY;
43         }
44         
45         dmusic->lpVtbl = &DirectMusic_Vtbl;
46         dmusic->ref = 1;
47         
48         *ppDM = (LPDIRECTMUSIC)dmusic;
49         return S_OK;
50         
51         WARN("No interface found\n");
52         return E_NOINTERFACE;
53 }
54
55 /* IDirectMusic IUnknown parts follow: */
56 HRESULT WINAPI IDirectMusicImpl_QueryInterface (LPDIRECTMUSIC iface, REFIID riid, LPVOID *ppobj)
57 {
58         ICOM_THIS(IDirectMusicImpl,iface);
59
60         if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDirectMusic))
61         {
62                 IDirectMusicImpl_AddRef(iface);
63                 *ppobj = This;
64                 return DS_OK;
65         }
66
67         WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
68         return E_NOINTERFACE;
69 }
70
71 ULONG WINAPI IDirectMusicImpl_AddRef (LPDIRECTMUSIC iface)
72 {
73         ICOM_THIS(IDirectMusicImpl,iface);
74         TRACE("(%p) : AddRef from %ld\n", This, This->ref);
75         return ++(This->ref);
76 }
77
78 ULONG WINAPI   IDirectMusicImpl_Release (LPDIRECTMUSIC iface)
79 {
80         ICOM_THIS(IDirectMusicImpl,iface);
81         ULONG ref = --This->ref;
82         TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
83         if (ref == 0)
84         {
85                 HeapFree(GetProcessHeap(), 0, This);
86         }
87         return ref;
88 }
89
90 /* IDirectMusic Interface follow: */
91 HRESULT WINAPI IDirectMusicImpl_EnumPort (LPDIRECTMUSIC iface, DWORD dwIndex, LPDMUS_PORTCAPS pPortCaps)
92 {
93         /* FIXME: this is only for making DXCapsViewer display something */
94         static const WCHAR name_WINE_SYNTHESIZER[] = {'W','i','n','e',' ','S','y','n','t','h','e','s','i','z','e','r',0};
95
96         if (dwIndex == 0)
97         {
98                 pPortCaps->dwSize = sizeof(DMUS_PORTCAPS);
99                 pPortCaps->dwFlags = DMUS_PC_DLS | DMUS_PC_SOFTWARESYNTH | DMUS_PC_DIRECTSOUND | DMUS_PC_DLS2 | DMUS_PC_AUDIOPATH | DMUS_PC_WAVE;
100                 /*pPortCaps->guidPort;*/ /* FIXME */
101                 pPortCaps->dwClass = DMUS_PC_OUTPUTCLASS;
102                 pPortCaps->dwType = DMUS_PORT_WINMM_DRIVER;
103                 pPortCaps->dwMemorySize = DMUS_PC_SYSTEMMEMORY;
104                 pPortCaps->dwMaxChannelGroups = 1000;
105                 pPortCaps->dwMaxVoices = 1000;
106                 pPortCaps->dwMaxAudioChannels = -1;
107                 pPortCaps->dwEffectFlags = DMUS_EFFECT_REVERB | DMUS_EFFECT_CHORUS | DMUS_EFFECT_DELAY;
108                 wsprintfW(pPortCaps->wszDescription, name_WINE_SYNTHESIZER);
109                 return S_OK;
110         }
111
112         FIXME("partial-stub (only first port supported)\n");
113         return S_FALSE;
114 }
115
116 HRESULT WINAPI IDirectMusicImpl_CreateMusicBuffer (LPDIRECTMUSIC iface, LPDMUS_BUFFERDESC pBufferDesc, LPDIRECTMUSICBUFFER** ppBuffer, LPUNKNOWN pUnkOuter)
117 {
118         FIXME("stub\n");
119         return DS_OK;
120 }
121
122 HRESULT WINAPI IDirectMusicImpl_CreatePort (LPDIRECTMUSIC iface, REFCLSID rclsidPort, LPDMUS_PORTPARAMS pPortParams, LPDIRECTMUSICPORT* ppPort, LPUNKNOWN pUnkOuter)
123 {
124         FIXME("stub\n");
125         return DS_OK;
126 }
127
128 HRESULT WINAPI IDirectMusicImpl_EnumMasterClock (LPDIRECTMUSIC iface, DWORD dwIndex, LPDMUS_CLOCKINFO lpClockInfo)
129 {
130         FIXME("stub\n");
131         return DS_OK;
132 }
133
134 HRESULT WINAPI IDirectMusicImpl_GetMasterClock (LPDIRECTMUSIC iface, LPGUID pguidClock, IReferenceClock** ppReferenceClock)
135 {
136         FIXME("stub\n");
137         return DS_OK;
138 }
139
140 HRESULT WINAPI IDirectMusicImpl_SetMasterClock (LPDIRECTMUSIC iface, REFGUID rguidClock)
141 {
142         FIXME("stub\n");
143         return DS_OK;
144 }
145
146 HRESULT WINAPI IDirectMusicImpl_Activate (LPDIRECTMUSIC iface, BOOL fEnable)
147 {
148         FIXME("stub\n");
149         return DS_OK;
150 }
151
152 HRESULT WINAPI IDirectMusicImpl_GetDefaultPort (LPDIRECTMUSIC iface, LPGUID pguidPort)
153 {
154         FIXME("stub\n");
155         return DS_OK;
156 }
157
158 HRESULT WINAPI IDirectMusicImpl_SetDirectSound (LPDIRECTMUSIC iface, LPDIRECTSOUND pDirectSound, HWND hWnd)
159 {
160         FIXME("stub\n");
161         return DS_OK;
162 }
163
164 ICOM_VTABLE(IDirectMusic) DirectMusic_Vtbl =
165 {
166     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
167         IDirectMusicImpl_QueryInterface,
168         IDirectMusicImpl_AddRef,
169         IDirectMusicImpl_Release,
170         IDirectMusicImpl_EnumPort,
171         IDirectMusicImpl_CreateMusicBuffer,
172         IDirectMusicImpl_CreatePort,
173         IDirectMusicImpl_EnumMasterClock,
174         IDirectMusicImpl_GetMasterClock,
175         IDirectMusicImpl_SetMasterClock,
176         IDirectMusicImpl_Activate,
177         IDirectMusicImpl_GetDefaultPort,
178         IDirectMusicImpl_SetDirectSound
179 };