Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
0ecde550
Commit
0ecde550
authored
Mar 08, 2022
by
Giovanni Mascellani
Committed by
Alexandre Julliard
Mar 10, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mfplat: Properly align system memory buffers.
Signed-off-by:
Nikolay Sivov
<
nsivov@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
288a1024
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
3 deletions
+60
-3
buffer.c
dlls/mfplat/buffer.c
+22
-2
mfplat.c
dlls/mfplat/tests/mfplat.c
+38
-1
No files found.
dlls/mfplat/buffer.c
View file @
0ecde550
...
...
@@ -18,6 +18,8 @@
#define COBJMACROS
#include <malloc.h>
#include "mfplat_private.h"
#include "rtworkq.h"
...
...
@@ -171,7 +173,7 @@ static ULONG WINAPI memory_buffer_Release(IMFMediaBuffer *iface)
}
DeleteCriticalSection
(
&
buffer
->
cs
);
free
(
buffer
->
_2d
.
linear_buffer
);
free
(
buffer
->
data
);
_aligned_
free
(
buffer
->
data
);
free
(
buffer
);
}
...
...
@@ -1254,8 +1256,26 @@ static const IMFDXGIBufferVtbl dxgi_buffer_vtbl =
static
HRESULT
memory_buffer_init
(
struct
buffer
*
buffer
,
DWORD
max_length
,
DWORD
alignment
,
const
IMFMediaBufferVtbl
*
vtbl
)
{
if
(
!
(
buffer
->
data
=
calloc
(
1
,
ALIGN_SIZE
(
max_length
,
alignment
))))
size_t
size
;
if
(
!
alignment
)
alignment
=
MF_64_BYTE_ALIGNMENT
;
alignment
++
;
if
(
alignment
&
(
alignment
-
1
))
{
alignment
--
;
alignment
|=
alignment
>>
1
;
alignment
|=
alignment
>>
2
;
alignment
|=
alignment
>>
4
;
alignment
|=
alignment
>>
8
;
alignment
|=
alignment
>>
16
;
alignment
++
;
}
size
=
ALIGN_SIZE
(
max_length
,
alignment
-
1
);
if
(
!
(
buffer
->
data
=
_aligned_malloc
(
size
,
alignment
)))
return
E_OUTOFMEMORY
;
memset
(
buffer
->
data
,
0
,
size
);
buffer
->
IMFMediaBuffer_iface
.
lpVtbl
=
vtbl
;
buffer
->
refcount
=
1
;
...
...
dlls/mfplat/tests/mfplat.c
View file @
0ecde550
...
...
@@ -2287,8 +2287,25 @@ static void test_system_memory_buffer(void)
ok
(
hr
==
S_OK
,
"Unexpected hr %#lx.
\n
"
,
hr
);
IMFMediaBuffer_Release
(
buffer
);
}
static
void
test_system_memory_aligned_buffer
(
void
)
{
static
const
DWORD
alignments
[]
=
{
MF_16_BYTE_ALIGNMENT
,
MF_32_BYTE_ALIGNMENT
,
MF_64_BYTE_ALIGNMENT
,
MF_128_BYTE_ALIGNMENT
,
MF_256_BYTE_ALIGNMENT
,
MF_512_BYTE_ALIGNMENT
,
};
IMFMediaBuffer
*
buffer
;
DWORD
length
,
max
;
unsigned
int
i
;
BYTE
*
data
;
HRESULT
hr
;
/* Aligned buffer. */
hr
=
MFCreateAlignedMemoryBuffer
(
16
,
MF_8_BYTE_ALIGNMENT
,
NULL
);
ok
(
FAILED
(
hr
),
"Unexpected hr %#lx.
\n
"
,
hr
);
...
...
@@ -2324,6 +2341,25 @@ static void test_system_memory_buffer(void)
ok
(
hr
==
S_OK
,
"Failed to unlock, hr %#lx.
\n
"
,
hr
);
IMFMediaBuffer_Release
(
buffer
);
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
alignments
);
++
i
)
{
hr
=
MFCreateAlignedMemoryBuffer
(
200
,
alignments
[
i
],
&
buffer
);
ok
(
hr
==
S_OK
,
"Failed to create memory buffer, hr %#lx.
\n
"
,
hr
);
hr
=
IMFMediaBuffer_Lock
(
buffer
,
&
data
,
&
max
,
&
length
);
ok
(
hr
==
S_OK
,
"Failed to lock, hr %#lx.
\n
"
,
hr
);
ok
(
max
==
200
&&
!
length
,
"Unexpected length.
\n
"
);
ok
(
!
((
uintptr_t
)
data
&
alignments
[
i
]),
"Data at %p is misaligned.
\n
"
,
data
);
hr
=
IMFMediaBuffer_Unlock
(
buffer
);
ok
(
hr
==
S_OK
,
"Failed to unlock, hr %#lx.
\n
"
,
hr
);
IMFMediaBuffer_Release
(
buffer
);
}
hr
=
MFCreateAlignedMemoryBuffer
(
200
,
0
,
&
buffer
);
ok
(
hr
==
S_OK
,
"Failed to create memory buffer, hr %#lx.
\n
"
,
hr
);
IMFMediaBuffer_Release
(
buffer
);
}
static
void
test_sample
(
void
)
...
...
@@ -7980,6 +8016,7 @@ START_TEST(mfplat)
test_file_stream
();
test_MFCreateMFByteStreamOnStream
();
test_system_memory_buffer
();
test_system_memory_aligned_buffer
();
test_source_resolver
();
test_MFCreateAsyncResult
();
test_allocate_queue
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment