mlang: Fix GetStrCodePages for characters with different codepages.
[wine.git] / dlls / dmsynth / dmsynth_main.c
blob84caeceb4720804bc3fa3bcf10c9bafcb18dc317
1 /* DirectMusicSynthesizer Main
3 * Copyright (C) 2003-2004 Rok Mandeljc
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.
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.
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
21 #include <stdio.h>
23 #include "dmsynth_private.h"
24 #include "rpcproxy.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(dmsynth);
28 typedef struct {
29 IClassFactory IClassFactory_iface;
30 HRESULT (*create_instance)(IUnknown **ret_iface);
31 } IClassFactoryImpl;
33 /******************************************************************
34 * IClassFactory implementation
36 static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
38 return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
41 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
43 if (ppv == NULL)
44 return E_POINTER;
46 if (IsEqualGUID(&IID_IUnknown, riid))
47 TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
48 else if (IsEqualGUID(&IID_IClassFactory, riid))
49 TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
50 else {
51 FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
52 *ppv = NULL;
53 return E_NOINTERFACE;
56 *ppv = iface;
57 IUnknown_AddRef((IUnknown*)*ppv);
58 return S_OK;
61 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
63 return 2; /* non-heap based object */
66 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
68 return 1; /* non-heap based object */
71 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *unk_outer,
72 REFIID riid, void **ret_iface)
74 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
75 IUnknown *object;
76 HRESULT hr;
78 TRACE("(%p, %s, %p)\n", unk_outer, debugstr_dmguid(riid), ret_iface);
80 *ret_iface = NULL;
81 if (unk_outer) return CLASS_E_NOAGGREGATION;
82 if (SUCCEEDED(hr = This->create_instance(&object)))
84 hr = IUnknown_QueryInterface(object, riid, ret_iface);
85 IUnknown_Release(object);
88 return hr;
91 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
93 TRACE("(%d)\n", dolock);
94 return S_OK;
97 static const IClassFactoryVtbl classfactory_vtbl = {
98 ClassFactory_QueryInterface,
99 ClassFactory_AddRef,
100 ClassFactory_Release,
101 ClassFactory_CreateInstance,
102 ClassFactory_LockServer
105 static IClassFactoryImpl Synth_CF = {{&classfactory_vtbl}, synth_create};
106 static IClassFactoryImpl SynthSink_CF = {{&classfactory_vtbl}, synth_sink_create};
109 /******************************************************************
110 * DllGetClassObject (DMSYNTH.@)
114 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
116 TRACE("(%s, %s, %p)\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
118 if (IsEqualCLSID(rclsid, &CLSID_DirectMusicSynth) && IsEqualIID(riid, &IID_IClassFactory)) {
119 *ppv = &Synth_CF;
120 IClassFactory_AddRef((IClassFactory*)*ppv);
121 return S_OK;
122 } else if (IsEqualCLSID(rclsid, &CLSID_DirectMusicSynthSink) && IsEqualIID(riid, &IID_IClassFactory)) {
123 *ppv = &SynthSink_CF;
124 IClassFactory_AddRef((IClassFactory*)*ppv);
125 return S_OK;
128 WARN("(%s,%s,%p): no interface found.\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
129 return CLASS_E_CLASSNOTAVAILABLE;
132 /******************************************************************
133 * Helper functions
138 /* returns name of given GUID */
139 const char *debugstr_dmguid (const GUID *id) {
140 static const guid_info guids[] = {
141 /* CLSIDs */
142 GE(CLSID_AudioVBScript),
143 GE(CLSID_DirectMusic),
144 GE(CLSID_DirectMusicAudioPathConfig),
145 GE(CLSID_DirectMusicAuditionTrack),
146 GE(CLSID_DirectMusicBand),
147 GE(CLSID_DirectMusicBandTrack),
148 GE(CLSID_DirectMusicChordMapTrack),
149 GE(CLSID_DirectMusicChordMap),
150 GE(CLSID_DirectMusicChordTrack),
151 GE(CLSID_DirectMusicCollection),
152 GE(CLSID_DirectMusicCommandTrack),
153 GE(CLSID_DirectMusicComposer),
154 GE(CLSID_DirectMusicContainer),
155 GE(CLSID_DirectMusicGraph),
156 GE(CLSID_DirectMusicLoader),
157 GE(CLSID_DirectMusicLyricsTrack),
158 GE(CLSID_DirectMusicMarkerTrack),
159 GE(CLSID_DirectMusicMelodyFormulationTrack),
160 GE(CLSID_DirectMusicMotifTrack),
161 GE(CLSID_DirectMusicMuteTrack),
162 GE(CLSID_DirectMusicParamControlTrack),
163 GE(CLSID_DirectMusicPatternTrack),
164 GE(CLSID_DirectMusicPerformance),
165 GE(CLSID_DirectMusicScript),
166 GE(CLSID_DirectMusicScriptAutoImpSegment),
167 GE(CLSID_DirectMusicScriptAutoImpPerformance),
168 GE(CLSID_DirectMusicScriptAutoImpSegmentState),
169 GE(CLSID_DirectMusicScriptAutoImpAudioPathConfig),
170 GE(CLSID_DirectMusicScriptAutoImpAudioPath),
171 GE(CLSID_DirectMusicScriptAutoImpSong),
172 GE(CLSID_DirectMusicScriptSourceCodeLoader),
173 GE(CLSID_DirectMusicScriptTrack),
174 GE(CLSID_DirectMusicSection),
175 GE(CLSID_DirectMusicSegment),
176 GE(CLSID_DirectMusicSegmentState),
177 GE(CLSID_DirectMusicSegmentTriggerTrack),
178 GE(CLSID_DirectMusicSegTriggerTrack),
179 GE(CLSID_DirectMusicSeqTrack),
180 GE(CLSID_DirectMusicSignPostTrack),
181 GE(CLSID_DirectMusicSong),
182 GE(CLSID_DirectMusicStyle),
183 GE(CLSID_DirectMusicStyleTrack),
184 GE(CLSID_DirectMusicSynth),
185 GE(CLSID_DirectMusicSynthSink),
186 GE(CLSID_DirectMusicSysExTrack),
187 GE(CLSID_DirectMusicTemplate),
188 GE(CLSID_DirectMusicTempoTrack),
189 GE(CLSID_DirectMusicTimeSigTrack),
190 GE(CLSID_DirectMusicWaveTrack),
191 GE(CLSID_DirectSoundWave),
192 /* IIDs */
193 GE(IID_IDirectMusic),
194 GE(IID_IDirectMusic2),
195 GE(IID_IDirectMusic8),
196 GE(IID_IDirectMusicAudioPath),
197 GE(IID_IDirectMusicBand),
198 GE(IID_IDirectMusicBuffer),
199 GE(IID_IDirectMusicChordMap),
200 GE(IID_IDirectMusicCollection),
201 GE(IID_IDirectMusicComposer),
202 GE(IID_IDirectMusicContainer),
203 GE(IID_IDirectMusicDownload),
204 GE(IID_IDirectMusicDownloadedInstrument),
205 GE(IID_IDirectMusicGetLoader),
206 GE(IID_IDirectMusicGraph),
207 GE(IID_IDirectMusicInstrument),
208 GE(IID_IDirectMusicLoader),
209 GE(IID_IDirectMusicLoader8),
210 GE(IID_IDirectMusicObject),
211 GE(IID_IDirectMusicPatternTrack),
212 GE(IID_IDirectMusicPerformance),
213 GE(IID_IDirectMusicPerformance2),
214 GE(IID_IDirectMusicPerformance8),
215 GE(IID_IDirectMusicPort),
216 GE(IID_IDirectMusicPortDownload),
217 GE(IID_IDirectMusicScript),
218 GE(IID_IDirectMusicSegment),
219 GE(IID_IDirectMusicSegment2),
220 GE(IID_IDirectMusicSegment8),
221 GE(IID_IDirectMusicSegmentState),
222 GE(IID_IDirectMusicSegmentState8),
223 GE(IID_IDirectMusicStyle),
224 GE(IID_IDirectMusicStyle8),
225 GE(IID_IDirectMusicSynth),
226 GE(IID_IDirectMusicSynth8),
227 GE(IID_IDirectMusicSynthSink),
228 GE(IID_IDirectMusicThru),
229 GE(IID_IDirectMusicTool),
230 GE(IID_IDirectMusicTool8),
231 GE(IID_IDirectMusicTrack),
232 GE(IID_IDirectMusicTrack8),
233 GE(IID_IUnknown),
234 GE(IID_IPersistStream),
235 GE(IID_IStream),
236 GE(IID_IClassFactory),
237 /* GUIDs */
238 GE(GUID_DirectMusicAllTypes),
239 GE(GUID_NOTIFICATION_CHORD),
240 GE(GUID_NOTIFICATION_COMMAND),
241 GE(GUID_NOTIFICATION_MEASUREANDBEAT),
242 GE(GUID_NOTIFICATION_PERFORMANCE),
243 GE(GUID_NOTIFICATION_RECOMPOSE),
244 GE(GUID_NOTIFICATION_SEGMENT),
245 GE(GUID_BandParam),
246 GE(GUID_ChordParam),
247 GE(GUID_CommandParam),
248 GE(GUID_CommandParam2),
249 GE(GUID_CommandParamNext),
250 GE(GUID_IDirectMusicBand),
251 GE(GUID_IDirectMusicChordMap),
252 GE(GUID_IDirectMusicStyle),
253 GE(GUID_MuteParam),
254 GE(GUID_Play_Marker),
255 GE(GUID_RhythmParam),
256 GE(GUID_TempoParam),
257 GE(GUID_TimeSignature),
258 GE(GUID_Valid_Start_Time),
259 GE(GUID_Clear_All_Bands),
260 GE(GUID_ConnectToDLSCollection),
261 GE(GUID_Disable_Auto_Download),
262 GE(GUID_DisableTempo),
263 GE(GUID_DisableTimeSig),
264 GE(GUID_Download),
265 GE(GUID_DownloadToAudioPath),
266 GE(GUID_Enable_Auto_Download),
267 GE(GUID_EnableTempo),
268 GE(GUID_EnableTimeSig),
269 GE(GUID_IgnoreBankSelectForGM),
270 GE(GUID_SeedVariations),
271 GE(GUID_StandardMIDIFile),
272 GE(GUID_Unload),
273 GE(GUID_UnloadFromAudioPath),
274 GE(GUID_Variations),
275 GE(GUID_PerfMasterTempo),
276 GE(GUID_PerfMasterVolume),
277 GE(GUID_PerfMasterGrooveLevel),
278 GE(GUID_PerfAutoDownload),
279 GE(GUID_DefaultGMCollection),
280 GE(GUID_Synth_Default),
281 GE(GUID_Buffer_Reverb),
282 GE(GUID_Buffer_EnvReverb),
283 GE(GUID_Buffer_Stereo),
284 GE(GUID_Buffer_3D_Dry),
285 GE(GUID_Buffer_Mono),
286 GE(GUID_DMUS_PROP_GM_Hardware),
287 GE(GUID_DMUS_PROP_GS_Capable),
288 GE(GUID_DMUS_PROP_GS_Hardware),
289 GE(GUID_DMUS_PROP_DLS1),
290 GE(GUID_DMUS_PROP_DLS2),
291 GE(GUID_DMUS_PROP_Effects),
292 GE(GUID_DMUS_PROP_INSTRUMENT2),
293 GE(GUID_DMUS_PROP_LegacyCaps),
294 GE(GUID_DMUS_PROP_MemorySize),
295 GE(GUID_DMUS_PROP_SampleMemorySize),
296 GE(GUID_DMUS_PROP_SamplePlaybackRate),
297 GE(GUID_DMUS_PROP_SetSynthSink),
298 GE(GUID_DMUS_PROP_SinkUsesDSound),
299 GE(GUID_DMUS_PROP_SynthSink_DSOUND),
300 GE(GUID_DMUS_PROP_SynthSink_WAVE),
301 GE(GUID_DMUS_PROP_Volume),
302 GE(GUID_DMUS_PROP_WavesReverb),
303 GE(GUID_DMUS_PROP_WriteLatency),
304 GE(GUID_DMUS_PROP_WritePeriod),
305 GE(GUID_DMUS_PROP_XG_Capable),
306 GE(GUID_DMUS_PROP_XG_Hardware)
309 unsigned int i;
311 if (!id) return "(null)";
313 for (i = 0; i < ARRAY_SIZE(guids); i++) {
314 if (IsEqualGUID(id, guids[i].guid))
315 return guids[i].name;
317 /* if we didn't find it, act like standard debugstr_guid */
318 return debugstr_guid(id);