timesigtrack.c 8.36 KB
Newer Older
1 2
/* IDirectMusicTimeSigTrack Implementation
 *
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
 */

#include "dmime_private.h"
21
#include "dmobject.h"
22 23 24 25 26 27

WINE_DEFAULT_DEBUG_CHANNEL(dmime);

/*****************************************************************************
 * IDirectMusicTimeSigTrack implementation
 */
28
typedef struct IDirectMusicTimeSigTrack {
29
    IDirectMusicTrack IDirectMusicTrack_iface;
30
    struct dmobject dmobj;  /* IPersistStream only */
31 32 33
    LONG ref;
} IDirectMusicTimeSigTrack;

34
/* IDirectMusicTimeSigTrack IDirectMusicTrack8 part: */
35 36 37 38 39
static inline IDirectMusicTimeSigTrack *impl_from_IDirectMusicTrack(IDirectMusicTrack *iface)
{
    return CONTAINING_RECORD(iface, IDirectMusicTimeSigTrack, IDirectMusicTrack_iface);
}

40
static HRESULT WINAPI IDirectMusicTrackImpl_QueryInterface(IDirectMusicTrack *iface, REFIID riid,
41
        void **ret_iface)
42
{
43
    IDirectMusicTimeSigTrack *This = impl_from_IDirectMusicTrack(iface);
44 45 46 47 48 49 50 51

    TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ret_iface);

    *ret_iface = NULL;

    if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDirectMusicTrack))
        *ret_iface = iface;
    else if (IsEqualIID(riid, &IID_IPersistStream))
52
        *ret_iface = &This->dmobj.IPersistStream_iface;
53 54 55 56 57 58 59
    else {
        WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ret_iface);
        return E_NOINTERFACE;
    }

    IUnknown_AddRef((IUnknown*)*ret_iface);
    return S_OK;
60
}
61

62 63
static ULONG WINAPI IDirectMusicTrackImpl_AddRef(IDirectMusicTrack *iface)
{
64
    IDirectMusicTimeSigTrack *This = impl_from_IDirectMusicTrack(iface);
65 66 67 68 69
    LONG ref = InterlockedIncrement(&This->ref);

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

    return ref;
70 71
}

72 73
static ULONG WINAPI IDirectMusicTrackImpl_Release(IDirectMusicTrack *iface)
{
74
    IDirectMusicTimeSigTrack *This = impl_from_IDirectMusicTrack(iface);
75 76 77 78 79 80 81 82 83 84
    LONG ref = InterlockedDecrement(&This->ref);

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

    if (!ref) {
        HeapFree(GetProcessHeap(), 0, This);
        DMIME_UnlockModule();
    }

    return ref;
85 86
}

87 88
static HRESULT WINAPI IDirectMusicTrackImpl_Init(IDirectMusicTrack *iface,
        IDirectMusicSegment *pSegment)
89
{
90
        IDirectMusicTimeSigTrack *This = impl_from_IDirectMusicTrack(iface);
91 92 93
	FIXME("(%p, %p): stub\n", This, pSegment);
	return S_OK;
}
94

95 96 97
static HRESULT WINAPI IDirectMusicTrackImpl_InitPlay(IDirectMusicTrack *iface,
        IDirectMusicSegmentState *pSegmentState, IDirectMusicPerformance *pPerformance,
        void **ppStateData, DWORD dwVirtualTrack8ID, DWORD dwFlags)
98
{
99
        IDirectMusicTimeSigTrack *This = impl_from_IDirectMusicTrack(iface);
100
	FIXME("(%p, %p, %p, %p, %d, %d): stub\n", This, pSegmentState, pPerformance, ppStateData, dwVirtualTrack8ID, dwFlags);
101 102 103
	return S_OK;
}

104
static HRESULT WINAPI IDirectMusicTrackImpl_EndPlay(IDirectMusicTrack *iface, void *pStateData)
105
{
106
        IDirectMusicTimeSigTrack *This = impl_from_IDirectMusicTrack(iface);
107 108 109 110
	FIXME("(%p, %p): stub\n", This, pStateData);
	return S_OK;
}

111 112 113
static HRESULT WINAPI IDirectMusicTrackImpl_Play(IDirectMusicTrack *iface, void *pStateData,
        MUSIC_TIME mtStart, MUSIC_TIME mtEnd, MUSIC_TIME mtOffset, DWORD dwFlags,
        IDirectMusicPerformance *pPerf, IDirectMusicSegmentState *pSegSt, DWORD dwVirtualID)
114
{
115
        IDirectMusicTimeSigTrack *This = impl_from_IDirectMusicTrack(iface);
116
	FIXME("(%p, %p, %d, %d, %d, %d, %p, %p, %d): stub\n", This, pStateData, mtStart, mtEnd, mtOffset, dwFlags, pPerf, pSegSt, dwVirtualID);
117 118 119
	return S_OK;
}

120 121
static HRESULT WINAPI IDirectMusicTrackImpl_GetParam(IDirectMusicTrack *iface, REFGUID type,
        MUSIC_TIME time, MUSIC_TIME *next, void *param)
122
{
123 124 125 126 127 128 129 130 131 132
    IDirectMusicTimeSigTrack *This = impl_from_IDirectMusicTrack(iface);

    TRACE("(%p, %s, %d, %p, %p)\n", This, debugstr_dmguid(type), time, next, param);

    if (IsEqualGUID(type, &GUID_TimeSignature)) {
        FIXME("GUID_TimeSignature not handled yet\n");
        return DMUS_E_NOT_FOUND;
    }

    return DMUS_E_GET_UNSUPPORTED;
133 134
}

