Preliminary implementation of ICreateTypeInfo2_fnAddFuncDesc() and
[wine] / dlls / dmusic / port.c
1 /* IDirectMusicPort Implementation
2  *
3  * Copyright (C) 2003-2004 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 "dmusic_private.h"
21
22 WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
23
24 /* IDirectMusicPortImpl IUnknown part: */
25 HRESULT WINAPI IDirectMusicPortImpl_QueryInterface (LPDIRECTMUSICPORT iface, REFIID riid, LPVOID *ppobj) {
26         ICOM_THIS(IDirectMusicPortImpl,iface);
27
28         if (IsEqualIID (riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDirectMusicPort)) {
29                 IDirectMusicPortImpl_AddRef(iface);
30                 *ppobj = This;
31                 return S_OK;
32         }
33         WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
34         return E_NOINTERFACE;
35 }
36
37 ULONG WINAPI IDirectMusicPortImpl_AddRef (LPDIRECTMUSICPORT iface) {
38         ICOM_THIS(IDirectMusicPortImpl,iface);
39         TRACE("(%p) : AddRef from %ld\n", This, This->ref);
40         return ++(This->ref);
41 }
42
43 ULONG WINAPI IDirectMusicPortImpl_Release (LPDIRECTMUSICPORT iface) {
44         ICOM_THIS(IDirectMusicPortImpl,iface);
45         ULONG ref = --This->ref;
46         TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
47         if (ref == 0) {
48                 HeapFree(GetProcessHeap(), 0, This);
49         }
50         return ref;
51 }
52
53 /* IDirectMusicPortImpl IDirectMusicPort part: */
54 HRESULT WINAPI IDirectMusicPortImpl_PlayBuffer (LPDIRECTMUSICPORT iface, LPDIRECTMUSICBUFFER pBuffer) {
55         ICOM_THIS(IDirectMusicPortImpl,iface);
56         FIXME("(%p, %p): stub\n", This, pBuffer);
57         return S_OK;
58 }
59
60 HRESULT WINAPI IDirectMusicPortImpl_SetReadNotificationHandle (LPDIRECTMUSICPORT iface, HANDLE hEvent) {
61         ICOM_THIS(IDirectMusicPortImpl,iface);
62         FIXME("(%p, %p): stub\n", This, hEvent);
63         return S_OK;
64 }
65
66 HRESULT WINAPI IDirectMusicPortImpl_Read (LPDIRECTMUSICPORT iface, LPDIRECTMUSICBUFFER pBuffer) {
67         ICOM_THIS(IDirectMusicPortImpl,iface);
68         FIXME("(%p, %p): stub\n", This, pBuffer);
69         return S_OK;
70 }
71
72 HRESULT WINAPI IDirectMusicPortImpl_DownloadInstrument (LPDIRECTMUSICPORT iface, IDirectMusicInstrument* pInstrument, IDirectMusicDownloadedInstrument** ppDownloadedInstrument, DMUS_NOTERANGE* pNoteRanges, DWORD dwNumNoteRanges) {
73         ICOM_THIS(IDirectMusicPortImpl,iface);
74         FIXME("(%p, %p, %p, %p, %ld): stub\n", This, pInstrument, ppDownloadedInstrument, pNoteRanges, dwNumNoteRanges);
75         return S_OK;
76 }
77
78 HRESULT WINAPI IDirectMusicPortImpl_UnloadInstrument (LPDIRECTMUSICPORT iface, IDirectMusicDownloadedInstrument *pDownloadedInstrument) {
79         ICOM_THIS(IDirectMusicPortImpl,iface);
80         FIXME("(%p, %p): stub\n", This, pDownloadedInstrument);
81         return S_OK;
82 }
83
84 HRESULT WINAPI IDirectMusicPortImpl_GetLatencyClock (LPDIRECTMUSICPORT iface, IReferenceClock** ppClock) {
85         ICOM_THIS(IDirectMusicPortImpl,iface);
86         TRACE("(%p, %p)\n", This, ppClock);
87         *ppClock = This->pLatencyClock;
88         IReferenceClock_AddRef (*ppClock);
89         return S_OK;
90 }
91
92 HRESULT WINAPI IDirectMusicPortImpl_GetRunningStats (LPDIRECTMUSICPORT iface, LPDMUS_SYNTHSTATS pStats) {
93         ICOM_THIS(IDirectMusicPortImpl,iface);
94         FIXME("(%p, %p): stub\n", This, pStats);
95         return S_OK;
96 }
97
98 HRESULT WINAPI IDirectMusicPortImpl_Compact (LPDIRECTMUSICPORT iface) {
99         ICOM_THIS(IDirectMusicPortImpl,iface);
100         FIXME("(%p): stub\n", This);
101         return S_OK;
102 }
103
104 HRESULT WINAPI IDirectMusicPortImpl_GetCaps (LPDIRECTMUSICPORT iface, LPDMUS_PORTCAPS pPortCaps) {
105         ICOM_THIS(IDirectMusicPortImpl,iface);
106         TRACE("(%p, %p)\n", This, pPortCaps);
107         pPortCaps = This->pCaps;        
108         return S_OK;
109 }
110
111 HRESULT WINAPI IDirectMusicPortImpl_DeviceIoControl (LPDIRECTMUSICPORT iface, DWORD dwIoControlCode, LPVOID lpInBuffer, DWORD nInBufferSize, LPVOID lpOutBuffer, DWORD nOutBufferSize, LPDWORD lpBytesReturned, LPOVERLAPPED lpOverlapped) {
112         ICOM_THIS(IDirectMusicPortImpl,iface);
113         FIXME("(%p, %ld, %p, %ld, %p, %ld, %p, %p): stub\n", This, dwIoControlCode, lpInBuffer, nInBufferSize, lpOutBuffer, nOutBufferSize, lpBytesReturned, lpOverlapped);
114         return S_OK;
115 }
116
117 HRESULT WINAPI IDirectMusicPortImpl_SetNumChannelGroups (LPDIRECTMUSICPORT iface, DWORD dwChannelGroups) {
118         ICOM_THIS(IDirectMusicPortImpl,iface);
119         FIXME("(%p, %ld): semi-stub\n", This, dwChannelGroups);
120         This->nrofgroups = dwChannelGroups;
121         return S_OK;
122 }
123
124 HRESULT WINAPI IDirectMusicPortImpl_GetNumChannelGroups (LPDIRECTMUSICPORT iface, LPDWORD pdwChannelGroups) {
125         ICOM_THIS(IDirectMusicPortImpl,iface);
126         TRACE("(%p, %p)\n", This, pdwChannelGroups);
127         *pdwChannelGroups = This->nrofgroups;
128         return S_OK;
129 }
130
131 HRESULT WINAPI IDirectMusicPortImpl_Activate (LPDIRECTMUSICPORT iface, BOOL fActive) {
132         ICOM_THIS(IDirectMusicPortImpl,iface);
133         TRACE("(%p, %d)\n", This, fActive);
134         This->fActive = fActive;
135         return S_OK;
136 }
137
138 HRESULT WINAPI IDirectMusicPortImpl_SetChannelPriority (LPDIRECTMUSICPORT iface, DWORD dwChannelGroup, DWORD dwChannel, DWORD dwPriority) {
139         ICOM_THIS(IDirectMusicPortImpl,iface);
140         FIXME("(%p, %ld, %ld, %ld): semi-stub\n", This, dwChannelGroup, dwChannel, dwPriority);
141         if (dwChannel > 16) {
142                 WARN("isn't there supposed to be 16 channels (no. %ld requested)?! (faking as it is ok)\n", dwChannel);
143                 /*return E_INVALIDARG;*/
144         }       
145         return S_OK;
146 }
147
148 HRESULT WINAPI IDirectMusicPortImpl_GetChannelPriority (LPDIRECTMUSICPORT iface, DWORD dwChannelGroup, DWORD dwChannel, LPDWORD pdwPriority) {
149         ICOM_THIS(IDirectMusicPortImpl,iface);
150         TRACE("(%p, %ld, %ld, %p)\n", This, dwChannelGroup, dwChannel, pdwPriority);
151         *pdwPriority = This->group[dwChannelGroup-1].channel[dwChannel].priority;
152         return S_OK;
153 }
154
155 HRESULT WINAPI IDirectMusicPortImpl_SetDirectSound (LPDIRECTMUSICPORT iface, LPDIRECTSOUND pDirectSound, LPDIRECTSOUNDBUFFER pDirectSoundBuffer) {
156         ICOM_THIS(IDirectMusicPortImpl,iface);
157         FIXME("(%p, %p, %p): stub\n", This, pDirectSound, pDirectSoundBuffer);
158         return S_OK;
159 }
160
161 HRESULT WINAPI IDirectMusicPortImpl_GetFormat (LPDIRECTMUSICPORT iface, LPWAVEFORMATEX pWaveFormatEx, LPDWORD pdwWaveFormatExSize, LPDWORD pdwBufferSize) {
162         ICOM_THIS(IDirectMusicPortImpl,iface);
163         FIXME("(%p, %p, %p, %p): stub\n", This, pWaveFormatEx, pdwWaveFormatExSize, pdwBufferSize);
164         return S_OK;
165 }
166
167 ICOM_VTABLE(IDirectMusicPort) DirectMusicPort_Vtbl = {
168     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
169         IDirectMusicPortImpl_QueryInterface,
170         IDirectMusicPortImpl_AddRef,
171         IDirectMusicPortImpl_Release,
172         IDirectMusicPortImpl_PlayBuffer,
173         IDirectMusicPortImpl_SetReadNotificationHandle,
174         IDirectMusicPortImpl_Read,
175         IDirectMusicPortImpl_DownloadInstrument,
176         IDirectMusicPortImpl_UnloadInstrument,
177         IDirectMusicPortImpl_GetLatencyClock,
178         IDirectMusicPortImpl_GetRunningStats,
179         IDirectMusicPortImpl_Compact,
180         IDirectMusicPortImpl_GetCaps,
181         IDirectMusicPortImpl_DeviceIoControl,
182         IDirectMusicPortImpl_SetNumChannelGroups,
183         IDirectMusicPortImpl_GetNumChannelGroups,
184         IDirectMusicPortImpl_Activate,
185         IDirectMusicPortImpl_SetChannelPriority,
186         IDirectMusicPortImpl_GetChannelPriority,
187         IDirectMusicPortImpl_SetDirectSound,
188         IDirectMusicPortImpl_GetFormat
189 };