wined3d: Added D3D9 render states.
[wine] / dlls / dmime / dmime_main.c
1 /* DirectMusicInteractiveEngine Main
2  *
3  * Copyright (C) 2003-2004 Rok Mandeljc
4  * Copyright (C) 2003-2004 Raphael Junqueira
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (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
14  * GNU Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19  */
20
21 #include "dmime_private.h"
22
23 WINE_DEFAULT_DEBUG_CHANNEL(dmime);
24
25 LONG DMIME_refCount = 0;
26
27 typedef struct {
28     const IClassFactoryVtbl *lpVtbl;
29 } IClassFactoryImpl;
30
31 /******************************************************************
32  *              DirectMusicPerformance ClassFactory
33  */
34 static HRESULT WINAPI PerformanceCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
35         FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
36
37         if (ppobj == NULL) return E_POINTER;
38
39         return E_NOINTERFACE;
40 }
41
42 static ULONG WINAPI PerformanceCF_AddRef(LPCLASSFACTORY iface) {
43         DMIME_LockModule();
44
45         return 2; /* non-heap based object */
46 }
47
48 static ULONG WINAPI PerformanceCF_Release(LPCLASSFACTORY iface) {
49         DMIME_UnlockModule();
50
51         return 1; /* non-heap based object */
52 }
53
54 static HRESULT WINAPI PerformanceCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
55         TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
56         
57         return DMUSIC_CreateDirectMusicPerformanceImpl (riid, ppobj, pOuter);
58 }
59
60 static HRESULT WINAPI PerformanceCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
61         TRACE("(%d)\n", dolock);
62
63         if (dolock)
64                 DMIME_LockModule();
65         else
66                 DMIME_UnlockModule();
67         
68         return S_OK;
69 }
70
71 static const IClassFactoryVtbl PerformanceCF_Vtbl = {
72         PerformanceCF_QueryInterface,
73         PerformanceCF_AddRef,
74         PerformanceCF_Release,
75         PerformanceCF_CreateInstance,
76         PerformanceCF_LockServer
77 };
78
79 static IClassFactoryImpl Performance_CF = {&PerformanceCF_Vtbl};
80
81 /******************************************************************
82  *              DirectMusicSegment ClassFactory
83  */
84 static HRESULT WINAPI SegmentCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
85         FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
86
87         if (ppobj == NULL) return E_POINTER;
88         
89         return E_NOINTERFACE;
90 }
91
92 static ULONG WINAPI SegmentCF_AddRef(LPCLASSFACTORY iface) {
93         DMIME_LockModule();
94
95         return 2; /* non-heap based object */
96 }
97
98 static ULONG WINAPI SegmentCF_Release(LPCLASSFACTORY iface) {
99         DMIME_UnlockModule();
100
101         return 1; /* non-heap based object */
102 }
103
104 static HRESULT WINAPI SegmentCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
105         TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
106         
107         return DMUSIC_CreateDirectMusicSegmentImpl (riid, ppobj, pOuter);
108 }
109
110 static HRESULT WINAPI SegmentCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
111         TRACE("(%d)\n", dolock);
112
113         if (dolock)
114                 DMIME_LockModule();
115         else
116                 DMIME_UnlockModule();
117         
118         return S_OK;
119 }
120
121 static const IClassFactoryVtbl SegmentCF_Vtbl = {
122         SegmentCF_QueryInterface,
123         SegmentCF_AddRef,
124         SegmentCF_Release,
125         SegmentCF_CreateInstance,
126         SegmentCF_LockServer
127 };
128
129 static IClassFactoryImpl Segment_CF = {&SegmentCF_Vtbl};
130
131 /******************************************************************
132  *              DirectMusicSegmentState ClassFactory
133  */
134 static HRESULT WINAPI SegmentStateCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
135         FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
136
137         if (ppobj == NULL) return E_POINTER;
138         
139         return E_NOINTERFACE;
140 }
141
142 static ULONG WINAPI SegmentStateCF_AddRef(LPCLASSFACTORY iface) {
143         DMIME_LockModule();
144
145         return 2; /* non-heap based objects */
146 }
147
148 static ULONG WINAPI SegmentStateCF_Release(LPCLASSFACTORY iface) {
149         DMIME_UnlockModule();
150         
151         return 1; /* non-heap based object */
152 }
153
154 static HRESULT WINAPI SegmentStateCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
155         TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
156
157         return DMUSIC_CreateDirectMusicSegmentStateImpl (riid, ppobj, pOuter);
158 }
159
160 static HRESULT WINAPI SegmentStateCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
161         TRACE("(%d)\n", dolock);
162
163         if (dolock)
164                 DMIME_LockModule();
165         else
166                 DMIME_UnlockModule();
167         
168         return S_OK;
169 }
170
171 static const IClassFactoryVtbl SegmentStateCF_Vtbl = {
172         SegmentStateCF_QueryInterface,
173         SegmentStateCF_AddRef,
174         SegmentStateCF_Release,
175         SegmentStateCF_CreateInstance,
176         SegmentStateCF_LockServer
177 };
178
179 static IClassFactoryImpl SegmentState_CF = {&SegmentStateCF_Vtbl};
180
181 /******************************************************************
182  *              DirectMusicGraph ClassFactory
183  */
184 static HRESULT WINAPI GraphCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
185         FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
186
187         if (ppobj == NULL) return E_POINTER;
188         
189         return E_NOINTERFACE;
190 }
191
192 static ULONG WINAPI GraphCF_AddRef(LPCLASSFACTORY iface) {
193         DMIME_LockModule();
194
195         return 2; /* non-heap based object */
196 }
197
198 static ULONG WINAPI GraphCF_Release(LPCLASSFACTORY iface) {
199         DMIME_UnlockModule();
200
201         return 1; /* non-heap based object */
202 }
203
204 static HRESULT WINAPI GraphCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
205         TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
206         
207         return DMUSIC_CreateDirectMusicGraphImpl (riid, ppobj, pOuter);
208 }
209
210 static HRESULT WINAPI GraphCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
211         TRACE("(%d)\n", dolock);
212
213         if (dolock)
214                 DMIME_LockModule();
215         else
216                 DMIME_UnlockModule();
217         
218         return S_OK;
219 }
220
221 static const IClassFactoryVtbl GraphCF_Vtbl = {
222         GraphCF_QueryInterface,
223         GraphCF_AddRef,
224         GraphCF_Release,
225         GraphCF_CreateInstance,
226         GraphCF_LockServer
227 };
228
229 static IClassFactoryImpl Graph_CF = {&GraphCF_Vtbl};
230
231 /******************************************************************
232  *              DirectMusicTempoTrack ClassFactory
233  */
234 static HRESULT WINAPI TempoTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
235         FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
236
237         if (ppobj == NULL) return E_POINTER;
238         
239         return E_NOINTERFACE;
240 }
241
242 static ULONG WINAPI TempoTrackCF_AddRef(LPCLASSFACTORY iface) {
243         DMIME_LockModule();
244
245         return 2; /* non-heap based object */
246 }
247
248 static ULONG WINAPI TempoTrackCF_Release(LPCLASSFACTORY iface) {
249         DMIME_UnlockModule();
250
251         return 1; /* non-heap based object */
252 }
253
254 static HRESULT WINAPI TempoTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
255         TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
256         
257         return DMUSIC_CreateDirectMusicTempoTrack (riid, ppobj, pOuter);
258 }
259
260 static HRESULT WINAPI TempoTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
261         TRACE("(%d)\n", dolock);
262
263         if (dolock)
264                 DMIME_LockModule();
265         else
266                 DMIME_UnlockModule();
267         
268         return S_OK;
269 }
270
271 static const IClassFactoryVtbl TempoTrackCF_Vtbl = {
272         TempoTrackCF_QueryInterface,
273         TempoTrackCF_AddRef,
274         TempoTrackCF_Release,
275         TempoTrackCF_CreateInstance,
276         TempoTrackCF_LockServer
277 };
278
279 static IClassFactoryImpl TempoTrack_CF = {&TempoTrackCF_Vtbl};
280
281 /******************************************************************
282  *              DirectMusicSeqTrack ClassFactory
283  */
284 static HRESULT WINAPI SeqTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
285         FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
286
287         if (ppobj == NULL) return E_POINTER;
288         
289         return E_NOINTERFACE;
290 }
291
292 static ULONG WINAPI SeqTrackCF_AddRef(LPCLASSFACTORY iface) {
293         DMIME_LockModule();
294         
295         return 2; /* non-heap based object */
296 }
297
298 static ULONG WINAPI SeqTrackCF_Release(LPCLASSFACTORY iface) {
299         DMIME_UnlockModule();
300
301         return 1; /* non-heap based object */
302 }
303
304 static HRESULT WINAPI SeqTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
305         TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
306         
307         return DMUSIC_CreateDirectMusicSeqTrack (riid, ppobj, pOuter);
308 }
309
310 static HRESULT WINAPI SeqTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
311         TRACE("(%d)\n", dolock);
312
313         if (dolock)
314                 DMIME_LockModule();
315         else
316                 DMIME_UnlockModule();
317         
318         return S_OK;
319 }
320
321 static const IClassFactoryVtbl SeqTrackCF_Vtbl = {
322         SeqTrackCF_QueryInterface,
323         SeqTrackCF_AddRef,
324         SeqTrackCF_Release,
325         SeqTrackCF_CreateInstance,
326         SeqTrackCF_LockServer
327 };
328
329 static IClassFactoryImpl SeqTrack_CF = {&SeqTrackCF_Vtbl};
330
331 /******************************************************************
332  *              DirectMusicSysExTrack ClassFactory
333  */
334 static HRESULT WINAPI SysExTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
335         FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
336
337         if (ppobj == NULL) return E_POINTER;
338         
339         return E_NOINTERFACE;
340 }
341
342 static ULONG WINAPI SysExTrackCF_AddRef(LPCLASSFACTORY iface) {
343         DMIME_LockModule();
344
345         return 2; /* non-heap based object */
346 }
347
348 static ULONG WINAPI SysExTrackCF_Release(LPCLASSFACTORY iface) {
349         DMIME_UnlockModule();
350
351         return 1; /* non-heap based object */
352 }
353
354 static HRESULT WINAPI SysExTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
355         TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
356         return DMUSIC_CreateDirectMusicSysExTrack (riid, ppobj, pOuter);
357 }
358
359 static HRESULT WINAPI SysExTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
360         TRACE("(%d)\n", dolock);
361
362         if (dolock)
363                 DMIME_LockModule();
364         else
365                 DMIME_UnlockModule();
366         
367         return S_OK;
368 }
369
370 static const IClassFactoryVtbl SysExTrackCF_Vtbl = {
371         SysExTrackCF_QueryInterface,
372         SysExTrackCF_AddRef,
373         SysExTrackCF_Release,
374         SysExTrackCF_CreateInstance,
375         SysExTrackCF_LockServer
376 };
377
378 static IClassFactoryImpl SysExTrack_CF = {&SysExTrackCF_Vtbl};
379
380 /******************************************************************
381  *              DirectMusicTimeSigTrack ClassFactory
382  */
383 static HRESULT WINAPI TimeSigTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
384         FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
385
386         if (ppobj == NULL) return E_POINTER;
387         
388         return E_NOINTERFACE;
389 }
390
391 static ULONG WINAPI TimeSigTrackCF_AddRef(LPCLASSFACTORY iface) {
392         DMIME_LockModule();
393
394         return 2; /* non-heap based object */
395 }
396
397 static ULONG WINAPI TimeSigTrackCF_Release(LPCLASSFACTORY iface) {
398         DMIME_UnlockModule();
399
400         return 1; /* non-heap based object */
401 }
402
403 static HRESULT WINAPI TimeSigTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
404         TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
405         
406         return DMUSIC_CreateDirectMusicTimeSigTrack (riid, ppobj, pOuter);
407 }
408
409 static HRESULT WINAPI TimeSigTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
410         TRACE("(%d)\n", dolock);
411
412         if (dolock)
413                 DMIME_LockModule();
414         else
415                 DMIME_UnlockModule();
416         
417         return S_OK;
418 }
419
420 static const IClassFactoryVtbl TimeSigTrackCF_Vtbl = {
421         TimeSigTrackCF_QueryInterface,
422         TimeSigTrackCF_AddRef,
423         TimeSigTrackCF_Release,
424         TimeSigTrackCF_CreateInstance,
425         TimeSigTrackCF_LockServer
426 };
427
428 static IClassFactoryImpl TimeSigTrack_CF = {&TimeSigTrackCF_Vtbl};
429
430 /******************************************************************
431  *              DirectMusicParamControlTrack ClassFactory
432  */
433 static HRESULT WINAPI ParamControlTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
434         FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
435
436         if (ppobj == NULL) return E_POINTER;
437         
438         return E_NOINTERFACE;
439 }
440
441 static ULONG WINAPI ParamControlTrackCF_AddRef(LPCLASSFACTORY iface) {
442         DMIME_LockModule();
443
444         return 2; /* non-heap based object */
445 }
446
447 static ULONG WINAPI ParamControlTrackCF_Release(LPCLASSFACTORY iface) {
448         DMIME_UnlockModule();
449
450         return 1; /* non-heap based object */
451 }
452
453 static HRESULT WINAPI ParamControlTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
454         TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
455         
456         return DMUSIC_CreateDirectMusicParamControlTrack (riid, ppobj, pOuter);
457 }
458
459 static HRESULT WINAPI ParamControlTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
460         TRACE("(%d)\n", dolock);
461
462         if (dolock)
463                 DMIME_LockModule();
464         else
465                 DMIME_UnlockModule();
466         
467         return S_OK;
468 }
469
470 static const IClassFactoryVtbl ParamControlTrackCF_Vtbl = {
471         ParamControlTrackCF_QueryInterface,
472         ParamControlTrackCF_AddRef,
473         ParamControlTrackCF_Release,
474         ParamControlTrackCF_CreateInstance,
475         ParamControlTrackCF_LockServer
476 };
477
478 static IClassFactoryImpl ParamControlTrack_CF = {&ParamControlTrackCF_Vtbl};
479
480 /******************************************************************
481  *              DirectMusicMarkerTrack ClassFactory
482  */
483 static HRESULT WINAPI MarkerTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
484         FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
485
486         if (ppobj == NULL) return E_POINTER;
487         
488         return E_NOINTERFACE;
489 }
490
491 static ULONG WINAPI MarkerTrackCF_AddRef(LPCLASSFACTORY iface) {
492         DMIME_LockModule();
493
494         return 2; /* non-heap based object */
495 }
496
497 static ULONG WINAPI MarkerTrackCF_Release(LPCLASSFACTORY iface) {
498         DMIME_UnlockModule();
499
500         return 1; /* non-heap based object */
501 }
502
503 static HRESULT WINAPI MarkerTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
504         TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
505
506         return DMUSIC_CreateDirectMusicMarkerTrack (riid, ppobj, pOuter);
507 }
508
509 static HRESULT WINAPI MarkerTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
510         TRACE("(%d)\n", dolock);
511
512         if (dolock)
513                 DMIME_LockModule();
514         else
515                 DMIME_UnlockModule();
516         
517         return S_OK;
518 }
519
520 static const IClassFactoryVtbl MarkerTrackCF_Vtbl = {
521         MarkerTrackCF_QueryInterface,
522         MarkerTrackCF_AddRef,
523         MarkerTrackCF_Release,
524         MarkerTrackCF_CreateInstance,
525         MarkerTrackCF_LockServer
526 };
527
528 static IClassFactoryImpl MarkerTrack_CF = {&MarkerTrackCF_Vtbl};
529
530 /******************************************************************
531  *              DirectMusicLyricsTrack ClassFactory
532  */
533 static HRESULT WINAPI LyricsTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
534         FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
535
536         if (ppobj == NULL) return E_POINTER;
537         
538         return E_NOINTERFACE;
539 }
540
541 static ULONG WINAPI LyricsTrackCF_AddRef(LPCLASSFACTORY iface) {
542         DMIME_LockModule();
543
544         return 2; /* non-heap based object */
545 }
546
547 static ULONG WINAPI LyricsTrackCF_Release(LPCLASSFACTORY iface) {
548         DMIME_UnlockModule();
549
550         return 1; /* non-heap based object */
551 }
552
553 static HRESULT WINAPI LyricsTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
554         TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
555         
556         return DMUSIC_CreateDirectMusicLyricsTrack (riid, ppobj, pOuter);
557 }
558
559 static HRESULT WINAPI LyricsTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
560         TRACE("(%d)\n", dolock);
561
562         if (dolock)
563                 DMIME_LockModule();
564         else
565                 DMIME_UnlockModule();
566         
567         return S_OK;
568 }
569
570 static const IClassFactoryVtbl LyricsTrackCF_Vtbl = {
571         LyricsTrackCF_QueryInterface,
572         LyricsTrackCF_AddRef,
573         LyricsTrackCF_Release,
574         LyricsTrackCF_CreateInstance,
575         LyricsTrackCF_LockServer
576 };
577
578 static IClassFactoryImpl LyricsTrack_CF = {&LyricsTrackCF_Vtbl};
579
580
581 /******************************************************************
582  *              DirectMusicSegTriggerTrack ClassFactory
583  */
584 static HRESULT WINAPI SegTriggerTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
585         FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
586
587         if (ppobj == NULL) return E_POINTER;
588         
589         return E_NOINTERFACE;
590 }
591
592 static ULONG WINAPI SegTriggerTrackCF_AddRef(LPCLASSFACTORY iface) {
593         DMIME_LockModule();
594
595         return 2; /* non-heap based object */
596 }
597
598 static ULONG WINAPI SegTriggerTrackCF_Release(LPCLASSFACTORY iface) {
599         DMIME_UnlockModule();
600         
601         return 1; /* non-heap based object */
602 }
603
604 static HRESULT WINAPI SegTriggerTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
605         TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
606         
607         return DMUSIC_CreateDirectMusicSegTriggerTrack (riid, ppobj, pOuter);
608 }
609
610 static HRESULT WINAPI SegTriggerTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
611         TRACE("(%d)\n", dolock);
612
613         if (dolock)
614                 DMIME_LockModule();
615         else
616                 DMIME_UnlockModule();
617         
618         return S_OK;
619 }
620
621 static const IClassFactoryVtbl SegTriggerTrackCF_Vtbl = {
622         SegTriggerTrackCF_QueryInterface,
623         SegTriggerTrackCF_AddRef,
624         SegTriggerTrackCF_Release,
625         SegTriggerTrackCF_CreateInstance,
626         SegTriggerTrackCF_LockServer
627 };
628
629 static IClassFactoryImpl SegTriggerTrack_CF = {&SegTriggerTrackCF_Vtbl};
630
631 /******************************************************************
632  *              DirectMusicAudioPath ClassFactory
633  */
634 static HRESULT WINAPI AudioPathCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
635         FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
636
637         if (ppobj == NULL) return E_POINTER;
638         
639         return E_NOINTERFACE;
640 }
641
642 static ULONG WINAPI AudioPathCF_AddRef(LPCLASSFACTORY iface) {
643         DMIME_LockModule();
644
645         return 2; /* non-heap based object */
646 }
647
648 static ULONG WINAPI AudioPathCF_Release(LPCLASSFACTORY iface) {
649         DMIME_UnlockModule();
650
651         return 1; /* non-heap based object */
652 }
653
654 static HRESULT WINAPI AudioPathCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
655         TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
656         
657         return DMUSIC_CreateDirectMusicAudioPathImpl (riid, ppobj, pOuter);
658 }
659
660 static HRESULT WINAPI AudioPathCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
661         TRACE("(%d)\n", dolock);
662
663         if (dolock)
664                 DMIME_LockModule();
665         else
666                 DMIME_UnlockModule();
667         
668         return S_OK;
669 }
670
671 static const IClassFactoryVtbl AudioPathCF_Vtbl = {
672         AudioPathCF_QueryInterface,
673         AudioPathCF_AddRef,
674         AudioPathCF_Release,
675         AudioPathCF_CreateInstance,
676         AudioPathCF_LockServer
677 };
678
679 static IClassFactoryImpl AudioPath_CF = {&AudioPathCF_Vtbl};
680
681 /******************************************************************
682  *              DirectMusicWaveTrack ClassFactory
683  */
684 static HRESULT WINAPI WaveTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
685         FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
686
687         if (ppobj == NULL) return E_POINTER;
688         
689         return E_NOINTERFACE;
690 }
691
692 static ULONG WINAPI WaveTrackCF_AddRef(LPCLASSFACTORY iface) {
693         DMIME_LockModule();
694
695         return 2; /* non-heap based object */
696 }
697
698 static ULONG WINAPI WaveTrackCF_Release(LPCLASSFACTORY iface) {
699         DMIME_UnlockModule();
700
701         return 1; /* non-heap based object */
702 }
703
704 static HRESULT WINAPI WaveTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
705         TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
706         
707         return DMUSIC_CreateDirectMusicWaveTrack (riid, ppobj, pOuter);
708 }
709
710 static HRESULT WINAPI WaveTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
711         TRACE("(%d)\n", dolock);
712
713         if (dolock)
714                 DMIME_LockModule();
715         else
716                 DMIME_UnlockModule();
717         
718         return S_OK;
719 }
720
721 static const IClassFactoryVtbl WaveTrackCF_Vtbl = {
722         WaveTrackCF_QueryInterface,
723         WaveTrackCF_AddRef,
724         WaveTrackCF_Release,
725         WaveTrackCF_CreateInstance,
726         WaveTrackCF_LockServer
727 };
728
729 static IClassFactoryImpl WaveTrack_CF = {&WaveTrackCF_Vtbl};
730
731 /******************************************************************
732  *              DllMain
733  *
734  *
735  */
736 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
737         if (fdwReason == DLL_PROCESS_ATTACH) {
738                 DisableThreadLibraryCalls(hinstDLL);
739                 /* FIXME: Initialisation */
740         }
741         else if (fdwReason == DLL_PROCESS_DETACH) {
742                 /* FIXME: Cleanup */
743         }
744
745         return TRUE;
746 }
747
748
749 /******************************************************************
750  *              DllCanUnloadNow (DMIME.1)
751  *
752  *
753  */
754 HRESULT WINAPI DllCanUnloadNow(void)
755 {
756         return DMIME_refCount != 0 ? S_FALSE : S_OK;
757 }
758
759
760 /******************************************************************
761  *              DllGetClassObject (DMIME.@)
762  *
763  *
764  */
765 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
766 {
767     TRACE("(%s, %s, %p)\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
768     if (IsEqualCLSID (rclsid, &CLSID_DirectMusicPerformance) && IsEqualIID (riid, &IID_IClassFactory)) {
769                 *ppv = (LPVOID) &Performance_CF;
770                 IClassFactory_AddRef((IClassFactory*)*ppv);
771                 return S_OK;
772         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicSegment) && IsEqualIID (riid, &IID_IClassFactory)) {
773                 *ppv = (LPVOID) &Segment_CF;
774                 IClassFactory_AddRef((IClassFactory*)*ppv);
775                 return S_OK;
776         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicSegmentState) && IsEqualIID (riid, &IID_IClassFactory)) {
777                 *ppv = (LPVOID) &SegmentState_CF;
778                 IClassFactory_AddRef((IClassFactory*)*ppv);
779                 return S_OK;
780         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicGraph) && IsEqualIID (riid, &IID_IClassFactory)) {
781                 *ppv = (LPVOID) &Graph_CF;
782                 IClassFactory_AddRef((IClassFactory*)*ppv);
783                 return S_OK;
784         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicTempoTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
785                 *ppv = (LPVOID) &TempoTrack_CF;
786                 IClassFactory_AddRef((IClassFactory*)*ppv);
787                 return S_OK;
788         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicSeqTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
789                 *ppv = (LPVOID) &SeqTrack_CF;
790                 IClassFactory_AddRef((IClassFactory*)*ppv);
791                 return S_OK;
792         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicSysExTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
793                 *ppv = (LPVOID) &SysExTrack_CF;
794                 IClassFactory_AddRef((IClassFactory*)*ppv);
795                 return S_OK;
796         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicTimeSigTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
797                 *ppv = (LPVOID) &TimeSigTrack_CF;
798                 IClassFactory_AddRef((IClassFactory*)*ppv);
799                 return S_OK;
800         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicParamControlTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
801                 *ppv = (LPVOID) &ParamControlTrack_CF;
802                 IClassFactory_AddRef((IClassFactory*)*ppv);
803                 return S_OK;
804         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicMarkerTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
805                 *ppv = (LPVOID) &MarkerTrack_CF;
806                 IClassFactory_AddRef((IClassFactory*)*ppv);
807                 return S_OK;
808         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicLyricsTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
809                 *ppv = (LPVOID) &LyricsTrack_CF;
810                 IClassFactory_AddRef((IClassFactory*)*ppv);
811                 return S_OK;
812         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicSegTriggerTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
813                 *ppv = (LPVOID) &SegTriggerTrack_CF;
814                 IClassFactory_AddRef((IClassFactory*)*ppv);
815                 return S_OK;
816         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicAudioPath) && IsEqualIID (riid, &IID_IClassFactory)) {
817                 *ppv = (LPVOID) &AudioPath_CF;
818                 IClassFactory_AddRef((IClassFactory*)*ppv);
819                 return S_OK;
820         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicWaveTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
821                 *ppv = (LPVOID) &WaveTrack_CF;
822                 IClassFactory_AddRef((IClassFactory*)*ppv);
823                 return S_OK;
824         } 
825         
826     WARN("(%s, %s, %p): no interface found.\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
827     return CLASS_E_CLASSNOTAVAILABLE;
828 }