msi/tests: Prevent crash when ConvertSidToStringSidA is not available.
[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
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (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 GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18  */
19
20 #include "dmsynth_private.h"
21
22 WINE_DEFAULT_DEBUG_CHANNEL(dmsynth);
23
24 /* IDirectMusicSynthSinkImpl IUnknown part: */
25 static HRESULT WINAPI IDirectMusicSynthSinkImpl_QueryInterface (LPDIRECTMUSICSYNTHSINK iface, REFIID riid, LPVOID *ppobj) {
26         IDirectMusicSynthSinkImpl *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                 IUnknown_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 static ULONG WINAPI IDirectMusicSynthSinkImpl_AddRef (LPDIRECTMUSICSYNTHSINK iface) {
40         IDirectMusicSynthSinkImpl *This = (IDirectMusicSynthSinkImpl *)iface;
41         ULONG refCount = InterlockedIncrement(&This->ref);
42
43         TRACE("(%p)->(ref before=%u)\n", This, refCount - 1);
44
45         DMSYNTH_LockModule();
46
47         return refCount;
48 }
49
50 static ULONG WINAPI IDirectMusicSynthSinkImpl_Release (LPDIRECTMUSICSYNTHSINK iface) {
51         IDirectMusicSynthSinkImpl *This = (IDirectMusicSynthSinkImpl *)iface;
52         ULONG refCount = InterlockedDecrement(&This->ref);
53
54         TRACE("(%p)->(ref before=%u)\n", This, refCount + 1);
55
56         if (!refCount) {
57                 HeapFree(GetProcessHeap(), 0, This);
58         }
59
60         DMSYNTH_UnlockModule();
61
62         return refCount;
63 }
64
65 /* IDirectMusicSynthSinkImpl IDirectMusicSynthSink part: */
66 static HRESULT WINAPI IDirectMusicSynthSinkImpl_Init (LPDIRECTMUSICSYNTHSINK iface, IDirectMusicSynth* pSynth) {
67         IDirectMusicSynthSinkImpl *This = (IDirectMusicSynthSinkImpl *)iface;
68         FIXME("(%p, %p): stub\n", This, pSynth);
69         return S_OK;
70 }
71
72 static HRESULT WINAPI IDirectMusicSynthSinkImpl_SetMasterClock (LPDIRECTMUSICSYNTHSINK iface, IReferenceClock* pClock) {
73         IDirectMusicSynthSinkImpl *This = (IDirectMusicSynthSinkImpl *)iface;
74         FIXME("(%p, %p): stub\n", This, pClock);
75         return S_OK;
76 }
77
78 static HRESULT WINAPI IDirectMusicSynthSinkImpl_GetLatencyClock (LPDIRECTMUSICSYNTHSINK iface, IReferenceClock** ppClock) {
79         IDirectMusicSynthSinkImpl *This = (IDirectMusicSynthSinkImpl *)iface;
80         FIXME("(%p, %p): stub\n", This, ppClock);
81         return S_OK;
82 }
83
84 static HRESULT WINAPI IDirectMusicSynthSinkImpl_Activate (LPDIRECTMUSICSYNTHSINK iface, BOOL fEnable) {
85         IDirectMusicSynthSinkImpl *This = (IDirectMusicSynthSinkImpl *)iface;
86         FIXME("(%p, %d): stub\n", This, fEnable);
87         return S_OK;
88 }
89
90 static HRESULT WINAPI IDirectMusicSynthSinkImpl_SampleToRefTime (LPDIRECTMUSICSYNTHSINK iface, LONGLONG llSampleTime, REFERENCE_TIME* prfTime) {
91         IDirectMusicSynthSinkImpl *This = (IDirectMusicSynthSinkImpl *)iface;
92         FIXME("(%p, 0x%s, %p): stub\n", This, wine_dbgstr_longlong(llSampleTime), prfTime);
93         return S_OK;
94 }
95
96 static HRESULT WINAPI IDirectMusicSynthSinkImpl_RefTimeToSample (LPDIRECTMUSICSYNTHSINK iface, REFERENCE_TIME rfTime, LONGLONG* pllSampleTime) {
97         IDirectMusicSynthSinkImpl *This = (IDirectMusicSynthSinkImpl *)iface;
98         FIXME("(%p, 0x%s, %p): stub\n", This, wine_dbgstr_longlong(rfTime), pllSampleTime );
99         return S_OK;
100 }
101
102 static HRESULT WINAPI IDirectMusicSynthSinkImpl_SetDirectSound (LPDIRECTMUSICSYNTHSINK iface, LPDIRECTSOUND pDirectSound, LPDIRECTSOUNDBUFFER pDirectSoundBuffer) {
103         IDirectMusicSynthSinkImpl *This = (IDirectMusicSynthSinkImpl *)iface;
104         FIXME("(%p, %p, %p): stub\n", This, pDirectSound, pDirectSoundBuffer);
105         return S_OK;
106 }
107
108 static HRESULT WINAPI IDirectMusicSynthSinkImpl_GetDesiredBufferSize (LPDIRECTMUSICSYNTHSINK iface, LPDWORD pdwBufferSizeInSamples) {
109         IDirectMusicSynthSinkImpl *This = (IDirectMusicSynthSinkImpl *)iface;
110         FIXME("(%p, %p): stub\n", This, pdwBufferSizeInSamples);
111         return S_OK;
112 }
113
114 static const IDirectMusicSynthSinkVtbl DirectMusicSynthSink_Vtbl = {
115         IDirectMusicSynthSinkImpl_QueryInterface,
116         IDirectMusicSynthSinkImpl_AddRef,
117         IDirectMusicSynthSinkImpl_Release,
118         IDirectMusicSynthSinkImpl_Init,
119         IDirectMusicSynthSinkImpl_SetMasterClock,
120         IDirectMusicSynthSinkImpl_GetLatencyClock,
121         IDirectMusicSynthSinkImpl_Activate,
122         IDirectMusicSynthSinkImpl_SampleToRefTime,
123         IDirectMusicSynthSinkImpl_RefTimeToSample,
124         IDirectMusicSynthSinkImpl_SetDirectSound,
125         IDirectMusicSynthSinkImpl_GetDesiredBufferSize
126 };
127
128 /* for ClassFactory */
129 HRESULT WINAPI DMUSIC_CreateDirectMusicSynthSinkImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) {
130         IDirectMusicSynthSinkImpl *obj;
131         
132         TRACE("(%p,%p,%p)\n", lpcGUID, ppobj, pUnkOuter);
133         obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicSynthSinkImpl));
134         if (NULL == obj) {
135                 *ppobj = NULL;
136                 return E_OUTOFMEMORY;
137         }
138         obj->lpVtbl = &DirectMusicSynthSink_Vtbl;
139         obj->ref = 0;
140         
141         return IDirectMusicSynthSinkImpl_QueryInterface((LPDIRECTMUSICSYNTHSINK)obj, lpcGUID, ppobj);
142 }