composer.c 6.22 KB
Newer Older
1 2
/* IDirectMusicComposer
 *
3
 * Copyright (C) 2003-2004 Rok Mandeljc
4
 *
5 6 7 8
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
9 10 11
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
14
 *
15 16 17
 * You should have received a copy of the GNU Lesser General Public
 * License along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18 19 20 21
 */

#include "dmcompos_private.h"

22
WINE_DEFAULT_DEBUG_CHANNEL(dmcompos);
23

24 25 26 27 28 29 30 31
typedef struct IDirectMusicComposerImpl {
    IDirectMusicComposer IDirectMusicComposer_iface;
    LONG  ref;
} IDirectMusicComposerImpl;

static inline IDirectMusicComposerImpl *impl_from_IDirectMusicComposer(IDirectMusicComposer *iface)
{
  return CONTAINING_RECORD(iface, IDirectMusicComposerImpl, IDirectMusicComposer_iface);
32 33
}

34 35 36 37 38 39 40 41 42 43 44 45 46 47
static HRESULT WINAPI IDirectMusicComposerImpl_QueryInterface(IDirectMusicComposer *iface,
        REFIID riid, void **ret_iface)
{
    TRACE("(%p, %s, %p)\n", iface, debugstr_dmguid(riid), ret_iface);

    if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDirectMusicComposer))
{
        *ret_iface = iface;
        IDirectMusicComposer_AddRef(iface);
        return S_OK;
    }

    WARN("(%p, %s, %p): not found\n", iface, debugstr_dmguid(riid), ret_iface);
    *ret_iface = NULL;
48

49
    return E_NOINTERFACE;
50 51
}

52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
static ULONG WINAPI IDirectMusicComposerImpl_AddRef(IDirectMusicComposer *iface)
{
    IDirectMusicComposerImpl *This = impl_from_IDirectMusicComposer(iface);
    ULONG ref = InterlockedIncrement(&This->ref);

    TRACE("(%p) ref=%d\n", This, ref);

    return ref;
}

static ULONG WINAPI IDirectMusicComposerImpl_Release(IDirectMusicComposer *iface)
{
    IDirectMusicComposerImpl *This = impl_from_IDirectMusicComposer(iface);
    ULONG ref = InterlockedDecrement(&This->ref);

    TRACE("(%p) ref=%d\n", This, ref);

    if (ref == 0) {
        HeapFree(GetProcessHeap(), 0, This);
        DMCOMPOS_UnlockModule();
    }

    return ref;
75 76
}

77
/* IDirectMusicComposerImpl IDirectMusicComposer part: */
78 79 80 81 82
static HRESULT WINAPI IDirectMusicComposerImpl_ComposeSegmentFromTemplate(IDirectMusicComposer *iface,
        IDirectMusicStyle *pStyle, IDirectMusicSegment *pTemplate, WORD wActivity,
        IDirectMusicChordMap *pChordMap, IDirectMusicSegment **ppSegment)
{
        IDirectMusicComposerImpl *This = impl_from_IDirectMusicComposer(iface);
83 84 85 86
	FIXME("(%p, %p, %p, %d, %p, %p): stub\n", This, pStyle, pTemplate, wActivity, pChordMap, ppSegment);
	return S_OK;
}

87 88 89 90 91
static HRESULT WINAPI IDirectMusicComposerImpl_ComposeSegmentFromShape(IDirectMusicComposer *iface,
        IDirectMusicStyle *pStyle, WORD wNumMeasures, WORD wShape, WORD wActivity, BOOL fIntro,
        BOOL fEnd, IDirectMusicChordMap *pChordMap, IDirectMusicSegment **ppSegment)
{
        IDirectMusicComposerImpl *This = impl_from_IDirectMusicComposer(iface);
92 93 94 95
	FIXME("(%p, %p, %d, %d, %d, %d, %d, %p, %p): stub\n", This, pStyle, wNumMeasures, wShape, wActivity, fIntro, fEnd, pChordMap, ppSegment);
	return S_OK;
}

