Added an initial (mostly stub) implementation of MSHTML.DLL.
[wine] / dlls / dmusic / port.c
1 /* IDirectMusicPort 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 <stdarg.h>
21
22 #include "windef.h"
23 #include "winbase.h"
24 #include "winuser.h"
25 #include "wingdi.h"
26 #include "wine/debug.h"
27
28 #include "dmusic_private.h"
29
30 WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
31
32 /* IDirectMusicPort IUnknown parts follow: */
33 HRESULT WINAPI IDirectMusicPortImpl_QueryInterface (LPDIRECTMUSICPORT iface, REFIID riid, LPVOID *ppobj)
34 {
35         ICOM_THIS(IDirectMusicPortImpl,iface);
36
37         if (IsEqualIID (riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDirectMusicPort)) {
38                 IDirectMusicPortImpl_AddRef(iface);
39                 *ppobj = This;
40                 return S_OK;
41         }
42
43         WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
44         return E_NOINTERFACE;
45 }
46
47 ULONG WINAPI IDirectMusicPortImpl_AddRef (LPDIRECTMUSICPORT iface)
48 {
49         ICOM_THIS(IDirectMusicPortImpl,iface);
50         TRACE("(%p) : AddRef from %ld\n", This, This->ref);
51         return ++(This->ref);
52 }
53
54 ULONG WINAPI IDirectMusicPortImpl_Release (LPDIRECTMUSICPORT iface)
55 {
56         ICOM_THIS(IDirectMusicPortImpl,iface);
57         ULONG ref = --This->ref;
58         TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
59         if (ref == 0) {
60                 HeapFree(GetProcessHeap(), 0, This);
61         }
62         return ref;
63 }
64
65 /* IDirectMusicPort Interface follow: */
66 HRESULT WINAPI IDirectMusicPortImpl_PlayBuffer (LPDIRECTMUSICPORT iface, LPDIRECTMUSICBUFFER pBuffer)
67 {
68         ICOM_THIS(IDirectMusicPortImpl,iface);
69
70         FIXME("(%p, %p): stub\n", This, pBuffer);
71
72         return S_OK;
73 }
74
75 HRESULT WINAPI IDirectMusicPortImpl_SetReadNotificationHandle (LPDIRECTMUSICPORT iface, HANDLE hEvent)
76 {
77         ICOM_THIS(IDirectMusicPortImpl,iface);
78
79         FIXME("(%p, %p): stub\n", This, hEvent);
80
81         return S_OK;
82 }
83
84 HRESULT WINAPI IDirectMusicPortImpl_Read (LPDIRECTMUSICPORT iface, LPDIRECTMUSICBUFFER pBuffer)
85 {
86         ICOM_THIS(IDirectMusicPortImpl,iface);
87
88         FIXME("(%p, %p): stub\n", This, pBuffer);
89
90         return S_OK;
91 }
92
93 HRESULT WINAPI IDirectMusicPortImpl_DownloadInstrument (LPDIRECTMUSICPORT iface, IDirectMusicInstrument* pInstrument, IDirectMusicDownloadedInstrument** ppDownloadedInstrument, DMUS_NOTERANGE* pNoteRanges, DWORD dwNumNoteRanges)
94 {
95         ICOM_THIS(IDirectMusicPortImpl,iface);
96
97         FIXME("(%p, %p, %p, %p, %ld): stub\n", This, pInstrument, ppDownloadedInstrument, pNoteRanges, dwNumNoteRanges);
98
99         return S_OK;
100 }
101
102 HRESULT WINAPI IDirectMusicPortImpl_UnloadInstrument (LPDIRECTMUSICPORT iface, IDirectMusicDownloadedInstrument *pDownloadedInstrument)
103 {
104         ICOM_THIS(IDirectMusicPortImpl,iface);
105
106         FIXME("(%p, %p): stub\n", This, pDownloadedInstrument);
107
108         return S_OK;
109 }
110
111 HRESULT WINAPI IDirectMusicPortImpl_GetLatencyClock (LPDIRECTMUSICPORT iface, IReferenceClock** ppClock)
112 {
113         ICOM_THIS(IDirectMusicPortImpl,iface);
114
115         TRACE("(%p, %p)\n", This, ppClock);
116         *ppClock = This->pLatencyClock;
117         IReferenceClock_AddRef (*ppClock);
118         
119         return S_OK;
120 }
121
122 HRESULT WINAPI IDirectMusicPortImpl_GetRunningStats (LPDIRECTMUSICPORT iface, LPDMUS_SYNTHSTATS pStats)
123 {
124         ICOM_THIS(IDirectMusicPortImpl,iface);
125
126         FIXME("(%p, %p): stub\n", This, pStats);
127
128         return S_OK;
129 }
130
131 HRESULT WINAPI IDirectMusicPortImpl_GetCaps (LPDIRECTMUSICPORT iface, LPDMUS_PORTCAPS pPortCaps)
132 {
133         ICOM_THIS(IDirectMusicPortImpl,iface);
134         
135         TRACE("(%p, %p)\n", This, pPortCaps);
136         pPortCaps = This->pCaps;
137         
138         return S_OK;
139 }
140
141 HRESULT WINAPI IDirectMusicPortImpl_DeviceIoControl (LPDIRECTMUSICPORT iface, DWORD dwIoControlCode, LPVOID lpInBuffer, DWORD nInBufferSize, LPVOID lpOutBuffer, DWORD nOutBufferSize, LPDWORD lpBytesReturned, LPOVERLAPPED lpOverlapped)
142 {
143         ICOM_THIS(IDirectMusicPortImpl,iface);
144
145         FIXME("(%p, %ld, %p, %ld, %p, %ld, %p, %p): stub\n", This, dwIoControlCode, lpInBuffer, nInBufferSize, lpOutBuffer, nOutBufferSize, lpBytesReturned, lpOverlapped);
146
147         return S_OK;
148 }
149
150 HRESULT WINAPI IDirectMusicPortImpl_SetNumChannelGroups (LPDIRECTMUSICPORT iface, DWORD dwChannelGroups)
151 {
152         ICOM_THIS(IDirectMusicPortImpl,iface);
153
154         FIXME("(%p, %ld): semi-stub\n", This, dwChannelGroups);
155         This->nrofgroups = dwChannelGroups;
156         
157         return S_OK;
158 }
159
160 HRESULT WINAPI IDirectMusicPortImpl_GetNumChannelGroups (LPDIRECTMUSICPORT iface, LPDWORD pdwChannelGroups)
161 {
162         ICOM_THIS(IDirectMusicPortImpl,iface);
163
164         TRACE("(%p, %p)\n", This, pdwChannelGroups);
165         *pdwChannelGroups = This->nrofgroups;
166         
167         return S_OK;
168 }
169
170 HRESULT WINAPI IDirectMusicPortImpl_Activate (LPDIRECTMUSICPORT iface, BOOL fActive)
171 {
172         ICOM_THIS(IDirectMusicPortImpl,iface);
173
174         TRACE("(%p, %d)\n", This, fActive);
175         This->fActive = fActive;
176         
177         return S_OK;
178 }
179
180 HRESULT WINAPI IDirectMusicPortImpl_SetChannelPriority (LPDIRECTMUSICPORT iface, DWORD dwChannelGroup, DWORD dwChannel, DWORD dwPriority)
181 {
182         ICOM_THIS(IDirectMusicPortImpl,iface);
183         
184         FIXME("(%p, %ld, %ld, %ld): semi-stub\n", This, dwChannelGroup, dwChannel, dwPriority);
185         
186         if (dwChannel > 16)
187         {
188                 WARN("isn't there supposed to be 16 channels (no. %ld requested)?! (faking as it is ok)\n", dwChannel);
189                 /*return E_INVALIDARG;*/
190         }       
191         
192         return S_OK;
193 }
194
195 HRESULT WINAPI IDirectMusicPortImpl_GetChannelPriority (LPDIRECTMUSICPORT iface, DWORD dwChannelGroup, DWORD dwChannel, LPDWORD pdwPriority)
196 {
197         ICOM_THIS(IDirectMusicPortImpl,iface);
198
199         TRACE("(%p, %ld, %ld, %p)\n", This, dwChannelGroup, dwChannel, pdwPriority);
200         *pdwPriority = This->group[dwChannelGroup-1].channel[dwChannel].priority;
201         
202         return S_OK;
203 }
204
205 HRESULT WINAPI IDirectMusicPortImpl_SetDirectSound (LPDIRECTMUSICPORT iface, LPDIRECTSOUND pDirectSound, LPDIRECTSOUNDBUFFER pDirectSoundBuffer)
206 {
207         ICOM_THIS(IDirectMusicPortImpl,iface);
208
209         FIXME("(%p, %p, %p): stub\n", This, pDirectSound, pDirectSoundBuffer);
210
211         return S_OK;
212 }
213
214 HRESULT WINAPI IDirectMusicPortImpl_GetFormat (LPDIRECTMUSICPORT iface, LPWAVEFORMATEX pWaveFormatEx, LPDWORD pdwWaveFormatExSize, LPDWORD pdwBufferSize)
215 {
216         ICOM_THIS(IDirectMusicPortImpl,iface);
217
218         FIXME("(%p, %p, %p, %p): stub\n", This, pWaveFormatEx, pdwWaveFormatExSize, pdwBufferSize);
219
220         return S_OK;
221 }
222
223 ICOM_VTABLE(IDirectMusicPort) DirectMusicPort_Vtbl =
224 {
225     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
226         IDirectMusicPortImpl_QueryInterface,
227         IDirectMusicPortImpl_AddRef,
228         IDirectMusicPortImpl_Release,
229         IDirectMusicPortImpl_PlayBuffer,
230         IDirectMusicPortImpl_SetReadNotificationHandle,
231         IDirectMusicPortImpl_Read,
232         IDirectMusicPortImpl_DownloadInstrument,
233         IDirectMusicPortImpl_UnloadInstrument,
234         IDirectMusicPortImpl_GetLatencyClock,
235         IDirectMusicPortImpl_GetRunningStats,
236         IDirectMusicPortImpl_GetCaps,
237         IDirectMusicPortImpl_DeviceIoControl,
238         IDirectMusicPortImpl_SetNumChannelGroups,
239         IDirectMusicPortImpl_GetNumChannelGroups,
240         IDirectMusicPortImpl_Activate,
241         IDirectMusicPortImpl_SetChannelPriority,
242         IDirectMusicPortImpl_GetChannelPriority,
243         IDirectMusicPortImpl_SetDirectSound,
244         IDirectMusicPortImpl_GetFormat
245 };
246
247 /* for ClassFactory */
248 HRESULT WINAPI DMUSIC_CreateDirectMusicPort (LPCGUID lpcGUID, LPDIRECTMUSICPORT* ppDMPort, LPUNKNOWN pUnkOuter)
249 {
250         if (IsEqualIID (lpcGUID, &IID_IDirectMusicPort))
251         {
252                 FIXME("Not yet\n");
253                 return E_NOINTERFACE;
254         }
255         WARN("No interface found\n");
256         
257         return E_NOINTERFACE;   
258 }