dmcompos: Use CRT allocation functions.
[wine.git] / dlls / dmcompos / composer.c
blob3451f2d4203211cf72acb2974e78ff84011494e1
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) free(This);
72 return ref;
75 /* IDirectMusicComposerImpl IDirectMusicComposer part: */
76 static HRESULT WINAPI IDirectMusicComposerImpl_ComposeSegmentFromTemplate(IDirectMusicComposer *iface,
77 IDirectMusicStyle *style, IDirectMusicSegment *template, WORD activity, IDirectMusicChordMap *chordmap,
78 IDirectMusicSegment **segment)
80 IDirectMusicComposerImpl *This = impl_from_IDirectMusicComposer(iface);
81 IDirectMusicTrack *track;
82 HRESULT hr;
84 FIXME("(%p, %p, %p, %d, %p, %p): semi-stub\n", This, style, template, activity, chordmap, segment);
86 if (!segment)
87 return E_POINTER;
88 if (!template)
89 return E_INVALIDARG;
91 if (!style) {
92 hr = IDirectMusicSegment_GetTrack(template, &CLSID_DirectMusicStyleTrack, 0xFFFFFFFF,
93 DMUS_SEG_ANYTRACK, &track);
94 if (FAILED(hr))
95 return E_INVALIDARG;
96 else
97 IDirectMusicTrack_Release(track); /* Temp to not leak memory */
99 if (!chordmap) {
100 hr = IDirectMusicSegment_GetTrack(template, &CLSID_DirectMusicChordMapTrack, 0xFFFFFFFF,
101 DMUS_SEG_ANYTRACK, &track);
102 if (FAILED(hr))
103 return E_INVALIDARG;
104 else
105 IDirectMusicTrack_Release(track); /* Temp to not leak memory */
108 return IDirectMusicSegment_Clone(template, -1, 0, segment);
111 static HRESULT WINAPI IDirectMusicComposerImpl_ComposeSegmentFromShape(IDirectMusicComposer *iface,
112 IDirectMusicStyle *pStyle, WORD wNumMeasures, WORD wShape, WORD wActivity, BOOL fIntro,
113 BOOL fEnd, IDirectMusicChordMap *pChordMap, IDirectMusicSegment **ppSegment)
115 IDirectMusicComposerImpl *This = impl_from_IDirectMusicComposer(iface);
116 FIXME("(%p, %p, %d, %d, %d, %d, %d, %p, %p): stub\n", This, pStyle, wNumMeasures, wShape, wActivity, fIntro, fEnd, pChordMap, ppSegment);
117 return S_OK;
120 static HRESULT WINAPI IDirectMusicComposerImpl_ComposeTransition(IDirectMusicComposer *iface,
121 IDirectMusicSegment *pFromSeg, IDirectMusicSegment *pToSeg, MUSIC_TIME mtTime,
122 WORD wCommand, DWORD dwFlags, IDirectMusicChordMap *pChordMap,
123 IDirectMusicSegment **ppTransSeg)
125 IDirectMusicComposerImpl *This = impl_from_IDirectMusicComposer(iface);
126 FIXME("(%p, %p, %p, %ld, %d, %ld, %p, %p): stub\n", This, pFromSeg, pToSeg, mtTime, wCommand, dwFlags, pChordMap, ppTransSeg);
127 return S_OK;
130 static HRESULT WINAPI IDirectMusicComposerImpl_AutoTransition(IDirectMusicComposer *iface,
131 IDirectMusicPerformance *pPerformance, IDirectMusicSegment *pToSeg, WORD wCommand,
132 DWORD dwFlags, IDirectMusicChordMap *pChordMap, IDirectMusicSegment **ppTransSeg,
133 IDirectMusicSegmentState **ppToSegState, IDirectMusicSegmentState **ppTransSegState)
135 IDirectMusicComposerImpl *This = impl_from_IDirectMusicComposer(iface);
136 FIXME("(%p, %p, %d, %ld, %p, %p, %p, %p): stub\n", This, pPerformance, wCommand, dwFlags, pChordMap, ppTransSeg, ppToSegState, ppTransSegState);
137 return S_OK;
140 static HRESULT WINAPI IDirectMusicComposerImpl_ComposeTemplateFromShape(IDirectMusicComposer *iface,
141 WORD wNumMeasures, WORD wShape, BOOL fIntro, BOOL fEnd, WORD wEndLength,
142 IDirectMusicSegment **ppTemplate)
144 IDirectMusicComposerImpl *This = impl_from_IDirectMusicComposer(iface);
145 FIXME("(%p, %d, %d, %d, %d, %d, %p): stub\n", This, wNumMeasures, wShape, fIntro, fEnd, wEndLength, ppTemplate);
146 return S_OK;
149 static HRESULT WINAPI IDirectMusicComposerImpl_ChangeChordMap(IDirectMusicComposer *iface,
150 IDirectMusicSegment *pSegment, BOOL fTrackScale, IDirectMusicChordMap *pChordMap)
152 IDirectMusicComposerImpl *This = impl_from_IDirectMusicComposer(iface);
153 FIXME("(%p, %p, %d, %p): stub\n", This, pSegment, fTrackScale, pChordMap);
154 return S_OK;
157 static const IDirectMusicComposerVtbl dmcomposer_vtbl = {
158 IDirectMusicComposerImpl_QueryInterface,
159 IDirectMusicComposerImpl_AddRef,
160 IDirectMusicComposerImpl_Release,
161 IDirectMusicComposerImpl_ComposeSegmentFromTemplate,
162 IDirectMusicComposerImpl_ComposeSegmentFromShape,
163 IDirectMusicComposerImpl_ComposeTransition,
164 IDirectMusicComposerImpl_AutoTransition,
165 IDirectMusicComposerImpl_ComposeTemplateFromShape,
166 IDirectMusicComposerImpl_ChangeChordMap
169 /* for ClassFactory */
170 HRESULT create_dmcomposer(REFIID riid, void **ret_iface)
172 IDirectMusicComposerImpl *obj;
173 HRESULT hr;
175 *ret_iface = NULL;
176 if (!(obj = calloc(1, sizeof(*obj)))) return E_OUTOFMEMORY;
177 obj->IDirectMusicComposer_iface.lpVtbl = &dmcomposer_vtbl;
178 obj->ref = 1;
180 hr = IDirectMusicComposer_QueryInterface(&obj->IDirectMusicComposer_iface, riid, ret_iface);
181 IDirectMusicComposer_Release(&obj->IDirectMusicComposer_iface);
183 return hr;