markertrack.c 7.89 KB
Newer Older
1 2
/* IDirectMusicMarkerTrack 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);

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

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

40
static HRESULT WINAPI IDirectMusicTrackImpl_QueryInterface(IDirectMusicTrack *iface, REFIID riid,
41
        void **ret_iface)
42
{
43
    IDirectMusicMarkerTrack *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
    IDirectMusicMarkerTrack *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
    IDirectMusicMarkerTrack *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 89
static HRESULT WINAPI IDirectMusicTrackImpl_Init(IDirectMusicTrack *iface,
        IDirectMusicSegment *pSegment)
{
90
        IDirectMusicMarkerTrack *This = impl_from_IDirectMusicTrack(iface);
91
	FIXME("(%p, %p): stub\n", This, pSegment);
92 93 94
	return S_OK;
}

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

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

111 112 113 114
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)
{
115
        IDirectMusicMarkerTrack *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 122
static HRESULT WINAPI IDirectMusicTrackImpl_GetParam(IDirectMusicTrack *iface, REFGUID rguidType,
        MUSIC_TIME mtTime, MUSIC_TIME *pmtNext, void *pParam)
{
123
        IDirectMusicMarkerTrack *This = impl_from_IDirectMusicTrack(iface);
124
	FIXME("(%p, %s, %d, %p, %p): stub\n", This, debugstr_dmguid(rguidType), mtTime, pmtNext, pParam);
125 126 127
	return S_OK;
}

128 129 130
static HRESULT WINAPI IDirectMusicTrackImpl_SetParam(IDirectMusicTrack *iface, REFGUID rguidType,
        MUSIC_TIME mtTime, void *pParam)
{
131
        IDirectMusicMarkerTrack *This = impl_from_IDirectMusicTrack(iface);
132
	FIXME("(%p, %s, %d, %p): stub\n", This, debugstr_dmguid(rguidType), mtTime, pParam);
133 134 135
	return S_OK;
}

136 137 138
static HRESULT WINAPI IDirectMusicTrackImpl_IsParamSupported(IDirectMusicTrack *iface,
        REFGUID rguidType)
{
139
        IDirectMusicMarkerTrack *This = impl_from_IDirectMusicTrack(iface);
140

141
	TRACE("(%p, %s)\n", This, debugstr_dmguid(rguidType));
142 143 144 145
	if (IsEqualGUID (rguidType, &GUID_Play_Marker)
		|| IsEqualGUID (rguidType, &GUID_Valid_Start_Time)) {
		TRACE("param supported\n");
		return S_OK;
146
	}
147 148 149 150
	TRACE("param unsupported\n");
	return DMUS_E_TYPE_UNSUPPORTED;
}

151 152 153
static HRESULT WINAPI IDirectMusicTrackImpl_AddNotificationType(IDirectMusicTrack *iface,
        REFGUID rguidNotificationType)
{
154
        IDirectMusicMarkerTrack *This = impl_from_IDirectMusicTrack(iface);
155
	FIXME("(%p, %s): stub\n", This, debugstr_dmguid(rguidNotificationType));
156 157 158
	return S_OK;
}

159 160 161
static HRESULT WINAPI IDirectMusicTrackImpl_RemoveNotificationType(IDirectMusicTrack *iface,
        REFGUID rguidNotificationType)
{
162
        IDirectMusicMarkerTrack *This = impl_from_IDirectMusicTrack(iface);
163
	FIXME("(%p, %s): stub\n", This, debugstr_dmguid(rguidNotificationType));
164 165 166
	return S_OK;
}

167 168 169
static HRESULT WINAPI IDirectMusicTrackImpl_Clone(IDirectMusicTrack *iface, MUSIC_TIME mtStart,
        MUSIC_TIME mtEnd, IDirectMusicTrack **ppTrack)
{
170
        IDirectMusicMarkerTrack *This = impl_from_IDirectMusicTrack(iface);
171
	FIXME("(%p, %d, %d, %p): stub\n", This, mtStart, mtEnd, ppTrack);
172 173 174
	return S_OK;
}

175
static const IDirectMusicTrackVtbl dmtrack_vtbl = {
176 177 178 179 180 181 182 183 184 185 186 187 188
    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
189 190
};

191 192
static HRESULT WINAPI IPersistStreamImpl_Load(IPersistStream *iface, IStream *stream)
{
193 194 195 196
	FIXME(": Loading not implemented yet\n");
	return S_OK;
}

197 198 199 200 201 202 203 204 205
static const IPersistStreamVtbl persiststream_vtbl = {
    dmobj_IPersistStream_QueryInterface,
    dmobj_IPersistStream_AddRef,
    dmobj_IPersistStream_Release,
    dmobj_IPersistStream_GetClassID,
    unimpl_IPersistStream_IsDirty,
    IPersistStreamImpl_Load,
    unimpl_IPersistStream_Save,
    unimpl_IPersistStream_GetSizeMax
206
};
207 208

/* for ClassFactory */
209 210
HRESULT WINAPI create_dmmarkertrack(REFIID lpcGUID, void **ppobj)
{
211 212 213 214 215 216 217 218
    IDirectMusicMarkerTrack *track;
    HRESULT hr;

    track = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*track));
    if (!track) {
        *ppobj = NULL;
        return E_OUTOFMEMORY;
    }
219
    track->IDirectMusicTrack_iface.lpVtbl = &dmtrack_vtbl;
220
    track->ref = 1;
221 222 223
    dmobject_init(&track->dmobj, &CLSID_DirectMusicMarkerTrack,
                  (IUnknown *)&track->IDirectMusicTrack_iface);
    track->dmobj.IPersistStream_iface.lpVtbl = &persiststream_vtbl;
224 225 226 227 228 229

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

    return hr;
230
}