Fix SetDataFormat and implement GetDeviceInfo for mouse device.
[wine] / dlls / dmusic / dmusic.c
1 /* IDirectMusic Implementation
2  * IDirectMusic8 Implementation
3  * IDirectMusicDownload Implementation
4  * IDirectMusicBuffer Implementation
5  * IDirectMusicObject Implementation
6  *
7  * Copyright (C) 2003 Rok Mandeljc
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU Library General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22  */
23
24 #include "config.h"
25
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winreg.h"
29 #include "winuser.h"
30 #include "wingdi.h"
31 #include "winuser.h"
32 #include "winerror.h"
33 #include "mmsystem.h"
34 #include "winternl.h"
35 #include "mmddk.h"
36 #include "wine/windef16.h"
37 #include "wine/winbase16.h"
38 #include "wine/debug.h"
39 #include "dsound.h"
40
41 #include "dmusic_private.h"
42
43 WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
44
45 /* IDirectMusic IUnknown parts follow: */
46 HRESULT WINAPI IDirectMusicImpl_QueryInterface (LPDIRECTMUSIC iface, REFIID riid, LPVOID *ppobj)
47 {
48         ICOM_THIS(IDirectMusicImpl,iface);
49
50         if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDirectMusic))
51         {
52                 IDirectMusicImpl_AddRef(iface);
53                 *ppobj = This;
54                 return DS_OK;
55         }
56
57         WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
58         return E_NOINTERFACE;
59 }
60
61 ULONG WINAPI IDirectMusicImpl_AddRef (LPDIRECTMUSIC iface)
62 {
63         ICOM_THIS(IDirectMusicImpl,iface);
64         TRACE("(%p) : AddRef from %ld\n", This, This->ref);
65         return ++(This->ref);
66 }
67
68 ULONG WINAPI   IDirectMusicImpl_Release (LPDIRECTMUSIC iface)
69 {
70         ICOM_THIS(IDirectMusicImpl,iface);
71         ULONG ref = --This->ref;
72         TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
73         if (ref == 0)
74         {
75                 HeapFree(GetProcessHeap(), 0, This);
76         }
77         return ref;
78 }
79
80 /* IDirectMusic Interface follow: */
81 HRESULT WINAPI IDirectMusicImpl_EnumPort (LPDIRECTMUSIC iface, DWORD dwIndex, LPDMUS_PORTCAPS pPortCaps)
82 {
83         ICOM_THIS(IDirectMusicImpl,iface);
84         int numMIDI = midiOutGetNumDevs();
85         int numWAVE = waveOutGetNumDevs();
86         int i;
87         
88         TRACE("(%p, %ld, %p)\n", This, dwIndex, pPortCaps);
89         TRACE("1 software synth. + %i WAVE + %i MIDI available\n", numWAVE, numMIDI);
90         /* i guess the first port shown is always software synthesizer */
91         if (dwIndex == 0)
92         {
93                 TRACE("enumerating 'Microsoft Software Synthesizer' port\n");
94                 pPortCaps->dwSize = sizeof(DMUS_PORTCAPS);
95                 pPortCaps->dwFlags = DMUS_PC_DLS | DMUS_PC_SOFTWARESYNTH | DMUS_PC_DIRECTSOUND | DMUS_PC_DLS2 | DMUS_PC_AUDIOPATH | DMUS_PC_WAVE;
96                 pPortCaps->guidPort = CLSID_DirectMusicSynth;
97                 pPortCaps->dwClass = DMUS_PC_OUTPUTCLASS;
98                 pPortCaps->dwType = DMUS_PORT_WINMM_DRIVER;
99                 pPortCaps->dwMemorySize = DMUS_PC_SYSTEMMEMORY;
100                 pPortCaps->dwMaxChannelGroups = 1000;
101                 pPortCaps->dwMaxVoices = 1000;
102                 pPortCaps->dwMaxAudioChannels = -1;
103                 pPortCaps->dwEffectFlags = DMUS_EFFECT_REVERB | DMUS_EFFECT_CHORUS | DMUS_EFFECT_DELAY;
104                 MultiByteToWideChar (CP_ACP, 0, "Microsotf Synthesizer", -1, pPortCaps->wszDescription, sizeof(pPortCaps->wszDescription)/sizeof(WCHAR));
105                 return S_OK;
106         }
107         /* then return digital sound ports */
108         for (i = 1; i <= numWAVE; i++)
109         {
110                 TRACE("enumerating 'digital sound' ports\n");   
111                 if (i == dwIndex)
112                 {
113                         DirectSoundEnumerateA((LPDSENUMCALLBACKA)register_waveport, (VOID*)pPortCaps);
114                         return S_OK;    
115                 }
116         }
117         /* finally, list all *real* MIDI ports*/
118         for (i = numWAVE+1; i <= numWAVE + numMIDI; i++) 
119         {
120                 TRACE("enumerating 'real MIDI' ports\n");               
121                 if (i == dwIndex)
122                         FIXME("Found MIDI port, but *real* MIDI ports not supported yet\n");
123         }
124         
125         return S_FALSE;
126 }
127
128 HRESULT WINAPI IDirectMusicImpl_CreateMusicBuffer (LPDIRECTMUSIC iface, LPDMUS_BUFFERDESC pBufferDesc, LPDIRECTMUSICBUFFER** ppBuffer, LPUNKNOWN pUnkOuter)
129 {
130         FIXME("stub\n");
131         return DS_OK;
132 }
133
134 HRESULT WINAPI IDirectMusicImpl_CreatePort (LPDIRECTMUSIC iface, REFCLSID rclsidPort, LPDMUS_PORTPARAMS pPortParams, LPDIRECTMUSICPORT* ppPort, LPUNKNOWN pUnkOuter)
135 {
136         ICOM_THIS(IDirectMusicImpl,iface);
137         int i;
138         DMUS_PORTCAPS PortCaps;
139         
140         TRACE("(%p, %s, %p, %p, %p)\n", This, debugstr_guid(rclsidPort), pPortParams, ppPort, pUnkOuter);
141         for (i = 0; IDirectMusicImpl_EnumPort (iface, i, &PortCaps) != S_FALSE; i++)
142         {                               
143                 if (IsEqualGUID(rclsidPort, &PortCaps.guidPort))
144                 {               
145                         This->ports = HeapReAlloc(GetProcessHeap(),0,This->ports,sizeof(LPDIRECTMUSICPORT)*This->nrofports);
146                         if (NULL == This->ports[This->nrofports])
147                         {
148                                 *ppPort = (LPDIRECTMUSICPORT)NULL;
149                                 return E_OUTOFMEMORY;
150                         }
151                         This->ports[This->nrofports]->lpVtbl = &DirectMusicPort_Vtbl;
152                         This->ports[This->nrofports]->ref = 0;
153                         This->ports[This->nrofports]->active = FALSE;
154                         This->ports[This->nrofports]->caps = &PortCaps;
155                         This->ports[This->nrofports]->params = pPortParams;
156                         *ppPort = (LPDIRECTMUSICPORT)This->ports[This->nrofports];
157                         IDirectMusicPortImpl_AddRef ((LPDIRECTMUSICPORT)This->ports[This->nrofports]);
158                         This->nrofports ++;
159                         return S_OK;                    
160                 }
161         }
162         /* FIXME: place correct error here */
163         return E_NOINTERFACE;
164 }
165
166 HRESULT WINAPI IDirectMusicImpl_EnumMasterClock (LPDIRECTMUSIC iface, DWORD dwIndex, LPDMUS_CLOCKINFO lpClockInfo)
167 {
168         ICOM_THIS(IDirectMusicImpl,iface);
169
170         FIXME("(%p, %ld, %p): stub\n", This, dwIndex, lpClockInfo);
171
172         return S_OK;
173 }
174
175 HRESULT WINAPI IDirectMusicImpl_GetMasterClock (LPDIRECTMUSIC iface, LPGUID pguidClock, IReferenceClock** ppReferenceClock)
176 {
177         ICOM_THIS(IDirectMusicImpl,iface);
178         
179         FIXME("(%p, %s, %p): stub\n", This, debugstr_guid (pguidClock), ppReferenceClock);
180         
181         return S_OK;
182 }
183
184 HRESULT WINAPI IDirectMusicImpl_SetMasterClock (LPDIRECTMUSIC iface, REFGUID rguidClock)
185 {
186         ICOM_THIS(IDirectMusicImpl,iface);
187         
188         FIXME("(%p, %s): stub\n", This, debugstr_guid(rguidClock));
189         
190         return S_OK;
191 }
192
193 HRESULT WINAPI IDirectMusicImpl_Activate (LPDIRECTMUSIC iface, BOOL fEnable)
194 {
195         ICOM_THIS(IDirectMusicImpl,iface);
196         int i;
197         
198         TRACE("(%p, %i)", This,  fEnable);      
199         for (i = 0; i < This->nrofports; i++)   
200         {
201                 This->ports[i]->active = fEnable;
202         }
203         
204         return S_OK;
205 }
206
207 HRESULT WINAPI IDirectMusicImpl_GetDefaultPort (LPDIRECTMUSIC iface, LPGUID pguidPort)
208 {
209         ICOM_THIS(IDirectMusicImpl,iface);
210         HKEY hkGUID;
211         DWORD returnTypeGUID, sizeOfReturnBuffer = 50;
212         char returnBuffer[51];
213         GUID defaultPortGUID;
214         WCHAR    buff[51];
215
216         TRACE("(%p, %p)\n", This, pguidPort);
217         if ((RegOpenKeyExA (HKEY_LOCAL_MACHINE, "Software\\Microsoft\\DirectMusic\\Defaults" , 0, KEY_READ, &hkGUID) != ERROR_SUCCESS) || (RegQueryValueExA (hkGUID, "DefaultOutputPort", NULL, &returnTypeGUID, returnBuffer, &sizeOfReturnBuffer) != ERROR_SUCCESS))
218         {
219                 WARN(": registry entry missing\n" );
220                 *pguidPort = CLSID_DirectMusicSynth;
221                 return S_OK;
222         }
223         /* FIXME: Check return types to ensure we're interpreting data right */
224         MultiByteToWideChar (CP_ACP, 0, returnBuffer, -1, buff, sizeof(buff)/sizeof(WCHAR));
225         CLSIDFromString ((LPCOLESTR)buff, &defaultPortGUID);
226         *pguidPort = defaultPortGUID;
227         
228         return S_OK;
229 }
230
231 HRESULT WINAPI IDirectMusicImpl_SetDirectSound (LPDIRECTMUSIC iface, LPDIRECTSOUND pDirectSound, HWND hWnd)
232 {
233         ICOM_THIS(IDirectMusicImpl,iface);
234
235         FIXME("(%p, %p, %p): stub\n", This, pDirectSound, hWnd);
236
237         return S_OK;
238 }
239
240 ICOM_VTABLE(IDirectMusic) DirectMusic_Vtbl =
241 {
242     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
243         IDirectMusicImpl_QueryInterface,
244         IDirectMusicImpl_AddRef,
245         IDirectMusicImpl_Release,
246         IDirectMusicImpl_EnumPort,
247         IDirectMusicImpl_CreateMusicBuffer,
248         IDirectMusicImpl_CreatePort,
249         IDirectMusicImpl_EnumMasterClock,
250         IDirectMusicImpl_GetMasterClock,
251         IDirectMusicImpl_SetMasterClock,
252         IDirectMusicImpl_Activate,
253         IDirectMusicImpl_GetDefaultPort,
254         IDirectMusicImpl_SetDirectSound
255 };
256
257 /* for ClassFactory */
258 HRESULT WINAPI DMUSIC_CreateDirectMusic (LPCGUID lpcGUID, LPDIRECTMUSIC *ppDM, LPUNKNOWN pUnkOuter)
259 {
260         IDirectMusicImpl *dmusic;
261
262         TRACE("(%p,%p,%p)\n",lpcGUID, ppDM, pUnkOuter);
263         if (IsEqualGUID(lpcGUID, &IID_IDirectMusic))
264         {
265                 dmusic = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicImpl));
266                 if (NULL == dmusic)
267                 {
268                         *ppDM = (LPDIRECTMUSIC)NULL;
269                         return E_OUTOFMEMORY;
270                 }
271                 dmusic->lpVtbl = &DirectMusic_Vtbl;
272                 dmusic->ref = 1;
273                 *ppDM = (LPDIRECTMUSIC)dmusic;
274                 return S_OK;
275         }
276         WARN("No interface found\n");
277         
278         return E_NOINTERFACE;
279 }
280
281
282 /* IDirectMusic8 IUnknown parts follow: */
283 HRESULT WINAPI IDirectMusic8Impl_QueryInterface (LPDIRECTMUSIC8 iface, REFIID riid, LPVOID *ppobj)
284 {
285         ICOM_THIS(IDirectMusic8Impl,iface);
286
287         if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDirectMusic8))
288         {
289                 IDirectMusic8Impl_AddRef(iface);
290                 *ppobj = This;
291                 return DS_OK;
292         }
293         WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
294         return E_NOINTERFACE;
295 }
296
297 ULONG WINAPI IDirectMusic8Impl_AddRef (LPDIRECTMUSIC8 iface)
298 {
299         ICOM_THIS(IDirectMusic8Impl,iface);
300         TRACE("(%p) : AddRef from %ld\n", This, This->ref);
301         return ++(This->ref);
302 }
303
304 ULONG WINAPI IDirectMusic8Impl_Release (LPDIRECTMUSIC8 iface)
305 {
306         ICOM_THIS(IDirectMusic8Impl,iface);
307         ULONG ref = --This->ref;
308         TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
309         if (ref == 0)
310         {
311                 HeapFree(GetProcessHeap(), 0, This);
312         }
313         return ref;
314 }
315
316 /* IDirectMusic8 Interface follow: */
317 HRESULT WINAPI IDirectMusic8Impl_EnumPort (LPDIRECTMUSIC8 iface, DWORD dwIndex, LPDMUS_PORTCAPS pPortCaps)
318 {
319         FIXME("stub\n");
320         return DS_OK;
321 }
322
323 HRESULT WINAPI IDirectMusic8Impl_CreateMusicBuffer (LPDIRECTMUSIC8 iface, LPDMUS_BUFFERDESC pBufferDesc, LPDIRECTMUSICBUFFER** ppBuffer, LPUNKNOWN pUnkOuter)
324 {
325         FIXME("stub\n");
326         return DS_OK;
327 }
328
329 HRESULT WINAPI IDirectMusic8Impl_CreatePort (LPDIRECTMUSIC8 iface, REFCLSID rclsidPort, LPDMUS_PORTPARAMS pPortParams, LPDIRECTMUSICPORT* ppPort, LPUNKNOWN pUnkOuter)
330 {
331         ICOM_THIS(IDirectMusic8Impl,iface);
332         FIXME("(%p, %s, %p, %p, %p): stub\n", This, debugstr_guid(rclsidPort), pPortParams, ppPort, pUnkOuter);
333         return S_OK;
334 }
335
336 HRESULT WINAPI IDirectMusic8Impl_EnumMasterClock (LPDIRECTMUSIC8 iface, DWORD dwIndex, LPDMUS_CLOCKINFO lpClockInfo)
337 {
338         FIXME("stub\n");
339         return DS_OK;
340 }
341
342 HRESULT WINAPI IDirectMusic8Impl_GetMasterClock (LPDIRECTMUSIC8 iface, LPGUID pguidClock, IReferenceClock** ppReferenceClock)
343 {
344         FIXME("stub\n");
345         return DS_OK;
346 }
347
348 HRESULT WINAPI IDirectMusic8Impl_SetMasterClock (LPDIRECTMUSIC8 iface, REFGUID rguidClock)
349 {
350         FIXME("stub\n");
351         return DS_OK;
352 }
353
354 HRESULT WINAPI IDirectMusic8Impl_Activate (LPDIRECTMUSIC8 iface, BOOL fEnable)
355 {
356         FIXME("stub\n");
357         return DS_OK;
358 }
359
360 HRESULT WINAPI IDirectMusic8Impl_GetDefaultPort (LPDIRECTMUSIC8 iface, LPGUID pguidPort)
361 {
362         FIXME("stub\n");
363         return DS_OK;
364 }
365
366 HRESULT WINAPI IDirectMusic8Impl_SetDirectSound (LPDIRECTMUSIC8 iface, LPDIRECTSOUND pDirectSound, HWND hWnd)
367 {
368         FIXME("stub\n");
369         return DS_OK;
370 }
371
372 HRESULT WINAPI IDirectMusic8Impl_SetExternalMasterClock (LPDIRECTMUSIC8 iface, IReferenceClock* pClock)
373 {
374         FIXME("stub\n");
375         return DS_OK;
376 }
377
378 ICOM_VTABLE(IDirectMusic8) DirectMusic8_Vtbl =
379 {
380     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
381         IDirectMusic8Impl_QueryInterface,
382         IDirectMusic8Impl_AddRef,
383         IDirectMusic8Impl_Release,
384         IDirectMusic8Impl_EnumPort,
385         IDirectMusic8Impl_CreateMusicBuffer,
386         IDirectMusic8Impl_CreatePort,
387         IDirectMusic8Impl_EnumMasterClock,
388         IDirectMusic8Impl_GetMasterClock,
389         IDirectMusic8Impl_SetMasterClock,
390         IDirectMusic8Impl_Activate,
391         IDirectMusic8Impl_GetDefaultPort,
392         IDirectMusic8Impl_SetDirectSound,
393         IDirectMusic8Impl_SetExternalMasterClock
394 };
395
396
397 /* IDirectMusicDownload IUnknown parts follow: */
398 HRESULT WINAPI IDirectMusicDownloadImpl_QueryInterface (LPDIRECTMUSICDOWNLOAD iface, REFIID riid, LPVOID *ppobj)
399 {
400         ICOM_THIS(IDirectMusicDownloadImpl,iface);
401
402         if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDirectMusicDownload))
403         {
404                 IDirectMusicDownloadImpl_AddRef(iface);
405                 *ppobj = This;
406                 return DS_OK;
407         }
408         WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
409         return E_NOINTERFACE;
410 }
411
412 ULONG WINAPI IDirectMusicDownloadImpl_AddRef (LPDIRECTMUSICDOWNLOAD iface)
413 {
414         ICOM_THIS(IDirectMusicDownloadImpl,iface);
415         TRACE("(%p) : AddRef from %ld\n", This, This->ref);
416         return ++(This->ref);
417 }
418
419 ULONG WINAPI IDirectMusicDownloadImpl_Release (LPDIRECTMUSICDOWNLOAD iface)
420 {
421         ICOM_THIS(IDirectMusicDownloadImpl,iface);
422         ULONG ref = --This->ref;
423         TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
424         if (ref == 0)
425         {
426                 HeapFree(GetProcessHeap(), 0, This);
427         }
428         return ref;
429 }
430
431 /* IDirectMusicDownload Interface follow: */
432 HRESULT WINAPI IDirectMusicDownloadImpl_GetBuffer (LPDIRECTMUSICDOWNLOAD iface, void** ppvBuffer, DWORD* pdwSize)
433 {
434         FIXME("stub\n");
435         return DS_OK;
436 }
437
438 ICOM_VTABLE(IDirectMusicDownload) DirectMusicDownload_Vtbl =
439 {
440     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
441         IDirectMusicDownloadImpl_QueryInterface,
442         IDirectMusicDownloadImpl_AddRef,
443         IDirectMusicDownloadImpl_Release,
444         IDirectMusicDownloadImpl_GetBuffer
445 };
446
447
448 /* IDirectMusicBuffer IUnknown parts follow: */
449 HRESULT WINAPI IDirectMusicBufferImpl_QueryInterface (LPDIRECTMUSICBUFFER iface, REFIID riid, LPVOID *ppobj)
450 {
451         ICOM_THIS(IDirectMusicBufferImpl,iface);
452
453         if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDirectMusicBuffer))
454         {
455                 IDirectMusicBufferImpl_AddRef(iface);
456                 *ppobj = This;
457                 return DS_OK;
458         }
459         WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
460         return E_NOINTERFACE;
461 }
462
463 ULONG WINAPI IDirectMusicBufferImpl_AddRef (LPDIRECTMUSICBUFFER iface)
464 {
465         ICOM_THIS(IDirectMusicBufferImpl,iface);
466         TRACE("(%p) : AddRef from %ld\n", This, This->ref);
467         return ++(This->ref);
468 }
469
470 ULONG WINAPI IDirectMusicBufferImpl_Release (LPDIRECTMUSICBUFFER iface)
471 {
472         ICOM_THIS(IDirectMusicBufferImpl,iface);
473         ULONG ref = --This->ref;
474         TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
475         if (ref == 0)
476         {
477                 HeapFree(GetProcessHeap(), 0, This);
478         }
479         return ref;
480 }
481
482 /* IDirectMusicBuffer Interface follow: */
483 HRESULT WINAPI IDirectMusicBufferImpl_Flush (LPDIRECTMUSICBUFFER iface)
484 {
485         FIXME("stub\n");
486         return DS_OK;
487 }
488
489 HRESULT WINAPI IDirectMusicBufferImpl_TotalTime (LPDIRECTMUSICBUFFER iface, LPREFERENCE_TIME prtTime)
490 {
491         FIXME("stub\n");
492         return DS_OK;
493 }
494
495 HRESULT WINAPI IDirectMusicBufferImpl_PackStructured (LPDIRECTMUSICBUFFER iface, REFERENCE_TIME rt, DWORD dwChannelGroup, DWORD dwChannelMessage)
496 {
497         FIXME("stub\n");
498         return DS_OK;
499 }
500
501 HRESULT WINAPI IDirectMusicBufferImpl_PackUnstructured (LPDIRECTMUSICBUFFER iface, REFERENCE_TIME rt, DWORD dwChannelGroup, DWORD cb, LPBYTE lpb)
502 {
503         FIXME("stub\n");
504         return DS_OK;
505 }
506
507 HRESULT WINAPI IDirectMusicBufferImpl_ResetReadPtr (LPDIRECTMUSICBUFFER iface)
508 {
509         FIXME("stub\n");
510         return DS_OK;
511 }
512
513 HRESULT WINAPI IDirectMusicBufferImpl_GetNextEvent (LPDIRECTMUSICBUFFER iface, LPREFERENCE_TIME prt, LPDWORD pdwChannelGroup, LPDWORD pdwLength, LPBYTE* ppData)
514 {
515         FIXME("stub\n");
516         return DS_OK;
517 }
518
519 HRESULT WINAPI IDirectMusicBufferImpl_GetRawBufferPtr (LPDIRECTMUSICBUFFER iface, LPBYTE* ppData)
520 {
521         FIXME("stub\n");
522         return DS_OK;
523 }
524
525 HRESULT WINAPI IDirectMusicBufferImpl_GetStartTime (LPDIRECTMUSICBUFFER iface, LPREFERENCE_TIME prt)
526 {
527         FIXME("stub\n");
528         return DS_OK;
529 }
530
531 HRESULT WINAPI IDirectMusicBufferImpl_GetUsedBytes (LPDIRECTMUSICBUFFER iface, LPDWORD pcb)
532 {
533         FIXME("stub\n");
534         return DS_OK;
535 }
536
537 HRESULT WINAPI IDirectMusicBufferImpl_GetMaxBytes (LPDIRECTMUSICBUFFER iface, LPDWORD pcb)
538 {
539         FIXME("stub\n");
540         return DS_OK;
541 }
542
543 HRESULT WINAPI IDirectMusicBufferImpl_GetBufferFormat (LPDIRECTMUSICBUFFER iface, LPGUID pGuidFormat)
544 {
545         FIXME("stub\n");
546         return DS_OK;
547 }
548
549 HRESULT WINAPI IDirectMusicBufferImpl_SetStartTime (LPDIRECTMUSICBUFFER iface, REFERENCE_TIME rt)
550 {
551         FIXME("stub\n");
552         return DS_OK;
553 }
554
555 HRESULT WINAPI IDirectMusicBufferImpl_SetUsedBytes (LPDIRECTMUSICBUFFER iface, DWORD cb)
556 {
557         FIXME("stub\n");
558         return DS_OK;
559 }
560
561 ICOM_VTABLE(IDirectMusicBuffer) DirectMusicBuffer_Vtbl =
562 {
563     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
564         IDirectMusicBufferImpl_QueryInterface,
565         IDirectMusicBufferImpl_AddRef,
566         IDirectMusicBufferImpl_Release,
567         IDirectMusicBufferImpl_Flush,
568         IDirectMusicBufferImpl_TotalTime,
569         IDirectMusicBufferImpl_PackStructured,
570         IDirectMusicBufferImpl_PackUnstructured,
571         IDirectMusicBufferImpl_ResetReadPtr,
572         IDirectMusicBufferImpl_GetNextEvent,
573         IDirectMusicBufferImpl_GetRawBufferPtr,
574         IDirectMusicBufferImpl_GetStartTime,
575         IDirectMusicBufferImpl_GetUsedBytes,
576         IDirectMusicBufferImpl_GetMaxBytes,
577         IDirectMusicBufferImpl_GetBufferFormat,
578         IDirectMusicBufferImpl_SetStartTime,
579         IDirectMusicBufferImpl_SetUsedBytes
580 };
581
582
583 /* IDirectMusicObject IUnknown parts follow: */
584 HRESULT WINAPI IDirectMusicObjectImpl_QueryInterface (LPDIRECTMUSICOBJECT iface, REFIID riid, LPVOID *ppobj)
585 {
586         ICOM_THIS(IDirectMusicObjectImpl,iface);
587
588         if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDirectMusicObject))
589         {
590                 IDirectMusicObjectImpl_AddRef(iface);
591                 *ppobj = This;
592                 return DS_OK;
593         }
594         WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
595         return E_NOINTERFACE;
596 }
597
598 ULONG WINAPI IDirectMusicObjectImpl_AddRef (LPDIRECTMUSICOBJECT iface)
599 {
600         ICOM_THIS(IDirectMusicObjectImpl,iface);
601         TRACE("(%p) : AddRef from %ld\n", This, This->ref);
602         return ++(This->ref);
603 }
604
605 ULONG WINAPI IDirectMusicObjectImpl_Release (LPDIRECTMUSICOBJECT iface)
606 {
607         ICOM_THIS(IDirectMusicObjectImpl,iface);
608         ULONG ref = --This->ref;
609         TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
610         if (ref == 0)
611         {
612                 HeapFree(GetProcessHeap(), 0, This);
613         }
614         return ref;
615 }
616
617 /* IDirectMusicObject Interface follow: */
618 HRESULT WINAPI IDirectMusicObjectImpl_GetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc)
619 {
620         FIXME("stub\n");
621         return DS_OK;
622 }
623
624 HRESULT WINAPI IDirectMusicObjectImpl_SetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc)
625 {
626         FIXME("stub\n");
627         return DS_OK;
628 }
629
630 HRESULT WINAPI IDirectMusicObjectImpl_ParseDescriptor (LPDIRECTMUSICOBJECT iface, LPSTREAM pStream, LPDMUS_OBJECTDESC pDesc)
631 {
632         FIXME("stub\n");
633         return DS_OK;
634 }
635
636 ICOM_VTABLE(IDirectMusicObject) DirectMusicObject_Vtbl =
637 {
638     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
639         IDirectMusicObjectImpl_QueryInterface,
640         IDirectMusicObjectImpl_AddRef,
641         IDirectMusicObjectImpl_Release,
642         IDirectMusicObjectImpl_GetDescriptor,
643         IDirectMusicObjectImpl_SetDescriptor,
644         IDirectMusicObjectImpl_ParseDescriptor
645 };
646
647
648 /* helper stuff */
649 void register_waveport (LPGUID lpGUID, LPCSTR lpszDesc, LPCSTR lpszDrvName, LPVOID lpContext)
650 {
651         LPDMUS_PORTCAPS pPortCaps = (LPDMUS_PORTCAPS)lpContext;
652         
653         pPortCaps->dwSize = sizeof(DMUS_PORTCAPS);
654         pPortCaps->dwFlags = DMUS_PC_DLS | DMUS_PC_SOFTWARESYNTH | DMUS_PC_DIRECTSOUND | DMUS_PC_DLS2 | DMUS_PC_AUDIOPATH | DMUS_PC_WAVE;
655         pPortCaps->guidPort = *lpGUID;
656         pPortCaps->dwClass = DMUS_PC_OUTPUTCLASS;
657         pPortCaps->dwType = DMUS_PORT_WINMM_DRIVER;
658         pPortCaps->dwMemorySize = DMUS_PC_SYSTEMMEMORY;
659         pPortCaps->dwMaxChannelGroups = 1000;
660         pPortCaps->dwMaxVoices = 1000;
661         pPortCaps->dwMaxAudioChannels = -1;
662         pPortCaps->dwEffectFlags = DMUS_EFFECT_REVERB | DMUS_EFFECT_CHORUS | DMUS_EFFECT_DELAY;
663         MultiByteToWideChar (CP_ACP, 0, lpszDesc, -1, pPortCaps->wszDescription, sizeof(pPortCaps->wszDescription)/sizeof(WCHAR));
664 }