d3d8: Get rid of the format switching code in d3d8_device_CopyRects().
[wine.git] / dlls / amstream / audiodata.c
blob3a62a9f898f25ba19025c20f859c6a9787a3de7e
1 /*
2 * Implementation of IAudioData Interface
4 * Copyright 2012 Christian Costa
6 * This library 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 library 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 library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "wine/debug.h"
23 #define COBJMACROS
25 #include "winbase.h"
26 #include "amstream_private.h"
28 #include "amstream.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(amstream);
32 typedef struct {
33 IAudioData IAudioData_iface;
34 LONG ref;
35 } AMAudioDataImpl;
37 static inline AMAudioDataImpl *impl_from_IAudioData(IAudioData *iface)
39 return CONTAINING_RECORD(iface, AMAudioDataImpl, IAudioData_iface);
42 /*** IUnknown methods ***/
43 static HRESULT WINAPI IAudioDataImpl_QueryInterface(IAudioData *iface, REFIID riid, void **ret_iface)
45 TRACE("(%p)->(%s,%p)\n", iface, debugstr_guid(riid), ret_iface);
47 if (IsEqualGUID(riid, &IID_IUnknown) ||
48 IsEqualGUID(riid, &IID_IMemoryData) ||
49 IsEqualGUID(riid, &IID_IAudioData))
51 IAudioData_AddRef(iface);
52 *ret_iface = iface;
53 return S_OK;
56 ERR("(%p)->(%s,%p),not found\n", iface, debugstr_guid(riid), ret_iface);
57 return E_NOINTERFACE;
60 static ULONG WINAPI IAudioDataImpl_AddRef(IAudioData* iface)
62 AMAudioDataImpl *This = impl_from_IAudioData(iface);
63 ULONG ref = InterlockedIncrement(&This->ref);
65 TRACE("(%p)->(): new ref = %u\n", iface, This->ref);
67 return ref;
70 static ULONG WINAPI IAudioDataImpl_Release(IAudioData* iface)
72 AMAudioDataImpl *This = impl_from_IAudioData(iface);
73 ULONG ref = InterlockedDecrement(&This->ref);
75 TRACE("(%p)->(): new ref = %u\n", iface, This->ref);
77 if (!ref)
78 HeapFree(GetProcessHeap(), 0, This);
80 return ref;
83 /*** IMemoryData methods ***/
84 static HRESULT WINAPI IAudioDataImpl_SetBuffer(IAudioData* iface, DWORD size, BYTE *data, DWORD flags)
86 FIXME("(%p)->(%u,%p,%x): stub\n", iface, size, data, flags);
88 return E_NOTIMPL;
91 static HRESULT WINAPI IAudioDataImpl_GetInfo(IAudioData* iface, DWORD *length, BYTE **data, DWORD *actual_data)
93 FIXME("(%p)->(%p,%p,%p): stub\n", iface, length, data, actual_data);
95 return E_NOTIMPL;
98 static HRESULT WINAPI IAudioDataImpl_SetActual(IAudioData* iface, DWORD data_valid)
100 FIXME("(%p)->(%u): stub\n", iface, data_valid);
102 return E_NOTIMPL;
105 /*** IAudioData methods ***/
106 static HRESULT WINAPI IAudioDataImpl_GetFormat(IAudioData* iface, WAVEFORMATEX *wave_format_current)
108 FIXME("(%p)->(%p): stub\n", iface, wave_format_current);
110 return E_NOTIMPL;
113 static HRESULT WINAPI IAudioDataImpl_SetFormat(IAudioData* iface, const WAVEFORMATEX *wave_format)
115 FIXME("(%p)->(%p): stub\n", iface, wave_format);
117 return E_NOTIMPL;
120 static const struct IAudioDataVtbl AudioData_Vtbl =
122 /*** IUnknown methods ***/
123 IAudioDataImpl_QueryInterface,
124 IAudioDataImpl_AddRef,
125 IAudioDataImpl_Release,
126 /*** IMemoryData methods ***/
127 IAudioDataImpl_SetBuffer,
128 IAudioDataImpl_GetInfo,
129 IAudioDataImpl_SetActual,
130 /*** IAudioData methods ***/
131 IAudioDataImpl_GetFormat,
132 IAudioDataImpl_SetFormat
135 HRESULT AMAudioData_create(IUnknown *pUnkOuter, LPVOID *ppObj)
137 AMAudioDataImpl *object;
139 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
141 if (pUnkOuter)
142 return CLASS_E_NOAGGREGATION;
144 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(AMAudioDataImpl));
145 if (!object)
146 return E_OUTOFMEMORY;
148 object->IAudioData_iface.lpVtbl = &AudioData_Vtbl;
149 object->ref = 1;
151 *ppObj = &object->IAudioData_iface;
153 return S_OK;