[PATCH 2/4] amstream: Add IAudioMediaStream stub implementation. (try 2)

Christian Costa titan.costa at gmail.com
Thu Apr 5 01:31:18 CDT 2012


try 2: Fix QueryInterface.
---
 dlls/amstream/Makefile.in        |    1 
 dlls/amstream/amstream.c         |    3 
 dlls/amstream/amstream_private.h |    2 
 dlls/amstream/audiomediastream.c |  233 ++++++++++++++++++++++++++++++++++++++
 dlls/amstream/tests/amstream.c   |    4 -
 5 files changed, 239 insertions(+), 4 deletions(-)
 create mode 100644 dlls/amstream/audiomediastream.c

diff --git a/dlls/amstream/Makefile.in b/dlls/amstream/Makefile.in
index 047bb73..50ae47b 100644
--- a/dlls/amstream/Makefile.in
+++ b/dlls/amstream/Makefile.in
@@ -4,6 +4,7 @@ IMPORTS   = strmiids strmbase uuid ole32 advapi32
 C_SRCS = \
 	amstream.c \
 	audiodata.c \
+	audiomediastream.c \
 	ddrawmediastream.c \
 	main.c \
 	mediastreamfilter.c
diff --git a/dlls/amstream/amstream.c b/dlls/amstream/amstream.c
index af9cb86..cc33d48 100644
--- a/dlls/amstream/amstream.c
+++ b/dlls/amstream/amstream.c
@@ -371,8 +371,7 @@ static HRESULT WINAPI IAMMultiMediaStreamImpl_AddMediaStream(IAMMultiMediaStream
     if (IsEqualGUID(PurposeId, &MSPID_PrimaryVideo))
         hr = ddrawmediastream_create((IMultiMediaStream*)iface, PurposeId, This->StreamType, &pStream);
     else
-        /* FIXME: should call audiomediastream_create instead */
-        hr = ddrawmediastream_create((IMultiMediaStream*)iface, PurposeId, This->StreamType, &pStream);
+        hr = audiomediastream_create((IMultiMediaStream*)iface, PurposeId, This->StreamType, &pStream);
     if (SUCCEEDED(hr))
     {
         pNewStreams = CoTaskMemRealloc(This->pStreams, (This->nbStreams+1) * sizeof(IMediaStream*));
diff --git a/dlls/amstream/amstream_private.h b/dlls/amstream/amstream_private.h
index d81b915..0881c3e 100644
--- a/dlls/amstream/amstream_private.h
+++ b/dlls/amstream/amstream_private.h
@@ -37,5 +37,7 @@ HRESULT AMAudioData_create(IUnknown *pUnkOuter, LPVOID *ppObj) DECLSPEC_HIDDEN;
 HRESULT MediaStreamFilter_create(IUnknown *pUnkOuter, LPVOID *ppObj) DECLSPEC_HIDDEN;
 HRESULT ddrawmediastream_create(IMultiMediaStream *Parent, const MSPID *pPurposeId,
         STREAM_TYPE StreamType, IMediaStream **ppMediaStream) DECLSPEC_HIDDEN;
+HRESULT audiomediastream_create(IMultiMediaStream *parent, const MSPID *purpose_id,
+        STREAM_TYPE stream_type, IMediaStream **media_stream) DECLSPEC_HIDDEN;
 
 #endif /* __AMSTREAM_PRIVATE_INCLUDED__ */
diff --git a/dlls/amstream/audiomediastream.c b/dlls/amstream/audiomediastream.c
new file mode 100644
index 0000000..9a09d33
--- /dev/null
+++ b/dlls/amstream/audiomediastream.c
@@ -0,0 +1,233 @@
+/*
+ * Implementation of IAudioMediaStream Interface
+ *
+ * Copyright 2012 Christian Costa
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include "wine/debug.h"
+
+#define COBJMACROS
+
+#include "winbase.h"
+#include "wingdi.h"
+
+#include "amstream_private.h"
+#include "amstream.h"
+
+#include "ddstream.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(amstream);
+
+typedef struct {
+    IAudioMediaStream IAudioMediaStream_iface;
+    LONG ref;
+    IMultiMediaStream* parent;
+    MSPID purpose_id;
+    STREAM_TYPE stream_type;
+} IAudioMediaStreamImpl;
+
+static inline IAudioMediaStreamImpl *impl_from_IAudioMediaStream(IAudioMediaStream *iface)
+{
+    return CONTAINING_RECORD(iface, IAudioMediaStreamImpl, IAudioMediaStream_iface);
+}
+
+/*** IUnknown methods ***/
+static HRESULT WINAPI IAudioMediaStreamImpl_QueryInterface(IAudioMediaStream *iface,
+        REFIID riid, void **ret_iface)
+{
+    IAudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface);
+
+    TRACE("(%p/%p)->(%s,%p)\n", iface, This, debugstr_guid(riid), ret_iface);
+
+    if (IsEqualGUID(riid, &IID_IUnknown) ||
+        IsEqualGUID(riid, &IID_IMediaStream) ||
+        IsEqualGUID(riid, &IID_IAudioMediaStream))
+    {
+        IAudioMediaStream_AddRef(iface);
+        *ret_iface = iface;
+        return S_OK;
+    }
+
+    *ret_iface = NULL;
+
+    ERR("(%p/%p)->(%s,%p),not found\n", iface, This, debugstr_guid(riid), ret_iface);
+    return E_NOINTERFACE;
+}
+
+static ULONG WINAPI IAudioMediaStreamImpl_AddRef(IAudioMediaStream *iface)
+{
+    IAudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface);
+    ULONG ref = InterlockedIncrement(&This->ref);
+
+    TRACE("(%p/%p): new ref = %u\n", iface, This, ref);
+
+    return ref;
+}
+
+static ULONG WINAPI IAudioMediaStreamImpl_Release(IAudioMediaStream *iface)
+{
+    IAudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface);
+    ULONG ref = InterlockedDecrement(&This->ref);
+
+    TRACE("(%p/%p): new ref = %u\n", iface, This, ref);
+
+    if (!ref)
+        HeapFree(GetProcessHeap(), 0, This);
+
+    return ref;
+}
+
+/*** IMediaStream methods ***/
+static HRESULT WINAPI IAudioMediaStreamImpl_GetMultiMediaStream(IAudioMediaStream *iface,
+        IMultiMediaStream** multimedia_stream)
+{
+    IAudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface);
+
+    FIXME("(%p/%p)->(%p) stub!\n", iface, This, multimedia_stream);
+
+    return S_FALSE;
+}
+
+static HRESULT WINAPI IAudioMediaStreamImpl_GetInformation(IAudioMediaStream *iface,
+        MSPID *purpose_id, STREAM_TYPE *type)
+{
+    IAudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface);
+
+    TRACE("(%p/%p)->(%p,%p)\n", iface, This, purpose_id, type);
+
+    if (purpose_id)
+        *purpose_id = This->purpose_id;
+    if (type)
+        *type = This->stream_type;
+
+    return S_OK;
+}
+
+static HRESULT WINAPI IAudioMediaStreamImpl_SetSameFormat(IAudioMediaStream *iface,
+        IMediaStream *stream_format, DWORD flags)
+{
+    IAudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface);
+
+    FIXME("(%p/%p)->(%p,%x) stub!\n", iface, This, stream_format, flags);
+
+    return S_FALSE;
+}
+
+static HRESULT WINAPI IAudioMediaStreamImpl_AllocateSample(IAudioMediaStream *iface,
+        DWORD flags, IStreamSample **sample)
+{
+    IAudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface);
+
+    FIXME("(%p/%p)->(%x,%p) stub!\n", iface, This, flags, sample);
+
+    return S_FALSE;
+}
+
+static HRESULT WINAPI IAudioMediaStreamImpl_CreateSharedSample(IAudioMediaStream *iface,
+        IStreamSample *existing_sample, DWORD flags, IStreamSample **sample)
+{
+    IAudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface);
+
+    FIXME("(%p/%p)->(%p,%x,%p) stub!\n", iface, This, existing_sample, flags, sample);
+
+    return S_FALSE;
+}
+
+static HRESULT WINAPI IAudioMediaStreamImpl_SendEndOfStream(IAudioMediaStream *iface,
+        DWORD flags)
+{
+    IAudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface);
+
+    FIXME("(%p/%p)->(%x) stub!\n", iface, This, flags);
+
+    return S_FALSE;
+}
+
+/*** IAudioMediaStream methods ***/
+static HRESULT WINAPI IAudioMediaStreamImpl_GetFormat(IAudioMediaStream *iface, WAVEFORMATEX *wave_format_current)
+{
+    IAudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface);
+
+    FIXME("(%p/%p)->(%p) stub!\n", iface, This, wave_format_current);
+
+    return E_NOTIMPL;
+
+}
+
+static HRESULT WINAPI IAudioMediaStreamImpl_SetFormat(IAudioMediaStream *iface, const WAVEFORMATEX *wave_format)
+{
+    IAudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface);
+
+    FIXME("(%p/%p)->(%p) stub!\n", iface, This, wave_format);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI IAudioMediaStreamImpl_CreateSample(IAudioMediaStream *iface, IAudioData *audio_data,
+                                                         DWORD flags, IAudioStreamSample **sample)
+{
+    IAudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface);
+
+    FIXME("(%p/%p)->(%p,%u,%p) stub!\n", iface, This, audio_data, flags, sample);
+
+    return E_NOTIMPL;
+}
+
+static const struct IAudioMediaStreamVtbl AudioMediaStream_Vtbl =
+{
+    /*** IUnknown methods ***/
+    IAudioMediaStreamImpl_QueryInterface,
+    IAudioMediaStreamImpl_AddRef,
+    IAudioMediaStreamImpl_Release,
+    /*** IMediaStream methods ***/
+    IAudioMediaStreamImpl_GetMultiMediaStream,
+    IAudioMediaStreamImpl_GetInformation,
+    IAudioMediaStreamImpl_SetSameFormat,
+    IAudioMediaStreamImpl_AllocateSample,
+    IAudioMediaStreamImpl_CreateSharedSample,
+    IAudioMediaStreamImpl_SendEndOfStream,
+    /*** IAudioMediaStream methods ***/
+    IAudioMediaStreamImpl_GetFormat,
+    IAudioMediaStreamImpl_SetFormat,
+    IAudioMediaStreamImpl_CreateSample
+};
+
+HRESULT audiomediastream_create(IMultiMediaStream *parent, const MSPID *purpose_id,
+        STREAM_TYPE stream_type, IMediaStream **media_stream)
+{
+    IAudioMediaStreamImpl *object;
+
+    TRACE("(%p,%s,%p)\n", parent, debugstr_guid(purpose_id), media_stream);
+
+    object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IAudioMediaStreamImpl));
+    if (!object)
+    {
+        ERR("Out of memory\n");
+        return E_OUTOFMEMORY;
+    }
+
+    object->IAudioMediaStream_iface.lpVtbl = &AudioMediaStream_Vtbl;
+    object->ref = 1;
+
+    object->parent = parent;
+    object->purpose_id = *purpose_id;
+    object->stream_type = stream_type;
+
+    *media_stream = (IMediaStream*)&object->IAudioMediaStream_iface;
+
+    return S_OK;
+}
diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c
index 87bbcc7..14c3e42 100644
--- a/dlls/amstream/tests/amstream.c
+++ b/dlls/amstream/tests/amstream.c
@@ -325,10 +325,10 @@ static void test_media_streams(void)
             IAMMediaStream_Release(am_media_stream);
 
         hr = IMediaStream_QueryInterface(audio_stream, &IID_IDirectDrawMediaStream, (LPVOID*)&ddraw_stream);
-        todo_wine ok(hr == E_NOINTERFACE, "IMediaStream_QueryInterface returned: %x\n", hr);
+        ok(hr == E_NOINTERFACE, "IMediaStream_QueryInterface returned: %x\n", hr);
 
         hr = IMediaStream_QueryInterface(audio_stream, &IID_IAudioMediaStream, (LPVOID*)&audio_media_stream);
-        todo_wine ok(hr == S_OK, "IMediaStream_QueryInterface returned: %x\n", hr);
+        ok(hr == S_OK, "IMediaStream_QueryInterface returned: %x\n", hr);
 
         if (SUCCEEDED(hr))
         {




More information about the wine-patches mailing list