dmusic: Rename IDirectMusicPortImpl object to SynthPortImpl.
[wine] / dlls / dmusic / port.c
1 /*
2  * IDirectMusicPort Implementation
3  *
4  * Copyright (C) 2003-2004 Rok Mandeljc
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #include "dmusic_private.h"
22
23 WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
24
25 static inline SynthPortImpl *impl_from_SynthPortImpl_IDirectMusicPort(IDirectMusicPort *iface)
26 {
27     return CONTAINING_RECORD(iface, SynthPortImpl, IDirectMusicPort_iface);
28 }
29
30 static inline SynthPortImpl *impl_from_SynthPortImpl_IDirectMusicPortDownload(IDirectMusicPortDownload *iface)
31 {
32     return CONTAINING_RECORD(iface, SynthPortImpl, IDirectMusicPortDownload_iface);
33 }
34
35 static inline SynthPortImpl *impl_from_SynthPortImpl_IDirectMusicThru(IDirectMusicThru *iface)
36 {
37     return CONTAINING_RECORD(iface, SynthPortImpl, IDirectMusicThru_iface);
38 }
39
40 /* SynthPortImpl IDirectMusicPort IUnknown part follows: */
41 static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_QueryInterface(LPDIRECTMUSICPORT iface, REFIID riid, LPVOID *ppobj)
42 {
43         SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
44
45         TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
46
47         if (IsEqualIID (riid, &IID_IUnknown) ||
48             IsEqualGUID(riid, &IID_IDirectMusicPort) ||
49             IsEqualGUID(riid, &IID_IDirectMusicPort8)) {
50                 *ppobj = &This->IDirectMusicPort_iface;
51                 IDirectMusicPort_AddRef((LPDIRECTMUSICPORT)*ppobj);
52                 return S_OK;
53         } else if (IsEqualGUID(riid, &IID_IDirectMusicPortDownload) ||
54                    IsEqualGUID(riid, &IID_IDirectMusicPortDownload8)) {
55                 *ppobj = &This->IDirectMusicPortDownload_iface;
56                 IDirectMusicPortDownload_AddRef((LPDIRECTMUSICPORTDOWNLOAD)*ppobj);
57                 return S_OK;
58         } else if (IsEqualGUID(riid, &IID_IDirectMusicThru) ||
59                    IsEqualGUID(riid, &IID_IDirectMusicThru8)) {
60                 *ppobj = &This->IDirectMusicThru_iface;
61                 IDirectMusicThru_AddRef((LPDIRECTMUSICTHRU)*ppobj);
62                 return S_OK;
63         }
64         WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ppobj);
65         return E_NOINTERFACE;
66 }
67
68 static ULONG WINAPI SynthPortImpl_IDirectMusicPort_AddRef(LPDIRECTMUSICPORT iface)
69 {
70     SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
71     ULONG ref = InterlockedIncrement(&This->ref);
72
73     TRACE("(%p)->(): new ref = %u\n", This, ref);
74
75     DMUSIC_LockModule();
76
77     return ref;
78 }
79
80 static ULONG WINAPI SynthPortImpl_IDirectMusicPort_Release(LPDIRECTMUSICPORT iface)
81 {
82     SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
83     ULONG ref = InterlockedDecrement(&This->ref);
84
85     TRACE("(%p)->(): new ref = %u\n", This, ref);
86
87     if (!ref)
88         HeapFree(GetProcessHeap(), 0, This);
89
90     DMUSIC_UnlockModule();
91
92     return ref;
93 }
94
95 /* SynthPortImpl IDirectMusicPort interface follows: */
96 static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_PlayBuffer(LPDIRECTMUSICPORT iface, LPDIRECTMUSICBUFFER buffer)
97 {
98     SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
99
100     FIXME("(%p/%p)->(%p): stub\n", iface, This, buffer);
101
102     return S_OK;
103 }
104
105 static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_SetReadNotificationHandle(LPDIRECTMUSICPORT iface, HANDLE event)
106 {
107     SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
108
109     FIXME("(%p/%p)->(%p): stub\n", iface, This, event);
110
111     return S_OK;
112 }
113
114 static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_Read(LPDIRECTMUSICPORT iface, LPDIRECTMUSICBUFFER buffer)
115 {
116     SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
117
118     FIXME("(%p/%p)->(%p): stub\n", iface, This, buffer);
119
120     return S_OK;
121 }
122
123 static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_DownloadInstrument(LPDIRECTMUSICPORT iface, IDirectMusicInstrument* pInstrument, IDirectMusicDownloadedInstrument** ppDownloadedInstrument, DMUS_NOTERANGE* pNoteRanges, DWORD dwNumNoteRanges)
124 {
125         SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
126
127         FIXME("(%p, %p, %p, %p, %d): stub\n", This, pInstrument, ppDownloadedInstrument, pNoteRanges, dwNumNoteRanges);
128
129         if (!pInstrument || !ppDownloadedInstrument || (dwNumNoteRanges && !pNoteRanges))
130                 return E_POINTER;
131
132         return DMUSIC_CreateDirectMusicDownloadedInstrumentImpl(&IID_IDirectMusicDownloadedInstrument, (LPVOID*)ppDownloadedInstrument, NULL);
133 }
134
135 static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_UnloadInstrument(LPDIRECTMUSICPORT iface, IDirectMusicDownloadedInstrument *downloaded_instrument)
136 {
137     SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
138
139     FIXME("(%p/%p)->(%p): stub\n", iface, This, downloaded_instrument);
140
141     return S_OK;
142 }
143
144 static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_GetLatencyClock(LPDIRECTMUSICPORT iface, IReferenceClock** clock)
145 {
146     SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
147
148     TRACE("(%p/%p)->(%p)\n", iface, This, clock);
149
150     *clock = This->pLatencyClock;
151     IReferenceClock_AddRef(*clock);
152
153     return S_OK;
154 }
155
156 static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_GetRunningStats(LPDIRECTMUSICPORT iface, LPDMUS_SYNTHSTATS stats)
157 {
158     SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
159
160     FIXME("(%p/%p)->(%p): stub\n", iface, This, stats);
161
162     return S_OK;
163 }
164
165 static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_Compact(LPDIRECTMUSICPORT iface)
166 {
167     SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
168
169     FIXME("(%p/%p)->(): stub\n", iface, This);
170
171     return S_OK;
172 }
173
174 static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_GetCaps(LPDIRECTMUSICPORT iface, LPDMUS_PORTCAPS port_caps)
175 {
176     SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
177
178     TRACE("(%p/%p)->(%p)\n", iface, This, port_caps);
179
180     *port_caps = This->caps;
181
182     return S_OK;
183 }
184
185 static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_DeviceIoControl(LPDIRECTMUSICPORT iface, DWORD io_control_code, LPVOID in_buffer, DWORD in_buffer_size,
186                                                            LPVOID out_buffer, DWORD out_buffer_size, LPDWORD bytes_returned, LPOVERLAPPED overlapped)
187 {
188     SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
189
190     FIXME("(%p/%p)->(%d, %p, %d, %p, %d, %p, %p): stub\n", iface, This, io_control_code, in_buffer, in_buffer_size, out_buffer, out_buffer_size, bytes_returned, overlapped);
191
192     return S_OK;
193 }
194
195 static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_SetNumChannelGroups(LPDIRECTMUSICPORT iface, DWORD channel_groups)
196 {
197     SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
198
199     FIXME("(%p/%p)->(%d): semi-stub\n", iface, This, channel_groups);
200
201     This->nrofgroups = channel_groups;
202
203     return S_OK;
204 }
205
206 static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_GetNumChannelGroups(LPDIRECTMUSICPORT iface, LPDWORD channel_groups)
207 {
208     SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
209
210     TRACE("(%p/%p)->(%p)\n", iface, This, channel_groups);
211
212     *channel_groups = This->nrofgroups;
213
214     return S_OK;
215 }
216
217 static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_Activate(LPDIRECTMUSICPORT iface, BOOL active)
218 {
219     SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
220
221     TRACE("(%p/%p)->(%d)\n", iface, This, active);
222
223     This->fActive = active;
224
225     return S_OK;
226 }
227
228 static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_SetChannelPriority(LPDIRECTMUSICPORT iface, DWORD channel_group, DWORD channel, DWORD priority)
229 {
230     SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
231
232     FIXME("(%p/%p)->(%d, %d, %d): semi-stub\n", iface, This, channel_group, channel, priority);
233
234     if (channel > 16)
235     {
236         WARN("isn't there supposed to be 16 channels (no. %d requested)?! (faking as it is ok)\n", channel);
237         /*return E_INVALIDARG;*/
238     }
239
240     return S_OK;
241 }
242
243 static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_GetChannelPriority(LPDIRECTMUSICPORT iface, DWORD channel_group, DWORD channel, LPDWORD priority)
244 {
245     SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
246
247     TRACE("(%p/%p)->(%u, %u, %p)\n", iface, This, channel_group, channel, priority);
248
249     *priority = This->group[channel_group - 1].channel[channel].priority;
250
251     return S_OK;
252 }
253
254 static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_SetDirectSound(LPDIRECTMUSICPORT iface, LPDIRECTSOUND direct_sound, LPDIRECTSOUNDBUFFER direct_sound_buffer)
255 {
256     SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
257
258     FIXME("(%p/%p)->(%p, %p): stub\n", iface, This, direct_sound, direct_sound_buffer);
259
260     return S_OK;
261 }
262
263 static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_GetFormat(LPDIRECTMUSICPORT iface, LPWAVEFORMATEX pWaveFormatEx, LPDWORD pdwWaveFormatExSize, LPDWORD pdwBufferSize)
264 {
265         SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
266         WAVEFORMATEX format;
267         FIXME("(%p, %p, %p, %p): stub\n", This, pWaveFormatEx, pdwWaveFormatExSize, pdwBufferSize);
268
269         if (pWaveFormatEx == NULL)
270         {
271                 if (pdwWaveFormatExSize)
272                         *pdwWaveFormatExSize = sizeof(format);
273                 else
274                         return E_POINTER;
275         }
276         else
277         {
278                 if (pdwWaveFormatExSize == NULL)
279                         return E_POINTER;
280
281                 /* Just fill this in with something that will not crash Direct Sound for now. */
282                 /* It won't be used anyway until Performances are completed */
283                 format.wFormatTag = WAVE_FORMAT_PCM;
284                 format.nChannels = 2; /* This->params.dwAudioChannels; */
285                 format.nSamplesPerSec = 44100; /* This->params.dwSampleRate; */
286                 format.wBitsPerSample = 16;     /* FIXME: check this */
287                 format.nBlockAlign = (format.wBitsPerSample * format.nChannels) / 8;
288                 format.nAvgBytesPerSec = format.nSamplesPerSec * format.nBlockAlign;
289                 format.cbSize = 0;
290
291                 if (*pdwWaveFormatExSize >= sizeof(format))
292                 {
293                         CopyMemory(pWaveFormatEx, &format, min(sizeof(format), *pdwWaveFormatExSize));
294                         *pdwWaveFormatExSize = sizeof(format);  /* FIXME check if this is set */
295                 }
296                 else
297                         return E_POINTER;       /* FIXME find right error */
298         }
299
300         if (pdwBufferSize)
301                 *pdwBufferSize = 44100 * 2 * 2;
302         else
303                 return E_POINTER;
304
305         return S_OK;
306 }
307
308 static const IDirectMusicPortVtbl SynthPortImpl_DirectMusicPort_Vtbl = {
309     SynthPortImpl_IDirectMusicPort_QueryInterface,
310     SynthPortImpl_IDirectMusicPort_AddRef,
311     SynthPortImpl_IDirectMusicPort_Release,
312     SynthPortImpl_IDirectMusicPort_PlayBuffer,
313     SynthPortImpl_IDirectMusicPort_SetReadNotificationHandle,
314     SynthPortImpl_IDirectMusicPort_Read,
315     SynthPortImpl_IDirectMusicPort_DownloadInstrument,
316     SynthPortImpl_IDirectMusicPort_UnloadInstrument,
317     SynthPortImpl_IDirectMusicPort_GetLatencyClock,
318     SynthPortImpl_IDirectMusicPort_GetRunningStats,
319     SynthPortImpl_IDirectMusicPort_Compact,
320     SynthPortImpl_IDirectMusicPort_GetCaps,
321     SynthPortImpl_IDirectMusicPort_DeviceIoControl,
322     SynthPortImpl_IDirectMusicPort_SetNumChannelGroups,
323     SynthPortImpl_IDirectMusicPort_GetNumChannelGroups,
324     SynthPortImpl_IDirectMusicPort_Activate,
325     SynthPortImpl_IDirectMusicPort_SetChannelPriority,
326     SynthPortImpl_IDirectMusicPort_GetChannelPriority,
327     SynthPortImpl_IDirectMusicPort_SetDirectSound,
328     SynthPortImpl_IDirectMusicPort_GetFormat
329 };
330
331 /* SynthPortImpl IDirectMusicPortDownload IUnknown part follows: */
332 static HRESULT WINAPI SynthPortImpl_IDirectMusicPortDownload_QueryInterface(LPDIRECTMUSICPORTDOWNLOAD iface, REFIID riid, LPVOID *ret_iface)
333 {
334     SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPortDownload(iface);
335
336     TRACE("(%p/%p)->(%s, %p)\n", iface, This, debugstr_dmguid(riid), ret_iface);
337
338     return IDirectMusicPort_QueryInterface(&This->IDirectMusicPort_iface, riid, ret_iface);
339 }
340
341 static ULONG WINAPI SynthPortImpl_IDirectMusicPortDownload_AddRef (LPDIRECTMUSICPORTDOWNLOAD iface)
342 {
343     SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPortDownload(iface);
344
345     TRACE("(%p/%p)->()\n", iface, This);
346
347     return IDirectMusicPort_AddRef(&This->IDirectMusicPort_iface);
348 }
349
350 static ULONG WINAPI SynthPortImpl_IDirectMusicPortDownload_Release(LPDIRECTMUSICPORTDOWNLOAD iface)
351 {
352     SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPortDownload(iface);
353
354     TRACE("(%p/%p)->()\n", iface, This);
355
356     return IDirectMusicPort_Release(&This->IDirectMusicPort_iface);
357 }
358
359 /* SynthPortImpl IDirectMusicPortDownload Interface follows: */
360 static HRESULT WINAPI SynthPortImpl_IDirectMusicPortDownload_GetBuffer(LPDIRECTMUSICPORTDOWNLOAD iface, DWORD DLId, IDirectMusicDownload** IDMDownload)
361 {
362     SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPortDownload(iface);
363
364     FIXME("(%p/%p)->(%u, %p): stub\n", iface, This, DLId, IDMDownload);
365
366     if (!IDMDownload)
367         return E_POINTER;
368
369     return DMUSIC_CreateDirectMusicDownloadImpl(&IID_IDirectMusicDownload, (LPVOID*)IDMDownload, NULL);
370 }
371
372 static HRESULT WINAPI SynthPortImpl_IDirectMusicPortDownload_AllocateBuffer(LPDIRECTMUSICPORTDOWNLOAD iface, DWORD size, IDirectMusicDownload** IDMDownload)
373 {
374     SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPortDownload(iface);
375
376     FIXME("(%p/%p)->(%u, %p): stub\n", iface, This, size, IDMDownload);
377
378     return S_OK;
379 }
380
381 static HRESULT WINAPI SynthPortImpl_IDirectMusicPortDownload_GetDLId(LPDIRECTMUSICPORTDOWNLOAD iface, DWORD* start_DLId, DWORD count)
382 {
383     SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPortDownload(iface);
384
385     FIXME("(%p/%p)->(%p, %u): stub\n", iface, This, start_DLId, count);
386
387     return S_OK;
388 }
389
390 static HRESULT WINAPI SynthPortImpl_IDirectMusicPortDownload_GetAppend (LPDIRECTMUSICPORTDOWNLOAD iface, DWORD* append)
391 {
392     SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPortDownload(iface);
393
394     FIXME("(%p/%p)->(%p): stub\n", iface, This, append);
395
396     return S_OK;
397 }
398
399 static HRESULT WINAPI SynthPortImpl_IDirectMusicPortDownload_Download(LPDIRECTMUSICPORTDOWNLOAD iface, IDirectMusicDownload* IDMDownload)
400 {
401     SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPortDownload(iface);
402
403     FIXME("(%p/%p)->(%p): stub\n", iface, This, IDMDownload);
404
405     return S_OK;
406 }
407
408 static HRESULT WINAPI SynthPortImpl_IDirectMusicPortDownload_Unload(LPDIRECTMUSICPORTDOWNLOAD iface, IDirectMusicDownload* IDMDownload)
409 {
410     SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPortDownload(iface);
411
412     FIXME("(%p/%p)->(%p): stub\n", iface, This, IDMDownload);
413
414     return S_OK;
415 }
416
417 static const IDirectMusicPortDownloadVtbl SynthPortImpl_DirectMusicPortDownload_Vtbl = {
418     SynthPortImpl_IDirectMusicPortDownload_QueryInterface,
419     SynthPortImpl_IDirectMusicPortDownload_AddRef,
420     SynthPortImpl_IDirectMusicPortDownload_Release,
421     SynthPortImpl_IDirectMusicPortDownload_GetBuffer,
422     SynthPortImpl_IDirectMusicPortDownload_AllocateBuffer,
423     SynthPortImpl_IDirectMusicPortDownload_GetDLId,
424     SynthPortImpl_IDirectMusicPortDownload_GetAppend,
425     SynthPortImpl_IDirectMusicPortDownload_Download,
426     SynthPortImpl_IDirectMusicPortDownload_Unload
427 };
428
429 /* SynthPortImpl IDirectMusicThru IUnknown part follows: */
430 static HRESULT WINAPI SynthPortImpl_IDirectMusicThru_QueryInterface(LPDIRECTMUSICTHRU iface, REFIID riid, LPVOID *ret_iface)
431 {
432     SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicThru(iface);
433
434     TRACE("(%p/%p)->(%s, %p)\n", iface, This, debugstr_dmguid(riid), ret_iface);
435
436     return IDirectMusicPort_QueryInterface(&This->IDirectMusicPort_iface, riid, ret_iface);
437 }
438
439 static ULONG WINAPI SynthPortImpl_IDirectMusicThru_AddRef(LPDIRECTMUSICTHRU iface)
440 {
441     SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicThru(iface);
442
443     TRACE("(%p/%p)->()\n", iface, This);
444
445     return IDirectMusicPort_AddRef(&This->IDirectMusicPort_iface);
446 }
447
448 static ULONG WINAPI SynthPortImpl_IDirectMusicThru_Release(LPDIRECTMUSICTHRU iface)
449 {
450     SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicThru(iface);
451
452     TRACE("(%p/%p)->()\n", iface, This);
453
454     return IDirectMusicPort_Release(&This->IDirectMusicPort_iface);
455 }
456
457 /*  SynthPortImpl IDirectMusicThru Interface follows: */
458 static HRESULT WINAPI SynthPortImpl_IDirectMusicThru_ThruChannel(LPDIRECTMUSICTHRU iface, DWORD source_channel_group, DWORD source_channel, DWORD destination_channel_group,
459                                                        DWORD destination_channel, LPDIRECTMUSICPORT destination_port)
460 {
461     SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicThru(iface);
462
463     FIXME("(%p/%p)->(%d, %d, %d, %d, %p): stub\n", iface, This, source_channel_group, source_channel, destination_channel_group, destination_channel, destination_port);
464
465     return S_OK;
466 }
467
468 static const IDirectMusicThruVtbl SynthPortImpl_DirectMusicThru_Vtbl = {
469     SynthPortImpl_IDirectMusicThru_QueryInterface,
470     SynthPortImpl_IDirectMusicThru_AddRef,
471     SynthPortImpl_IDirectMusicThru_Release,
472     SynthPortImpl_IDirectMusicThru_ThruChannel
473 };
474
475 HRESULT DMUSIC_CreateSynthPortImpl(LPCGUID lpcGUID, LPVOID *ppobj, LPUNKNOWN pUnkOuter, LPDMUS_PORTPARAMS pPortParams, LPDMUS_PORTCAPS pPortCaps, DWORD device)
476 {
477         SynthPortImpl *obj;
478         HRESULT hr = E_FAIL;
479         UINT j;
480
481         TRACE("(%p,%p,%p,%d)\n", lpcGUID, ppobj, pUnkOuter, device);
482
483         obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(SynthPortImpl));
484         if (NULL == obj) {
485                 *ppobj = NULL;
486                 return E_OUTOFMEMORY;
487         }
488         obj->IDirectMusicPort_iface.lpVtbl = &SynthPortImpl_DirectMusicPort_Vtbl;
489         obj->IDirectMusicPortDownload_iface.lpVtbl = &SynthPortImpl_DirectMusicPortDownload_Vtbl;
490         obj->IDirectMusicThru_iface.lpVtbl = &SynthPortImpl_DirectMusicThru_Vtbl;
491         obj->ref = 0;  /* will be inited by QueryInterface */
492         obj->fActive = FALSE;
493         obj->params = *pPortParams;
494         obj->caps = *pPortCaps;
495         obj->pDirectSound = NULL;
496         obj->pLatencyClock = NULL;
497         hr = DMUSIC_CreateReferenceClockImpl(&IID_IReferenceClock, (LPVOID*)&obj->pLatencyClock, NULL);
498         if(hr != S_OK)
499         {
500                 HeapFree(GetProcessHeap(), 0, obj);
501                 return hr;
502         }
503
504 if(0)
505 {
506         if (pPortParams->dwValidParams & DMUS_PORTPARAMS_CHANNELGROUPS) {
507           obj->nrofgroups = pPortParams->dwChannelGroups;
508           /* setting default priorities */                      
509           for (j = 0; j < obj->nrofgroups; j++) {
510             TRACE ("Setting default channel priorities on channel group %i\n", j + 1);
511             obj->group[j].channel[0].priority = DAUD_CHAN1_DEF_VOICE_PRIORITY;
512             obj->group[j].channel[1].priority = DAUD_CHAN2_DEF_VOICE_PRIORITY;
513             obj->group[j].channel[2].priority = DAUD_CHAN3_DEF_VOICE_PRIORITY;
514             obj->group[j].channel[3].priority = DAUD_CHAN4_DEF_VOICE_PRIORITY;
515             obj->group[j].channel[4].priority = DAUD_CHAN5_DEF_VOICE_PRIORITY;
516             obj->group[j].channel[5].priority = DAUD_CHAN6_DEF_VOICE_PRIORITY;
517             obj->group[j].channel[6].priority = DAUD_CHAN7_DEF_VOICE_PRIORITY;
518             obj->group[j].channel[7].priority = DAUD_CHAN8_DEF_VOICE_PRIORITY;
519             obj->group[j].channel[8].priority = DAUD_CHAN9_DEF_VOICE_PRIORITY;
520             obj->group[j].channel[9].priority = DAUD_CHAN10_DEF_VOICE_PRIORITY;
521             obj->group[j].channel[10].priority = DAUD_CHAN11_DEF_VOICE_PRIORITY;
522             obj->group[j].channel[11].priority = DAUD_CHAN12_DEF_VOICE_PRIORITY;
523             obj->group[j].channel[12].priority = DAUD_CHAN13_DEF_VOICE_PRIORITY;
524             obj->group[j].channel[13].priority = DAUD_CHAN14_DEF_VOICE_PRIORITY;
525             obj->group[j].channel[14].priority = DAUD_CHAN15_DEF_VOICE_PRIORITY;
526             obj->group[j].channel[15].priority = DAUD_CHAN16_DEF_VOICE_PRIORITY;
527           }
528         }
529 }
530
531         return IDirectMusicPort_QueryInterface((LPDIRECTMUSICPORT)obj, lpcGUID, ppobj);
532 }
533
534 HRESULT DMUSIC_CreateMidiOutPortImpl(LPCGUID guid, LPVOID *object, LPUNKNOWN unkouter, LPDMUS_PORTPARAMS port_params, LPDMUS_PORTCAPS port_caps, DWORD device)
535 {
536     TRACE("(%p,%p,%p,%p,%p,%d): stub\n", guid, object, unkouter, port_params, port_caps, device);
537
538     return E_NOTIMPL;
539 }
540
541 HRESULT DMUSIC_CreateMidiInPortImpl(LPCGUID guid, LPVOID *object, LPUNKNOWN unkouter, LPDMUS_PORTPARAMS port_params, LPDMUS_PORTCAPS port_caps, DWORD device)
542 {
543     TRACE("(%p,%p,%p,%p,%p,%d): stub\n", guid, object, unkouter, port_params, port_caps, device);
544
545     return E_NOTIMPL;
546 }