135 136
static HRESULT WINAPI IDirectMusicTrackImpl_SetParam(IDirectMusicTrack *iface, REFGUID type,
        MUSIC_TIME time, void *param)
137
{
138 139 140 141 142 143 144 145 146 147 148 149 150 151
    IDirectMusicTimeSigTrack *This = impl_from_IDirectMusicTrack(iface);

    TRACE("(%p, %s, %d, %p)\n", This, debugstr_dmguid(type), time, param);

    if (IsEqualGUID(type, &GUID_DisableTimeSig)) {
        FIXME("GUID_DisableTimeSig not handled yet\n");
        return S_OK;
    }
    if (IsEqualGUID(type, &GUID_EnableTimeSig)) {
        FIXME("GUID_EnableTimeSig not handled yet\n");
        return S_OK;
    }

    return DMUS_E_SET_UNSUPPORTED;
152 153
}

154 155 156
static HRESULT WINAPI IDirectMusicTrackImpl_IsParamSupported(IDirectMusicTrack *iface,
        REFGUID rguidType)
{
157
        IDirectMusicTimeSigTrack *This = impl_from_IDirectMusicTrack(iface);
158

159
	TRACE("(%p, %s)\n", This, debugstr_dmguid(rguidType));
160 161 162 163 164
	if (IsEqualGUID (rguidType, &GUID_DisableTimeSig)
		|| IsEqualGUID (rguidType, &GUID_EnableTimeSig)
		|| IsEqualGUID (rguidType, &GUID_TimeSignature)) {
		TRACE("param supported\n");
		return S_OK;
165
	}
166 167 168 169
	TRACE("param unsupported\n");
	return DMUS_E_TYPE_UNSUPPORTED;
}

170 171 172
static HRESULT WINAPI IDirectMusicTrackImpl_AddNotificationType(IDirectMusicTrack *iface,
        REFGUID rguidNotificationType)
{
173
        IDirectMusicTimeSigTrack *This = impl_from_IDirectMusicTrack(iface);
174
	FIXME("(%p, %s): stub\n", This, debugstr_dmguid(rguidNotificationType));
175 176 177
	return S_OK;
}

178 179 180
static HRESULT WINAPI IDirectMusicTrackImpl_RemoveNotificationType(IDirectMusicTrack *iface,
        REFGUID rguidNotificationType)
{
181
        IDirectMusicTimeSigTrack *This = impl_from_IDirectMusicTrack(iface);
182
	FIXME("(%p, %s): stub\n", This, debugstr_dmguid(rguidNotificationType));
183 184 185
	return S_OK;
}

186 187 188
static HRESULT WINAPI IDirectMusicTrackImpl_Clone(IDirectMusicTrack *iface, MUSIC_TIME mtStart,
        MUSIC_TIME mtEnd, IDirectMusicTrack **ppTrack)
{
189
        IDirectMusicTimeSigTrack *This = impl_from_IDirectMusicTrack(iface);
190
	FIXME("(%p, %d, %d, %p): stub\n", This, mtStart, mtEnd, ppTrack);
191 192 193
	return S_OK;
}

194
static const IDirectMusicTrackVtbl dmtack_vtbl = {
195 196 197 198 199 200 201 202 203 204 205 206 207
    IDirectMusicTrackImpl_QueryInterface,
    IDirectMusicTrackImpl_AddRef,
    IDirectMusicTrackImpl_Release,
    IDirectMusicTrackImpl_Init,
    IDirectMusicTrackImpl_InitPlay,
    IDirectMusicTrackImpl_EndPlay,
    IDirectMusicTrackImpl_Play,
    IDirectMusicTrackImpl_GetParam,
    IDirectMusicTrackImpl_SetParam,
    IDirectMusicTrackImpl_IsParamSupported,
    IDirectMusicTrackImpl_AddNotificationType,
    IDirectMusicTrackImpl_RemoveNotificationType,
    IDirectMusicTrackImpl_Clone
208 209
};

210
static HRESULT WINAPI time_IPersistStream_Load(IPersistStream *iface, IStream *stream)
211
{
212 213 214 215
	FIXME(": Loading not implemented yet\n");
	return S_OK;
}

216 217 218 219 220 221
static const IPersistStreamVtbl persiststream_vtbl = {
    dmobj_IPersistStream_QueryInterface,
    dmobj_IPersistStream_AddRef,
    dmobj_IPersistStream_Release,
    dmobj_IPersistStream_GetClassID,
    unimpl_IPersistStream_IsDirty,
222
    time_IPersistStream_Load,
223 224
    unimpl_IPersistStream_Save,
    unimpl_IPersistStream_GetSizeMax
225
};
226 227

/* for ClassFactory */
228 229
HRESULT WINAPI create_dmtimesigtrack(REFIID lpcGUID, void **ppobj)
{
230 231 232 233 234 235 236 237
    IDirectMusicTimeSigTrack *track;
    HRESULT hr;

    track = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*track));
    if (!track) {
        *ppobj = NULL;
        return E_OUTOFMEMORY;
    }
238
    track->IDirectMusicTrack_iface.lpVtbl = &dmtack_vtbl;
239
    track->ref = 1;
240 241 242
    dmobject_init(&track->dmobj, &CLSID_DirectMusicTimeSigTrack,
                  (IUnknown *)&track->IDirectMusicTrack_iface);
    track->dmobj.IPersistStream_iface.lpVtbl = &persiststream_vtbl;
243 244 245 246

    DMIME_LockModule();
    hr = IDirectMusicTrack_QueryInterface(&track->IDirectMusicTrack_iface, lpcGUID, ppobj);
    IDirectMusicTrack_Release(&track->IDirectMusicTrack_iface);
247

248
    return hr;
249
}