patterntrack.c 4.07 KB
Newer Older
1 2
/* IDirectMusicPatternTrack 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 21
 */

#include "dmime_private.h"

22
WINE_DEFAULT_DEBUG_CHANNEL(dmime);
23 24

/* IDirectMusicPatternTrack IUnknown parts follow: */
25
static HRESULT WINAPI IDirectMusicPatternTrackImpl_QueryInterface (LPDIRECTMUSICPATTERNTRACK iface, REFIID riid, LPVOID *ppobj) {
26
	IDirectMusicPatternTrackImpl *This = (IDirectMusicPatternTrackImpl *)iface;
27
	TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
28

29 30
	if (IsEqualIID (riid, &IID_IUnknown) || 
	    IsEqualIID (riid, &IID_IDirectMusicPatternTrack)) {
31
		IUnknown_AddRef(iface);
32 33 34
		*ppobj = This;
		return S_OK;
	}
35
	
36
	WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ppobj);
37 38 39
	return E_NOINTERFACE;
}

40
static ULONG WINAPI IDirectMusicPatternTrackImpl_AddRef (LPDIRECTMUSICPATTERNTRACK iface) {
41
	IDirectMusicPatternTrackImpl *This = (IDirectMusicPatternTrackImpl *)iface;
42 43
        ULONG ref = InterlockedIncrement(&This->ref);

44
	TRACE("(%p): AddRef from %d\n", This, ref - 1);
45

46 47
	DMIME_LockModule();

48
	return ref;
49 50
}

Mike McCormack's avatar
Mike McCormack committed
51
static ULONG WINAPI IDirectMusicPatternTrackImpl_Release (LPDIRECTMUSICPATTERNTRACK iface) {
52
	IDirectMusicPatternTrackImpl *This = (IDirectMusicPatternTrackImpl *)iface;
53
	ULONG ref = InterlockedDecrement(&This->ref);
54
	TRACE("(%p): ReleaseRef to %d\n", This, ref);
55
	
56
	if (ref == 0) {
57 58
		HeapFree(GetProcessHeap(), 0, This);
	}
59 60 61

	DMIME_UnlockModule();

62 63 64 65
	return ref;
}

/* IDirectMusicPatternTrack Interface follow: */
Mike McCormack's avatar
Mike McCormack committed
66
static HRESULT WINAPI IDirectMusicPatternTrackImpl_CreateSegment (LPDIRECTMUSICPATTERNTRACK iface, IDirectMusicStyle* pStyle, IDirectMusicSegment** ppSegment) {
67
	IDirectMusicPatternTrackImpl *This = (IDirectMusicPatternTrackImpl *)iface;
68 69 70 71
	FIXME("(%p, %p, %p): stub\n", This, pStyle, ppSegment);
	return S_OK;
}

Mike McCormack's avatar
Mike McCormack committed
72
static HRESULT WINAPI IDirectMusicPatternTrackImpl_SetVariation (LPDIRECTMUSICPATTERNTRACK iface, IDirectMusicSegmentState* pSegState, DWORD dwVariationFlags, DWORD dwPart) {
73
	IDirectMusicPatternTrackImpl *This = (IDirectMusicPatternTrackImpl *)iface;
74
	FIXME("(%p, %p, %d, %d): stub\n", This, pSegState, dwVariationFlags, dwPart);
75 76 77
	return S_OK;
}

Mike McCormack's avatar
Mike McCormack committed
78
static HRESULT WINAPI IDirectMusicPatternTrackImpl_SetPatternByName (LPDIRECTMUSICPATTERNTRACK iface, IDirectMusicSegmentState* pSegState, WCHAR* wszName, IDirectMusicStyle* pStyle, DWORD dwPatternType, DWORD* pdwLength) {
79
	IDirectMusicPatternTrackImpl *This = (IDirectMusicPatternTrackImpl *)iface;
80
	FIXME("(%p, %p, %p, %p, %d, %p): stub\n", This, pSegState, wszName, pStyle, dwPatternType, pdwLength);
81 82 83
	return S_OK;
}

84
static const IDirectMusicPatternTrackVtbl DirectMusicPatternTrack_Vtbl = {
85 86 87 88 89 90 91 92 93
	IDirectMusicPatternTrackImpl_QueryInterface,
	IDirectMusicPatternTrackImpl_AddRef,
	IDirectMusicPatternTrackImpl_Release,
	IDirectMusicPatternTrackImpl_CreateSegment,
	IDirectMusicPatternTrackImpl_SetVariation,
	IDirectMusicPatternTrackImpl_SetPatternByName
};

/* for ClassFactory */
94 95 96 97 98
HRESULT WINAPI DMUSIC_CreateDirectMusicPatternTrackImpl (LPCGUID lpcGUID, LPVOID *ppobj, LPUNKNOWN pUnkOuter) {
	IDirectMusicPatternTrackImpl* track;
	
	track = HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicPatternTrackImpl));
	if (NULL == track) {
99
		*ppobj = NULL;
100
		return E_OUTOFMEMORY;
101
	}
102 103
	track->lpVtbl = &DirectMusicPatternTrack_Vtbl;
	track->ref = 0; /* will be inited by QueryInterface */
104
	
105
	return IDirectMusicPatternTrackImpl_QueryInterface ((LPDIRECTMUSICPATTERNTRACK)track, lpcGUID, ppobj);
106
}