Add AppDefaults app selection to control panel
[wine/gsoc-2012-control.git] / dlls / amstream / mediastream.c
blob6656bf725cc05ddc42e80c1edd3f9ed3383daad5
1 /*
2 * Implementation of IMediaStream Interfaces
4 * Copyright 2005, 2008, 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 "wingdi.h"
28 #include "amstream_private.h"
29 #include "amstream.h"
31 #include "ddstream.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(amstream);
35 static HRESULT ddrawstreamsample_create(IDirectDrawMediaStream *parent, IDirectDrawStreamSample **ddraw_stream_sample);
36 static HRESULT audiostreamsample_create(IAudioMediaStream *parent, IAudioData *audio_data, IAudioStreamSample **audio_stream_sample);
38 typedef struct {
39 IDirectDrawMediaStream IDirectDrawMediaStream_iface;
40 LONG ref;
41 IMultiMediaStream* Parent;
42 MSPID PurposeId;
43 STREAM_TYPE StreamType;
44 } IDirectDrawMediaStreamImpl;
46 static inline IDirectDrawMediaStreamImpl *impl_from_IDirectDrawMediaStream(IDirectDrawMediaStream *iface)
48 return CONTAINING_RECORD(iface, IDirectDrawMediaStreamImpl, IDirectDrawMediaStream_iface);
51 /*** IUnknown methods ***/
52 static HRESULT WINAPI IDirectDrawMediaStreamImpl_QueryInterface(IDirectDrawMediaStream *iface,
53 REFIID riid, void **ppv)
55 IDirectDrawMediaStreamImpl *This = impl_from_IDirectDrawMediaStream(iface);
57 TRACE("(%p/%p)->(%s,%p)\n", iface, This, debugstr_guid(riid), ppv);
59 if (IsEqualGUID(riid, &IID_IUnknown) ||
60 IsEqualGUID(riid, &IID_IMediaStream) ||
61 IsEqualGUID(riid, &IID_IDirectDrawMediaStream))
63 IUnknown_AddRef(iface);
64 *ppv = This;
65 return S_OK;
68 ERR("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppv);
69 return E_NOINTERFACE;
72 static ULONG WINAPI IDirectDrawMediaStreamImpl_AddRef(IDirectDrawMediaStream *iface)
74 IDirectDrawMediaStreamImpl *This = impl_from_IDirectDrawMediaStream(iface);
76 TRACE("(%p/%p)\n", iface, This);
78 return InterlockedIncrement(&This->ref);
81 static ULONG WINAPI IDirectDrawMediaStreamImpl_Release(IDirectDrawMediaStream *iface)
83 IDirectDrawMediaStreamImpl *This = impl_from_IDirectDrawMediaStream(iface);
84 ULONG ref = InterlockedDecrement(&This->ref);
86 TRACE("(%p/%p)\n", iface, This);
88 if (!ref)
89 HeapFree(GetProcessHeap(), 0, This);
91 return ref;
94 /*** IMediaStream methods ***/
95 static HRESULT WINAPI IDirectDrawMediaStreamImpl_GetMultiMediaStream(IDirectDrawMediaStream *iface,
96 IMultiMediaStream** ppMultiMediaStream)
98 IDirectDrawMediaStreamImpl *This = impl_from_IDirectDrawMediaStream(iface);
100 FIXME("(%p/%p)->(%p) stub!\n", This, iface, ppMultiMediaStream);
102 return S_FALSE;
105 static HRESULT WINAPI IDirectDrawMediaStreamImpl_GetInformation(IDirectDrawMediaStream *iface,
106 MSPID *pPurposeId, STREAM_TYPE *pType)
108 IDirectDrawMediaStreamImpl *This = impl_from_IDirectDrawMediaStream(iface);
110 TRACE("(%p/%p)->(%p,%p)\n", This, iface, pPurposeId, pType);
112 if (pPurposeId)
113 *pPurposeId = This->PurposeId;
114 if (pType)
115 *pType = This->StreamType;
117 return S_OK;
120 static HRESULT WINAPI IDirectDrawMediaStreamImpl_SetSameFormat(IDirectDrawMediaStream *iface,
121 IMediaStream *pStreamThatHasDesiredFormat, DWORD dwFlags)
123 IDirectDrawMediaStreamImpl *This = impl_from_IDirectDrawMediaStream(iface);
125 FIXME("(%p/%p)->(%p,%x) stub!\n", This, iface, pStreamThatHasDesiredFormat, dwFlags);
127 return S_FALSE;
130 static HRESULT WINAPI IDirectDrawMediaStreamImpl_AllocateSample(IDirectDrawMediaStream *iface,
131 DWORD dwFlags, IStreamSample **ppSample)
133 IDirectDrawMediaStreamImpl *This = impl_from_IDirectDrawMediaStream(iface);
135 FIXME("(%p/%p)->(%x,%p) stub!\n", This, iface, dwFlags, ppSample);
137 return S_FALSE;
140 static HRESULT WINAPI IDirectDrawMediaStreamImpl_CreateSharedSample(IDirectDrawMediaStream *iface,
141 IStreamSample *pExistingSample, DWORD dwFlags, IStreamSample **ppSample)
143 IDirectDrawMediaStreamImpl *This = impl_from_IDirectDrawMediaStream(iface);
145 FIXME("(%p/%p)->(%p,%x,%p) stub!\n", This, iface, pExistingSample, dwFlags, ppSample);
147 return S_FALSE;
150 static HRESULT WINAPI IDirectDrawMediaStreamImpl_SendEndOfStream(IDirectDrawMediaStream *iface,
151 DWORD dwFlags)
153 IDirectDrawMediaStreamImpl *This = impl_from_IDirectDrawMediaStream(iface);
155 FIXME("(%p/%p)->(%x) stub!\n", This, iface, dwFlags);
157 return S_FALSE;
160 /*** IDirectDrawMediaStream methods ***/
161 static HRESULT WINAPI IDirectDrawMediaStreamImpl_GetFormat(IDirectDrawMediaStream *iface,
162 DDSURFACEDESC *current_format, IDirectDrawPalette **palette,
163 DDSURFACEDESC *desired_format, DWORD *flags)
165 FIXME("(%p)->(%p,%p,%p,%p) stub!\n", iface, current_format, palette, desired_format,
166 flags);
168 return MS_E_NOSTREAM;
172 static HRESULT WINAPI IDirectDrawMediaStreamImpl_SetFormat(IDirectDrawMediaStream *iface,
173 const DDSURFACEDESC *pDDSurfaceDesc, IDirectDrawPalette *pDirectDrawPalette)
175 FIXME("(%p)->(%p,%p) stub!\n", iface, pDDSurfaceDesc, pDirectDrawPalette);
177 return E_NOTIMPL;
180 static HRESULT WINAPI IDirectDrawMediaStreamImpl_GetDirectDraw(IDirectDrawMediaStream *iface,
181 IDirectDraw **ppDirectDraw)
183 FIXME("(%p)->(%p) stub!\n", iface, ppDirectDraw);
185 return E_NOTIMPL;
188 static HRESULT WINAPI IDirectDrawMediaStreamImpl_SetDirectDraw(IDirectDrawMediaStream *iface,
189 IDirectDraw *pDirectDraw)
191 FIXME("(%p)->(%p) stub!\n", iface, pDirectDraw);
193 return E_NOTIMPL;
196 static HRESULT WINAPI IDirectDrawMediaStreamImpl_CreateSample(IDirectDrawMediaStream *iface,
197 IDirectDrawSurface *pSurface, const RECT *pRect, DWORD dwFlags,
198 IDirectDrawStreamSample **ppSample)
200 TRACE("(%p)->(%p,%p,%x,%p)\n", iface, pSurface, pRect, dwFlags, ppSample);
202 return ddrawstreamsample_create(iface, ppSample);
205 static HRESULT WINAPI IDirectDrawMediaStreamImpl_GetTimePerFrame(IDirectDrawMediaStream *iface,
206 STREAM_TIME *pFrameTime)
208 FIXME("(%p)->(%p) stub!\n", iface, pFrameTime);
210 return E_NOTIMPL;
213 static const struct IDirectDrawMediaStreamVtbl DirectDrawMediaStream_Vtbl =
215 /*** IUnknown methods ***/
216 IDirectDrawMediaStreamImpl_QueryInterface,
217 IDirectDrawMediaStreamImpl_AddRef,
218 IDirectDrawMediaStreamImpl_Release,
219 /*** IMediaStream methods ***/
220 IDirectDrawMediaStreamImpl_GetMultiMediaStream,
221 IDirectDrawMediaStreamImpl_GetInformation,
222 IDirectDrawMediaStreamImpl_SetSameFormat,
223 IDirectDrawMediaStreamImpl_AllocateSample,
224 IDirectDrawMediaStreamImpl_CreateSharedSample,
225 IDirectDrawMediaStreamImpl_SendEndOfStream,
226 /*** IDirectDrawMediaStream methods ***/
227 IDirectDrawMediaStreamImpl_GetFormat,
228 IDirectDrawMediaStreamImpl_SetFormat,
229 IDirectDrawMediaStreamImpl_GetDirectDraw,
230 IDirectDrawMediaStreamImpl_SetDirectDraw,
231 IDirectDrawMediaStreamImpl_CreateSample,
232 IDirectDrawMediaStreamImpl_GetTimePerFrame
235 HRESULT ddrawmediastream_create(IMultiMediaStream *Parent, const MSPID *pPurposeId,
236 STREAM_TYPE StreamType, IMediaStream **ppMediaStream)
238 IDirectDrawMediaStreamImpl *object;
240 TRACE("(%p,%s,%p)\n", Parent, debugstr_guid(pPurposeId), ppMediaStream);
242 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectDrawMediaStreamImpl));
243 if (!object)
245 ERR("Out of memory\n");
246 return E_OUTOFMEMORY;
249 object->IDirectDrawMediaStream_iface.lpVtbl = &DirectDrawMediaStream_Vtbl;
250 object->ref = 1;
252 object->Parent = Parent;
253 object->PurposeId = *pPurposeId;
254 object->StreamType = StreamType;
256 *ppMediaStream = (IMediaStream*)&object->IDirectDrawMediaStream_iface;
258 return S_OK;
261 typedef struct {
262 IAudioMediaStream IAudioMediaStream_iface;
263 LONG ref;
264 IMultiMediaStream* parent;
265 MSPID purpose_id;
266 STREAM_TYPE stream_type;
267 } IAudioMediaStreamImpl;
269 static inline IAudioMediaStreamImpl *impl_from_IAudioMediaStream(IAudioMediaStream *iface)
271 return CONTAINING_RECORD(iface, IAudioMediaStreamImpl, IAudioMediaStream_iface);
274 /*** IUnknown methods ***/
275 static HRESULT WINAPI IAudioMediaStreamImpl_QueryInterface(IAudioMediaStream *iface,
276 REFIID riid, void **ret_iface)
278 IAudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface);
280 TRACE("(%p/%p)->(%s,%p)\n", iface, This, debugstr_guid(riid), ret_iface);
282 if (IsEqualGUID(riid, &IID_IUnknown) ||
283 IsEqualGUID(riid, &IID_IMediaStream) ||
284 IsEqualGUID(riid, &IID_IAudioMediaStream))
286 IAudioMediaStream_AddRef(iface);
287 *ret_iface = iface;
288 return S_OK;
291 *ret_iface = NULL;
293 ERR("(%p/%p)->(%s,%p),not found\n", iface, This, debugstr_guid(riid), ret_iface);
294 return E_NOINTERFACE;
297 static ULONG WINAPI IAudioMediaStreamImpl_AddRef(IAudioMediaStream *iface)
299 IAudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface);
300 ULONG ref = InterlockedIncrement(&This->ref);
302 TRACE("(%p/%p): new ref = %u\n", iface, This, ref);
304 return ref;
307 static ULONG WINAPI IAudioMediaStreamImpl_Release(IAudioMediaStream *iface)
309 IAudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface);
310 ULONG ref = InterlockedDecrement(&This->ref);
312 TRACE("(%p/%p): new ref = %u\n", iface, This, ref);
314 if (!ref)
315 HeapFree(GetProcessHeap(), 0, This);
317 return ref;
320 /*** IMediaStream methods ***/
321 static HRESULT WINAPI IAudioMediaStreamImpl_GetMultiMediaStream(IAudioMediaStream *iface,
322 IMultiMediaStream** multimedia_stream)
324 IAudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface);
326 FIXME("(%p/%p)->(%p) stub!\n", iface, This, multimedia_stream);
328 return S_FALSE;
331 static HRESULT WINAPI IAudioMediaStreamImpl_GetInformation(IAudioMediaStream *iface,
332 MSPID *purpose_id, STREAM_TYPE *type)
334 IAudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface);
336 TRACE("(%p/%p)->(%p,%p)\n", iface, This, purpose_id, type);
338 if (purpose_id)
339 *purpose_id = This->purpose_id;
340 if (type)
341 *type = This->stream_type;
343 return S_OK;
346 static HRESULT WINAPI IAudioMediaStreamImpl_SetSameFormat(IAudioMediaStream *iface,
347 IMediaStream *stream_format, DWORD flags)
349 IAudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface);
351 FIXME("(%p/%p)->(%p,%x) stub!\n", iface, This, stream_format, flags);
353 return S_FALSE;
356 static HRESULT WINAPI IAudioMediaStreamImpl_AllocateSample(IAudioMediaStream *iface,
357 DWORD flags, IStreamSample **sample)
359 IAudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface);
361 FIXME("(%p/%p)->(%x,%p) stub!\n", iface, This, flags, sample);
363 return S_FALSE;
366 static HRESULT WINAPI IAudioMediaStreamImpl_CreateSharedSample(IAudioMediaStream *iface,
367 IStreamSample *existing_sample, DWORD flags, IStreamSample **sample)
369 IAudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface);
371 FIXME("(%p/%p)->(%p,%x,%p) stub!\n", iface, This, existing_sample, flags, sample);
373 return S_FALSE;
376 static HRESULT WINAPI IAudioMediaStreamImpl_SendEndOfStream(IAudioMediaStream *iface,
377 DWORD flags)
379 IAudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface);
381 FIXME("(%p/%p)->(%x) stub!\n", iface, This, flags);
383 return S_FALSE;
386 /*** IAudioMediaStream methods ***/
387 static HRESULT WINAPI IAudioMediaStreamImpl_GetFormat(IAudioMediaStream *iface, WAVEFORMATEX *wave_format_current)
389 IAudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface);
391 FIXME("(%p/%p)->(%p) stub!\n", iface, This, wave_format_current);
393 if (!wave_format_current)
394 return E_POINTER;
396 return MS_E_NOSTREAM;
400 static HRESULT WINAPI IAudioMediaStreamImpl_SetFormat(IAudioMediaStream *iface, const WAVEFORMATEX *wave_format)
402 IAudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface);
404 FIXME("(%p/%p)->(%p) stub!\n", iface, This, wave_format);
406 return E_NOTIMPL;
409 static HRESULT WINAPI IAudioMediaStreamImpl_CreateSample(IAudioMediaStream *iface, IAudioData *audio_data,
410 DWORD flags, IAudioStreamSample **sample)
412 IAudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface);
414 TRACE("(%p/%p)->(%p,%u,%p)\n", iface, This, audio_data, flags, sample);
416 if (!audio_data)
417 return E_POINTER;
419 return audiostreamsample_create(iface, audio_data, sample);
422 static const struct IAudioMediaStreamVtbl AudioMediaStream_Vtbl =
424 /*** IUnknown methods ***/
425 IAudioMediaStreamImpl_QueryInterface,
426 IAudioMediaStreamImpl_AddRef,
427 IAudioMediaStreamImpl_Release,
428 /*** IMediaStream methods ***/
429 IAudioMediaStreamImpl_GetMultiMediaStream,
430 IAudioMediaStreamImpl_GetInformation,
431 IAudioMediaStreamImpl_SetSameFormat,
432 IAudioMediaStreamImpl_AllocateSample,
433 IAudioMediaStreamImpl_CreateSharedSample,
434 IAudioMediaStreamImpl_SendEndOfStream,
435 /*** IAudioMediaStream methods ***/
436 IAudioMediaStreamImpl_GetFormat,
437 IAudioMediaStreamImpl_SetFormat,
438 IAudioMediaStreamImpl_CreateSample
441 HRESULT audiomediastream_create(IMultiMediaStream *parent, const MSPID *purpose_id,
442 STREAM_TYPE stream_type, IMediaStream **media_stream)
444 IAudioMediaStreamImpl *object;
446 TRACE("(%p,%s,%p)\n", parent, debugstr_guid(purpose_id), media_stream);
448 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IAudioMediaStreamImpl));
449 if (!object)
451 ERR("Out of memory\n");
452 return E_OUTOFMEMORY;
455 object->IAudioMediaStream_iface.lpVtbl = &AudioMediaStream_Vtbl;
456 object->ref = 1;
458 object->parent = parent;
459 object->purpose_id = *purpose_id;
460 object->stream_type = stream_type;
462 *media_stream = (IMediaStream*)&object->IAudioMediaStream_iface;
464 return S_OK;
467 typedef struct {
468 IDirectDrawStreamSample IDirectDrawStreamSample_iface;
469 LONG ref;
470 IMediaStream *parent;
471 } IDirectDrawStreamSampleImpl;
473 static inline IDirectDrawStreamSampleImpl *impl_from_IDirectDrawStreamSample(IDirectDrawStreamSample *iface)
475 return CONTAINING_RECORD(iface, IDirectDrawStreamSampleImpl, IDirectDrawStreamSample_iface);
478 /*** IUnknown methods ***/
479 static HRESULT WINAPI IDirectDrawStreamSampleImpl_QueryInterface(IDirectDrawStreamSample *iface,
480 REFIID riid, void **ret_iface)
482 TRACE("(%p)->(%s,%p)\n", iface, debugstr_guid(riid), ret_iface);
484 if (IsEqualGUID(riid, &IID_IUnknown) ||
485 IsEqualGUID(riid, &IID_IStreamSample) ||
486 IsEqualGUID(riid, &IID_IDirectDrawStreamSample))
488 IDirectDrawStreamSample_AddRef(iface);
489 *ret_iface = iface;
490 return S_OK;
493 *ret_iface = NULL;
495 ERR("(%p)->(%s,%p),not found\n", iface, debugstr_guid(riid), ret_iface);
496 return E_NOINTERFACE;
499 static ULONG WINAPI IDirectDrawStreamSampleImpl_AddRef(IDirectDrawStreamSample *iface)
501 IDirectDrawStreamSampleImpl *This = impl_from_IDirectDrawStreamSample(iface);
502 ULONG ref = InterlockedIncrement(&This->ref);
504 TRACE("(%p)->(): new ref = %u\n", iface, ref);
506 return ref;
509 static ULONG WINAPI IDirectDrawStreamSampleImpl_Release(IDirectDrawStreamSample *iface)
511 IDirectDrawStreamSampleImpl *This = impl_from_IDirectDrawStreamSample(iface);
512 ULONG ref = InterlockedDecrement(&This->ref);
514 TRACE("(%p)->(): new ref = %u\n", iface, ref);
516 if (!ref)
517 HeapFree(GetProcessHeap(), 0, This);
519 return ref;
522 /*** IStreamSample methods ***/
523 static HRESULT WINAPI IDirectDrawStreamSampleImpl_GetMediaStream(IDirectDrawStreamSample *iface, IMediaStream **media_stream)
525 FIXME("(%p)->(%p): stub\n", iface, media_stream);
527 return E_NOTIMPL;
530 static HRESULT WINAPI IDirectDrawStreamSampleImpl_GetSampleTimes(IDirectDrawStreamSample *iface, STREAM_TIME *start_time,
531 STREAM_TIME *end_time, STREAM_TIME *current_time)
533 FIXME("(%p)->(%p,%p,%p): stub\n", iface, start_time, end_time, current_time);
535 return E_NOTIMPL;
538 static HRESULT WINAPI IDirectDrawStreamSampleImpl_SetSampleTimes(IDirectDrawStreamSample *iface, const STREAM_TIME *start_time,
539 const STREAM_TIME *end_time)
541 FIXME("(%p)->(%p,%p): stub\n", iface, start_time, end_time);
543 return E_NOTIMPL;
546 static HRESULT WINAPI IDirectDrawStreamSampleImpl_Update(IDirectDrawStreamSample *iface, DWORD flags, HANDLE event,
547 PAPCFUNC func_APC, DWORD APC_data)
549 FIXME("(%p)->(%x,%p,%p,%u): stub\n", iface, flags, event, func_APC, APC_data);
551 return E_NOTIMPL;
554 static HRESULT WINAPI IDirectDrawStreamSampleImpl_CompletionStatus(IDirectDrawStreamSample *iface, DWORD flags, DWORD milliseconds)
556 FIXME("(%p)->(%x,%u): stub\n", iface, flags, milliseconds);
558 return E_NOTIMPL;
561 /*** IDirectDrawStreamSample methods ***/
562 static HRESULT WINAPI IDirectDrawStreamSampleImpl_GetSurface(IDirectDrawStreamSample *iface, IDirectDrawSurface **ddraw_surface,
563 RECT *rect)
565 FIXME("(%p)->(%p,%p): stub\n", iface, ddraw_surface, rect);
567 return E_NOTIMPL;
570 static HRESULT WINAPI IDirectDrawStreamSampleImpl_SetRect(IDirectDrawStreamSample *iface, const RECT *rect)
572 FIXME("(%p)->(%p): stub\n", iface, rect);
574 return E_NOTIMPL;
577 static const struct IDirectDrawStreamSampleVtbl DirectDrawStreamSample_Vtbl =
579 /*** IUnknown methods ***/
580 IDirectDrawStreamSampleImpl_QueryInterface,
581 IDirectDrawStreamSampleImpl_AddRef,
582 IDirectDrawStreamSampleImpl_Release,
583 /*** IStreamSample methods ***/
584 IDirectDrawStreamSampleImpl_GetMediaStream,
585 IDirectDrawStreamSampleImpl_GetSampleTimes,
586 IDirectDrawStreamSampleImpl_SetSampleTimes,
587 IDirectDrawStreamSampleImpl_Update,
588 IDirectDrawStreamSampleImpl_CompletionStatus,
589 /*** IDirectDrawStreamSample methods ***/
590 IDirectDrawStreamSampleImpl_GetSurface,
591 IDirectDrawStreamSampleImpl_SetRect
594 static HRESULT ddrawstreamsample_create(IDirectDrawMediaStream *parent, IDirectDrawStreamSample **ddraw_stream_sample)
596 IDirectDrawStreamSampleImpl *object;
598 TRACE("(%p)\n", ddraw_stream_sample);
600 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectDrawStreamSampleImpl));
601 if (!object)
603 ERR("Out of memory\n");
604 return E_OUTOFMEMORY;
607 object->IDirectDrawStreamSample_iface.lpVtbl = &DirectDrawStreamSample_Vtbl;
608 object->ref = 1;
609 object->parent = (IMediaStream*)parent;
611 *ddraw_stream_sample = (IDirectDrawStreamSample*)&object->IDirectDrawStreamSample_iface;
613 return S_OK;
616 typedef struct {
617 IAudioStreamSample IAudioStreamSample_iface;
618 LONG ref;
619 IMediaStream *parent;
620 IAudioData *audio_data;
621 } IAudioStreamSampleImpl;
623 static inline IAudioStreamSampleImpl *impl_from_IAudioStreamSample(IAudioStreamSample *iface)
625 return CONTAINING_RECORD(iface, IAudioStreamSampleImpl, IAudioStreamSample_iface);
628 /*** IUnknown methods ***/
629 static HRESULT WINAPI IAudioStreamSampleImpl_QueryInterface(IAudioStreamSample *iface,
630 REFIID riid, void **ret_iface)
632 TRACE("(%p)->(%s,%p)\n", iface, debugstr_guid(riid), ret_iface);
634 if (IsEqualGUID(riid, &IID_IUnknown) ||
635 IsEqualGUID(riid, &IID_IStreamSample) ||
636 IsEqualGUID(riid, &IID_IAudioStreamSample))
638 IAudioStreamSample_AddRef(iface);
639 *ret_iface = iface;
640 return S_OK;
643 *ret_iface = NULL;
645 ERR("(%p)->(%s,%p),not found\n", iface, debugstr_guid(riid), ret_iface);
646 return E_NOINTERFACE;
649 static ULONG WINAPI IAudioStreamSampleImpl_AddRef(IAudioStreamSample *iface)
651 IAudioStreamSampleImpl *This = impl_from_IAudioStreamSample(iface);
652 ULONG ref = InterlockedIncrement(&This->ref);
654 TRACE("(%p)->(): new ref = %u\n", iface, ref);
656 return ref;
659 static ULONG WINAPI IAudioStreamSampleImpl_Release(IAudioStreamSample *iface)
661 IAudioStreamSampleImpl *This = impl_from_IAudioStreamSample(iface);
662 ULONG ref = InterlockedDecrement(&This->ref);
664 TRACE("(%p)->(): new ref = %u\n", iface, ref);
666 if (!ref)
667 HeapFree(GetProcessHeap(), 0, This);
669 return ref;
672 /*** IStreamSample methods ***/
673 static HRESULT WINAPI IAudioStreamSampleImpl_GetMediaStream(IAudioStreamSample *iface, IMediaStream **media_stream)
675 FIXME("(%p)->(%p): stub\n", iface, media_stream);
677 return E_NOTIMPL;
680 static HRESULT WINAPI IAudioStreamSampleImpl_GetSampleTimes(IAudioStreamSample *iface, STREAM_TIME *start_time,
681 STREAM_TIME *end_time, STREAM_TIME *current_time)
683 FIXME("(%p)->(%p,%p,%p): stub\n", iface, start_time, end_time, current_time);
685 return E_NOTIMPL;
688 static HRESULT WINAPI IAudioStreamSampleImpl_SetSampleTimes(IAudioStreamSample *iface, const STREAM_TIME *start_time,
689 const STREAM_TIME *end_time)
691 FIXME("(%p)->(%p,%p): stub\n", iface, start_time, end_time);
693 return E_NOTIMPL;
696 static HRESULT WINAPI IAudioStreamSampleImpl_Update(IAudioStreamSample *iface, DWORD flags, HANDLE event,
697 PAPCFUNC func_APC, DWORD APC_data)
699 FIXME("(%p)->(%x,%p,%p,%u): stub\n", iface, flags, event, func_APC, APC_data);
701 return E_NOTIMPL;
704 static HRESULT WINAPI IAudioStreamSampleImpl_CompletionStatus(IAudioStreamSample *iface, DWORD flags, DWORD milliseconds)
706 FIXME("(%p)->(%x,%u): stub\n", iface, flags, milliseconds);
708 return E_NOTIMPL;
711 /*** IAudioStreamSample methods ***/
712 static HRESULT WINAPI IAudioStreamSampleImpl_GetAudioData(IAudioStreamSample *iface, IAudioData **audio_data)
714 FIXME("(%p)->(%p): stub\n", iface, audio_data);
716 return E_NOTIMPL;
719 static const struct IAudioStreamSampleVtbl AudioStreamSample_Vtbl =
721 /*** IUnknown methods ***/
722 IAudioStreamSampleImpl_QueryInterface,
723 IAudioStreamSampleImpl_AddRef,
724 IAudioStreamSampleImpl_Release,
725 /*** IStreamSample methods ***/
726 IAudioStreamSampleImpl_GetMediaStream,
727 IAudioStreamSampleImpl_GetSampleTimes,
728 IAudioStreamSampleImpl_SetSampleTimes,
729 IAudioStreamSampleImpl_Update,
730 IAudioStreamSampleImpl_CompletionStatus,
731 /*** IAudioStreamSample methods ***/
732 IAudioStreamSampleImpl_GetAudioData
735 static HRESULT audiostreamsample_create(IAudioMediaStream *parent, IAudioData *audio_data, IAudioStreamSample **audio_stream_sample)
737 IAudioStreamSampleImpl *object;
739 TRACE("(%p)\n", audio_stream_sample);
741 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IAudioStreamSampleImpl));
742 if (!object)
744 ERR("Out of memory\n");
745 return E_OUTOFMEMORY;
748 object->IAudioStreamSample_iface.lpVtbl = &AudioStreamSample_Vtbl;
749 object->ref = 1;
750 object->parent = (IMediaStream*)parent;
751 object->audio_data = audio_data;
753 *audio_stream_sample = (IAudioStreamSample*)&object->IAudioStreamSample_iface;
755 return S_OK;