From 6a451198b14616c79e10615a8ba25e6aaabef044 Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Thu, 18 Aug 2016 09:14:24 +0000 Subject: [PATCH] [AMSTREAM] Sync with Wine Staging 1.9.16. CORE-11866 svn path=/trunk/; revision=72249 --- .../dll/directx/wine/amstream/CMakeLists.txt | 2 +- reactos/dll/directx/wine/amstream/audiodata.c | 118 ++++++++++++++++-- reactos/dll/directx/wine/amstream/main.c | 4 +- .../dll/directx/wine/amstream/mediastream.c | 6 +- reactos/media/doc/README.WINE | 2 +- 5 files changed, 112 insertions(+), 20 deletions(-) diff --git a/reactos/dll/directx/wine/amstream/CMakeLists.txt b/reactos/dll/directx/wine/amstream/CMakeLists.txt index 11808269709..695b778ffc6 100644 --- a/reactos/dll/directx/wine/amstream/CMakeLists.txt +++ b/reactos/dll/directx/wine/amstream/CMakeLists.txt @@ -21,6 +21,6 @@ add_library(amstream SHARED set_module_type(amstream win32dll) target_link_libraries(amstream strmbase strmiids uuid wine) -add_importlibs(amstream ole32 ddraw msvcrt kernel32 ntdll) +add_importlibs(amstream ole32 ddraw user32 msvcrt kernel32 ntdll) add_pch(amstream amstream_private.h SOURCE) add_cd_file(TARGET amstream DESTINATION reactos/system32 FOR all) diff --git a/reactos/dll/directx/wine/amstream/audiodata.c b/reactos/dll/directx/wine/amstream/audiodata.c index c4f9b74e4f7..b50f7b58e1b 100644 --- a/reactos/dll/directx/wine/amstream/audiodata.c +++ b/reactos/dll/directx/wine/amstream/audiodata.c @@ -23,6 +23,11 @@ typedef struct { IAudioData IAudioData_iface; LONG ref; + DWORD size; + BYTE *data; + BOOL data_owned; + DWORD actual_data; + WAVEFORMATEX wave_format; } AMAudioDataImpl; static inline AMAudioDataImpl *impl_from_IAudioData(IAudioData *iface) @@ -36,7 +41,6 @@ static HRESULT WINAPI IAudioDataImpl_QueryInterface(IAudioData *iface, REFIID ri TRACE("(%p)->(%s,%p)\n", iface, debugstr_guid(riid), ret_iface); if (IsEqualGUID(riid, &IID_IUnknown) || - IsEqualGUID(riid, &IID_IMemoryData) || IsEqualGUID(riid, &IID_IAudioData)) { IAudioData_AddRef(iface); @@ -66,7 +70,14 @@ static ULONG WINAPI IAudioDataImpl_Release(IAudioData* iface) TRACE("(%p)->(): new ref = %u\n", iface, This->ref); if (!ref) + { + if (This->data_owned) + { + CoTaskMemFree(This->data); + } + HeapFree(GetProcessHeap(), 0, This); + } return ref; } @@ -74,38 +85,116 @@ static ULONG WINAPI IAudioDataImpl_Release(IAudioData* iface) /*** IMemoryData methods ***/ static HRESULT WINAPI IAudioDataImpl_SetBuffer(IAudioData* iface, DWORD size, BYTE *data, DWORD flags) { - FIXME("(%p)->(%u,%p,%x): stub\n", iface, size, data, flags); + AMAudioDataImpl *This = impl_from_IAudioData(iface); - return E_NOTIMPL; + TRACE("(%p)->(%u,%p,%x)\n", iface, size, data, flags); + + if (!size) + { + return E_INVALIDARG; + } + + if (This->data_owned) + { + CoTaskMemFree(This->data); + This->data_owned = FALSE; + } + + This->size = size; + This->data = data; + + if (!This->data) + { + This->data = CoTaskMemAlloc(This->size); + This->data_owned = TRUE; + if (!This->data) + { + return E_OUTOFMEMORY; + } + } + + return S_OK; } static HRESULT WINAPI IAudioDataImpl_GetInfo(IAudioData* iface, DWORD *length, BYTE **data, DWORD *actual_data) { - FIXME("(%p)->(%p,%p,%p): stub\n", iface, length, data, actual_data); + AMAudioDataImpl *This = impl_from_IAudioData(iface); - return E_NOTIMPL; + TRACE("(%p)->(%p,%p,%p)\n", iface, length, data, actual_data); + + if (!This->data) + { + return MS_E_NOTINIT; + } + + if (length) + { + *length = This->size; + } + if (data) + { + *data = This->data; + } + if (actual_data) + { + *actual_data = This->actual_data; + } + + return S_OK; } static HRESULT WINAPI IAudioDataImpl_SetActual(IAudioData* iface, DWORD data_valid) { - FIXME("(%p)->(%u): stub\n", iface, data_valid); + AMAudioDataImpl *This = impl_from_IAudioData(iface); - return E_NOTIMPL; + TRACE("(%p)->(%u)\n", iface, data_valid); + + if (data_valid > This->size) + { + return E_INVALIDARG; + } + + This->actual_data = data_valid; + + return S_OK; } /*** IAudioData methods ***/ static HRESULT WINAPI IAudioDataImpl_GetFormat(IAudioData* iface, WAVEFORMATEX *wave_format_current) { - FIXME("(%p)->(%p): stub\n", iface, wave_format_current); + AMAudioDataImpl *This = impl_from_IAudioData(iface); - return E_NOTIMPL; + TRACE("(%p)->(%p)\n", iface, wave_format_current); + + if (!wave_format_current) + { + return E_POINTER; + } + + *wave_format_current = This->wave_format; + + return S_OK; } static HRESULT WINAPI IAudioDataImpl_SetFormat(IAudioData* iface, const WAVEFORMATEX *wave_format) { - FIXME("(%p)->(%p): stub\n", iface, wave_format); + AMAudioDataImpl *This = impl_from_IAudioData(iface); - return E_NOTIMPL; + TRACE("(%p)->(%p)\n", iface, wave_format); + + if (!wave_format) + { + return E_POINTER; + } + + if (WAVE_FORMAT_PCM != wave_format->wFormatTag) + { + return E_INVALIDARG; + } + + This->wave_format = *wave_format; + + return S_OK; } static const struct IAudioDataVtbl AudioData_Vtbl = @@ -139,6 +228,13 @@ HRESULT AMAudioData_create(IUnknown *pUnkOuter, LPVOID *ppObj) object->IAudioData_iface.lpVtbl = &AudioData_Vtbl; object->ref = 1; + object->wave_format.wFormatTag = WAVE_FORMAT_PCM; + object->wave_format.nChannels = 1; + object->wave_format.nSamplesPerSec = 11025; + object->wave_format.wBitsPerSample = 16; + object->wave_format.nBlockAlign = object->wave_format.wBitsPerSample * object->wave_format.nChannels / 8; + object->wave_format.nAvgBytesPerSec = object->wave_format.nBlockAlign * object->wave_format.nSamplesPerSec; + *ppObj = &object->IAudioData_iface; return S_OK; diff --git a/reactos/dll/directx/wine/amstream/main.c b/reactos/dll/directx/wine/amstream/main.c index 672796b670e..7a1f7d888d5 100644 --- a/reactos/dll/directx/wine/amstream/main.c +++ b/reactos/dll/directx/wine/amstream/main.c @@ -102,8 +102,8 @@ static HRESULT WINAPI AMCF_CreateInstance(IClassFactory *iface, IUnknown *pOuter { IClassFactoryImpl *This = impl_from_IClassFactory(iface); HRESULT hres; - LPUNKNOWN punk; - + IUnknown *punk; + TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj); *ppobj = NULL; diff --git a/reactos/dll/directx/wine/amstream/mediastream.c b/reactos/dll/directx/wine/amstream/mediastream.c index 5b96209cf60..c44eaad895d 100644 --- a/reactos/dll/directx/wine/amstream/mediastream.c +++ b/reactos/dll/directx/wine/amstream/mediastream.c @@ -1038,11 +1038,7 @@ static HRESULT ddrawstreamsample_create(IDirectDrawMediaStream *parent, IDirectD DDSURFACEDESC desc = { sizeof(desc) }; hr = IDirectDrawSurface_GetSurfaceDesc(object->surface, &desc); if (hr == S_OK) - { - object->rect.left = object->rect.top = 0; - object->rect.right = desc.dwWidth; - object->rect.bottom = desc.dwHeight; - } + SetRect(&object->rect, 0, 0, desc.dwWidth, desc.dwHeight); } *ddraw_stream_sample = &object->IDirectDrawStreamSample_iface; diff --git a/reactos/media/doc/README.WINE b/reactos/media/doc/README.WINE index 1b696c277b0..07184e48ae4 100644 --- a/reactos/media/doc/README.WINE +++ b/reactos/media/doc/README.WINE @@ -21,7 +21,7 @@ reactos/sdk/tools/wpp # Synced to WineStaging-1.9.11 The following libraries are shared with Wine. -reactos/dll/directx/wine/amstream # Synced to WineStaging-1.9.11 +reactos/dll/directx/wine/amstream # Synced to WineStaging-1.9.16 reactos/dll/directx/wine/d3d8 # Synced to WineStaging-1.9.4 reactos/dll/directx/wine/d3d9 # Synced to WineStaging-1.9.4 reactos/dll/directx/wine/d3dcompiler_43 # Synced to WineStaging-1.9.4