[DIRECTX/WINE]
[reactos.git] / reactos / dll / directx / wine / dmusic / download.c
1 /*
2 * IDirectMusicDownload Implementation
3 *
4 * Copyright (C) 2003-2004 Rok Mandeljc
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21 #include "dmusic_private.h"
22
23 WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
24
25 static inline IDirectMusicDownloadImpl* impl_from_IDirectMusicDownload(IDirectMusicDownload *iface)
26 {
27 return CONTAINING_RECORD(iface, IDirectMusicDownloadImpl, IDirectMusicDownload_iface);
28 }
29
30 /* IDirectMusicDownloadImpl IUnknown part: */
31 static HRESULT WINAPI IDirectMusicDownloadImpl_QueryInterface(IDirectMusicDownload *iface, REFIID riid, void **ret_iface)
32 {
33 TRACE("(%p, %s, %p)\n", iface, debugstr_dmguid(riid), ret_iface);
34
35 if (IsEqualIID(riid, &IID_IUnknown) ||
36 IsEqualIID(riid, &IID_IDirectMusicDownload))
37 {
38 IDirectMusicDownload_AddRef(iface);
39 *ret_iface = iface;
40 return S_OK;
41 }
42
43 *ret_iface = NULL;
44 WARN("(%p, %s, %p): not found\n", iface, debugstr_dmguid(riid), ret_iface);
45 return E_NOINTERFACE;
46 }
47
48 static ULONG WINAPI IDirectMusicDownloadImpl_AddRef(IDirectMusicDownload *iface)
49 {
50 IDirectMusicDownloadImpl *This = impl_from_IDirectMusicDownload(iface);
51 ULONG ref = InterlockedIncrement(&This->ref);
52
53 TRACE("(%p)->(): new ref = %u\n", iface, ref);
54
55 DMUSIC_LockModule();
56
57 return ref;
58 }
59
60 static ULONG WINAPI IDirectMusicDownloadImpl_Release(IDirectMusicDownload *iface)
61 {
62 IDirectMusicDownloadImpl *This = impl_from_IDirectMusicDownload(iface);
63 ULONG ref = InterlockedDecrement(&This->ref);
64
65 TRACE("(%p)->(): new ref = %u\n", iface, ref);
66
67 if (!ref)
68 HeapFree(GetProcessHeap(), 0, This);
69
70 DMUSIC_UnlockModule();
71
72 return ref;
73 }
74
75 /* IDirectMusicDownloadImpl IDirectMusicDownload part: */
76 static HRESULT WINAPI IDirectMusicDownloadImpl_GetBuffer(IDirectMusicDownload *iface, void **buffer, DWORD *size)
77 {
78 FIXME("(%p, %p, %p): stub\n", iface, buffer, size);
79
80 return S_OK;
81 }
82
83 static const IDirectMusicDownloadVtbl DirectMusicDownload_Vtbl = {
84 IDirectMusicDownloadImpl_QueryInterface,
85 IDirectMusicDownloadImpl_AddRef,
86 IDirectMusicDownloadImpl_Release,
87 IDirectMusicDownloadImpl_GetBuffer
88 };
89
90 /* for ClassFactory */
91 HRESULT DMUSIC_CreateDirectMusicDownloadImpl(const GUID *guid, void **ret_iface, IUnknown *unk_outer)
92 {
93 IDirectMusicDownloadImpl *download;
94
95 download = HeapAlloc(GetProcessHeap(), 0, sizeof(*download));
96 if (!download)
97 {
98 *ret_iface = NULL;
99 return E_OUTOFMEMORY;
100 }
101
102 download->IDirectMusicDownload_iface.lpVtbl = &DirectMusicDownload_Vtbl;
103 download->ref = 1;
104 *ret_iface = download;
105 return S_OK;
106 }