Fix subclassing to support nested messages.
[wine] / dlls / dmsynth / synthsink.c
1 /* IDirectMusicSynthSink 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 "dmsynth_private.h"
21
22 WINE_DEFAULT_DEBUG_CHANNEL(dmsynth);
23
24 /* IDirectMusicSynthSinkImpl IUnknown part: */
25 HRESULT WINAPI IDirectMusicSynthSinkImpl_QueryInterface (LPDIRECTMUSICSYNTHSINK iface, REFIID riid, LPVOID *ppobj) {
26         ICOM_THIS(IDirectMusicSynthSinkImpl,iface);
27         TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
28
29         if (IsEqualIID (riid, &IID_IUnknown) || 
30             IsEqualIID (riid, &IID_IDirectMusicSynthSink)) {
31                 IDirectMusicSynthSinkImpl_AddRef(iface);
32                 *ppobj = This;
33                 return S_OK;
34         }
35         WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ppobj);
36         return E_NOINTERFACE;
37 }
38
39 ULONG WINAPI IDirectMusicSynthSinkImpl_AddRef (LPDIRECTMUSICSYNTHSINK iface) {
40         ICOM_THIS(IDirectMusicSynthSinkImpl,iface);
41         TRACE("(%p): AddRef from %ld\n", This, This->ref);
42         return ++(This->ref);
43 }
44
45 ULONG WINAPI IDirectMusicSynthSinkImpl_Release (LPDIRECTMUSICSYNTHSINK iface) {
46         ICOM_THIS(IDirectMusicSynthSinkImpl,iface);
47         ULONG ref = --This->ref;
48         TRACE("(%p): ReleaseRef to %ld\n", This, This->ref);
49         if (ref == 0) {
50                 HeapFree(GetProcessHeap(), 0, This);
51         }
52         return ref;
53 }
54
55 /* IDirectMusicSynthSinkImpl IDirectMusicSynthSink part: */
56 HRESULT WINAPI IDirectMusicSynthSinkImpl_Init (LPDIRECTMUSICSYNTHSINK iface, IDirectMusicSynth* pSynth) {
57         ICOM_THIS(IDirectMusicSynthSinkImpl,iface);
58         FIXME("(%p, %p): stub\n", This, pSynth);
59         return S_OK;
60 }
61
62 HRESULT WINAPI IDirectMusicSynthSinkImpl_SetMasterClock (LPDIRECTMUSICSYNTHSINK iface, IReferenceClock* pClock) {
63         ICOM_THIS(IDirectMusicSynthSinkImpl,iface);
64         FIXME("(%p, %p): stub\n", This, pClock);
65         return S_OK;
66 }
67
68 HRESULT WINAPI IDirectMusicSynthSinkImpl_GetLatencyClock (LPDIRECTMUSICSYNTHSINK iface, IReferenceClock** ppClock) {
69         ICOM_THIS(IDirectMusicSynthSinkImpl,iface);
70         FIXME("(%p, %p): stub\n", This, ppClock);
71         return S_OK;
72 }
73
74 HRESULT WINAPI IDirectMusicSynthSinkImpl_Activate (LPDIRECTMUSICSYNTHSINK iface, BOOL fEnable) {
75         ICOM_THIS(IDirectMusicSynthSinkImpl,iface);
76         FIXME("(%p, %d): stub\n", This, fEnable);
77         return S_OK;
78 }
79
80 HRESULT WINAPI IDirectMusicSynthSinkImpl_SampleToRefTime (LPDIRECTMUSICSYNTHSINK iface, LONGLONG llSampleTime, REFERENCE_TIME* prfTime) {
81         ICOM_THIS(IDirectMusicSynthSinkImpl,iface);
82         FIXME("(%p, %lli, %p): stub\n", This, llSampleTime, prfTime);
83         return S_OK;
84 }
85
86 HRESULT WINAPI IDirectMusicSynthSinkImpl_RefTimeToSample (LPDIRECTMUSICSYNTHSINK iface, REFERENCE_TIME rfTime, LONGLONG* pllSampleTime) {
87         ICOM_THIS(IDirectMusicSynthSinkImpl,iface);
88         FIXME("(%p, %lli, %p): stub\n", This, rfTime, pllSampleTime );
89         return S_OK;
90 }
91
92 HRESULT WINAPI IDirectMusicSynthSinkImpl_SetDirectSound (LPDIRECTMUSICSYNTHSINK iface, LPDIRECTSOUND pDirectSound, LPDIRECTSOUNDBUFFER pDirectSoundBuffer) {
93         ICOM_THIS(IDirectMusicSynthSinkImpl,iface);
94         FIXME("(%p, %p, %p): stub\n", This, pDirectSound, pDirectSoundBuffer);
95         return S_OK;
96 }
97
98 HRESULT WINAPI IDirectMusicSynthSinkImpl_GetDesiredBufferSize (LPDIRECTMUSICSYNTHSINK iface, LPDWORD pdwBufferSizeInSamples) {
99         ICOM_THIS(IDirectMusicSynthSinkImpl,iface);
100         FIXME("(%p, %p): stub\n", This, pdwBufferSizeInSamples);
101         return S_OK;
102 }
103
104 ICOM_VTABLE(IDirectMusicSynthSink) DirectMusicSynthSink_Vtbl = {
105     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
106         IDirectMusicSynthSinkImpl_QueryInterface,
107         IDirectMusicSynthSinkImpl_AddRef,
108         IDirectMusicSynthSinkImpl_Release,
109         IDirectMusicSynthSinkImpl_Init,
110         IDirectMusicSynthSinkImpl_SetMasterClock,
111         IDirectMusicSynthSinkImpl_GetLatencyClock,
112         IDirectMusicSynthSinkImpl_Activate,
113         IDirectMusicSynthSinkImpl_SampleToRefTime,
114         IDirectMusicSynthSinkImpl_RefTimeToSample,
115         IDirectMusicSynthSinkImpl_SetDirectSound,
116         IDirectMusicSynthSinkImpl_GetDesiredBufferSize
117 };
118
119 /* for ClassFactory */
120 HRESULT WINAPI DMUSIC_CreateDirectMusicSynthSinkImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) {
121         IDirectMusicSynthSinkImpl *obj;
122         
123         TRACE("(%p,%p,%p)\n", lpcGUID, ppobj, pUnkOuter);
124         obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicSynthSinkImpl));
125         if (NULL == obj) {
126                 *ppobj = (LPDIRECTMUSICSYNTHSINK) NULL;
127                 return E_OUTOFMEMORY;
128         }
129         obj->lpVtbl = &DirectMusicSynthSink_Vtbl;
130         obj->ref = 0;
131         
132         return IDirectMusicSynthSinkImpl_QueryInterface((LPDIRECTMUSICSYNTHSINK)obj, lpcGUID, ppobj);
133 }