Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/amstream/audiostream.c | 69 +++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 34 deletions(-)
diff --git a/dlls/amstream/audiostream.c b/dlls/amstream/audiostream.c index bae4d5fae2b..683ab7d3c66 100644 --- a/dlls/amstream/audiostream.c +++ b/dlls/amstream/audiostream.c @@ -168,10 +168,11 @@ struct AudioMediaStreamImpl;
typedef struct { BaseInputPin pin; - struct AudioMediaStreamImpl *parent; + struct audio_stream *parent; } AudioMediaStreamInputPin;
-typedef struct AudioMediaStreamImpl { +struct audio_stream +{ IAMMediaStream IAMMediaStream_iface; IAudioMediaStream IAudioMediaStream_iface; LONG ref; @@ -180,18 +181,18 @@ typedef struct AudioMediaStreamImpl { STREAM_TYPE stream_type; AudioMediaStreamInputPin *input_pin; CRITICAL_SECTION critical_section; -} AudioMediaStreamImpl; +};
-static inline AudioMediaStreamImpl *impl_from_AudioMediaStream_IAMMediaStream(IAMMediaStream *iface) +static inline struct audio_stream *impl_from_IAMMediaStream(IAMMediaStream *iface) { - return CONTAINING_RECORD(iface, AudioMediaStreamImpl, IAMMediaStream_iface); + return CONTAINING_RECORD(iface, struct audio_stream, IAMMediaStream_iface); }
/*** IUnknown methods ***/ static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_QueryInterface(IAMMediaStream *iface, REFIID riid, void **ret_iface) { - AudioMediaStreamImpl *This = impl_from_AudioMediaStream_IAMMediaStream(iface); + struct audio_stream *This = impl_from_IAMMediaStream(iface);
TRACE("(%p/%p)->(%s,%p)\n", iface, This, debugstr_guid(riid), ret_iface);
@@ -228,7 +229,7 @@ static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_QueryInterface(IAMMedi
static ULONG WINAPI AudioMediaStreamImpl_IAMMediaStream_AddRef(IAMMediaStream *iface) { - AudioMediaStreamImpl *This = impl_from_AudioMediaStream_IAMMediaStream(iface); + struct audio_stream *This = impl_from_IAMMediaStream(iface); ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p/%p)->(): new ref = %u\n", iface, This, ref); @@ -238,7 +239,7 @@ static ULONG WINAPI AudioMediaStreamImpl_IAMMediaStream_AddRef(IAMMediaStream *i
static ULONG WINAPI AudioMediaStreamImpl_IAMMediaStream_Release(IAMMediaStream *iface) { - AudioMediaStreamImpl *This = impl_from_AudioMediaStream_IAMMediaStream(iface); + struct audio_stream *This = impl_from_IAMMediaStream(iface); ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p/%p)->(): new ref = %u\n", iface, This, ref); @@ -257,7 +258,7 @@ static ULONG WINAPI AudioMediaStreamImpl_IAMMediaStream_Release(IAMMediaStream * static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_GetMultiMediaStream(IAMMediaStream *iface, IMultiMediaStream** multi_media_stream) { - AudioMediaStreamImpl *This = impl_from_AudioMediaStream_IAMMediaStream(iface); + struct audio_stream *This = impl_from_IAMMediaStream(iface);
TRACE("(%p/%p)->(%p)\n", This, iface, multi_media_stream);
@@ -273,7 +274,7 @@ static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_GetMultiMediaStream(IA static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_GetInformation(IAMMediaStream *iface, MSPID *purpose_id, STREAM_TYPE *type) { - AudioMediaStreamImpl *This = impl_from_AudioMediaStream_IAMMediaStream(iface); + struct audio_stream *This = impl_from_IAMMediaStream(iface);
TRACE("(%p/%p)->(%p,%p)\n", This, iface, purpose_id, type);
@@ -288,7 +289,7 @@ static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_GetInformation(IAMMedi static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_SetSameFormat(IAMMediaStream *iface, IMediaStream *pStreamThatHasDesiredFormat, DWORD flags) { - AudioMediaStreamImpl *This = impl_from_AudioMediaStream_IAMMediaStream(iface); + struct audio_stream *This = impl_from_IAMMediaStream(iface);
FIXME("(%p/%p)->(%p,%x) stub!\n", This, iface, pStreamThatHasDesiredFormat, flags);
@@ -298,7 +299,7 @@ static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_SetSameFormat(IAMMedia static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_AllocateSample(IAMMediaStream *iface, DWORD flags, IStreamSample **sample) { - AudioMediaStreamImpl *This = impl_from_AudioMediaStream_IAMMediaStream(iface); + struct audio_stream *This = impl_from_IAMMediaStream(iface);
FIXME("(%p/%p)->(%x,%p) stub!\n", This, iface, flags, sample);
@@ -308,7 +309,7 @@ static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_AllocateSample(IAMMedi static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_CreateSharedSample(IAMMediaStream *iface, IStreamSample *existing_sample, DWORD flags, IStreamSample **sample) { - AudioMediaStreamImpl *This = impl_from_AudioMediaStream_IAMMediaStream(iface); + struct audio_stream *This = impl_from_IAMMediaStream(iface);
FIXME("(%p/%p)->(%p,%x,%p) stub!\n", This, iface, existing_sample, flags, sample);
@@ -317,7 +318,7 @@ static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_CreateSharedSample(IAM
static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_SendEndOfStream(IAMMediaStream *iface, DWORD flags) { - AudioMediaStreamImpl *This = impl_from_AudioMediaStream_IAMMediaStream(iface); + struct audio_stream *This = impl_from_IAMMediaStream(iface);
FIXME("(%p/%p)->(%x) stub!\n", This, iface, flags);
@@ -328,7 +329,7 @@ static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_SendEndOfStream(IAMMed static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_Initialize(IAMMediaStream *iface, IUnknown *source_object, DWORD flags, REFMSPID purpose_id, const STREAM_TYPE stream_type) { - AudioMediaStreamImpl *This = impl_from_AudioMediaStream_IAMMediaStream(iface); + struct audio_stream *This = impl_from_IAMMediaStream(iface);
FIXME("(%p/%p)->(%p,%x,%p,%u) stub!\n", This, iface, source_object, flags, purpose_id, stream_type);
@@ -337,7 +338,7 @@ static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_Initialize(IAMMediaStr
static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_SetState(IAMMediaStream *iface, FILTER_STATE state) { - AudioMediaStreamImpl *This = impl_from_AudioMediaStream_IAMMediaStream(iface); + struct audio_stream *This = impl_from_IAMMediaStream(iface);
FIXME("(%p/%p)->(%u) stub!\n", This, iface, state);
@@ -346,7 +347,7 @@ static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_SetState(IAMMediaStrea
static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_JoinAMMultiMediaStream(IAMMediaStream *iface, IAMMultiMediaStream *am_multi_media_stream) { - AudioMediaStreamImpl *This = impl_from_AudioMediaStream_IAMMediaStream(iface); + struct audio_stream *This = impl_from_IAMMediaStream(iface);
FIXME("(%p/%p)->(%p) stub!\n", This, iface, am_multi_media_stream);
@@ -355,7 +356,7 @@ static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_JoinAMMultiMediaStream
static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_JoinFilter(IAMMediaStream *iface, IMediaStreamFilter *media_stream_filter) { - AudioMediaStreamImpl *This = impl_from_AudioMediaStream_IAMMediaStream(iface); + struct audio_stream *This = impl_from_IAMMediaStream(iface);
TRACE("(%p/%p)->(%p)\n", This, iface, media_stream_filter);
@@ -366,7 +367,7 @@ static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_JoinFilter(IAMMediaStr
static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_JoinFilterGraph(IAMMediaStream *iface, IFilterGraph *filtergraph) { - AudioMediaStreamImpl *This = impl_from_AudioMediaStream_IAMMediaStream(iface); + struct audio_stream *This = impl_from_IAMMediaStream(iface);
FIXME("(%p/%p)->(%p) stub!\n", This, iface, filtergraph);
@@ -394,30 +395,30 @@ static const struct IAMMediaStreamVtbl AudioMediaStreamImpl_IAMMediaStream_Vtbl AudioMediaStreamImpl_IAMMediaStream_JoinFilterGraph };
-static inline AudioMediaStreamImpl *impl_from_IAudioMediaStream(IAudioMediaStream *iface) +static inline struct audio_stream *impl_from_IAudioMediaStream(IAudioMediaStream *iface) { - return CONTAINING_RECORD(iface, AudioMediaStreamImpl, IAudioMediaStream_iface); + return CONTAINING_RECORD(iface, struct audio_stream, IAudioMediaStream_iface); }
/*** IUnknown methods ***/ static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_QueryInterface(IAudioMediaStream *iface, REFIID riid, void **ret_iface) { - AudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface); + struct audio_stream *This = impl_from_IAudioMediaStream(iface); TRACE("(%p/%p)->(%s,%p)\n", iface, This, debugstr_guid(riid), ret_iface); return IAMMediaStream_QueryInterface(&This->IAMMediaStream_iface, riid, ret_iface); }
static ULONG WINAPI AudioMediaStreamImpl_IAudioMediaStream_AddRef(IAudioMediaStream *iface) { - AudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface); + struct audio_stream *This = impl_from_IAudioMediaStream(iface); TRACE("(%p/%p)\n", iface, This); return IAMMediaStream_AddRef(&This->IAMMediaStream_iface); }
static ULONG WINAPI AudioMediaStreamImpl_IAudioMediaStream_Release(IAudioMediaStream *iface) { - AudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface); + struct audio_stream *This = impl_from_IAudioMediaStream(iface); TRACE("(%p/%p)\n", iface, This); return IAMMediaStream_Release(&This->IAMMediaStream_iface); } @@ -426,7 +427,7 @@ static ULONG WINAPI AudioMediaStreamImpl_IAudioMediaStream_Release(IAudioMediaSt static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_GetMultiMediaStream(IAudioMediaStream *iface, IMultiMediaStream **multi_media_stream) { - AudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface); + struct audio_stream *This = impl_from_IAudioMediaStream(iface);
TRACE("(%p/%p)->(%p)\n", iface, This, multi_media_stream);
@@ -442,7 +443,7 @@ static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_GetMultiMediaStream static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_GetInformation(IAudioMediaStream *iface, MSPID *purpose_id, STREAM_TYPE *type) { - AudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface); + struct audio_stream *This = impl_from_IAudioMediaStream(iface);
TRACE("(%p/%p)->(%p,%p)\n", iface, This, purpose_id, type);
@@ -457,7 +458,7 @@ static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_GetInformation(IAud static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_SetSameFormat(IAudioMediaStream *iface, IMediaStream *stream_format, DWORD flags) { - AudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface); + struct audio_stream *This = impl_from_IAudioMediaStream(iface);
FIXME("(%p/%p)->(%p,%x) stub!\n", iface, This, stream_format, flags);
@@ -467,7 +468,7 @@ static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_SetSameFormat(IAudi static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_AllocateSample(IAudioMediaStream *iface, DWORD flags, IStreamSample **sample) { - AudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface); + struct audio_stream *This = impl_from_IAudioMediaStream(iface);
FIXME("(%p/%p)->(%x,%p) stub!\n", iface, This, flags, sample);
@@ -477,7 +478,7 @@ static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_AllocateSample(IAud static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_CreateSharedSample(IAudioMediaStream *iface, IStreamSample *existing_sample, DWORD flags, IStreamSample **sample) { - AudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface); + struct audio_stream *This = impl_from_IAudioMediaStream(iface);
FIXME("(%p/%p)->(%p,%x,%p) stub!\n", iface, This, existing_sample, flags, sample);
@@ -487,7 +488,7 @@ static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_CreateSharedSample( static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_SendEndOfStream(IAudioMediaStream *iface, DWORD flags) { - AudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface); + struct audio_stream *This = impl_from_IAudioMediaStream(iface);
FIXME("(%p/%p)->(%x) stub!\n", iface, This, flags);
@@ -497,7 +498,7 @@ static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_SendEndOfStream(IAu /*** IAudioMediaStream methods ***/ static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_GetFormat(IAudioMediaStream *iface, WAVEFORMATEX *wave_format_current) { - AudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface); + struct audio_stream *This = impl_from_IAudioMediaStream(iface);
FIXME("(%p/%p)->(%p) stub!\n", iface, This, wave_format_current);
@@ -510,7 +511,7 @@ static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_GetFormat(IAudioMed
static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_SetFormat(IAudioMediaStream *iface, const WAVEFORMATEX *wave_format) { - AudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface); + struct audio_stream *This = impl_from_IAudioMediaStream(iface);
FIXME("(%p/%p)->(%p) stub!\n", iface, This, wave_format);
@@ -520,7 +521,7 @@ static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_SetFormat(IAudioMed static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_CreateSample(IAudioMediaStream *iface, IAudioData *audio_data, DWORD flags, IAudioStreamSample **sample) { - AudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface); + struct audio_stream *This = impl_from_IAudioMediaStream(iface);
TRACE("(%p/%p)->(%p,%u,%p)\n", iface, This, audio_data, flags, sample);
@@ -796,7 +797,7 @@ static const BaseInputPinFuncTable AudioMediaStreamInputPin_FuncTable = HRESULT audiomediastream_create(IMultiMediaStream *parent, const MSPID *purpose_id, IUnknown *stream_object, STREAM_TYPE stream_type, IAMMediaStream **media_stream) { - AudioMediaStreamImpl *object; + struct audio_stream *object; PIN_INFO pin_info; HRESULT hr;
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/amstream/audiostream.c | 102 ++++++++++++++++++++++++++++++++- dlls/amstream/tests/amstream.c | 1 + 2 files changed, 102 insertions(+), 1 deletion(-)
diff --git a/dlls/amstream/audiostream.c b/dlls/amstream/audiostream.c index 683ab7d3c66..966e1aec815 100644 --- a/dlls/amstream/audiostream.c +++ b/dlls/amstream/audiostream.c @@ -175,12 +175,16 @@ struct audio_stream { IAMMediaStream IAMMediaStream_iface; IAudioMediaStream IAudioMediaStream_iface; + IMemInputPin IMemInputPin_iface; LONG ref; + IMultiMediaStream* parent; MSPID purpose_id; STREAM_TYPE stream_type; AudioMediaStreamInputPin *input_pin; CRITICAL_SECTION critical_section; + + IMemAllocator *allocator; };
static inline struct audio_stream *impl_from_IAMMediaStream(IAMMediaStream *iface) @@ -219,7 +223,7 @@ static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_QueryInterface(IAMMedi else if (IsEqualGUID(riid, &IID_IMemInputPin)) { IAMMediaStream_AddRef(iface); - *ret_iface = &This->input_pin->pin.IMemInputPin_iface; + *ret_iface = &This->IMemInputPin_iface; return S_OK; }
@@ -794,6 +798,101 @@ static const BaseInputPinFuncTable AudioMediaStreamInputPin_FuncTable = AudioMediaStreamInputPin_Receive, };
+static inline struct audio_stream *impl_from_IMemInputPin(IMemInputPin *iface) +{ + return CONTAINING_RECORD(iface, struct audio_stream, IMemInputPin_iface); +} + +static HRESULT WINAPI audio_meminput_QueryInterface(IMemInputPin *iface, REFIID iid, void **out) +{ + struct audio_stream *stream = impl_from_IMemInputPin(iface); + return IAMMediaStream_QueryInterface(&stream->IAMMediaStream_iface, iid, out); +} + +static ULONG WINAPI audio_meminput_AddRef(IMemInputPin *iface) +{ + struct audio_stream *stream = impl_from_IMemInputPin(iface); + return IAMMediaStream_AddRef(&stream->IAMMediaStream_iface); +} + +static ULONG WINAPI audio_meminput_Release(IMemInputPin *iface) +{ + struct audio_stream *stream = impl_from_IMemInputPin(iface); + return IAMMediaStream_Release(&stream->IAMMediaStream_iface); +} + +static HRESULT WINAPI audio_meminput_GetAllocator(IMemInputPin *iface, IMemAllocator **allocator) +{ + struct audio_stream *stream = impl_from_IMemInputPin(iface); + + TRACE("stream %p, allocator %p.\n", stream, allocator); + + if (stream->allocator) + { + IMemAllocator_AddRef(*allocator = stream->allocator); + return S_OK; + } + + *allocator = NULL; + return VFW_E_NO_ALLOCATOR; +} + +static HRESULT WINAPI audio_meminput_NotifyAllocator(IMemInputPin *iface, IMemAllocator *allocator, BOOL readonly) +{ + struct audio_stream *stream = impl_from_IMemInputPin(iface); + + TRACE("stream %p, allocator %p, readonly %d.\n", stream, allocator, readonly); + + if (!allocator) + return E_POINTER; + + if (allocator) + IMemAllocator_AddRef(allocator); + if (stream->allocator) + IMemAllocator_Release(stream->allocator); + stream->allocator = allocator; + + return S_OK; +} + +static HRESULT WINAPI audio_meminput_GetAllocatorRequirements(IMemInputPin *iface, ALLOCATOR_PROPERTIES *props) +{ + TRACE("iface %p, props %p.\n", iface, props); + return E_NOTIMPL; +} + +static HRESULT WINAPI audio_meminput_Receive(IMemInputPin *iface, IMediaSample *sample) +{ + FIXME("iface %p, sample %p, stub!\n", iface, sample); + return E_NOTIMPL; +} + +static HRESULT WINAPI audio_meminput_ReceiveMultiple(IMemInputPin *iface, + IMediaSample **samples, LONG count, LONG *processed) +{ + FIXME("iface %p, samples %p, count %u, processed %p, stub!\n", iface, samples, count, processed); + return E_NOTIMPL; +} + +static HRESULT WINAPI audio_meminput_ReceiveCanBlock(IMemInputPin *iface) +{ + TRACE("iface %p.\n", iface); + return S_OK; +} + +static const IMemInputPinVtbl audio_meminput_vtbl = +{ + audio_meminput_QueryInterface, + audio_meminput_AddRef, + audio_meminput_Release, + audio_meminput_GetAllocator, + audio_meminput_NotifyAllocator, + audio_meminput_GetAllocatorRequirements, + audio_meminput_Receive, + audio_meminput_ReceiveMultiple, + audio_meminput_ReceiveCanBlock, +}; + HRESULT audiomediastream_create(IMultiMediaStream *parent, const MSPID *purpose_id, IUnknown *stream_object, STREAM_TYPE stream_type, IAMMediaStream **media_stream) { @@ -812,6 +911,7 @@ HRESULT audiomediastream_create(IMultiMediaStream *parent, const MSPID *purpose_
object->IAMMediaStream_iface.lpVtbl = &AudioMediaStreamImpl_IAMMediaStream_Vtbl; object->IAudioMediaStream_iface.lpVtbl = &AudioMediaStreamImpl_IAudioMediaStream_Vtbl; + object->IMemInputPin_iface.lpVtbl = &audio_meminput_vtbl; object->ref = 1;
InitializeCriticalSection(&object->critical_section); diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index fd192cebbb4..12d7d9be32d 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -172,6 +172,7 @@ static void test_interfaces(void) check_interface(stream, &IID_IAMMediaStream, TRUE); check_interface(stream, &IID_IAudioMediaStream, TRUE); check_interface(stream, &IID_IMediaStream, TRUE); + check_interface(stream, &IID_IMemInputPin, TRUE); check_interface(stream, &IID_IPin, TRUE); check_interface(stream, &IID_IUnknown, TRUE);
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/amstream/audiostream.c | 318 ++++++++++++++++++++++++------------ 1 file changed, 210 insertions(+), 108 deletions(-)
diff --git a/dlls/amstream/audiostream.c b/dlls/amstream/audiostream.c index 966e1aec815..9395a7a257c 100644 --- a/dlls/amstream/audiostream.c +++ b/dlls/amstream/audiostream.c @@ -25,6 +25,10 @@
WINE_DEFAULT_DEBUG_CHANNEL(amstream);
+static const WCHAR sink_id[] = {'I','{','A','3','5','F','F','5','6','B', + '-','9','F','D','A','-','1','1','D','0','-','8','F','D','F', + '-','0','0','C','0','4','F','D','9','1','8','9','D','}',0}; + typedef struct { IAudioStreamSample IAudioStreamSample_iface; LONG ref; @@ -164,27 +168,23 @@ static HRESULT audiostreamsample_create(IAudioMediaStream *parent, IAudioData *a return S_OK; }
-struct AudioMediaStreamImpl; - -typedef struct { - BaseInputPin pin; - struct audio_stream *parent; -} AudioMediaStreamInputPin; - struct audio_stream { IAMMediaStream IAMMediaStream_iface; IAudioMediaStream IAudioMediaStream_iface; IMemInputPin IMemInputPin_iface; + IPin IPin_iface; LONG ref;
IMultiMediaStream* parent; MSPID purpose_id; STREAM_TYPE stream_type; - AudioMediaStreamInputPin *input_pin; - CRITICAL_SECTION critical_section; + CRITICAL_SECTION cs; + IMediaStreamFilter *filter;
+ IPin *peer; IMemAllocator *allocator; + AM_MEDIA_TYPE mt; };
static inline struct audio_stream *impl_from_IAMMediaStream(IAMMediaStream *iface) @@ -217,7 +217,7 @@ static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_QueryInterface(IAMMedi else if (IsEqualGUID(riid, &IID_IPin)) { IAMMediaStream_AddRef(iface); - *ret_iface = &This->input_pin->pin.pin.IPin_iface; + *ret_iface = &This->IPin_iface; return S_OK; } else if (IsEqualGUID(riid, &IID_IMemInputPin)) @@ -250,8 +250,7 @@ static ULONG WINAPI AudioMediaStreamImpl_IAMMediaStream_Release(IAMMediaStream *
if (!ref) { - BaseInputPin_Destroy((BaseInputPin *)This->input_pin); - DeleteCriticalSection(&This->critical_section); + DeleteCriticalSection(&This->cs); HeapFree(GetProcessHeap(), 0, This); }
@@ -358,13 +357,13 @@ static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_JoinAMMultiMediaStream return S_FALSE; }
-static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_JoinFilter(IAMMediaStream *iface, IMediaStreamFilter *media_stream_filter) +static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_JoinFilter(IAMMediaStream *iface, IMediaStreamFilter *filter) { - struct audio_stream *This = impl_from_IAMMediaStream(iface); + struct audio_stream *stream = impl_from_IAMMediaStream(iface);
- TRACE("(%p/%p)->(%p)\n", This, iface, media_stream_filter); + TRACE("stream %p, filter %p.\n", stream, filter);
- This->input_pin->pin.pin.pinInfo.pFilter = (IBaseFilter *)media_stream_filter; + stream->filter = filter;
return S_OK; } @@ -675,127 +674,249 @@ static const IEnumMediaTypesVtbl enum_media_types_vtbl = enum_media_types_Clone, };
-static inline AudioMediaStreamInputPin *impl_from_AudioMediaStreamInputPin_IPin(IPin *iface) +static inline struct audio_stream *impl_from_IPin(IPin *iface) { - return CONTAINING_RECORD(iface, AudioMediaStreamInputPin, pin.pin.IPin_iface); + return CONTAINING_RECORD(iface, struct audio_stream, IPin_iface); }
-/*** IUnknown methods ***/ -static HRESULT WINAPI AudioMediaStreamInputPin_IPin_QueryInterface(IPin *iface, REFIID riid, void **ret_iface) +static HRESULT WINAPI audio_sink_QueryInterface(IPin *iface, REFIID iid, void **out) { - AudioMediaStreamInputPin *This = impl_from_AudioMediaStreamInputPin_IPin(iface); + struct audio_stream *stream = impl_from_IPin(iface); + return IAMMediaStream_QueryInterface(&stream->IAMMediaStream_iface, iid, out); +}
- return IAMMediaStream_QueryInterface(&This->parent->IAMMediaStream_iface, riid, ret_iface); +static ULONG WINAPI audio_sink_AddRef(IPin *iface) +{ + struct audio_stream *stream = impl_from_IPin(iface); + return IAMMediaStream_AddRef(&stream->IAMMediaStream_iface); }
-static ULONG WINAPI AudioMediaStreamInputPin_IPin_AddRef(IPin *iface) +static ULONG WINAPI audio_sink_Release(IPin *iface) { - AudioMediaStreamInputPin *This = impl_from_AudioMediaStreamInputPin_IPin(iface); + struct audio_stream *stream = impl_from_IPin(iface); + return IAMMediaStream_Release(&stream->IAMMediaStream_iface); +}
- return IAMMediaStream_AddRef(&This->parent->IAMMediaStream_iface); +static HRESULT WINAPI audio_sink_Connect(IPin *iface, IPin *peer, const AM_MEDIA_TYPE *mt) +{ + WARN("iface %p, peer %p, mt %p, unexpected call!\n", iface, peer, mt); + return E_UNEXPECTED; }
-static ULONG WINAPI AudioMediaStreamInputPin_IPin_Release(IPin *iface) +static HRESULT WINAPI audio_sink_ReceiveConnection(IPin *iface, IPin *peer, const AM_MEDIA_TYPE *mt) { - AudioMediaStreamInputPin *This = impl_from_AudioMediaStreamInputPin_IPin(iface); + struct audio_stream *stream = impl_from_IPin(iface); + PIN_DIRECTION dir; + + TRACE("stream %p, peer %p, mt %p.\n", stream, peer, mt); + + EnterCriticalSection(&stream->cs);
- return IAMMediaStream_Release(&This->parent->IAMMediaStream_iface); + if (stream->peer) + { + LeaveCriticalSection(&stream->cs); + return VFW_E_ALREADY_CONNECTED; + } + + IPin_QueryDirection(peer, &dir); + if (dir != PINDIR_OUTPUT) + { + WARN("Rejecting connection from input pin.\n"); + LeaveCriticalSection(&stream->cs); + return VFW_E_INVALID_DIRECTION; + } + + CopyMediaType(&stream->mt, mt); + IPin_AddRef(stream->peer = peer); + + LeaveCriticalSection(&stream->cs); + + return S_OK; }
-static HRESULT WINAPI audio_sink_EnumMediaTypes(IPin *iface, IEnumMediaTypes **enum_media_types) +static HRESULT WINAPI audio_sink_Disconnect(IPin *iface) { - struct enum_media_types *object; + struct audio_stream *stream = impl_from_IPin(iface);
- TRACE("iface %p, enum_media_types %p.\n", iface, enum_media_types); + TRACE("stream %p.\n", stream);
- if (!enum_media_types) - return E_POINTER; + EnterCriticalSection(&stream->cs);
- if (!(object = heap_alloc(sizeof(*object)))) - return E_OUTOFMEMORY; + if (!stream->peer) + { + LeaveCriticalSection(&stream->cs); + return S_FALSE; + }
- object->IEnumMediaTypes_iface.lpVtbl = &enum_media_types_vtbl; - object->refcount = 1; - object->index = 0; + IPin_Release(stream->peer); + stream->peer = NULL; + FreeMediaType(&stream->mt); + memset(&stream->mt, 0, sizeof(AM_MEDIA_TYPE)); + + LeaveCriticalSection(&stream->cs);
- *enum_media_types = &object->IEnumMediaTypes_iface; return S_OK; }
-static const IPinVtbl AudioMediaStreamInputPin_IPin_Vtbl = -{ - AudioMediaStreamInputPin_IPin_QueryInterface, - AudioMediaStreamInputPin_IPin_AddRef, - AudioMediaStreamInputPin_IPin_Release, - BaseInputPinImpl_Connect, - BaseInputPinImpl_ReceiveConnection, - BasePinImpl_Disconnect, - BasePinImpl_ConnectedTo, - BasePinImpl_ConnectionMediaType, - BasePinImpl_QueryPinInfo, - BasePinImpl_QueryDirection, - BasePinImpl_QueryId, - BasePinImpl_QueryAccept, - audio_sink_EnumMediaTypes, - BasePinImpl_QueryInternalConnections, - BaseInputPinImpl_EndOfStream, - BaseInputPinImpl_BeginFlush, - BaseInputPinImpl_EndFlush, - BaseInputPinImpl_NewSegment, -}; +static HRESULT WINAPI audio_sink_ConnectedTo(IPin *iface, IPin **peer) +{ + struct audio_stream *stream = impl_from_IPin(iface); + HRESULT hr; + + TRACE("stream %p, peer %p.\n", stream, peer);
-static HRESULT WINAPI AudioMediaStreamInputPin_CheckMediaType(BasePin *base, const AM_MEDIA_TYPE *media_type) + EnterCriticalSection(&stream->cs); + + if (stream->peer) + { + IPin_AddRef(*peer = stream->peer); + hr = S_OK; + } + else + { + *peer = NULL; + hr = VFW_E_NOT_CONNECTED; + } + + LeaveCriticalSection(&stream->cs); + + return hr; +} + +static HRESULT WINAPI audio_sink_ConnectionMediaType(IPin *iface, AM_MEDIA_TYPE *mt) { - AudioMediaStreamInputPin *This = impl_from_AudioMediaStreamInputPin_IPin(&base->IPin_iface); + struct audio_stream *stream = impl_from_IPin(iface); + HRESULT hr;
- TRACE("(%p)->(%p)\n", This, media_type); + TRACE("stream %p, mt %p.\n", stream, mt);
- if (IsEqualGUID(&media_type->majortype, &MEDIATYPE_Audio)) + EnterCriticalSection(&stream->cs); + + if (stream->peer) + { + CopyMediaType(mt, &stream->mt); + hr = S_OK; + } + else { - if (IsEqualGUID(&media_type->subtype, &MEDIASUBTYPE_PCM)) - { - TRACE("Audio sub-type %s matches\n", debugstr_guid(&media_type->subtype)); - return S_OK; - } + memset(mt, 0, sizeof(AM_MEDIA_TYPE)); + hr = VFW_E_NOT_CONNECTED; }
+ LeaveCriticalSection(&stream->cs); + + return hr; +} + +static HRESULT WINAPI audio_sink_QueryPinInfo(IPin *iface, PIN_INFO *info) +{ + struct audio_stream *stream = impl_from_IPin(iface); + + TRACE("stream %p, info %p.\n", stream, info); + + IBaseFilter_AddRef(info->pFilter = (IBaseFilter *)stream->filter); + info->dir = PINDIR_INPUT; + lstrcpyW(info->achName, sink_id); + return S_OK; }
-static HRESULT WINAPI AudioMediaStreamInputPin_GetMediaType(BasePin *base, int index, AM_MEDIA_TYPE *media_type) +static HRESULT WINAPI audio_sink_QueryDirection(IPin *iface, PIN_DIRECTION *dir) { - AudioMediaStreamInputPin *This = impl_from_AudioMediaStreamInputPin_IPin(&base->IPin_iface); + TRACE("iface %p, dir %p.\n", iface, dir); + *dir = PINDIR_INPUT; + return S_OK; +}
- TRACE("(%p)->(%d,%p)\n", This, index, media_type); +static HRESULT WINAPI audio_sink_QueryId(IPin *iface, WCHAR **id) +{ + TRACE("iface %p, id %p.\n", iface, id);
- /* FIXME: Reset structure as we only fill majortype and minortype for now */ - ZeroMemory(media_type, sizeof(*media_type)); + if (!(*id = CoTaskMemAlloc(sizeof(sink_id)))) + return E_OUTOFMEMORY;
- if (index) - return S_FALSE; + lstrcpyW(*id, sink_id); + + return S_OK; +} + +static HRESULT WINAPI audio_sink_QueryAccept(IPin *iface, const AM_MEDIA_TYPE *mt) +{ + TRACE("iface %p, mt %p.\n", iface, mt); + return S_OK; +} + +static HRESULT WINAPI audio_sink_EnumMediaTypes(IPin *iface, IEnumMediaTypes **enum_media_types) +{ + struct enum_media_types *object; + + TRACE("iface %p, enum_media_types %p.\n", iface, enum_media_types); + + if (!enum_media_types) + return E_POINTER;
- media_type->majortype = MEDIATYPE_Audio; - media_type->subtype = MEDIASUBTYPE_PCM; + if (!(object = heap_alloc(sizeof(*object)))) + return E_OUTOFMEMORY; + + object->IEnumMediaTypes_iface.lpVtbl = &enum_media_types_vtbl; + object->refcount = 1; + object->index = 0;
+ *enum_media_types = &object->IEnumMediaTypes_iface; return S_OK; }
-static HRESULT WINAPI AudioMediaStreamInputPin_Receive(BaseInputPin *base, IMediaSample *sample) +static HRESULT WINAPI audio_sink_QueryInternalConnections(IPin *iface, IPin **pins, ULONG *count) { - AudioMediaStreamInputPin *This = impl_from_AudioMediaStreamInputPin_IPin(&base->pin.IPin_iface); + TRACE("iface %p, pins %p, count %p.\n", iface, pins, count); + return E_NOTIMPL; +}
- FIXME("(%p)->(%p) stub!\n", This, sample); +static HRESULT WINAPI audio_sink_EndOfStream(IPin *iface) +{ + FIXME("iface %p, stub!\n", iface); + return E_NOTIMPL; +}
+static HRESULT WINAPI audio_sink_BeginFlush(IPin *iface) +{ + FIXME("iface %p, stub!\n", iface); return E_NOTIMPL; }
-static const BaseInputPinFuncTable AudioMediaStreamInputPin_FuncTable = +static HRESULT WINAPI audio_sink_EndFlush(IPin *iface) { - { - AudioMediaStreamInputPin_CheckMediaType, - AudioMediaStreamInputPin_GetMediaType, - }, - AudioMediaStreamInputPin_Receive, + FIXME("iface %p, stub!\n", iface); + return E_NOTIMPL; +} + +static HRESULT WINAPI audio_sink_NewSegment(IPin *iface, REFERENCE_TIME start, REFERENCE_TIME stop, double rate) +{ + FIXME("iface %p, start %s, stop %s, rate %0.16e, stub!\n", + iface, wine_dbgstr_longlong(start), wine_dbgstr_longlong(stop), rate); + return E_NOTIMPL; +} + +static const IPinVtbl audio_sink_vtbl = +{ + audio_sink_QueryInterface, + audio_sink_AddRef, + audio_sink_Release, + audio_sink_Connect, + audio_sink_ReceiveConnection, + audio_sink_Disconnect, + audio_sink_ConnectedTo, + audio_sink_ConnectionMediaType, + audio_sink_QueryPinInfo, + audio_sink_QueryDirection, + audio_sink_QueryId, + audio_sink_QueryAccept, + audio_sink_EnumMediaTypes, + audio_sink_QueryInternalConnections, + audio_sink_EndOfStream, + audio_sink_BeginFlush, + audio_sink_EndFlush, + audio_sink_NewSegment, };
static inline struct audio_stream *impl_from_IMemInputPin(IMemInputPin *iface) @@ -897,8 +1018,6 @@ HRESULT audiomediastream_create(IMultiMediaStream *parent, const MSPID *purpose_ IUnknown *stream_object, STREAM_TYPE stream_type, IAMMediaStream **media_stream) { struct audio_stream *object; - PIN_INFO pin_info; - HRESULT hr;
TRACE("(%p,%s,%p,%p)\n", parent, debugstr_guid(purpose_id), stream_object, media_stream);
@@ -912,22 +1031,10 @@ HRESULT audiomediastream_create(IMultiMediaStream *parent, const MSPID *purpose_ object->IAMMediaStream_iface.lpVtbl = &AudioMediaStreamImpl_IAMMediaStream_Vtbl; object->IAudioMediaStream_iface.lpVtbl = &AudioMediaStreamImpl_IAudioMediaStream_Vtbl; object->IMemInputPin_iface.lpVtbl = &audio_meminput_vtbl; + object->IPin_iface.lpVtbl = &audio_sink_vtbl; object->ref = 1;
- InitializeCriticalSection(&object->critical_section); - - pin_info.pFilter = NULL; - pin_info.dir = PINDIR_INPUT; - pin_info.achName[0] = 'I'; - StringFromGUID2(purpose_id, pin_info.achName + 1, MAX_PIN_NAME - 1); - hr = BaseInputPin_Construct(&AudioMediaStreamInputPin_IPin_Vtbl, - sizeof(AudioMediaStreamInputPin), &pin_info, &AudioMediaStreamInputPin_FuncTable, - &object->critical_section, NULL, (IPin **)&object->input_pin); - if (FAILED(hr)) - goto out_object; - - object->input_pin->parent = object; - + InitializeCriticalSection(&object->cs); object->parent = parent; object->purpose_id = *purpose_id; object->stream_type = stream_type; @@ -935,9 +1042,4 @@ HRESULT audiomediastream_create(IMultiMediaStream *parent, const MSPID *purpose_ *media_stream = &object->IAMMediaStream_iface;
return S_OK; - -out_object: - HeapFree(GetProcessHeap(), 0, object); - - return hr; }
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/amstream/amstream_private.h | 2 +- dlls/amstream/audiostream.c | 127 +++++++++++++++---------------- dlls/amstream/multimedia.c | 2 +- 3 files changed, 63 insertions(+), 68 deletions(-)
diff --git a/dlls/amstream/amstream_private.h b/dlls/amstream/amstream_private.h index fb0f0d54bac..bec107f819b 100644 --- a/dlls/amstream/amstream_private.h +++ b/dlls/amstream/amstream_private.h @@ -39,7 +39,7 @@ HRESULT AMAudioData_create(IUnknown *pUnkOuter, LPVOID *ppObj) DECLSPEC_HIDDEN; HRESULT filter_create(IUnknown *outer, void **out) DECLSPEC_HIDDEN; HRESULT ddraw_stream_create(IMultiMediaStream *parent, const MSPID *purpose_id, IUnknown *stream_object, STREAM_TYPE type, IAMMediaStream **stream) DECLSPEC_HIDDEN; -HRESULT audiomediastream_create(IMultiMediaStream *parent, const MSPID *purpose_id, +HRESULT audio_stream_create(IMultiMediaStream *parent, const MSPID *purpose_id, IUnknown *stream_object, STREAM_TYPE stream_type, IAMMediaStream **media_stream) DECLSPEC_HIDDEN;
#endif /* __AMSTREAM_PRIVATE_INCLUDED__ */ diff --git a/dlls/amstream/audiostream.c b/dlls/amstream/audiostream.c index 9395a7a257c..911cbd4d19f 100644 --- a/dlls/amstream/audiostream.c +++ b/dlls/amstream/audiostream.c @@ -193,8 +193,8 @@ static inline struct audio_stream *impl_from_IAMMediaStream(IAMMediaStream *ifac }
/*** IUnknown methods ***/ -static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_QueryInterface(IAMMediaStream *iface, - REFIID riid, void **ret_iface) +static HRESULT WINAPI audio_IAMMediaStream_QueryInterface(IAMMediaStream *iface, + REFIID riid, void **ret_iface) { struct audio_stream *This = impl_from_IAMMediaStream(iface);
@@ -231,7 +231,7 @@ static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_QueryInterface(IAMMedi return E_NOINTERFACE; }
-static ULONG WINAPI AudioMediaStreamImpl_IAMMediaStream_AddRef(IAMMediaStream *iface) +static ULONG WINAPI audio_IAMMediaStream_AddRef(IAMMediaStream *iface) { struct audio_stream *This = impl_from_IAMMediaStream(iface); ULONG ref = InterlockedIncrement(&This->ref); @@ -241,7 +241,7 @@ static ULONG WINAPI AudioMediaStreamImpl_IAMMediaStream_AddRef(IAMMediaStream *i return ref; }
-static ULONG WINAPI AudioMediaStreamImpl_IAMMediaStream_Release(IAMMediaStream *iface) +static ULONG WINAPI audio_IAMMediaStream_Release(IAMMediaStream *iface) { struct audio_stream *This = impl_from_IAMMediaStream(iface); ULONG ref = InterlockedDecrement(&This->ref); @@ -258,7 +258,7 @@ static ULONG WINAPI AudioMediaStreamImpl_IAMMediaStream_Release(IAMMediaStream * }
/*** IMediaStream methods ***/ -static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_GetMultiMediaStream(IAMMediaStream *iface, +static HRESULT WINAPI audio_IAMMediaStream_GetMultiMediaStream(IAMMediaStream *iface, IMultiMediaStream** multi_media_stream) { struct audio_stream *This = impl_from_IAMMediaStream(iface); @@ -274,7 +274,7 @@ static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_GetMultiMediaStream(IA return S_OK; }
-static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_GetInformation(IAMMediaStream *iface, +static HRESULT WINAPI audio_IAMMediaStream_GetInformation(IAMMediaStream *iface, MSPID *purpose_id, STREAM_TYPE *type) { struct audio_stream *This = impl_from_IAMMediaStream(iface); @@ -289,7 +289,7 @@ static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_GetInformation(IAMMedi return S_OK; }
-static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_SetSameFormat(IAMMediaStream *iface, +static HRESULT WINAPI audio_IAMMediaStream_SetSameFormat(IAMMediaStream *iface, IMediaStream *pStreamThatHasDesiredFormat, DWORD flags) { struct audio_stream *This = impl_from_IAMMediaStream(iface); @@ -299,7 +299,7 @@ static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_SetSameFormat(IAMMedia return S_FALSE; }
-static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_AllocateSample(IAMMediaStream *iface, +static HRESULT WINAPI audio_IAMMediaStream_AllocateSample(IAMMediaStream *iface, DWORD flags, IStreamSample **sample) { struct audio_stream *This = impl_from_IAMMediaStream(iface); @@ -309,7 +309,7 @@ static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_AllocateSample(IAMMedi return S_FALSE; }
-static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_CreateSharedSample(IAMMediaStream *iface, +static HRESULT WINAPI audio_IAMMediaStream_CreateSharedSample(IAMMediaStream *iface, IStreamSample *existing_sample, DWORD flags, IStreamSample **sample) { struct audio_stream *This = impl_from_IAMMediaStream(iface); @@ -319,7 +319,7 @@ static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_CreateSharedSample(IAM return S_FALSE; }
-static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_SendEndOfStream(IAMMediaStream *iface, DWORD flags) +static HRESULT WINAPI audio_IAMMediaStream_SendEndOfStream(IAMMediaStream *iface, DWORD flags) { struct audio_stream *This = impl_from_IAMMediaStream(iface);
@@ -329,7 +329,7 @@ static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_SendEndOfStream(IAMMed }
/*** IAMMediaStream methods ***/ -static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_Initialize(IAMMediaStream *iface, IUnknown *source_object, DWORD flags, +static HRESULT WINAPI audio_IAMMediaStream_Initialize(IAMMediaStream *iface, IUnknown *source_object, DWORD flags, REFMSPID purpose_id, const STREAM_TYPE stream_type) { struct audio_stream *This = impl_from_IAMMediaStream(iface); @@ -339,7 +339,7 @@ static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_Initialize(IAMMediaStr return S_FALSE; }
-static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_SetState(IAMMediaStream *iface, FILTER_STATE state) +static HRESULT WINAPI audio_IAMMediaStream_SetState(IAMMediaStream *iface, FILTER_STATE state) { struct audio_stream *This = impl_from_IAMMediaStream(iface);
@@ -348,7 +348,8 @@ static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_SetState(IAMMediaStrea return S_FALSE; }
-static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_JoinAMMultiMediaStream(IAMMediaStream *iface, IAMMultiMediaStream *am_multi_media_stream) +static HRESULT WINAPI audio_IAMMediaStream_JoinAMMultiMediaStream(IAMMediaStream *iface, + IAMMultiMediaStream *am_multi_media_stream) { struct audio_stream *This = impl_from_IAMMediaStream(iface);
@@ -357,7 +358,7 @@ static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_JoinAMMultiMediaStream return S_FALSE; }
-static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_JoinFilter(IAMMediaStream *iface, IMediaStreamFilter *filter) +static HRESULT WINAPI audio_IAMMediaStream_JoinFilter(IAMMediaStream *iface, IMediaStreamFilter *filter) { struct audio_stream *stream = impl_from_IAMMediaStream(iface);
@@ -368,7 +369,7 @@ static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_JoinFilter(IAMMediaStr return S_OK; }
-static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_JoinFilterGraph(IAMMediaStream *iface, IFilterGraph *filtergraph) +static HRESULT WINAPI audio_IAMMediaStream_JoinFilterGraph(IAMMediaStream *iface, IFilterGraph *filtergraph) { struct audio_stream *This = impl_from_IAMMediaStream(iface);
@@ -377,25 +378,22 @@ static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_JoinFilterGraph(IAMMed return S_FALSE; }
-static const struct IAMMediaStreamVtbl AudioMediaStreamImpl_IAMMediaStream_Vtbl = -{ - /*** IUnknown methods ***/ - AudioMediaStreamImpl_IAMMediaStream_QueryInterface, - AudioMediaStreamImpl_IAMMediaStream_AddRef, - AudioMediaStreamImpl_IAMMediaStream_Release, - /*** IMediaStream methods ***/ - AudioMediaStreamImpl_IAMMediaStream_GetMultiMediaStream, - AudioMediaStreamImpl_IAMMediaStream_GetInformation, - AudioMediaStreamImpl_IAMMediaStream_SetSameFormat, - AudioMediaStreamImpl_IAMMediaStream_AllocateSample, - AudioMediaStreamImpl_IAMMediaStream_CreateSharedSample, - AudioMediaStreamImpl_IAMMediaStream_SendEndOfStream, - /*** IAMMediaStream methods ***/ - AudioMediaStreamImpl_IAMMediaStream_Initialize, - AudioMediaStreamImpl_IAMMediaStream_SetState, - AudioMediaStreamImpl_IAMMediaStream_JoinAMMultiMediaStream, - AudioMediaStreamImpl_IAMMediaStream_JoinFilter, - AudioMediaStreamImpl_IAMMediaStream_JoinFilterGraph +static const struct IAMMediaStreamVtbl audio_IAMMediaStream_vtbl = +{ + audio_IAMMediaStream_QueryInterface, + audio_IAMMediaStream_AddRef, + audio_IAMMediaStream_Release, + audio_IAMMediaStream_GetMultiMediaStream, + audio_IAMMediaStream_GetInformation, + audio_IAMMediaStream_SetSameFormat, + audio_IAMMediaStream_AllocateSample, + audio_IAMMediaStream_CreateSharedSample, + audio_IAMMediaStream_SendEndOfStream, + audio_IAMMediaStream_Initialize, + audio_IAMMediaStream_SetState, + audio_IAMMediaStream_JoinAMMultiMediaStream, + audio_IAMMediaStream_JoinFilter, + audio_IAMMediaStream_JoinFilterGraph, };
static inline struct audio_stream *impl_from_IAudioMediaStream(IAudioMediaStream *iface) @@ -404,7 +402,7 @@ static inline struct audio_stream *impl_from_IAudioMediaStream(IAudioMediaStream }
/*** IUnknown methods ***/ -static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_QueryInterface(IAudioMediaStream *iface, +static HRESULT WINAPI audio_IAudioMediaStream_QueryInterface(IAudioMediaStream *iface, REFIID riid, void **ret_iface) { struct audio_stream *This = impl_from_IAudioMediaStream(iface); @@ -412,14 +410,14 @@ static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_QueryInterface(IAud return IAMMediaStream_QueryInterface(&This->IAMMediaStream_iface, riid, ret_iface); }
-static ULONG WINAPI AudioMediaStreamImpl_IAudioMediaStream_AddRef(IAudioMediaStream *iface) +static ULONG WINAPI audio_IAudioMediaStream_AddRef(IAudioMediaStream *iface) { struct audio_stream *This = impl_from_IAudioMediaStream(iface); TRACE("(%p/%p)\n", iface, This); return IAMMediaStream_AddRef(&This->IAMMediaStream_iface); }
-static ULONG WINAPI AudioMediaStreamImpl_IAudioMediaStream_Release(IAudioMediaStream *iface) +static ULONG WINAPI audio_IAudioMediaStream_Release(IAudioMediaStream *iface) { struct audio_stream *This = impl_from_IAudioMediaStream(iface); TRACE("(%p/%p)\n", iface, This); @@ -427,7 +425,7 @@ static ULONG WINAPI AudioMediaStreamImpl_IAudioMediaStream_Release(IAudioMediaSt }
/*** IMediaStream methods ***/ -static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_GetMultiMediaStream(IAudioMediaStream *iface, +static HRESULT WINAPI audio_IAudioMediaStream_GetMultiMediaStream(IAudioMediaStream *iface, IMultiMediaStream **multi_media_stream) { struct audio_stream *This = impl_from_IAudioMediaStream(iface); @@ -443,7 +441,7 @@ static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_GetMultiMediaStream return S_OK; }
-static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_GetInformation(IAudioMediaStream *iface, +static HRESULT WINAPI audio_IAudioMediaStream_GetInformation(IAudioMediaStream *iface, MSPID *purpose_id, STREAM_TYPE *type) { struct audio_stream *This = impl_from_IAudioMediaStream(iface); @@ -458,7 +456,7 @@ static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_GetInformation(IAud return S_OK; }
-static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_SetSameFormat(IAudioMediaStream *iface, +static HRESULT WINAPI audio_IAudioMediaStream_SetSameFormat(IAudioMediaStream *iface, IMediaStream *stream_format, DWORD flags) { struct audio_stream *This = impl_from_IAudioMediaStream(iface); @@ -468,7 +466,7 @@ static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_SetSameFormat(IAudi return S_FALSE; }
-static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_AllocateSample(IAudioMediaStream *iface, +static HRESULT WINAPI audio_IAudioMediaStream_AllocateSample(IAudioMediaStream *iface, DWORD flags, IStreamSample **sample) { struct audio_stream *This = impl_from_IAudioMediaStream(iface); @@ -478,7 +476,7 @@ static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_AllocateSample(IAud return S_FALSE; }
-static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_CreateSharedSample(IAudioMediaStream *iface, +static HRESULT WINAPI audio_IAudioMediaStream_CreateSharedSample(IAudioMediaStream *iface, IStreamSample *existing_sample, DWORD flags, IStreamSample **sample) { struct audio_stream *This = impl_from_IAudioMediaStream(iface); @@ -488,7 +486,7 @@ static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_CreateSharedSample( return S_FALSE; }
-static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_SendEndOfStream(IAudioMediaStream *iface, +static HRESULT WINAPI audio_IAudioMediaStream_SendEndOfStream(IAudioMediaStream *iface, DWORD flags) { struct audio_stream *This = impl_from_IAudioMediaStream(iface); @@ -499,7 +497,7 @@ static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_SendEndOfStream(IAu }
/*** IAudioMediaStream methods ***/ -static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_GetFormat(IAudioMediaStream *iface, WAVEFORMATEX *wave_format_current) +static HRESULT WINAPI audio_IAudioMediaStream_GetFormat(IAudioMediaStream *iface, WAVEFORMATEX *wave_format_current) { struct audio_stream *This = impl_from_IAudioMediaStream(iface);
@@ -512,7 +510,7 @@ static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_GetFormat(IAudioMed
}
-static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_SetFormat(IAudioMediaStream *iface, const WAVEFORMATEX *wave_format) +static HRESULT WINAPI audio_IAudioMediaStream_SetFormat(IAudioMediaStream *iface, const WAVEFORMATEX *wave_format) { struct audio_stream *This = impl_from_IAudioMediaStream(iface);
@@ -521,7 +519,7 @@ static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_SetFormat(IAudioMed return E_NOTIMPL; }
-static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_CreateSample(IAudioMediaStream *iface, IAudioData *audio_data, +static HRESULT WINAPI audio_IAudioMediaStream_CreateSample(IAudioMediaStream *iface, IAudioData *audio_data, DWORD flags, IAudioStreamSample **sample) { struct audio_stream *This = impl_from_IAudioMediaStream(iface); @@ -534,23 +532,20 @@ static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_CreateSample(IAudio return audiostreamsample_create(iface, audio_data, sample); }
-static const struct IAudioMediaStreamVtbl AudioMediaStreamImpl_IAudioMediaStream_Vtbl = -{ - /*** IUnknown methods ***/ - AudioMediaStreamImpl_IAudioMediaStream_QueryInterface, - AudioMediaStreamImpl_IAudioMediaStream_AddRef, - AudioMediaStreamImpl_IAudioMediaStream_Release, - /*** IMediaStream methods ***/ - AudioMediaStreamImpl_IAudioMediaStream_GetMultiMediaStream, - AudioMediaStreamImpl_IAudioMediaStream_GetInformation, - AudioMediaStreamImpl_IAudioMediaStream_SetSameFormat, - AudioMediaStreamImpl_IAudioMediaStream_AllocateSample, - AudioMediaStreamImpl_IAudioMediaStream_CreateSharedSample, - AudioMediaStreamImpl_IAudioMediaStream_SendEndOfStream, - /*** IAudioMediaStream methods ***/ - AudioMediaStreamImpl_IAudioMediaStream_GetFormat, - AudioMediaStreamImpl_IAudioMediaStream_SetFormat, - AudioMediaStreamImpl_IAudioMediaStream_CreateSample +static const struct IAudioMediaStreamVtbl audio_IAudioMediaStream_vtbl = +{ + audio_IAudioMediaStream_QueryInterface, + audio_IAudioMediaStream_AddRef, + audio_IAudioMediaStream_Release, + audio_IAudioMediaStream_GetMultiMediaStream, + audio_IAudioMediaStream_GetInformation, + audio_IAudioMediaStream_SetSameFormat, + audio_IAudioMediaStream_AllocateSample, + audio_IAudioMediaStream_CreateSharedSample, + audio_IAudioMediaStream_SendEndOfStream, + audio_IAudioMediaStream_GetFormat, + audio_IAudioMediaStream_SetFormat, + audio_IAudioMediaStream_CreateSample, };
struct enum_media_types @@ -1014,7 +1009,7 @@ static const IMemInputPinVtbl audio_meminput_vtbl = audio_meminput_ReceiveCanBlock, };
-HRESULT audiomediastream_create(IMultiMediaStream *parent, const MSPID *purpose_id, +HRESULT audio_stream_create(IMultiMediaStream *parent, const MSPID *purpose_id, IUnknown *stream_object, STREAM_TYPE stream_type, IAMMediaStream **media_stream) { struct audio_stream *object; @@ -1028,8 +1023,8 @@ HRESULT audiomediastream_create(IMultiMediaStream *parent, const MSPID *purpose_ if (!object) return E_OUTOFMEMORY;
- object->IAMMediaStream_iface.lpVtbl = &AudioMediaStreamImpl_IAMMediaStream_Vtbl; - object->IAudioMediaStream_iface.lpVtbl = &AudioMediaStreamImpl_IAudioMediaStream_Vtbl; + object->IAMMediaStream_iface.lpVtbl = &audio_IAMMediaStream_vtbl; + object->IAudioMediaStream_iface.lpVtbl = &audio_IAudioMediaStream_vtbl; object->IMemInputPin_iface.lpVtbl = &audio_meminput_vtbl; object->IPin_iface.lpVtbl = &audio_sink_vtbl; object->ref = 1; diff --git a/dlls/amstream/multimedia.c b/dlls/amstream/multimedia.c index 0f3fa05b18b..e42c13d3514 100644 --- a/dlls/amstream/multimedia.c +++ b/dlls/amstream/multimedia.c @@ -324,7 +324,7 @@ static HRESULT WINAPI multimedia_stream_AddMediaStream(IAMMultiMediaStream *ifac if (IsEqualGUID(PurposeId, &MSPID_PrimaryVideo)) hr = ddraw_stream_create((IMultiMediaStream*)iface, PurposeId, stream_object, This->StreamType, &pStream); else - hr = audiomediastream_create((IMultiMediaStream*)iface, PurposeId, stream_object, This->StreamType, &pStream); + hr = audio_stream_create((IMultiMediaStream*)iface, PurposeId, stream_object, This->StreamType, &pStream);
if (SUCCEEDED(hr)) {
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/winegstreamer/gst_private.h | 1 + dlls/winegstreamer/gstdemux.c | 58 +++++++++++++++++--------------- 2 files changed, 31 insertions(+), 28 deletions(-)
diff --git a/dlls/winegstreamer/gst_private.h b/dlls/winegstreamer/gst_private.h index 06236e26369..18d6eb8a8e8 100644 --- a/dlls/winegstreamer/gst_private.h +++ b/dlls/winegstreamer/gst_private.h @@ -30,6 +30,7 @@ #include "winuser.h" #include "dshow.h" #include "strmif.h" +#include "wine/heap.h" #include "wine/strmbase.h"
#define MEDIATIME_FROM_BYTES(x) ((LONGLONG)(x) * 10000000) diff --git a/dlls/winegstreamer/gstdemux.c b/dlls/winegstreamer/gstdemux.c index babf98c67b3..1a9aec8f033 100644 --- a/dlls/winegstreamer/gstdemux.c +++ b/dlls/winegstreamer/gstdemux.c @@ -104,7 +104,7 @@ static const IPinVtbl GST_InputPin_Vtbl; static const IBaseFilterVtbl GST_Vtbl; static const IQualityControlVtbl GSTOutPin_QualityControl_Vtbl;
-static HRESULT GST_AddPin(GSTImpl *This, const PIN_INFO *piOutput, const AM_MEDIA_TYPE *amt); +static BOOL create_pin(GSTImpl *filter, const PIN_INFO *pin_info, const AM_MEDIA_TYPE *mt); static HRESULT GST_RemoveOutputPins(GSTImpl *This); static HRESULT WINAPI GST_ChangeCurrent(IMediaSeeking *iface); static HRESULT WINAPI GST_ChangeStop(IMediaSeeking *iface); @@ -825,9 +825,9 @@ static void init_new_decoded_pad(GstElement *bin, GstPad *pad, GSTImpl *This) return; }
- hr = GST_AddPin(This, &piOutput, &amt); - if (FAILED(hr)) { - ERR("%08x\n", hr); + if (!create_pin(This, &piOutput, &amt)) + { + ERR("Failed to allocate memory.\n"); return; }
@@ -1767,13 +1767,12 @@ static void free_source_pin(GSTOutPin *pin) gst_object_unref(pin->my_sink); CloseHandle(pin->caps_event); DeleteMediaType(pin->pmt); - FreeMediaType(&pin->pin.pin.mtCurrent); gst_segment_free(pin->segment); if (pin->gstpool) gst_object_unref(pin->gstpool); - if (pin->pin.pAllocator) - IMemAllocator_Release(pin->pin.pAllocator); - CoTaskMemFree(pin); + + strmbase_source_cleanup(&pin->pin); + heap_free(pin); }
static const IPinVtbl GST_OutputPin_Vtbl = { @@ -1807,27 +1806,30 @@ static const BaseOutputPinFuncTable output_BaseOutputFuncTable = { GSTOutPin_DecideAllocator, };
-static HRESULT GST_AddPin(GSTImpl *This, const PIN_INFO *piOutput, const AM_MEDIA_TYPE *amt) +static BOOL create_pin(GSTImpl *filter, const PIN_INFO *pin_info, const AM_MEDIA_TYPE *mt) { - HRESULT hr; - This->ppPins = CoTaskMemRealloc(This->ppPins, (This->cStreams + 1) * sizeof(IPin *)); - - hr = BaseOutputPin_Construct(&GST_OutputPin_Vtbl, sizeof(GSTOutPin), piOutput, &output_BaseOutputFuncTable, &This->filter.csFilter, (IPin**)(This->ppPins + This->cStreams)); - if (SUCCEEDED(hr)) { - GSTOutPin *pin = This->ppPins[This->cStreams]; - memset((char*)pin + sizeof(pin->pin), 0, sizeof(GSTOutPin) - sizeof(pin->pin)); - pin->pmt = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE)); - CopyMediaType(pin->pmt, amt); - pin->pin.pin.pinInfo.pFilter = &This->filter.IBaseFilter_iface; - pin->caps_event = CreateEventW(NULL, 0, 0, NULL); - pin->segment = gst_segment_new(); - This->cStreams++; - pin->IQualityControl_iface.lpVtbl = &GSTOutPin_QualityControl_Vtbl; - SourceSeeking_Init(&pin->seek, &GST_Seeking_Vtbl, GST_ChangeStop, GST_ChangeCurrent, GST_ChangeRate, &This->filter.csFilter); - BaseFilterImpl_IncrementPinVersion(&This->filter); - } else - ERR("Failed with error %x\n", hr); - return hr; + GSTOutPin *pin, **new_array; + + if (!(new_array = CoTaskMemRealloc(filter->ppPins, (filter->cStreams + 1) * sizeof(*new_array)))) + return FALSE; + filter->ppPins = new_array; + + if (!(pin = heap_alloc_zero(sizeof(*pin)))) + return FALSE; + + strmbase_source_init(&pin->pin, &GST_OutputPin_Vtbl, pin_info, + &output_BaseOutputFuncTable, &filter->filter.csFilter); + pin->pmt = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE)); + CopyMediaType(pin->pmt, mt); + pin->caps_event = CreateEventW(NULL, FALSE, FALSE, NULL); + pin->segment = gst_segment_new(); + pin->IQualityControl_iface.lpVtbl = &GSTOutPin_QualityControl_Vtbl; + SourceSeeking_Init(&pin->seek, &GST_Seeking_Vtbl, GST_ChangeStop, + GST_ChangeCurrent, GST_ChangeRate, &filter->filter.csFilter); + BaseFilterImpl_IncrementPinVersion(&filter->filter); + + filter->ppPins[filter->cStreams++] = pin; + return TRUE; }
static HRESULT GST_RemoveOutputPins(GSTImpl *This)