Mercurial > mplayer.hg
annotate loader/dshow/cmediasample.c @ 24408:614f9efc91a8
Fix indentation after r24367.
author | cehoyos |
---|---|
date | Mon, 10 Sep 2007 23:14:17 +0000 |
parents | 89347ff2c31a |
children | 2c8cdb9123b8 |
rev | line source |
---|---|
15166
f5537cc95b02
Mark modified imported files as such to comply with GPL ¡ø2a.
diego
parents:
9964
diff
changeset
|
1 /* |
18783 | 2 * Modified for use with MPlayer, detailed changelog at |
3 * http://svn.mplayerhq.hu/mplayer/trunk/ | |
15166
f5537cc95b02
Mark modified imported files as such to comply with GPL ¡ø2a.
diego
parents:
9964
diff
changeset
|
4 * $Id$ |
f5537cc95b02
Mark modified imported files as such to comply with GPL ¡ø2a.
diego
parents:
9964
diff
changeset
|
5 */ |
f5537cc95b02
Mark modified imported files as such to comply with GPL ¡ø2a.
diego
parents:
9964
diff
changeset
|
6 |
1545 | 7 #include "cmediasample.h" |
22305
3d1b23cf3d08
Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
22028
diff
changeset
|
8 #include "mediatype.h" |
2069 | 9 #include "wine/winerror.h" |
168 | 10 #include <stdio.h> |
11 #include <string.h> | |
7386 | 12 #include <stdlib.h> |
1545 | 13 |
8292 | 14 /* |
15 * currently hack to make some extra room for DS Acel codec which | |
16 * seems to overwrite allocated memory - FIXME better later | |
17 * check the buffer allocation | |
18 */ | |
19 static const int SAFETY_ACEL = 1024; | |
20 | |
22028 | 21 /** |
22 * \brief IPin::QueryInternalConnections (retries pin's internal connections) | |
23 * | |
24 * \param[in] This pointer to IPin interface | |
25 * \param[out] apPin Array that receives pins, internally connected to this | |
26 * \param[in,out] nPint Size of an array | |
27 * | |
28 * \return S_OK - success | |
29 * \return S_FALSE - pin rejects media type | |
30 * \return E_NOTIMPL - not implemented | |
31 * | |
32 */ | |
3056 | 33 static long STDCALL CMediaSample_QueryInterface(IUnknown* This, |
7386 | 34 /* [in] */ const GUID* iid, |
1545 | 35 /* [iid_is][out] */ void **ppv) |
168 | 36 { |
3056 | 37 Debug printf("CMediaSample_QueryInterface(%p) called\n", This); |
1545 | 38 if (!ppv) |
39 return E_INVALIDARG; | |
3056 | 40 if (memcmp(iid, &IID_IUnknown, sizeof(*iid)) == 0) |
168 | 41 { |
3056 | 42 *ppv = (void*)This; |
43 ((IMediaSample*) This)->vt->AddRef(This); | |
168 | 44 return 0; |
45 } | |
3056 | 46 if (memcmp(iid, &IID_IMediaSample, sizeof(*iid)) == 0) |
168 | 47 { |
3056 | 48 *ppv = (void*)This; |
49 ((IMediaSample*) This)->vt->AddRef(This); | |
168 | 50 return 0; |
51 } | |
1545 | 52 return E_NOINTERFACE; |
168 | 53 } |
54 | |
22028 | 55 /** |
56 * \brief IUnknown::AddRef (increases reference counter for interface) | |
57 * | |
58 * \param[in] This pointer to IUnknown class | |
59 * | |
60 * \return new value of reference counter | |
61 * | |
62 * \remarks | |
63 * Return value should be used only for debug purposes | |
64 * | |
65 */ | |
1545 | 66 static long STDCALL CMediaSample_AddRef(IUnknown* This) |
168 | 67 { |
3056 | 68 Debug printf("CMediaSample_AddRef(%p) called\n", This); |
168 | 69 ((CMediaSample*)This)->refcount++; |
70 return 0; | |
71 } | |
1545 | 72 |
22028 | 73 /** |
74 * \brief CMediaSample destructor | |
75 * | |
76 * \param[in] This pointer to CMediaSample object | |
77 * | |
78 */ | |
3056 | 79 void CMediaSample_Destroy(CMediaSample* This) |
80 { | |
81 | |
82 Debug printf("CMediaSample_Destroy(%p) called (ref:%d)\n", This, This->refcount); | |
83 free(This->vt); | |
84 free(This->own_block); | |
24347 | 85 if(((CMediaSample*)This)->type_valid) |
24408 | 86 FreeMediaType(&(This->media_type)); |
3056 | 87 free(This); |
88 } | |
89 | |
22028 | 90 /** |
91 * \brief IUnknown::Release (desreases reference counter for interface) | |
92 * | |
93 * \param[in] This pointer to IUnknown class | |
94 * | |
95 * \return new value of reference counter | |
96 * | |
97 * \remarks | |
98 * When reference counter reaches zero calls destructor | |
99 * Return value should be used only for debug purposes | |
100 * | |
101 */ | |
1545 | 102 static long STDCALL CMediaSample_Release(IUnknown* This) |
168 | 103 { |
3467 | 104 CMediaSample* parent = (CMediaSample*)This; |
3056 | 105 Debug printf("CMediaSample_Release(%p) called (new ref:%d)\n", |
1545 | 106 This, ((CMediaSample*)This)->refcount-1); |
3467 | 107 |
108 if (--((CMediaSample*) This)->refcount == 0) | |
3056 | 109 { |
1545 | 110 parent->all->vt->ReleaseBuffer((IMemAllocator*)(parent->all), |
111 (IMediaSample*)This); | |
3056 | 112 } |
168 | 113 return 0; |
114 } | |
1545 | 115 |
22028 | 116 /** |
117 * \brief IMediaSample::GetPointer (retrieves a read/write pointer to the media sample's buffer) | |
118 * | |
119 * \param[in] This pointer to CMediaSample object | |
120 * \param[out] address of variable that receives pointer to sample's buffer | |
121 * | |
122 * \return S_OK success | |
123 * \return apropriate error otherwise | |
124 * | |
125 * \note The calles should not free or reallocate buffer | |
126 * | |
127 */ | |
3467 | 128 static HRESULT STDCALL CMediaSample_GetPointer(IMediaSample* This, |
129 /* [out] */ BYTE** ppBuffer) | |
168 | 130 { |
3467 | 131 Debug printf("CMediaSample_GetPointer(%p) called -> %p, size: %d %d\n", This, ((CMediaSample*) This)->block, ((CMediaSample*)This)->actual_size, ((CMediaSample*)This)->size); |
1545 | 132 if (!ppBuffer) |
133 return E_INVALIDARG; | |
3467 | 134 *ppBuffer = (BYTE*) ((CMediaSample*) This)->block; |
168 | 135 return 0; |
136 } | |
137 | |
22028 | 138 /** |
139 * \brief IMediaSample::GetSize (retrieves a size of buffer in bytes) | |
140 * | |
141 * \param[in] This pointer to CMediaSample object | |
142 * | |
143 * \return size of buffer in bytes | |
144 * | |
145 */ | |
1545 | 146 static long STDCALL CMediaSample_GetSize(IMediaSample * This) |
168 | 147 { |
3467 | 148 Debug printf("CMediaSample_GetSize(%p) called -> %d\n", This, ((CMediaSample*) This)->size); |
149 return ((CMediaSample*) This)->size; | |
168 | 150 } |
151 | |
22028 | 152 /** |
153 * \brief IMediaSample::GetTime (retrieves a stream time at wich sample sould start and finish) | |
154 * | |
155 * \param[in] This pointer to CMediaSample object | |
156 * \param[out] pTimeStart pointer to variable that receives start time | |
157 * \param[out] pTimeEnd pointer to variable that receives end time | |
158 * | |
159 * \return S_OK success | |
160 * \return VFW_E_NO_STOP_TIME The sample has valid start time, but no stop time | |
161 * \return VFW_E_SAMPLE_TIME_NOT_SET The sample is not time-stamped | |
162 * | |
163 * \remarks | |
164 * Both values are relative to stream time | |
165 * | |
166 */ | |
1545 | 167 static HRESULT STDCALL CMediaSample_GetTime(IMediaSample * This, |
168 /* [out] */ REFERENCE_TIME *pTimeStart, | |
169 /* [out] */ REFERENCE_TIME *pTimeEnd) | |
168 | 170 { |
8292 | 171 Debug printf("CMediaSample_GetTime(%p) called (UNIMPLEMENTED)\n", This); |
168 | 172 return E_NOTIMPL; |
173 } | |
174 | |
22028 | 175 /** |
176 * \brief IMediaSample::SetTime (sets a stream time at wich sample sould start and finish) | |
177 * | |
178 * \param[in] This pointer to CMediaSample object | |
179 * \param[out] pTimeStart pointer to variable that contains start time | |
180 * \param[out] pTimeEnd pointer to variable that contains end time | |
181 * | |
182 * \return S_OK success | |
183 * \return apropriate error otherwise | |
184 * | |
185 * \remarks | |
186 * Both values are relative to stream time | |
187 * To invalidate the stream times set pTimeStart and pTimeEnd to NULL. this will cause | |
188 * IMEdiaSample::GetTime to return VFW_E_SAMPLE_TIME_NOT_SET | |
189 * | |
190 */ | |
1545 | 191 static HRESULT STDCALL CMediaSample_SetTime(IMediaSample * This, |
192 /* [in] */ REFERENCE_TIME *pTimeStart, | |
193 /* [in] */ REFERENCE_TIME *pTimeEnd) | |
168 | 194 { |
8292 | 195 Debug printf("CMediaSample_SetTime(%p) called (UNIMPLEMENTED)\n", This); |
168 | 196 return E_NOTIMPL; |
197 } | |
198 | |
22028 | 199 /** |
200 * \brief IMediaSample::IsSyncPoint (determines if start of this sample is sync point) | |
201 * | |
202 * \param[in] This pointer to CMediaSample object | |
203 * | |
204 * \return S_OK start of this sample is sync point | |
205 * \return S_FALSE start of this sample is not sync point | |
206 * | |
207 * \remarks | |
208 * If bTemporalCompression of AM_MEDIA_TYPE is FALSE, all samples are sync points. | |
209 * | |
210 */ | |
1545 | 211 static HRESULT STDCALL CMediaSample_IsSyncPoint(IMediaSample * This) |
168 | 212 { |
3056 | 213 Debug printf("CMediaSample_IsSyncPoint(%p) called\n", This); |
1545 | 214 if (((CMediaSample*)This)->isSyncPoint) |
215 return 0; | |
168 | 216 return 1; |
217 } | |
218 | |
22028 | 219 /** |
220 * \brief IMediaSample::SetSyncPoint (specifies if start of this sample is sync point) | |
221 * | |
222 * \param[in] This pointer to CMediaSample object | |
223 * \param[in] bIsSyncPoint specifies whether this is sync point or not | |
224 * | |
225 * \return S_OK success | |
226 * \return apropriate error code otherwise | |
227 * | |
228 */ | |
1545 | 229 static HRESULT STDCALL CMediaSample_SetSyncPoint(IMediaSample * This, |
230 long bIsSyncPoint) | |
168 | 231 { |
3056 | 232 Debug printf("CMediaSample_SetSyncPoint(%p) called\n", This); |
3467 | 233 ((CMediaSample*)This)->isSyncPoint = bIsSyncPoint; |
168 | 234 return 0; |
235 } | |
236 | |
22028 | 237 /** |
238 * \brief IMediaSample::IsPreroll (determines if this sample is preroll sample) | |
239 * | |
240 * \param[in] This pointer to CMediaSample object | |
241 * | |
242 * \return S_OK if this sample is preroll sample | |
243 * \return S_FALSE if this sample is not preroll sample | |
244 * | |
245 * \remarks | |
246 * Preroll samples are processed but not displayed. They are lokated in media stream | |
247 * before displayable samples. | |
248 * | |
249 */ | |
1545 | 250 static HRESULT STDCALL CMediaSample_IsPreroll(IMediaSample * This) |
168 | 251 { |
3056 | 252 Debug printf("CMediaSample_IsPreroll(%p) called\n", This); |
1545 | 253 |
254 if (((CMediaSample*)This)->isPreroll) | |
168 | 255 return 0;//S_OK |
1545 | 256 |
257 return 1;//S_FALSE | |
168 | 258 } |
259 | |
22028 | 260 /** |
261 * \brief IMediaSample::SetPreroll (specifies if this sample is preroll sample) | |
262 * | |
263 * \param[in] This pointer to CMediaSample object | |
264 * \param[in] bIsPreroll specifies whether this sample is preroll sample or not | |
265 * | |
266 * \return S_OK success | |
267 * \return apropriate error code otherwise | |
268 * | |
269 * \remarks | |
270 * Preroll samples are processed but not displayed. They are lokated in media stream | |
271 * before displayable samples. | |
272 * | |
273 */ | |
1545 | 274 static HRESULT STDCALL CMediaSample_SetPreroll(IMediaSample * This, |
275 long bIsPreroll) | |
168 | 276 { |
3056 | 277 Debug printf("CMediaSample_SetPreroll(%p) called\n", This); |
168 | 278 ((CMediaSample*)This)->isPreroll=bIsPreroll; |
279 return 0; | |
280 } | |
281 | |
22028 | 282 /** |
283 * \brief IMediaSample::GetActualDataLength (retrieves the length of valid data in the buffer) | |
284 * | |
285 * \param[in] This pointer to CMediaSample object | |
286 * | |
287 * \return length of valid data in buffer in bytes | |
288 * | |
289 */ | |
3056 | 290 static long STDCALL CMediaSample_GetActualDataLength(IMediaSample* This) |
168 | 291 { |
3056 | 292 Debug printf("CMediaSample_GetActualDataLength(%p) called -> %d\n", This, ((CMediaSample*)This)->actual_size); |
168 | 293 return ((CMediaSample*)This)->actual_size; |
294 } | |
295 | |
22028 | 296 /** |
297 * \brief IMediaSample::SetActualDataLength (specifies the length of valid data in the buffer) | |
298 * | |
299 * \param[in] This pointer to CMediaSample object | |
300 * \param[in] __MIDL_0010 length of data in sample in bytes | |
301 * | |
302 * \return S_OK success | |
303 * \return VFW_E_BUFFER_OVERFLOW length specified by parameter is larger than buffer size | |
304 * | |
305 */ | |
3056 | 306 static HRESULT STDCALL CMediaSample_SetActualDataLength(IMediaSample* This, |
1545 | 307 long __MIDL_0010) |
168 | 308 { |
3467 | 309 CMediaSample* cms = (CMediaSample*)This; |
3056 | 310 Debug printf("CMediaSample_SetActualDataLength(%p, %ld) called\n", This, __MIDL_0010); |
8292 | 311 |
3467 | 312 if (__MIDL_0010 > cms->size) |
168 | 313 { |
3467 | 314 char* c = cms->own_block; |
8292 | 315 Debug printf("CMediaSample - buffer overflow %ld %d %p %p\n", |
3467 | 316 __MIDL_0010, ((CMediaSample*)This)->size, cms->own_block, cms->block); |
8292 | 317 cms->own_block = (char*) realloc(cms->own_block, (size_t) __MIDL_0010 + SAFETY_ACEL); |
3467 | 318 if (c == cms->block) |
319 cms->block = cms->own_block; | |
320 cms->size = __MIDL_0010; | |
168 | 321 } |
3467 | 322 cms->actual_size = __MIDL_0010; |
168 | 323 return 0; |
324 } | |
325 | |
22028 | 326 /** |
327 * \brief IMediaSample::GetMediaType (retrieves media type, if it changed from previous sample) | |
328 * | |
329 * \param[in] This pointer to CMediaSample object | |
330 * \param[out] ppMediaType address of variable that receives pointer to AM_MEDIA_TYPE. | |
331 * | |
332 * \return S_OK success | |
333 * \return S_FALSE Media type was not changed from previous sample | |
334 * \return E_OUTOFMEMORY Insufficient memory | |
335 * | |
336 * \remarks | |
337 * If media type is not changed from previous sample, ppMediaType is null | |
338 * If method returns S_OK caller should free memory allocated for structure | |
339 * including pbFormat block | |
340 */ | |
3056 | 341 static HRESULT STDCALL CMediaSample_GetMediaType(IMediaSample* This, |
342 AM_MEDIA_TYPE** ppMediaType) | |
168 | 343 { |
3056 | 344 AM_MEDIA_TYPE* t; |
345 Debug printf("CMediaSample_GetMediaType(%p) called\n", This); | |
168 | 346 if(!ppMediaType) |
1545 | 347 return E_INVALIDARG; |
168 | 348 if(!((CMediaSample*)This)->type_valid) |
349 { | |
350 *ppMediaType=0; | |
351 return 1; | |
352 } | |
3056 | 353 |
354 t = &((CMediaSample*)This)->media_type; | |
9964 | 355 // if(t.pbFormat)free(t.pbFormat); |
22305
3d1b23cf3d08
Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
22028
diff
changeset
|
356 *ppMediaType=CreateMediaType(t); |
3056 | 357 // *ppMediaType=0; //media type was not changed |
1545 | 358 return 0; |
168 | 359 } |
360 | |
22028 | 361 /** |
362 * \brief IMediaType::SetMediaType (specifies media type for sample) | |
363 * | |
364 * \param[in] This pointer to CMediaSample object | |
365 * \param[in] pMediaType pointer to AM_MEDIA_TYPE specifies new media type | |
366 * | |
367 * \return S_OK success | |
368 * \return E_OUTOFMEMORY insufficient memory | |
369 * | |
370 */ | |
1545 | 371 static HRESULT STDCALL CMediaSample_SetMediaType(IMediaSample * This, |
372 AM_MEDIA_TYPE *pMediaType) | |
168 | 373 { |
3056 | 374 AM_MEDIA_TYPE* t; |
375 Debug printf("CMediaSample_SetMediaType(%p) called\n", This); | |
1545 | 376 if (!pMediaType) |
377 return E_INVALIDARG; | |
3056 | 378 t = &((CMediaSample*)This)->media_type; |
24347 | 379 if(((CMediaSample*)This)->type_valid) |
24408 | 380 FreeMediaType(t); |
22305
3d1b23cf3d08
Moving duplicated (and sometimes wrong) AM_MEDIA_TYPE related code into separate file
voroshil
parents:
22028
diff
changeset
|
381 CopyMediaType(t,pMediaType); |
3467 | 382 ((CMediaSample*) This)->type_valid=1; |
1545 | 383 |
168 | 384 return 0; |
385 } | |
386 | |
22028 | 387 /** |
388 * \brief IMediaSample::IsDiscontinuity (determines if this sample represents data break | |
389 * in stream) | |
390 * | |
391 * \param[in] This pointer to CMediaSample object | |
392 * | |
393 * \return S_OK if this sample is break in data stream | |
394 * \return S_FALSE otherwise | |
395 * | |
396 * \remarks | |
397 * Discontinuity occures when filter seeks to different place in the stream or when drops | |
398 * samples. | |
399 * | |
400 */ | |
1545 | 401 static HRESULT STDCALL CMediaSample_IsDiscontinuity(IMediaSample * This) |
168 | 402 { |
3056 | 403 Debug printf("CMediaSample_IsDiscontinuity(%p) called\n", This); |
3467 | 404 return ((CMediaSample*) This)->isDiscontinuity; |
168 | 405 } |
406 | |
22028 | 407 /** |
408 * \brief IMediaSample::IsDiscontinuity (specifies whether this sample represents data break | |
409 * in stream) | |
410 * | |
411 * \param[in] This pointer to CMediaSample object | |
412 * \param[in] bDiscontinuity if TRUE this sample represents discontinuity with previous sample | |
413 * | |
414 * \return S_OK success | |
415 * \return apropriate error code otherwise | |
416 * | |
417 */ | |
1545 | 418 static HRESULT STDCALL CMediaSample_SetDiscontinuity(IMediaSample * This, |
419 long bDiscontinuity) | |
168 | 420 { |
3467 | 421 Debug printf("CMediaSample_SetDiscontinuity(%p) called (%ld)\n", This, bDiscontinuity); |
422 ((CMediaSample*) This)->isDiscontinuity = bDiscontinuity; | |
423 return 0; | |
1545 | 424 } |
425 | |
22028 | 426 /** |
427 * \brief IMediaSample::GetMediaTime (retrieves the media times of this sample) | |
428 * | |
429 * \param[in] This pointer to CMediaSample object | |
430 * \param[out] pTimeStart pointer to variable that receives start time | |
431 * \param[out] pTimeEnd pointer to variable that receives end time | |
432 * | |
433 * \return S_OK success | |
434 * \return VFW_E_MEDIA_TIME_NOT_SET The sample is not time-stamped | |
435 * | |
436 */ | |
1545 | 437 static HRESULT STDCALL CMediaSample_GetMediaTime(IMediaSample * This, |
438 /* [out] */ LONGLONG *pTimeStart, | |
439 /* [out] */ LONGLONG *pTimeEnd) | |
440 { | |
3056 | 441 Debug printf("CMediaSample_GetMediaTime(%p) called\n", This); |
3467 | 442 if (pTimeStart) |
443 *pTimeStart = ((CMediaSample*) This)->time_start; | |
444 if (pTimeEnd) | |
445 *pTimeEnd = ((CMediaSample*) This)->time_end; | |
446 return 0; | |
1545 | 447 } |
448 | |
22028 | 449 /** |
450 * \brief IMediaSample::GetMediaTime (retrieves the media times of this sample) | |
451 * | |
452 * \param[in] This pointer to CMediaSample object | |
453 * \param[out] pTimeStart pointer to variable that specifies start time | |
454 * \param[out] pTimeEnd pointer to variable that specifies end time | |
455 * | |
456 * \return S_OK success | |
457 * \return apropriate error code otherwise | |
458 * | |
459 * \remarks | |
460 * To invalidate the media times set pTimeStart and pTimeEnd to NULL. this will cause | |
461 * IMEdiaSample::GetTime to return VFW_E_MEDIA_TIME_NOT_SET | |
462 */ | |
1545 | 463 static HRESULT STDCALL CMediaSample_SetMediaTime(IMediaSample * This, |
464 /* [in] */ LONGLONG *pTimeStart, | |
465 /* [in] */ LONGLONG *pTimeEnd) | |
466 { | |
3056 | 467 Debug printf("CMediaSample_SetMediaTime(%p) called\n", This); |
3467 | 468 if (pTimeStart) |
469 ((CMediaSample*) This)->time_start = *pTimeStart; | |
470 if (pTimeEnd) | |
471 ((CMediaSample*) This)->time_end = *pTimeEnd; | |
472 return 0; | |
168 | 473 } |
474 | |
22028 | 475 /** |
476 * \brief CMediaSample::SetPointer (extension for direct memory write of decompressed data) | |
477 * | |
478 * \param[in] This pointer to CMediaSample object | |
479 * \param[in] pointer pointer to an external buffer to store data to | |
480 * | |
481 */ | |
3056 | 482 static void CMediaSample_SetPointer(CMediaSample* This, char* pointer) |
168 | 483 { |
3056 | 484 Debug printf("CMediaSample_SetPointer(%p) called -> %p\n", This, pointer); |
485 if (pointer) | |
486 This->block = pointer; | |
487 else | |
488 This->block = This->own_block; | |
489 } | |
1545 | 490 |
22028 | 491 /** |
492 * \brief CMediaSample::SetPointer (resets pointer to external buffer with internal one) | |
493 * | |
494 * \param[in] This pointer to CMediaSample object | |
495 * | |
496 */ | |
3056 | 497 static void CMediaSample_ResetPointer(CMediaSample* This) |
498 { | |
499 Debug printf("CMediaSample_ResetPointer(%p) called\n", This); | |
500 This->block = This->own_block; | |
168 | 501 } |
502 | |
22028 | 503 /** |
504 * \brief CMediaSample constructor | |
505 * | |
506 * \param[in] allocator IMemallocator interface of allocator to use | |
507 * \param[in] _size size of internal buffer | |
508 * | |
509 * \return pointer to CMediaSample object of NULL if error occured | |
510 * | |
511 */ | |
3056 | 512 CMediaSample* CMediaSampleCreate(IMemAllocator* allocator, int _size) |
168 | 513 { |
3467 | 514 CMediaSample* This = (CMediaSample*) malloc(sizeof(CMediaSample)); |
515 if (!This) | |
516 return NULL; | |
517 | |
518 // some hack here! | |
519 // it looks like Acelp decoder is actually accessing | |
520 // the allocated memory before it sets the new size for it ??? | |
521 // -- maybe it's being initialized with wrong parameters | |
522 // anyway this is fixes the problem somehow with some reserves | |
523 // | |
524 // using different trick for now - in DS_Audio modify sample size | |
525 //if (_size < 0x1000) | |
526 // _size = (_size + 0xfff) & ~0xfff; | |
527 | |
3056 | 528 This->vt = (IMediaSample_vt*) malloc(sizeof(IMediaSample_vt)); |
8292 | 529 This->own_block = (char*) malloc((size_t)_size + SAFETY_ACEL); |
3467 | 530 This->media_type.pbFormat = 0; |
24343 | 531 This->media_type.pUnk = 0; |
3467 | 532 |
533 if (!This->vt || !This->own_block) | |
534 { | |
535 CMediaSample_Destroy(This); | |
536 return NULL; | |
537 } | |
3056 | 538 |
539 This->vt->QueryInterface = CMediaSample_QueryInterface; | |
540 This->vt->AddRef = CMediaSample_AddRef; | |
541 This->vt->Release = CMediaSample_Release; | |
542 This->vt->GetPointer = CMediaSample_GetPointer; | |
543 This->vt->GetSize = CMediaSample_GetSize; | |
544 This->vt->GetTime = CMediaSample_GetTime; | |
545 This->vt->SetTime = CMediaSample_SetTime; | |
546 This->vt->IsSyncPoint = CMediaSample_IsSyncPoint; | |
547 This->vt->SetSyncPoint = CMediaSample_SetSyncPoint; | |
548 This->vt->IsPreroll = CMediaSample_IsPreroll; | |
549 This->vt->SetPreroll = CMediaSample_SetPreroll; | |
550 This->vt->GetActualDataLength = CMediaSample_GetActualDataLength; | |
551 This->vt->SetActualDataLength = CMediaSample_SetActualDataLength; | |
552 This->vt->GetMediaType = CMediaSample_GetMediaType; | |
553 This->vt->SetMediaType = CMediaSample_SetMediaType; | |
554 This->vt->IsDiscontinuity = CMediaSample_IsDiscontinuity; | |
555 This->vt->SetDiscontinuity = CMediaSample_SetDiscontinuity; | |
556 This->vt->GetMediaTime = CMediaSample_GetMediaTime; | |
557 This->vt->SetMediaTime = CMediaSample_SetMediaTime; | |
558 | |
559 This->all = allocator; | |
560 This->size = _size; | |
561 This->refcount = 0; // increased by MemAllocator | |
562 This->actual_size = 0; | |
563 This->isPreroll = 0; | |
3467 | 564 This->isDiscontinuity = 1; |
565 This->time_start = 0; | |
566 This->time_end = 0; | |
3056 | 567 This->type_valid = 0; |
568 This->block = This->own_block; | |
569 | |
570 This->SetPointer = CMediaSample_SetPointer; | |
571 This->ResetPointer = CMediaSample_ResetPointer; | |
572 | |
573 Debug printf("CMediaSample_Create(%p) called - sample size %d, buffer %p\n", | |
574 This, This->size, This->block); | |
575 | |
576 return This; | |
168 | 577 } |