Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
miniaudio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
miniaudio
Commits
35ce972b
Commit
35ce972b
authored
Jul 04, 2021
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure heap layouts are aligned properly.
parent
ebaa74d6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
9 deletions
+15
-9
research/miniaudio_engine.h
research/miniaudio_engine.h
+15
-9
No files found.
research/miniaudio_engine.h
View file @
35ce972b
...
@@ -2378,6 +2378,9 @@ MA_API float ma_delay_node_get_decay(const ma_delay_node* pDelayNode);
...
@@ -2378,6 +2378,9 @@ MA_API float ma_delay_node_get_decay(const ma_delay_node* pDelayNode);
#if defined(MA_IMPLEMENTATION) || defined(MINIAUDIO_IMPLEMENTATION)
#if defined(MA_IMPLEMENTATION) || defined(MINIAUDIO_IMPLEMENTATION)
#define ma_align(x, a) ((x + (a-1)) & ~(a-1))
#define ma_align_64(x) ma_align(x, 8)
MA_API
ma_result
ma_paged_audio_buffer_data_init
(
ma_format
format
,
ma_uint32
channels
,
ma_paged_audio_buffer_data
*
pData
)
MA_API
ma_result
ma_paged_audio_buffer_data_init
(
ma_format
format
,
ma_uint32
channels
,
ma_paged_audio_buffer_data
*
pData
)
{
{
if
(
pData
==
NULL
)
{
if
(
pData
==
NULL
)
{
...
@@ -2825,6 +2828,9 @@ static ma_result ma_gainer_get_heap_layout(const ma_gainer_config* pConfig, ma_g
...
@@ -2825,6 +2828,9 @@ static ma_result ma_gainer_get_heap_layout(const ma_gainer_config* pConfig, ma_g
pHeapLayout
->
newGainsOffset
=
pHeapLayout
->
sizeInBytes
;
pHeapLayout
->
newGainsOffset
=
pHeapLayout
->
sizeInBytes
;
pHeapLayout
->
sizeInBytes
+=
sizeof
(
float
)
*
pConfig
->
channels
;
pHeapLayout
->
sizeInBytes
+=
sizeof
(
float
)
*
pConfig
->
channels
;
/* Alignment. */
pHeapLayout
->
sizeInBytes
=
ma_align_64
(
pHeapLayout
->
sizeInBytes
);
return
MA_SUCCESS
;
return
MA_SUCCESS
;
}
}
...
@@ -4306,7 +4312,7 @@ static ma_result ma_node_get_heap_layout(const ma_node_config* pConfig, ma_node_
...
@@ -4306,7 +4312,7 @@ static ma_result ma_node_get_heap_layout(const ma_node_config* pConfig, ma_node_
/* Input buses. */
/* Input buses. */
if
(
inputBusCount
>
MA_MAX_NODE_LOCAL_BUS_COUNT
)
{
if
(
inputBusCount
>
MA_MAX_NODE_LOCAL_BUS_COUNT
)
{
pHeapLayout
->
inputBusOffset
=
pHeapLayout
->
sizeInBytes
;
pHeapLayout
->
inputBusOffset
=
pHeapLayout
->
sizeInBytes
;
pHeapLayout
->
sizeInBytes
+=
sizeof
(
ma_node_input_bus
)
*
inputBusCount
;
pHeapLayout
->
sizeInBytes
+=
ma_align_64
(
sizeof
(
ma_node_input_bus
)
*
inputBusCount
)
;
}
else
{
}
else
{
pHeapLayout
->
inputBusOffset
=
MA_SIZE_MAX
;
/* MA_SIZE_MAX indicates that no heap allocation is required for the input bus. */
pHeapLayout
->
inputBusOffset
=
MA_SIZE_MAX
;
/* MA_SIZE_MAX indicates that no heap allocation is required for the input bus. */
}
}
...
@@ -4314,7 +4320,7 @@ static ma_result ma_node_get_heap_layout(const ma_node_config* pConfig, ma_node_
...
@@ -4314,7 +4320,7 @@ static ma_result ma_node_get_heap_layout(const ma_node_config* pConfig, ma_node_
/* Output buses. */
/* Output buses. */
if
(
outputBusCount
>
MA_MAX_NODE_LOCAL_BUS_COUNT
)
{
if
(
outputBusCount
>
MA_MAX_NODE_LOCAL_BUS_COUNT
)
{
pHeapLayout
->
outputBusOffset
=
pHeapLayout
->
sizeInBytes
;
pHeapLayout
->
outputBusOffset
=
pHeapLayout
->
sizeInBytes
;
pHeapLayout
->
sizeInBytes
+=
sizeof
(
ma_node_output_bus
)
*
outputBusCount
;
pHeapLayout
->
sizeInBytes
+=
ma_align_64
(
sizeof
(
ma_node_output_bus
)
*
outputBusCount
)
;
}
else
{
}
else
{
pHeapLayout
->
outputBusOffset
=
MA_SIZE_MAX
;
pHeapLayout
->
outputBusOffset
=
MA_SIZE_MAX
;
}
}
...
@@ -4354,7 +4360,7 @@ static ma_result ma_node_get_heap_layout(const ma_node_config* pConfig, ma_node_
...
@@ -4354,7 +4360,7 @@ static ma_result ma_node_get_heap_layout(const ma_node_config* pConfig, ma_node_
}
}
pHeapLayout
->
cachedDataOffset
=
pHeapLayout
->
sizeInBytes
;
pHeapLayout
->
cachedDataOffset
=
pHeapLayout
->
sizeInBytes
;
pHeapLayout
->
sizeInBytes
+=
cachedDataSizeInBytes
;
pHeapLayout
->
sizeInBytes
+=
ma_align_64
(
cachedDataSizeInBytes
)
;
}
}
...
@@ -10991,7 +10997,7 @@ static ma_result ma_spatializer_listener_get_heap_layout(const ma_spatializer_li
...
@@ -10991,7 +10997,7 @@ static ma_result ma_spatializer_listener_get_heap_layout(const ma_spatializer_li
/* Channel map. We always need this, even for passthroughs. */
/* Channel map. We always need this, even for passthroughs. */
pHeapLayout
->
channelMapOutOffset
=
pHeapLayout
->
sizeInBytes
;
pHeapLayout
->
channelMapOutOffset
=
pHeapLayout
->
sizeInBytes
;
pHeapLayout
->
sizeInBytes
+=
sizeof
(
*
pConfig
->
pChannelMapOut
)
*
pConfig
->
channelsOut
;
pHeapLayout
->
sizeInBytes
+=
ma_align_64
(
sizeof
(
*
pConfig
->
pChannelMapOut
)
*
pConfig
->
channelsOut
)
;
return
MA_SUCCESS
;
return
MA_SUCCESS
;
}
}
...
@@ -11306,12 +11312,12 @@ static ma_result ma_spatializer_get_heap_layout(const ma_spatializer_config* pCo
...
@@ -11306,12 +11312,12 @@ static ma_result ma_spatializer_get_heap_layout(const ma_spatializer_config* pCo
pHeapLayout
->
channelMapInOffset
=
MA_SIZE_MAX
;
/* <-- MA_SIZE_MAX indicates no allocation necessary. */
pHeapLayout
->
channelMapInOffset
=
MA_SIZE_MAX
;
/* <-- MA_SIZE_MAX indicates no allocation necessary. */
if
(
pConfig
->
pChannelMapIn
!=
NULL
)
{
if
(
pConfig
->
pChannelMapIn
!=
NULL
)
{
pHeapLayout
->
channelMapInOffset
=
pHeapLayout
->
sizeInBytes
;
pHeapLayout
->
channelMapInOffset
=
pHeapLayout
->
sizeInBytes
;
pHeapLayout
->
sizeInBytes
+=
sizeof
(
*
pConfig
->
pChannelMapIn
)
*
pConfig
->
channelsIn
;
pHeapLayout
->
sizeInBytes
+=
ma_align_64
(
sizeof
(
*
pConfig
->
pChannelMapIn
)
*
pConfig
->
channelsIn
)
;
}
}
/* New channel gains for output. */
/* New channel gains for output. */
pHeapLayout
->
newChannelGainsOffset
=
pHeapLayout
->
sizeInBytes
;
pHeapLayout
->
newChannelGainsOffset
=
pHeapLayout
->
sizeInBytes
;
pHeapLayout
->
sizeInBytes
+=
sizeof
(
float
)
*
pConfig
->
channelsOut
;
pHeapLayout
->
sizeInBytes
+=
ma_align_64
(
sizeof
(
float
)
*
pConfig
->
channelsOut
)
;
/* Gainer. */
/* Gainer. */
{
{
...
@@ -11326,7 +11332,7 @@ static ma_result ma_spatializer_get_heap_layout(const ma_spatializer_config* pCo
...
@@ -11326,7 +11332,7 @@ static ma_result ma_spatializer_get_heap_layout(const ma_spatializer_config* pCo
}
}
pHeapLayout
->
gainerOffset
=
pHeapLayout
->
sizeInBytes
;
pHeapLayout
->
gainerOffset
=
pHeapLayout
->
sizeInBytes
;
pHeapLayout
->
sizeInBytes
+=
gainerHeapSizeInBytes
;
pHeapLayout
->
sizeInBytes
+=
ma_align_64
(
gainerHeapSizeInBytes
)
;
}
}
return
MA_SUCCESS
;
return
MA_SUCCESS
;
...
@@ -12582,7 +12588,7 @@ static ma_result ma_engine_node_get_heap_layout(const ma_engine_node_config* pCo
...
@@ -12582,7 +12588,7 @@ static ma_result ma_engine_node_get_heap_layout(const ma_engine_node_config* pCo
}
}
pHeapLayout
->
baseNodeOffset
=
pHeapLayout
->
sizeInBytes
;
pHeapLayout
->
baseNodeOffset
=
pHeapLayout
->
sizeInBytes
;
pHeapLayout
->
sizeInBytes
+=
tempHeapSize
;
pHeapLayout
->
sizeInBytes
+=
ma_align_64
(
tempHeapSize
)
;
/* Spatializer. */
/* Spatializer. */
...
@@ -12594,7 +12600,7 @@ static ma_result ma_engine_node_get_heap_layout(const ma_engine_node_config* pCo
...
@@ -12594,7 +12600,7 @@ static ma_result ma_engine_node_get_heap_layout(const ma_engine_node_config* pCo
}
}
pHeapLayout
->
spatializerOffset
=
pHeapLayout
->
sizeInBytes
;
pHeapLayout
->
spatializerOffset
=
pHeapLayout
->
sizeInBytes
;
pHeapLayout
->
sizeInBytes
+=
tempHeapSize
;
pHeapLayout
->
sizeInBytes
+=
ma_align_64
(
tempHeapSize
)
;
return
MA_SUCCESS
;
return
MA_SUCCESS
;
...
...
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