96 97 98 99 100 101
static HRESULT WINAPI IDirectMusicComposerImpl_ComposeTransition(IDirectMusicComposer *iface,
        IDirectMusicSegment *pFromSeg, IDirectMusicSegment *pToSeg, MUSIC_TIME mtTime,
        WORD wCommand, DWORD dwFlags, IDirectMusicChordMap *pChordMap,
        IDirectMusicSegment **ppTransSeg)
{
        IDirectMusicComposerImpl *This = impl_from_IDirectMusicComposer(iface);
102
	FIXME("(%p, %p, %p, %d, %d, %d, %p, %p): stub\n", This, pFromSeg, pToSeg, mtTime, wCommand, dwFlags, pChordMap, ppTransSeg);
103 104 105
	return S_OK;
}

106 107 108 109 110 111
static HRESULT WINAPI IDirectMusicComposerImpl_AutoTransition(IDirectMusicComposer *iface,
        IDirectMusicPerformance *pPerformance, IDirectMusicSegment *pToSeg, WORD wCommand,
        DWORD dwFlags, IDirectMusicChordMap *pChordMap, IDirectMusicSegment **ppTransSeg,
        IDirectMusicSegmentState **ppToSegState, IDirectMusicSegmentState **ppTransSegState)
{
        IDirectMusicComposerImpl *This = impl_from_IDirectMusicComposer(iface);
112
	FIXME("(%p, %p, %d, %d, %p, %p, %p, %p): stub\n", This, pPerformance, wCommand, dwFlags, pChordMap, ppTransSeg, ppToSegState, ppTransSegState);
113 114 115
	return S_OK;
}

116 117 118 119 120
static HRESULT WINAPI IDirectMusicComposerImpl_ComposeTemplateFromShape(IDirectMusicComposer *iface,
        WORD wNumMeasures, WORD wShape, BOOL fIntro, BOOL fEnd, WORD wEndLength,
        IDirectMusicSegment **ppTemplate)
{
        IDirectMusicComposerImpl *This = impl_from_IDirectMusicComposer(iface);
121 122 123 124
	FIXME("(%p, %d, %d, %d, %d, %d, %p): stub\n", This, wNumMeasures, wShape, fIntro, fEnd, wEndLength, ppTemplate);
	return S_OK;
}

125 126 127 128
static HRESULT WINAPI IDirectMusicComposerImpl_ChangeChordMap(IDirectMusicComposer *iface,
        IDirectMusicSegment *pSegment, BOOL fTrackScale, IDirectMusicChordMap *pChordMap)
{
        IDirectMusicComposerImpl *This = impl_from_IDirectMusicComposer(iface);
129 130 131 132
	FIXME("(%p, %p, %d, %p): stub\n", This, pSegment, fTrackScale, pChordMap);
	return S_OK;
}

133
static const IDirectMusicComposerVtbl dmcomposer_vtbl = {
134 135 136 137 138 139 140 141 142 143 144 145
	IDirectMusicComposerImpl_QueryInterface,
	IDirectMusicComposerImpl_AddRef,
	IDirectMusicComposerImpl_Release,
	IDirectMusicComposerImpl_ComposeSegmentFromTemplate,
	IDirectMusicComposerImpl_ComposeSegmentFromShape,
	IDirectMusicComposerImpl_ComposeTransition,
	IDirectMusicComposerImpl_AutoTransition,
	IDirectMusicComposerImpl_ComposeTemplateFromShape,
	IDirectMusicComposerImpl_ChangeChordMap
};

/* for ClassFactory */
146
HRESULT WINAPI create_dmcomposer(REFIID riid, void **ret_iface)
147
{
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
    IDirectMusicComposerImpl *obj;
    HRESULT hr;

    obj = HeapAlloc(GetProcessHeap(), 0, sizeof(*obj));
    if (!obj) {
        *ret_iface = NULL;
        return E_OUTOFMEMORY;
    }
    obj->IDirectMusicComposer_iface.lpVtbl = &dmcomposer_vtbl;
    obj->ref = 1;

    DMCOMPOS_LockModule();
    hr = IDirectMusicComposer_QueryInterface(&obj->IDirectMusicComposer_iface, riid, ret_iface);
    IDirectMusicComposer_Release(&obj->IDirectMusicComposer_iface);

    return hr;
164
}