ReactOS 0.4.17-dev-966-gf06eace
download.c
Go to the documentation of this file.
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
24
26{
27 IDirectMusicDownload IDirectMusicDownload_iface;
29
32};
33
34#ifdef __REACTOS__
35C_ASSERT(sizeof(struct download) == offsetof(struct download, data));
36#else
37C_ASSERT(sizeof(struct download) == offsetof(struct download, data[0]));
38#endif
39
40static inline struct download *impl_from_IDirectMusicDownload(IDirectMusicDownload *iface)
41{
43}
44
45static HRESULT WINAPI download_QueryInterface(IDirectMusicDownload *iface, REFIID riid, void **ret_iface)
46{
47 TRACE("(%p, %s, %p)\n", iface, debugstr_dmguid(riid), ret_iface);
48
50 IsEqualIID(riid, &IID_IDirectMusicDownload))
51 {
53 *ret_iface = iface;
54 return S_OK;
55 }
56
57 *ret_iface = NULL;
58 WARN("(%p, %s, %p): not found\n", iface, debugstr_dmguid(riid), ret_iface);
59 return E_NOINTERFACE;
60}
61
62static ULONG WINAPI download_AddRef(IDirectMusicDownload *iface)
63{
66
67 TRACE("(%p): new ref = %lu\n", iface, ref);
68
69 return ref;
70}
71
72static ULONG WINAPI download_Release(IDirectMusicDownload *iface)
73{
76
77 TRACE("(%p): new ref = %lu\n", iface, ref);
78
79 if (!ref) {
80 free(This);
81 }
82
83 return ref;
84}
85
86static HRESULT WINAPI download_GetBuffer(IDirectMusicDownload *iface, void **buffer, DWORD *size)
87{
89
90 TRACE("(%p, %p, %p)\n", iface, buffer, size);
91
92 *buffer = This->data;
93 *size = This->size;
94
95 return S_OK;
96}
97
98static const IDirectMusicDownloadVtbl download_vtbl =
99{
104};
105
106HRESULT download_create(DWORD size, IDirectMusicDownload **ret_iface)
107{
108 struct download *download;
109
110 *ret_iface = NULL;
111 if (!(download = malloc(offsetof(struct download, data[size])))) return E_OUTOFMEMORY;
113 download->ref = 1;
114 download->size = size;
115
116 TRACE("Created DirectMusicDownload %p\n", download);
118 return S_OK;
119}
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define WARN(fmt,...)
Definition: precomp.h:61
const GUID IID_IUnknown
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
static ULONG WINAPI download_AddRef(IDirectMusicDownload *iface)
Definition: download.c:62
static HRESULT WINAPI download_GetBuffer(IDirectMusicDownload *iface, void **buffer, DWORD *size)
Definition: download.c:86
static const IDirectMusicDownloadVtbl download_vtbl
Definition: download.c:98
static HRESULT WINAPI download_QueryInterface(IDirectMusicDownload *iface, REFIID riid, void **ret_iface)
Definition: download.c:45
static ULONG WINAPI download_Release(IDirectMusicDownload *iface)
Definition: download.c:72
static struct download * impl_from_IDirectMusicDownload(IDirectMusicDownload *iface)
Definition: download.c:40
HRESULT download_create(DWORD size, IDirectMusicDownload **ret_iface)
Definition: download.c:106
#define NULL
Definition: types.h:112
const char * debugstr_dmguid(const GUID *id)
Definition: dmobject.c:36
#define IDirectMusicDownload_AddRef(p)
Definition: dmusicc.h:603
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLuint buffer
Definition: glext.h:5915
GLsizeiptr size
Definition: glext.h:5919
REFIID riid
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define C_ASSERT(e)
Definition: intsafe.h:73
long LONG
Definition: pedump.c:60
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define REFIID
Definition: guiddef.h:118
#define offsetof(TYPE, MEMBER)
#define TRACE(s)
Definition: solgame.cpp:4
IDirectMusicDownload IDirectMusicDownload_iface
Definition: download.c:27
DWORD size
Definition: download.c:30
LONG ref
Definition: download.c:28
Definition: send.c:48
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
#define WINAPI
Definition: msvc.h:6
#define E_NOINTERFACE
Definition: winerror.h:3479
unsigned char BYTE
Definition: xxhash.c:193