quartz/vmr9: Do not clear the previous allocator and presenter in IVMRFilterConfig9...
[wine.git] / dlls / dmcompos / composer.c
bloba2a58396ee56012afd3a7ac00337507c4cb89595
1 /* IDirectMusicComposer
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
20 #include "dmcompos_private.h"
21 #include "dmobject.h"
23 WINE_DEFAULT_DEBUG_CHANNEL(dmcompos);
25 typedef struct IDirectMusicComposerImpl {
26 IDirectMusicComposer IDirectMusicComposer_iface;
27 LONG ref;
28 } IDirectMusicComposerImpl;
30 static inline IDirectMusicComposerImpl *impl_from_IDirectMusicComposer(IDirectMusicComposer *iface)
32 return CONTAINING_RECORD(iface, IDirectMusicComposerImpl, IDirectMusicComposer_iface);
35 static HRESULT WINAPI IDirectMusicComposerImpl_QueryInterface(IDirectMusicComposer *iface,
36 REFIID riid, void **ret_iface)
38 TRACE("(%p, %s, %p)\n", iface, debugstr_dmguid(riid), ret_iface);
40 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDirectMusicComposer))
42 *ret_iface = iface;
43 IDirectMusicComposer_AddRef(iface);
44 return S_OK;
47 WARN("(%p, %s, %p): not found\n", iface, debugstr_dmguid(riid), ret_iface);
48 *ret_iface = NULL;
50 return E_NOINTERFACE;
53 static ULONG WINAPI IDirectMusicComposerImpl_AddRef(IDirectMusicComposer *iface)
55 IDirectMusicComposerImpl *This = impl_from_IDirectMusicComposer(iface);
56 ULONG ref = InterlockedIncrement(&This->ref);
58 TRACE("(%p) ref=%ld\n", This, ref);
60 return ref;
63 static ULONG WINAPI IDirectMusicComposerImpl_Release(IDirectMusicComposer *iface)
65 IDirectMusicComposerImpl *This = impl_from_IDirectMusicComposer(iface);
66 ULONG ref = InterlockedDecrement(&This->ref);
68 TRACE("(%p) ref=%ld\n", This, ref);
70 if (ref == 0) {
71 HeapFree(GetProcessHeap(), 0, This);
72 DMCOMPOS_UnlockModule();
75 return ref;
78 /* IDirectMusicComposerImpl IDirectMusicComposer part: */
79 static HRESULT WINAPI IDirectMusicComposerImpl_ComposeSegmentFromTemplate(IDirectMusicComposer *iface,
80 IDirectMusicStyle *style, IDirectMusicSegment *template, WORD activity, IDirectMusicChordMap *chordmap,
81 IDirectMusicSegment **segment)
83 IDirectMusicComposerImpl *This = impl_from_IDirectMusicComposer(iface);
84 IDirectMusicTrack *track;
85 HRESULT hr;
87 FIXME("(%p, %p, %p, %d, %p, %p): semi-stub\n", This, style, template, activity, chordmap, segment);
89 if (!segment)
90 return E_POINTER;
91 if (!template)
92 return E_INVALIDARG;
94 if (!style) {
95 hr = IDirectMusicSegment_GetTrack(template, &CLSID_DirectMusicStyleTrack, 0xFFFFFFFF,
96 DMUS_SEG_ANYTRACK, &track);
97 if (FAILED(hr))
98 return E_INVALIDARG;
99 else
100 IDirectMusicTrack_Release(track); /* Temp to not leak memory */
102 if (!chordmap) {
103 hr = IDirectMusicSegment_GetTrack(template, &CLSID_DirectMusicChordMapTrack, 0xFFFFFFFF,
104 DMUS_SEG_ANYTRACK, &track);
105 if (FAILED(hr))
106 return E_INVALIDARG;
107 else
108 IDirectMusicTrack_Release(track); /* Temp to not leak memory */
111 return IDirectMusicSegment_Clone(template, -1, 0, segment);
114 static HRESULT WINAPI IDirectMusicComposerImpl_ComposeSegmentFromShape(IDirectMusicComposer *iface,
115 IDirectMusicStyle *pStyle, WORD wNumMeasures, WORD wShape, WORD wActivity, BOOL fIntro,
116 BOOL fEnd, IDirectMusicChordMap *pChordMap, IDirectMusicSegment **ppSegment)
118 IDirectMusicComposerImpl *This = impl_from_IDirectMusicComposer(iface);
119 FIXME("(%p, %p, %d, %d, %d, %d, %d, %p, %p): stub\n", This, pStyle, wNumMeasures, wShape, wActivity, fIntro, fEnd, pChordMap, ppSegment);
120 return S_OK;
123 static HRESULT WINAPI IDirectMusicComposerImpl_ComposeTransition(IDirectMusicComposer *iface,
124 IDirectMusicSegment *pFromSeg, IDirectMusicSegment *pToSeg, MUSIC_TIME mtTime,
125 WORD wCommand, DWORD dwFlags, IDirectMusicChordMap *pChordMap,
126 IDirectMusicSegment **ppTransSeg)
128 IDirectMusicComposerImpl *This = impl_from_IDirectMusicComposer(iface);
129 FIXME("(%p, %p, %p, %ld, %d, %ld, %p, %p): stub\n", This, pFromSeg, pToSeg, mtTime, wCommand, dwFlags, pChordMap, ppTransSeg);
130 return S_OK;
133 static HRESULT WINAPI IDirectMusicComposerImpl_AutoTransition(IDirectMusicComposer *iface,
134 IDirectMusicPerformance *pPerformance, IDirectMusicSegment *pToSeg, WORD wCommand,
135 DWORD dwFlags, IDirectMusicChordMap *pChordMap, IDirectMusicSegment **ppTransSeg,
136 IDirectMusicSegmentState **ppToSegState, IDirectMusicSegmentState **ppTransSegState)
138 IDirectMusicComposerImpl *This = impl_from_IDirectMusicComposer(iface);
139 FIXME("(%p, %p, %d, %ld, %p, %p, %p, %p): stub\n", This, pPerformance, wCommand, dwFlags, pChordMap, ppTransSeg, ppToSegState, ppTransSegState);
140 return S_OK;
143 static HRESULT WINAPI IDirectMusicComposerImpl_ComposeTemplateFromShape(IDirectMusicComposer *iface,
144 WORD wNumMeasures, WORD wShape, BOOL fIntro, BOOL fEnd, WORD wEndLength,
145 IDirectMusicSegment **ppTemplate)
147 IDirectMusicComposerImpl *This = impl_from_IDirectMusicComposer(iface);
148 FIXME("(%p, %d, %d, %d, %d, %d, %p): stub\n", This, wNumMeasures, wShape, fIntro, fEnd, wEndLength, ppTemplate);
149 return S_OK;
152 static HRESULT WINAPI IDirectMusicComposerImpl_ChangeChordMap(IDirectMusicComposer *iface,
153 IDirectMusicSegment *pSegment, BOOL fTrackScale, IDirectMusicChordMap *pChordMap)
155 IDirectMusicComposerImpl *This = impl_from_IDirectMusicComposer(iface);
156 FIXME("(%p, %p, %d, %p): stub\n", This, pSegment, fTrackScale, pChordMap);
157 return S_OK;
160 static const IDirectMusicComposerVtbl dmcomposer_vtbl = {
161 IDirectMusicComposerImpl_QueryInterface,
162 IDirectMusicComposerImpl_AddRef,
163 IDirectMusicComposerImpl_Release,
164 IDirectMusicComposerImpl_ComposeSegmentFromTemplate,
165 IDirectMusicComposerImpl_ComposeSegmentFromShape,
166 IDirectMusicComposerImpl_ComposeTransition,
167 IDirectMusicComposerImpl_AutoTransition,
168 IDirectMusicComposerImpl_ComposeTemplateFromShape,
169 IDirectMusicComposerImpl_ChangeChordMap
172 /* for ClassFactory */
173 HRESULT create_dmcomposer(REFIID riid, void **ret_iface)
175 IDirectMusicComposerImpl *obj;
176 HRESULT hr;
178 obj = HeapAlloc(GetProcessHeap(), 0, sizeof(*obj));
179 if (!obj) {
180 *ret_iface = NULL;
181 return E_OUTOFMEMORY;
183 obj->IDirectMusicComposer_iface.lpVtbl = &dmcomposer_vtbl;
184 obj->ref = 1;
186 DMCOMPOS_LockModule();
187 hr = IDirectMusicComposer_QueryInterface(&obj->IDirectMusicComposer_iface, riid, ret_iface);
188 IDirectMusicComposer_Release(&obj->IDirectMusicComposer_iface);
190 return hr;