ntdll: Avoid using the CONTEXT86 type.
[wine] / dlls / dmcompos / composer.c
1 /* IDirectMusicComposer
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 "dmcompos_private.h"
21
22 WINE_DEFAULT_DEBUG_CHANNEL(dmcompos);
23
24 /* IDirectMusicComposerImpl IUnknown part: */
25 static HRESULT WINAPI IDirectMusicComposerImpl_QueryInterface (LPDIRECTMUSICCOMPOSER iface, REFIID riid, LPVOID *ppobj) {
26         IDirectMusicComposerImpl *This = (IDirectMusicComposerImpl *)iface;
27         TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
28
29         if (IsEqualIID (riid, &IID_IUnknown) || 
30             IsEqualIID (riid, &IID_IDirectMusicComposer)) {
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 IDirectMusicComposerImpl_AddRef (LPDIRECTMUSICCOMPOSER iface) {
40         IDirectMusicComposerImpl *This = (IDirectMusicComposerImpl *)iface;
41         ULONG ref = InterlockedIncrement(&This->ref);
42
43         TRACE("(%p): AddRef from %d\n", This, ref - 1);
44         
45         DMCOMPOS_LockModule();
46         
47         return ref;
48 }
49
50 static ULONG WINAPI IDirectMusicComposerImpl_Release (LPDIRECTMUSICCOMPOSER iface) {
51         IDirectMusicComposerImpl *This = (IDirectMusicComposerImpl *)iface;
52         ULONG ref = InterlockedDecrement(&This->ref);
53
54         TRACE("(%p): ReleaseRef to %d\n", This, ref);
55         
56         if (ref == 0) {
57                 HeapFree(GetProcessHeap(), 0, This);
58         }
59         
60         DMCOMPOS_UnlockModule();
61         
62         return ref;
63 }
64
65 /* IDirectMusicComposerImpl IDirectMusicComposer part: */
66 static HRESULT WINAPI IDirectMusicComposerImpl_ComposeSegmentFromTemplate (LPDIRECTMUSICCOMPOSER iface, IDirectMusicStyle* pStyle, IDirectMusicSegment* pTemplate, WORD wActivity, IDirectMusicChordMap* pChordMap, IDirectMusicSegment** ppSegment) {
67         IDirectMusicComposerImpl *This = (IDirectMusicComposerImpl *)iface;
68         FIXME("(%p, %p, %p, %d, %p, %p): stub\n", This, pStyle, pTemplate, wActivity, pChordMap, ppSegment);
69         return S_OK;
70 }
71
72 static HRESULT WINAPI IDirectMusicComposerImpl_ComposeSegmentFromShape (LPDIRECTMUSICCOMPOSER iface, IDirectMusicStyle* pStyle, WORD wNumMeasures, WORD wShape, WORD wActivity, BOOL fIntro, BOOL fEnd, IDirectMusicChordMap* pChordMap, IDirectMusicSegment** ppSegment) {
73         IDirectMusicComposerImpl *This = (IDirectMusicComposerImpl *)iface;
74         FIXME("(%p, %p, %d, %d, %d, %d, %d, %p, %p): stub\n", This, pStyle, wNumMeasures, wShape, wActivity, fIntro, fEnd, pChordMap, ppSegment);
75         return S_OK;
76 }
77
78 static HRESULT WINAPI IDirectMusicComposerImpl_ComposeTransition (LPDIRECTMUSICCOMPOSER iface, IDirectMusicSegment* pFromSeg, IDirectMusicSegment* pToSeg, MUSIC_TIME mtTime, WORD wCommand, DWORD dwFlags, IDirectMusicChordMap* pChordMap, IDirectMusicSegment** ppTransSeg) {
79         IDirectMusicComposerImpl *This = (IDirectMusicComposerImpl *)iface;
80         FIXME("(%p, %p, %p, %d, %d, %d, %p, %p): stub\n", This, pFromSeg, pToSeg, mtTime, wCommand, dwFlags, pChordMap, ppTransSeg);
81         return S_OK;
82 }
83
84 static HRESULT WINAPI IDirectMusicComposerImpl_AutoTransition (LPDIRECTMUSICCOMPOSER iface, IDirectMusicPerformance* pPerformance, IDirectMusicSegment* pToSeg, WORD wCommand, DWORD dwFlags, IDirectMusicChordMap* pChordMap, IDirectMusicSegment** ppTransSeg, IDirectMusicSegmentState** ppToSegState, IDirectMusicSegmentState** ppTransSegState) {
85         IDirectMusicComposerImpl *This = (IDirectMusicComposerImpl *)iface;
86         FIXME("(%p, %p, %d, %d, %p, %p, %p, %p): stub\n", This, pPerformance, wCommand, dwFlags, pChordMap, ppTransSeg, ppToSegState, ppTransSegState);
87         return S_OK;
88 }
89
90 static HRESULT WINAPI IDirectMusicComposerImpl_ComposeTemplateFromShape (LPDIRECTMUSICCOMPOSER iface, WORD wNumMeasures, WORD wShape, BOOL fIntro, BOOL fEnd, WORD wEndLength, IDirectMusicSegment** ppTemplate) {
91         IDirectMusicComposerImpl *This = (IDirectMusicComposerImpl *)iface;
92         FIXME("(%p, %d, %d, %d, %d, %d, %p): stub\n", This, wNumMeasures, wShape, fIntro, fEnd, wEndLength, ppTemplate);
93         return S_OK;
94 }
95
96 static HRESULT WINAPI IDirectMusicComposerImpl_ChangeChordMap (LPDIRECTMUSICCOMPOSER iface, IDirectMusicSegment* pSegment, BOOL fTrackScale, IDirectMusicChordMap* pChordMap) {
97         IDirectMusicComposerImpl *This = (IDirectMusicComposerImpl *)iface;
98         FIXME("(%p, %p, %d, %p): stub\n", This, pSegment, fTrackScale, pChordMap);
99         return S_OK;
100 }
101
102 static const IDirectMusicComposerVtbl DirectMusicComposer_Vtbl = {
103         IDirectMusicComposerImpl_QueryInterface,
104         IDirectMusicComposerImpl_AddRef,
105         IDirectMusicComposerImpl_Release,
106         IDirectMusicComposerImpl_ComposeSegmentFromTemplate,
107         IDirectMusicComposerImpl_ComposeSegmentFromShape,
108         IDirectMusicComposerImpl_ComposeTransition,
109         IDirectMusicComposerImpl_AutoTransition,
110         IDirectMusicComposerImpl_ComposeTemplateFromShape,
111         IDirectMusicComposerImpl_ChangeChordMap
112 };
113
114 /* for ClassFactory */
115 HRESULT WINAPI DMUSIC_CreateDirectMusicComposerImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) {
116         IDirectMusicComposerImpl* obj;
117         
118         obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicComposerImpl));
119         if (NULL == obj) {
120                 *ppobj = NULL;
121                 return E_OUTOFMEMORY;
122         }
123         obj->lpVtbl = &DirectMusicComposer_Vtbl;
124         obj->ref = 0; /* will be inited by QueryInterface */
125         
126         return IDirectMusicComposerImpl_QueryInterface ((LPDIRECTMUSICCOMPOSER)obj, lpcGUID, ppobj);    
127 }