buffer.c 6.43 KB
Newer Older
1 2
/* IDirectMusicBuffer 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 22 23
 */

#include "dmusic_private.h"

WINE_DEFAULT_DEBUG_CHANNEL(dmusic);

24
/* IDirectMusicBufferImpl IUnknown part: */
25
static HRESULT WINAPI IDirectMusicBufferImpl_QueryInterface (LPDIRECTMUSICBUFFER iface, REFIID riid, LPVOID *ppobj) {
26
	IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
27
	TRACE("(%p, (%s, %p)\n",This,debugstr_dmguid(riid),ppobj);
28 29
	if (IsEqualIID (riid, &IID_IUnknown) 
		|| IsEqualIID (riid, &IID_IDirectMusicBuffer)) {
30
		IUnknown_AddRef(iface);
31 32 33
		*ppobj = This;
		return S_OK;
	}
34
	WARN("(%p, (%s, %p): not found\n",This,debugstr_dmguid(riid),ppobj);
35 36 37
	return E_NOINTERFACE;
}

38
static ULONG WINAPI IDirectMusicBufferImpl_AddRef (LPDIRECTMUSICBUFFER iface) {
39
	IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
40 41
	ULONG refCount = InterlockedIncrement(&This->ref);

42
	TRACE("(%p)->(ref before=%u)\n", This, refCount - 1);
43

44 45
	DMUSIC_LockModule();

46
	return refCount;
47 48
}

49
static ULONG WINAPI IDirectMusicBufferImpl_Release (LPDIRECTMUSICBUFFER iface) {
50
	IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
51 52
	ULONG refCount = InterlockedDecrement(&This->ref);

53
	TRACE("(%p)->(ref before=%u)\n", This, refCount + 1);
54 55

	if (!refCount) {
56 57
		HeapFree(GetProcessHeap(), 0, This);
	}
58 59 60

	DMUSIC_UnlockModule();
	
61
	return refCount;
62 63
}

64
/* IDirectMusicBufferImpl IDirectMusicBuffer part: */
65
static HRESULT WINAPI IDirectMusicBufferImpl_Flush (LPDIRECTMUSICBUFFER iface) {
66
	IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
67 68 69 70
	FIXME("(%p): stub\n", This);
	return S_OK;
}

71
static HRESULT WINAPI IDirectMusicBufferImpl_TotalTime (LPDIRECTMUSICBUFFER iface, LPREFERENCE_TIME prtTime) {
72
	IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
73
	FIXME("(%p, %p): stub\n", This, prtTime);	
74 75 76
	return S_OK;
}

77
static HRESULT WINAPI IDirectMusicBufferImpl_PackStructured (LPDIRECTMUSICBUFFER iface, REFERENCE_TIME rt, DWORD dwChannelGroup, DWORD dwChannelMessage) {
78
	IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
79
	FIXME("(%p, 0x%s, %d, %d): stub\n", This, wine_dbgstr_longlong(rt), dwChannelGroup, dwChannelMessage);
80 81 82
	return S_OK;
}

83
static HRESULT WINAPI IDirectMusicBufferImpl_PackUnstructured (LPDIRECTMUSICBUFFER iface, REFERENCE_TIME rt, DWORD dwChannelGroup, DWORD cb, LPBYTE lpb) {
84
	IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
85
	FIXME("(%p, 0x%s, %d, %d, %p): stub\n", This, wine_dbgstr_longlong(rt), dwChannelGroup, cb, lpb);
86 87 88
	return S_OK;
}

89
static HRESULT WINAPI IDirectMusicBufferImpl_ResetReadPtr (LPDIRECTMUSICBUFFER iface) {
90
	IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
91 92 93 94
	FIXME("(%p): stub\n", This);
	return S_OK;
}

95
static HRESULT WINAPI IDirectMusicBufferImpl_GetNextEvent (LPDIRECTMUSICBUFFER iface, LPREFERENCE_TIME prt, LPDWORD pdwChannelGroup, LPDWORD pdwLength, LPBYTE* ppData) {
96
	IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
97 98 99 100
	FIXME("(%p, %p, %p, %p, %p): stub\n", This, prt, pdwChannelGroup, pdwLength, ppData);
	return S_OK;
}

