Various test fixes for XP/msvc.
[wine/multimedia.git] / dlls / msdmo / dmort.c
blob6172f65d7e9a4edaf90f7fe85d84978f3bc89994
1 /*
2 * Copyright (C) 2003 Michael Günnewig
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #define COM_NO_WINDOWS_H
20 #include <stdarg.h>
22 #include "windef.h"
23 #include "winbase.h"
24 #include "objbase.h"
25 #include "mediaobj.h"
26 #include "dmort.h"
28 #include "wine/debug.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(msdmo);
32 /***********************************************************************
33 * MoCreateMediaType (MSDMO.@)
35 HRESULT WINAPI MoCreateMediaType(DMO_MEDIA_TYPE** ppmedia, DWORD cbFormat)
37 HRESULT hr;
39 TRACE("(%p,%lu)\n", ppmedia, cbFormat);
41 if (ppmedia == NULL)
42 return E_POINTER;
44 *ppmedia = CoTaskMemAlloc(sizeof(DMO_MEDIA_TYPE));
45 if (*ppmedia == NULL)
46 return E_OUTOFMEMORY;
48 hr = MoInitMediaType(*ppmedia, cbFormat);
49 if (FAILED(hr)) {
50 CoTaskMemFree(*ppmedia);
51 *ppmedia = NULL;
54 return hr;
57 /***********************************************************************
58 * MoInitMediaType (MSDMO.@)
60 HRESULT WINAPI MoInitMediaType(DMO_MEDIA_TYPE* pmedia, DWORD cbFormat)
62 TRACE("(%p,%lu)\n", pmedia,cbFormat);
64 if (pmedia == NULL)
65 return E_POINTER;
67 memset(pmedia, 0, sizeof(DMO_MEDIA_TYPE));
69 if (cbFormat > 0) {
70 pmedia->pbFormat = CoTaskMemAlloc(cbFormat);
71 if (pmedia->pbFormat == NULL)
72 return E_OUTOFMEMORY;
74 pmedia->cbFormat = cbFormat;
77 return S_OK;
80 /***********************************************************************
81 * MoDeleteMediaType (MSDMO.@)
83 HRESULT WINAPI MoDeleteMediaType(DMO_MEDIA_TYPE* pmedia)
85 TRACE("(%p)\n", pmedia);
87 if (pmedia == NULL)
88 return E_POINTER;
90 MoFreeMediaType(pmedia);
91 CoTaskMemFree(pmedia);
93 return S_OK;
96 /***********************************************************************
97 * MoFreeMediaType (MSDMO.@)
99 HRESULT WINAPI MoFreeMediaType(DMO_MEDIA_TYPE* pmedia)
101 TRACE("(%p)\n", pmedia);
103 if (pmedia == NULL)
104 return E_POINTER;
106 if (pmedia->pUnk != NULL) {
107 IUnknown_Release(pmedia->pUnk);
108 pmedia->pUnk = NULL;
111 if (pmedia->pbFormat != NULL) {
112 CoTaskMemFree(pmedia->pbFormat);
113 pmedia->pbFormat = NULL;
116 return S_OK;
119 /***********************************************************************
120 * MoDuplicateMediaType (MSDMO.@)
122 HRESULT WINAPI MoDuplicateMediaType(DMO_MEDIA_TYPE** ppdst,
123 const DMO_MEDIA_TYPE* psrc)
125 HRESULT hr;
127 TRACE("(%p,%p)\n", ppdst, psrc);
129 if (ppdst == NULL || psrc == NULL)
130 return E_POINTER;
132 *ppdst = CoTaskMemAlloc(sizeof(DMO_MEDIA_TYPE));
133 if (*ppdst == NULL)
134 return E_OUTOFMEMORY;
136 hr = MoCopyMediaType(*ppdst, psrc);
137 if (FAILED(hr)) {
138 MoFreeMediaType(*ppdst);
139 *ppdst = NULL;
142 return hr;
145 /***********************************************************************
146 * MoCopyMediaType (MSDMO.@)
148 HRESULT WINAPI MoCopyMediaType(DMO_MEDIA_TYPE* pdst,
149 const DMO_MEDIA_TYPE* psrc)
151 TRACE("(%p,%p)\n", pdst, psrc);
153 if (pdst == NULL || psrc == NULL)
154 return E_POINTER;
156 memcpy(&pdst->majortype, &psrc->majortype, sizeof(psrc->majortype));
157 memcpy(&pdst->subtype, &psrc->subtype, sizeof(psrc->subtype));
158 memcpy(&pdst->formattype, &psrc->formattype, sizeof(psrc->formattype));
160 pdst->bFixedSizeSamples = psrc->bFixedSizeSamples;
161 pdst->bTemporalCompression = psrc->bTemporalCompression;
162 pdst->lSampleSize = psrc->lSampleSize;
163 pdst->cbFormat = psrc->cbFormat;
165 if (psrc->pbFormat != NULL && psrc->cbFormat > 0) {
166 pdst->pbFormat = CoTaskMemAlloc(psrc->cbFormat);
167 if (pdst->pbFormat == NULL)
168 return E_OUTOFMEMORY;
170 memcpy(pdst->pbFormat, psrc->pbFormat, psrc->cbFormat);
171 } else
172 pdst->pbFormat = NULL;
174 if (psrc->pUnk != NULL) {
175 pdst->pUnk = psrc->pUnk;
176 IUnknown_AddRef(pdst->pUnk);
177 } else
178 pdst->pUnk = NULL;
180 return S_OK;