2 * IDirectMusicDownload Implementation
4 * Copyright (C) 2003-2004 Rok Mandeljc
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.
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.
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
21 #include "dmusic_private.h"
23 WINE_DEFAULT_DEBUG_CHANNEL(dmusic
);
27 IDirectMusicDownload IDirectMusicDownload_iface
;
34 C_ASSERT(sizeof(struct download
) == offsetof(struct download
, data
[0]));
36 static inline struct download
*impl_from_IDirectMusicDownload(IDirectMusicDownload
*iface
)
38 return CONTAINING_RECORD(iface
, struct download
, IDirectMusicDownload_iface
);
41 static HRESULT WINAPI
download_QueryInterface(IDirectMusicDownload
*iface
, REFIID riid
, void **ret_iface
)
43 TRACE("(%p, %s, %p)\n", iface
, debugstr_dmguid(riid
), ret_iface
);
45 if (IsEqualIID(riid
, &IID_IUnknown
) ||
46 IsEqualIID(riid
, &IID_IDirectMusicDownload
))
48 IDirectMusicDownload_AddRef(iface
);
54 WARN("(%p, %s, %p): not found\n", iface
, debugstr_dmguid(riid
), ret_iface
);
58 static ULONG WINAPI
download_AddRef(IDirectMusicDownload
*iface
)
60 struct download
*This
= impl_from_IDirectMusicDownload(iface
);
61 ULONG ref
= InterlockedIncrement(&This
->ref
);
63 TRACE("(%p): new ref = %lu\n", iface
, ref
);
68 static ULONG WINAPI
download_Release(IDirectMusicDownload
*iface
)
70 struct download
*This
= impl_from_IDirectMusicDownload(iface
);
71 ULONG ref
= InterlockedDecrement(&This
->ref
);
73 TRACE("(%p): new ref = %lu\n", iface
, ref
);
82 static HRESULT WINAPI
download_GetBuffer(IDirectMusicDownload
*iface
, void **buffer
, DWORD
*size
)
84 struct download
*This
= impl_from_IDirectMusicDownload(iface
);
86 TRACE("(%p, %p, %p)\n", iface
, buffer
, size
);
94 static const IDirectMusicDownloadVtbl download_vtbl
=
96 download_QueryInterface
,
102 HRESULT
download_create(DWORD size
, IDirectMusicDownload
**ret_iface
)
104 struct download
*download
;
107 if (!(download
= malloc(offsetof(struct download
, data
[size
])))) return E_OUTOFMEMORY
;
108 download
->IDirectMusicDownload_iface
.lpVtbl
= &download_vtbl
;
110 download
->size
= size
;
112 TRACE("Created DirectMusicDownload %p\n", download
);
113 *ret_iface
= &download
->IDirectMusicDownload_iface
;