101
static HRESULT WINAPI IDirectMusicBufferImpl_GetRawBufferPtr (LPDIRECTMUSICBUFFER iface, LPBYTE* ppData) {
102
	IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
103 104 105 106
	FIXME("(%p, %p): stub\n", This, ppData);
	return S_OK;
}

107
static HRESULT WINAPI IDirectMusicBufferImpl_GetStartTime (LPDIRECTMUSICBUFFER iface, LPREFERENCE_TIME prt) {
108
	IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
109 110 111 112
	FIXME("(%p, %p): stub\n", This, prt);
	return S_OK;
}

113
static HRESULT WINAPI IDirectMusicBufferImpl_GetUsedBytes (LPDIRECTMUSICBUFFER iface, LPDWORD pcb) {
114
	IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
115 116 117 118
	FIXME("(%p, %p): stub\n", This, pcb);
	return S_OK;
}

119
static HRESULT WINAPI IDirectMusicBufferImpl_GetMaxBytes (LPDIRECTMUSICBUFFER iface, LPDWORD pcb) {
120
	IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
121 122 123 124
	FIXME("(%p, %p): stub\n", This, pcb);
	return S_OK;
}

125
static HRESULT WINAPI IDirectMusicBufferImpl_GetBufferFormat (LPDIRECTMUSICBUFFER iface, LPGUID pGuidFormat) {
126
	IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
127 128 129 130
	FIXME("(%p, %p): stub\n", This, pGuidFormat);
	return S_OK;
}

131
static HRESULT WINAPI IDirectMusicBufferImpl_SetStartTime (LPDIRECTMUSICBUFFER iface, REFERENCE_TIME rt) {
132
	IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
133
	FIXME("(%p, 0x%s): stub\n", This, wine_dbgstr_longlong(rt));
134 135 136
	return S_OK;
}

137
static HRESULT WINAPI IDirectMusicBufferImpl_SetUsedBytes (LPDIRECTMUSICBUFFER iface, DWORD cb) {
138
	IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
139
	FIXME("(%p, %d): stub\n", This, cb);
140 141 142
	return S_OK;
}

143
static const IDirectMusicBufferVtbl DirectMusicBuffer_Vtbl = {
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
	IDirectMusicBufferImpl_QueryInterface,
	IDirectMusicBufferImpl_AddRef,
	IDirectMusicBufferImpl_Release,
	IDirectMusicBufferImpl_Flush,
	IDirectMusicBufferImpl_TotalTime,
	IDirectMusicBufferImpl_PackStructured,
	IDirectMusicBufferImpl_PackUnstructured,
	IDirectMusicBufferImpl_ResetReadPtr,
	IDirectMusicBufferImpl_GetNextEvent,
	IDirectMusicBufferImpl_GetRawBufferPtr,
	IDirectMusicBufferImpl_GetStartTime,
	IDirectMusicBufferImpl_GetUsedBytes,
	IDirectMusicBufferImpl_GetMaxBytes,
	IDirectMusicBufferImpl_GetBufferFormat,
	IDirectMusicBufferImpl_SetStartTime,
	IDirectMusicBufferImpl_SetUsedBytes
};

/* for ClassFactory */
163 164 165 166 167
HRESULT WINAPI DMUSIC_CreateDirectMusicBufferImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) {
	IDirectMusicBufferImpl* dmbuff;
	
	dmbuff = HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicBufferImpl));
	if (NULL == dmbuff) {
168
		*ppobj = NULL;
169
		return E_OUTOFMEMORY;
170
	}
171 172
	dmbuff->lpVtbl = &DirectMusicBuffer_Vtbl;
	dmbuff->ref = 0; /* will be inited by QueryInterface */
173
	
174
	return IDirectMusicBufferImpl_QueryInterface ((LPDIRECTMUSICBUFFER)dmbuff, lpcGUID, ppobj);
175
}