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
322688d7
Commit
322688d7
authored
Mar 31, 2018
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix a bad input validation check.
parent
72b28cc0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
115 additions
and
15 deletions
+115
-15
mini_al.h
mini_al.h
+1
-1
tests/mal_test_0.c
tests/mal_test_0.c
+114
-14
No files found.
mini_al.h
View file @
322688d7
...
@@ -17446,7 +17446,7 @@ mal_result mal_channel_router_init__common(const mal_channel_router_config* pCon
...
@@ -17446,7 +17446,7 @@ mal_result mal_channel_router_init__common(const mal_channel_router_config* pCon
if (!mal_channel_map_valid(pConfig->channelsIn, pConfig->channelMapIn)) {
if (!mal_channel_map_valid(pConfig->channelsIn, pConfig->channelMapIn)) {
return MAL_INVALID_ARGS; // Invalid input channel map.
return MAL_INVALID_ARGS; // Invalid input channel map.
}
}
if (!mal_channel_map_valid(pConfig->channels
In
, pConfig->channelMapOut)) {
if (!mal_channel_map_valid(pConfig->channels
Out
, pConfig->channelMapOut)) {
return MAL_INVALID_ARGS; // Invalid output channel map.
return MAL_INVALID_ARGS; // Invalid output channel map.
}
}
...
...
tests/mal_test_0.c
View file @
322688d7
...
@@ -1290,7 +1290,6 @@ int do_channel_routing_tests()
...
@@ -1290,7 +1290,6 @@ int do_channel_routing_tests()
mal_channel_router
router
;
mal_channel_router
router
;
mal_result
result
=
mal_channel_router_init_separated
(
&
routerConfig
,
channel_router_callback__passthrough_test
,
NULL
,
&
router
);
mal_result
result
=
mal_channel_router_init_separated
(
&
routerConfig
,
channel_router_callback__passthrough_test
,
NULL
,
&
router
);
if
(
result
==
MAL_SUCCESS
)
{
if
(
result
==
MAL_SUCCESS
)
{
// Expecing a passthrough.
if
(
!
router
.
isPassthrough
)
{
if
(
!
router
.
isPassthrough
)
{
printf
(
"Failed to init router as passthrough.
\n
"
);
printf
(
"Failed to init router as passthrough.
\n
"
);
hasError
=
MAL_TRUE
;
hasError
=
MAL_TRUE
;
...
@@ -1338,7 +1337,6 @@ int do_channel_routing_tests()
...
@@ -1338,7 +1337,6 @@ int do_channel_routing_tests()
mal_channel_router
router
;
mal_channel_router
router
;
mal_result
result
=
mal_channel_router_init_separated
(
&
routerConfig
,
channel_router_callback__passthrough_test
,
NULL
,
&
router
);
mal_result
result
=
mal_channel_router_init_separated
(
&
routerConfig
,
channel_router_callback__passthrough_test
,
NULL
,
&
router
);
if
(
result
==
MAL_SUCCESS
)
{
if
(
result
==
MAL_SUCCESS
)
{
// Expecing a shuffle, but not a passthrough.
if
(
router
.
isPassthrough
)
{
if
(
router
.
isPassthrough
)
{
printf
(
"Router incorrectly configured as a passthrough.
\n
"
);
printf
(
"Router incorrectly configured as a passthrough.
\n
"
);
hasError
=
MAL_TRUE
;
hasError
=
MAL_TRUE
;
...
@@ -1388,7 +1386,6 @@ int do_channel_routing_tests()
...
@@ -1388,7 +1386,6 @@ int do_channel_routing_tests()
mal_channel_router
router
;
mal_channel_router
router
;
mal_result
result
=
mal_channel_router_init_separated
(
&
routerConfig
,
channel_router_callback__passthrough_test
,
NULL
,
&
router
);
mal_result
result
=
mal_channel_router_init_separated
(
&
routerConfig
,
channel_router_callback__passthrough_test
,
NULL
,
&
router
);
if
(
result
==
MAL_SUCCESS
)
{
if
(
result
==
MAL_SUCCESS
)
{
// Expecing a shuffle, but not a passthrough.
if
(
router
.
isPassthrough
)
{
if
(
router
.
isPassthrough
)
{
printf
(
"Router incorrectly configured as a passthrough.
\n
"
);
printf
(
"Router incorrectly configured as a passthrough.
\n
"
);
hasError
=
MAL_TRUE
;
hasError
=
MAL_TRUE
;
...
@@ -1435,7 +1432,6 @@ int do_channel_routing_tests()
...
@@ -1435,7 +1432,6 @@ int do_channel_routing_tests()
mal_channel_router
router
;
mal_channel_router
router
;
mal_result
result
=
mal_channel_router_init_separated
(
&
routerConfig
,
channel_router_callback__passthrough_test
,
NULL
,
&
router
);
mal_result
result
=
mal_channel_router_init_separated
(
&
routerConfig
,
channel_router_callback__passthrough_test
,
NULL
,
&
router
);
if
(
result
==
MAL_SUCCESS
)
{
if
(
result
==
MAL_SUCCESS
)
{
// Expecing a shuffle, but not a passthrough.
if
(
router
.
isPassthrough
)
{
if
(
router
.
isPassthrough
)
{
printf
(
"Router incorrectly configured as a passthrough.
\n
"
);
printf
(
"Router incorrectly configured as a passthrough.
\n
"
);
hasError
=
MAL_TRUE
;
hasError
=
MAL_TRUE
;
...
@@ -1493,7 +1489,6 @@ int do_channel_routing_tests()
...
@@ -1493,7 +1489,6 @@ int do_channel_routing_tests()
mal_channel_router
router
;
mal_channel_router
router
;
mal_result
result
=
mal_channel_router_init_separated
(
&
routerConfig
,
channel_router_callback__passthrough_test
,
NULL
,
&
router
);
mal_result
result
=
mal_channel_router_init_separated
(
&
routerConfig
,
channel_router_callback__passthrough_test
,
NULL
,
&
router
);
if
(
result
==
MAL_SUCCESS
)
{
if
(
result
==
MAL_SUCCESS
)
{
// Expecing a shuffle, but not a passthrough.
if
(
router
.
isPassthrough
)
{
if
(
router
.
isPassthrough
)
{
printf
(
"Router incorrectly configured as a passthrough.
\n
"
);
printf
(
"Router incorrectly configured as a passthrough.
\n
"
);
hasError
=
MAL_TRUE
;
hasError
=
MAL_TRUE
;
...
@@ -1505,14 +1500,14 @@ int do_channel_routing_tests()
...
@@ -1505,14 +1500,14 @@ int do_channel_routing_tests()
float
expectedWeights
[
MAL_MAX_CHANNELS
][
MAL_MAX_CHANNELS
];
float
expectedWeights
[
MAL_MAX_CHANNELS
][
MAL_MAX_CHANNELS
];
mal_zero_memory
(
expectedWeights
,
sizeof
(
expectedWeights
));
mal_zero_memory
(
expectedWeights
,
sizeof
(
expectedWeights
));
expectedWeights
[
0
][
0
]
=
1
.
0
f
;
// FRONT_LEFT -> FRONT_LEFT
expectedWeights
[
0
][
0
]
=
1
.
0
f
;
// FRONT_LEFT
-> FRONT_LEFT
expectedWeights
[
0
][
1
]
=
0
.
0
f
;
// FRONT_LEFT -> FRONT_RIGHT
expectedWeights
[
0
][
1
]
=
0
.
0
f
;
// FRONT_LEFT
-> FRONT_RIGHT
expectedWeights
[
0
][
2
]
=
0
.
5
f
;
// FRONT_LEFT -> FRONT_CENTER
expectedWeights
[
0
][
2
]
=
0
.
5
f
;
// FRONT_LEFT
-> FRONT_CENTER
expectedWeights
[
0
][
3
]
=
0
.
0
f
;
// FRONT_LEFT -> LFE
expectedWeights
[
0
][
3
]
=
0
.
0
f
;
// FRONT_LEFT
-> LFE
expectedWeights
[
0
][
4
]
=
0
.
25
f
;
// FRONT_LEFT -> BACK_LEFT
expectedWeights
[
0
][
4
]
=
0
.
25
f
;
// FRONT_LEFT
-> BACK_LEFT
expectedWeights
[
0
][
5
]
=
0
.
0
f
;
// FRONT_LEFT -> BACK_RIGHT
expectedWeights
[
0
][
5
]
=
0
.
0
f
;
// FRONT_LEFT
-> BACK_RIGHT
expectedWeights
[
0
][
6
]
=
0
.
5
f
;
// FRONT_LEFT -> SIDE_LEFT
expectedWeights
[
0
][
6
]
=
0
.
5
f
;
// FRONT_LEFT
-> SIDE_LEFT
expectedWeights
[
0
][
7
]
=
0
.
0
f
;
// FRONT_LEFT -> SIDE_RIGHT
expectedWeights
[
0
][
7
]
=
0
.
0
f
;
// FRONT_LEFT
-> SIDE_RIGHT
expectedWeights
[
1
][
0
]
=
0
.
0
f
;
// FRONT_RIGHT -> FRONT_LEFT
expectedWeights
[
1
][
0
]
=
0
.
0
f
;
// FRONT_RIGHT -> FRONT_LEFT
expectedWeights
[
1
][
1
]
=
1
.
0
f
;
// FRONT_RIGHT -> FRONT_RIGHT
expectedWeights
[
1
][
1
]
=
1
.
0
f
;
// FRONT_RIGHT -> FRONT_RIGHT
expectedWeights
[
1
][
2
]
=
0
.
5
f
;
// FRONT_RIGHT -> FRONT_CENTER
expectedWeights
[
1
][
2
]
=
0
.
5
f
;
// FRONT_RIGHT -> FRONT_CENTER
...
@@ -1564,7 +1559,6 @@ int do_channel_routing_tests()
...
@@ -1564,7 +1559,6 @@ int do_channel_routing_tests()
mal_channel_router
router
;
mal_channel_router
router
;
mal_result
result
=
mal_channel_router_init_separated
(
&
routerConfig
,
channel_router_callback__passthrough_test
,
NULL
,
&
router
);
mal_result
result
=
mal_channel_router_init_separated
(
&
routerConfig
,
channel_router_callback__passthrough_test
,
NULL
,
&
router
);
if
(
result
==
MAL_SUCCESS
)
{
if
(
result
==
MAL_SUCCESS
)
{
// Expecing a shuffle, but not a passthrough.
if
(
router
.
isPassthrough
)
{
if
(
router
.
isPassthrough
)
{
printf
(
"Router incorrectly configured as a passthrough.
\n
"
);
printf
(
"Router incorrectly configured as a passthrough.
\n
"
);
hasError
=
MAL_TRUE
;
hasError
=
MAL_TRUE
;
...
@@ -1611,6 +1605,112 @@ int do_channel_routing_tests()
...
@@ -1611,6 +1605,112 @@ int do_channel_routing_tests()
}
}
}
}
printf
(
"Mono -> 2.1 + None... "
);
{
mal_channel_router_config
routerConfig
;
mal_zero_object
(
&
routerConfig
);
routerConfig
.
mixingMode
=
mal_channel_mix_mode_planar_blend
;
// Use very specific mappings for this test.
routerConfig
.
channelsIn
=
1
;
routerConfig
.
channelMapIn
[
0
]
=
MAL_CHANNEL_MONO
;
routerConfig
.
channelsOut
=
4
;
routerConfig
.
channelMapOut
[
0
]
=
MAL_CHANNEL_FRONT_LEFT
;
routerConfig
.
channelMapOut
[
1
]
=
MAL_CHANNEL_FRONT_RIGHT
;
routerConfig
.
channelMapOut
[
2
]
=
MAL_CHANNEL_NONE
;
routerConfig
.
channelMapOut
[
3
]
=
MAL_CHANNEL_LFE
;
mal_channel_router
router
;
mal_result
result
=
mal_channel_router_init_separated
(
&
routerConfig
,
channel_router_callback__passthrough_test
,
NULL
,
&
router
);
if
(
result
==
MAL_SUCCESS
)
{
if
(
router
.
isPassthrough
)
{
printf
(
"Router incorrectly configured as a passthrough.
\n
"
);
hasError
=
MAL_TRUE
;
}
if
(
router
.
isSimpleShuffle
)
{
printf
(
"Router incorrectly configured as a simple shuffle.
\n
"
);
hasError
=
MAL_TRUE
;
}
float
expectedWeights
[
MAL_MAX_CHANNELS
][
MAL_MAX_CHANNELS
];
mal_zero_memory
(
expectedWeights
,
sizeof
(
expectedWeights
));
expectedWeights
[
0
][
0
]
=
1
.
0
f
;
// MONO -> FRONT_LEFT
expectedWeights
[
0
][
1
]
=
1
.
0
f
;
// MONO -> FRONT_RIGHT
expectedWeights
[
0
][
2
]
=
0
.
0
f
;
// MONO -> NONE
expectedWeights
[
0
][
3
]
=
0
.
0
f
;
// MONO -> LFE
for
(
mal_uint32
iChannelIn
=
0
;
iChannelIn
<
routerConfig
.
channelsIn
;
++
iChannelIn
)
{
for
(
mal_uint32
iChannelOut
=
0
;
iChannelOut
<
routerConfig
.
channelsOut
;
++
iChannelOut
)
{
if
(
router
.
weights
[
iChannelIn
][
iChannelOut
]
!=
expectedWeights
[
iChannelIn
][
iChannelOut
])
{
printf
(
"Failed. Channel weight incorrect for [%d][%d]. Expected %f, got %f
\n
"
,
iChannelIn
,
iChannelOut
,
expectedWeights
[
iChannelIn
][
iChannelOut
],
router
.
weights
[
iChannelIn
][
iChannelOut
]);
hasError
=
MAL_TRUE
;
}
}
}
}
else
{
printf
(
"Failed to init router.
\n
"
);
hasError
=
MAL_TRUE
;
}
if
(
!
hasError
)
{
printf
(
"PASSED
\n
"
);
}
}
printf
(
"2.1 + None -> Mono... "
);
{
mal_channel_router_config
routerConfig
;
mal_zero_object
(
&
routerConfig
);
routerConfig
.
mixingMode
=
mal_channel_mix_mode_planar_blend
;
// Use very specific mappings for this test.
routerConfig
.
channelsIn
=
4
;
routerConfig
.
channelMapIn
[
0
]
=
MAL_CHANNEL_FRONT_LEFT
;
routerConfig
.
channelMapIn
[
1
]
=
MAL_CHANNEL_FRONT_RIGHT
;
routerConfig
.
channelMapIn
[
2
]
=
MAL_CHANNEL_NONE
;
routerConfig
.
channelMapIn
[
3
]
=
MAL_CHANNEL_LFE
;
routerConfig
.
channelsOut
=
1
;
routerConfig
.
channelMapOut
[
0
]
=
MAL_CHANNEL_MONO
;
mal_channel_router
router
;
mal_result
result
=
mal_channel_router_init_separated
(
&
routerConfig
,
channel_router_callback__passthrough_test
,
NULL
,
&
router
);
if
(
result
==
MAL_SUCCESS
)
{
if
(
router
.
isPassthrough
)
{
printf
(
"Router incorrectly configured as a passthrough.
\n
"
);
hasError
=
MAL_TRUE
;
}
if
(
router
.
isSimpleShuffle
)
{
printf
(
"Router incorrectly configured as a simple shuffle.
\n
"
);
hasError
=
MAL_TRUE
;
}
float
expectedWeights
[
MAL_MAX_CHANNELS
][
MAL_MAX_CHANNELS
];
mal_zero_memory
(
expectedWeights
,
sizeof
(
expectedWeights
));
expectedWeights
[
0
][
0
]
=
0
.
5
f
;
// FRONT_LEFT -> MONO
expectedWeights
[
1
][
0
]
=
0
.
5
f
;
// FRONT_RIGHT -> MONO
expectedWeights
[
2
][
0
]
=
0
.
0
f
;
// NONE -> MONO
expectedWeights
[
3
][
0
]
=
0
.
0
f
;
// LFE -> MONO
for
(
mal_uint32
iChannelIn
=
0
;
iChannelIn
<
routerConfig
.
channelsIn
;
++
iChannelIn
)
{
for
(
mal_uint32
iChannelOut
=
0
;
iChannelOut
<
routerConfig
.
channelsOut
;
++
iChannelOut
)
{
if
(
router
.
weights
[
iChannelIn
][
iChannelOut
]
!=
expectedWeights
[
iChannelIn
][
iChannelOut
])
{
printf
(
"Failed. Channel weight incorrect for [%d][%d]. Expected %f, got %f
\n
"
,
iChannelIn
,
iChannelOut
,
expectedWeights
[
iChannelIn
][
iChannelOut
],
router
.
weights
[
iChannelIn
][
iChannelOut
]);
hasError
=
MAL_TRUE
;
}
}
}
}
else
{
printf
(
"Failed to init router.
\n
"
);
hasError
=
MAL_TRUE
;
}
if
(
!
hasError
)
{
printf
(
"PASSED
\n
"
);
}
}
if
(
hasError
)
{
if
(
hasError
)
{
return
-
1
;
return
-
1
;
...
...
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