Remove unneeded NULL casts.
[wine] / dlls / dmusic / buffer.c
1 /* IDirectMusicBuffer Implementation
2  *
3  * Copyright (C) 2003-2004 Rok Mandeljc
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  */
19
20 #include "dmusic_private.h"
21
22 WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
23
24 /* IDirectMusicBufferImpl IUnknown part: */
25 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         if (IsEqualIID (riid, &IID_IUnknown) 
29                 || IsEqualIID (riid, &IID_IDirectMusicBuffer)) {
30                 IDirectMusicBufferImpl_AddRef(iface);
31                 *ppobj = This;
32                 return S_OK;
33         }
34         WARN("(%p, (%s, %p): not found\n",This,debugstr_dmguid(riid),ppobj);
35         return E_NOINTERFACE;
36 }
37
38 ULONG WINAPI IDirectMusicBufferImpl_AddRef (LPDIRECTMUSICBUFFER iface) {
39         IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
40         TRACE("(%p): AddRef from %ld\n", This, This->ref);
41         return ++(This->ref);
42 }
43
44 ULONG WINAPI IDirectMusicBufferImpl_Release (LPDIRECTMUSICBUFFER iface) {
45         IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
46         ULONG ref = --This->ref;
47         TRACE("(%p): ReleaseRef to %ld\n", This, This->ref);
48         if (ref == 0) {
49                 HeapFree(GetProcessHeap(), 0, This);
50         }
51         return ref;
52 }
53
54 /* IDirectMusicBufferImpl IDirectMusicBuffer part: */
55 HRESULT WINAPI IDirectMusicBufferImpl_Flush (LPDIRECTMUSICBUFFER iface) {
56         IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
57         FIXME("(%p): stub\n", This);
58         return S_OK;
59 }
60
61 HRESULT WINAPI IDirectMusicBufferImpl_TotalTime (LPDIRECTMUSICBUFFER iface, LPREFERENCE_TIME prtTime) {
62         IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
63         FIXME("(%p, %p): stub\n", This, prtTime);       
64         return S_OK;
65 }
66
67 HRESULT WINAPI IDirectMusicBufferImpl_PackStructured (LPDIRECTMUSICBUFFER iface, REFERENCE_TIME rt, DWORD dwChannelGroup, DWORD dwChannelMessage) {
68         IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
69         FIXME("(%p, %lli, %ld, %ld): stub\n", This, rt, dwChannelGroup, dwChannelMessage);
70         return S_OK;
71 }
72
73 HRESULT WINAPI IDirectMusicBufferImpl_PackUnstructured (LPDIRECTMUSICBUFFER iface, REFERENCE_TIME rt, DWORD dwChannelGroup, DWORD cb, LPBYTE lpb) {
74         IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
75         FIXME("(%p, %lli, %ld, %ld, %p): stub\n", This, rt, dwChannelGroup, cb, lpb);
76         return S_OK;
77 }
78
79 HRESULT WINAPI IDirectMusicBufferImpl_ResetReadPtr (LPDIRECTMUSICBUFFER iface) {
80         IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
81         FIXME("(%p): stub\n", This);
82         return S_OK;
83 }
84
85 HRESULT WINAPI IDirectMusicBufferImpl_GetNextEvent (LPDIRECTMUSICBUFFER iface, LPREFERENCE_TIME prt, LPDWORD pdwChannelGroup, LPDWORD pdwLength, LPBYTE* ppData) {
86         IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
87         FIXME("(%p, %p, %p, %p, %p): stub\n", This, prt, pdwChannelGroup, pdwLength, ppData);
88         return S_OK;
89 }
90
91 HRESULT WINAPI IDirectMusicBufferImpl_GetRawBufferPtr (LPDIRECTMUSICBUFFER iface, LPBYTE* ppData) {
92         IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
93         FIXME("(%p, %p): stub\n", This, ppData);
94         return S_OK;
95 }
96
97 HRESULT WINAPI IDirectMusicBufferImpl_GetStartTime (LPDIRECTMUSICBUFFER iface, LPREFERENCE_TIME prt) {
98         IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
99         FIXME("(%p, %p): stub\n", This, prt);
100         return S_OK;
101 }
102
103 HRESULT WINAPI IDirectMusicBufferImpl_GetUsedBytes (LPDIRECTMUSICBUFFER iface, LPDWORD pcb) {
104         IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
105         FIXME("(%p, %p): stub\n", This, pcb);
106         return S_OK;
107 }
108
109 HRESULT WINAPI IDirectMusicBufferImpl_GetMaxBytes (LPDIRECTMUSICBUFFER iface, LPDWORD pcb) {
110         IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
111         FIXME("(%p, %p): stub\n", This, pcb);
112         return S_OK;
113 }
114
115 HRESULT WINAPI IDirectMusicBufferImpl_GetBufferFormat (LPDIRECTMUSICBUFFER iface, LPGUID pGuidFormat) {
116         IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
117         FIXME("(%p, %p): stub\n", This, pGuidFormat);
118         return S_OK;
119 }
120
121 HRESULT WINAPI IDirectMusicBufferImpl_SetStartTime (LPDIRECTMUSICBUFFER iface, REFERENCE_TIME rt) {
122         IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
123         FIXME("(%p, %lli): stub\n", This, rt);
124         return S_OK;
125 }
126
127 HRESULT WINAPI IDirectMusicBufferImpl_SetUsedBytes (LPDIRECTMUSICBUFFER iface, DWORD cb) {
128         IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface;
129         FIXME("(%p, %ld): stub\n", This, cb);
130         return S_OK;
131 }
132
133 IDirectMusicBufferVtbl DirectMusicBuffer_Vtbl = {
134         IDirectMusicBufferImpl_QueryInterface,
135         IDirectMusicBufferImpl_AddRef,
136         IDirectMusicBufferImpl_Release,
137         IDirectMusicBufferImpl_Flush,
138         IDirectMusicBufferImpl_TotalTime,
139         IDirectMusicBufferImpl_PackStructured,
140         IDirectMusicBufferImpl_PackUnstructured,
141         IDirectMusicBufferImpl_ResetReadPtr,
142         IDirectMusicBufferImpl_GetNextEvent,
143         IDirectMusicBufferImpl_GetRawBufferPtr,
144         IDirectMusicBufferImpl_GetStartTime,
145         IDirectMusicBufferImpl_GetUsedBytes,
146         IDirectMusicBufferImpl_GetMaxBytes,
147         IDirectMusicBufferImpl_GetBufferFormat,
148         IDirectMusicBufferImpl_SetStartTime,
149         IDirectMusicBufferImpl_SetUsedBytes
150 };
151
152 /* for ClassFactory */
153 HRESULT WINAPI DMUSIC_CreateDirectMusicBufferImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) {
154         IDirectMusicBufferImpl* dmbuff;
155         
156         dmbuff = HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicBufferImpl));
157         if (NULL == dmbuff) {
158                 *ppobj = NULL;
159                 return E_OUTOFMEMORY;
160         }
161         dmbuff->lpVtbl = &DirectMusicBuffer_Vtbl;
162         dmbuff->ref = 0; /* will be inited by QueryInterface */
163         
164         return IDirectMusicBufferImpl_QueryInterface ((LPDIRECTMUSICBUFFER)dmbuff, lpcGUID, ppobj);
165 }