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
ac4c1109
Commit
ac4c1109
authored
Apr 01, 2018
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make channel router API consistent with format converter.
parent
96815f43
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
45 deletions
+51
-45
mini_al.h
mini_al.h
+16
-29
tests/mal_test_0.c
tests/mal_test_0.c
+35
-16
No files found.
mini_al.h
View file @
ac4c1109
...
@@ -730,13 +730,13 @@ typedef struct
...
@@ -730,13 +730,13 @@ typedef struct
mal_channel
channelMapIn
[
MAL_MAX_CHANNELS
];
mal_channel
channelMapIn
[
MAL_MAX_CHANNELS
];
mal_channel
channelMapOut
[
MAL_MAX_CHANNELS
];
mal_channel
channelMapOut
[
MAL_MAX_CHANNELS
];
mal_channel_mix_mode
mixingMode
;
mal_channel_mix_mode
mixingMode
;
mal_channel_router_read_deinterleaved_proc
onReadDeinterleaved
;
void
*
pUserData
;
}
mal_channel_router_config
;
}
mal_channel_router_config
;
struct
mal_channel_router
struct
mal_channel_router
{
{
mal_channel_router_config
config
;
mal_channel_router_config
config
;
mal_channel_router_read_deinterleaved_proc onReadDeinterleaved;
void* pUserData;
mal_bool32
isPassthrough
:
1
;
mal_bool32
isPassthrough
:
1
;
mal_bool32
isSimpleShuffle
:
1
;
mal_bool32
isSimpleShuffle
:
1
;
mal_uint8
shuffleTable
[
MAL_MAX_CHANNELS
];
mal_uint8
shuffleTable
[
MAL_MAX_CHANNELS
];
...
@@ -1856,13 +1856,13 @@ mal_uint64 mal_format_converter_read_deinterleaved(mal_format_converter* pConver
...
@@ -1856,13 +1856,13 @@ mal_uint64 mal_format_converter_read_deinterleaved(mal_format_converter* pConver
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Initializes a channel router where it is assumed that the input data is non-interleaved.
// Initializes a channel router where it is assumed that the input data is non-interleaved.
mal_result mal_channel_router_init_deinterleaved(const mal_channel_router_config* pConfig, mal_channel_router
_read_deinterleaved_proc onRead, void* pUserData, mal_channel_router
* pRouter);
mal_result
mal_channel_router_init_deinterleaved
(
const
mal_channel_router_config
*
pConfig
,
mal_channel_router
*
pRouter
);
// Reads data from the channel router as deinterleaved channels.
// Reads data from the channel router as deinterleaved channels.
mal_uint64
mal_channel_router_read_deinterleaved
(
mal_channel_router
*
pRouter
,
mal_uint64
frameCount
,
void
**
ppSamplesOut
,
void
*
pUserData
);
mal_uint64
mal_channel_router_read_deinterleaved
(
mal_channel_router
*
pRouter
,
mal_uint64
frameCount
,
void
**
ppSamplesOut
,
void
*
pUserData
);
// Helper for initializing a channel router config.
// Helper for initializing a channel router config.
mal_channel_router_config mal_channel_router_config_init(mal_uint32 channelsIn, const mal_channel channelMapIn[MAL_MAX_CHANNELS], mal_uint32 channelsOut, const mal_channel channelMapOut[MAL_MAX_CHANNELS], mal_channel_mix_mode mixingMode);
mal_channel_router_config
mal_channel_router_config_init
(
mal_uint32
channelsIn
,
const
mal_channel
channelMapIn
[
MAL_MAX_CHANNELS
],
mal_uint32
channelsOut
,
const
mal_channel
channelMapOut
[
MAL_MAX_CHANNELS
],
mal_channel_mix_mode
mixingMode
,
mal_channel_router_read_deinterleaved_proc
onRead
,
void
*
pUserData
);
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
...
@@ -17421,7 +17421,7 @@ mal_bool32 mal_channel_router__is_spatial_channel_position(const mal_channel_rou
...
@@ -17421,7 +17421,7 @@ mal_bool32 mal_channel_router__is_spatial_channel_position(const mal_channel_rou
return
MAL_TRUE
;
return
MAL_TRUE
;
}
}
mal_result mal_channel_router_init_
_common(const mal_channel_router_config* pConfig, void* pUserData
, mal_channel_router* pRouter)
mal_result
mal_channel_router_init_
deinterleaved
(
const
mal_channel_router_config
*
pConfig
,
mal_channel_router
*
pRouter
)
{
{
if
(
pRouter
==
NULL
)
{
if
(
pRouter
==
NULL
)
{
return
MAL_INVALID_ARGS
;
return
MAL_INVALID_ARGS
;
...
@@ -17432,6 +17432,9 @@ mal_result mal_channel_router_init__common(const mal_channel_router_config* pCon
...
@@ -17432,6 +17432,9 @@ mal_result mal_channel_router_init__common(const mal_channel_router_config* pCon
if
(
pConfig
==
NULL
)
{
if
(
pConfig
==
NULL
)
{
return
MAL_INVALID_ARGS
;
return
MAL_INVALID_ARGS
;
}
}
if
(
pConfig
->
onReadDeinterleaved
==
NULL
)
{
return
MAL_INVALID_ARGS
;
}
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.
...
@@ -17441,7 +17444,6 @@ mal_result mal_channel_router_init__common(const mal_channel_router_config* pCon
...
@@ -17441,7 +17444,6 @@ mal_result mal_channel_router_init__common(const mal_channel_router_config* pCon
}
}
pRouter
->
config
=
*
pConfig
;
pRouter
->
config
=
*
pConfig
;
pRouter->pUserData = pUserData;
// If the input and output channels and channel maps are the same we should use a passthrough.
// If the input and output channels and channel maps are the same we should use a passthrough.
if
(
pRouter
->
config
.
channelsIn
==
pRouter
->
config
.
channelsOut
)
{
if
(
pRouter
->
config
.
channelsIn
==
pRouter
->
config
.
channelsOut
)
{
...
@@ -17628,23 +17630,6 @@ mal_result mal_channel_router_init__common(const mal_channel_router_config* pCon
...
@@ -17628,23 +17630,6 @@ mal_result mal_channel_router_init__common(const mal_channel_router_config* pCon
}
}
}
}
return MAL_SUCCESS;
}
mal_result mal_channel_router_init_deinterleaved(const mal_channel_router_config* pConfig, mal_channel_router_read_deinterleaved_proc onRead, void* pUserData, mal_channel_router* pRouter)
{
mal_result result = mal_channel_router_init__common(pConfig, pUserData, pRouter);
if (result != MAL_SUCCESS) {
return result;
}
if (onRead == NULL) {
return MAL_INVALID_ARGS;
}
pRouter->onReadDeinterleaved = onRead;
return
MAL_SUCCESS
;
return
MAL_SUCCESS
;
}
}
...
@@ -17688,7 +17673,7 @@ mal_uint64 mal_channel_router_read_deinterleaved(mal_channel_router* pRouter, ma
...
@@ -17688,7 +17673,7 @@ mal_uint64 mal_channel_router_read_deinterleaved(mal_channel_router* pRouter, ma
// Fast path for a passthrough.
// Fast path for a passthrough.
if
(
pRouter
->
isPassthrough
)
{
if
(
pRouter
->
isPassthrough
)
{
if
(
frameCount
<=
0xFFFFFFFF
)
{
if
(
frameCount
<=
0xFFFFFFFF
)
{
return (mal_uint32)pRouter->onReadDeinterleaved(pRouter, (mal_uint32)frameCount, ppSamplesOut, pUserData);
return
(
mal_uint32
)
pRouter
->
config
.
onReadDeinterleaved
(
pRouter
,
(
mal_uint32
)
frameCount
,
ppSamplesOut
,
pUserData
);
}
else
{
}
else
{
float
*
ppNextSamplesOut
[
MAL_MAX_CHANNELS
];
float
*
ppNextSamplesOut
[
MAL_MAX_CHANNELS
];
mal_copy_memory
(
ppNextSamplesOut
,
ppSamplesOut
,
sizeof
(
float
*
)
*
pRouter
->
config
.
channelsOut
);
mal_copy_memory
(
ppNextSamplesOut
,
ppSamplesOut
,
sizeof
(
float
*
)
*
pRouter
->
config
.
channelsOut
);
...
@@ -17701,7 +17686,7 @@ mal_uint64 mal_channel_router_read_deinterleaved(mal_channel_router* pRouter, ma
...
@@ -17701,7 +17686,7 @@ mal_uint64 mal_channel_router_read_deinterleaved(mal_channel_router* pRouter, ma
framesToReadRightNow
=
0xFFFFFFFF
;
framesToReadRightNow
=
0xFFFFFFFF
;
}
}
mal_uint32 framesJustRead = (mal_uint32)pRouter->onReadDeinterleaved(pRouter, (mal_uint32)framesToReadRightNow, (void**)ppNextSamplesOut, pUserData);
mal_uint32
framesJustRead
=
(
mal_uint32
)
pRouter
->
config
.
onReadDeinterleaved
(
pRouter
,
(
mal_uint32
)
framesToReadRightNow
,
(
void
**
)
ppNextSamplesOut
,
pUserData
);
if
(
framesJustRead
==
0
)
{
if
(
framesJustRead
==
0
)
{
break
;
break
;
}
}
...
@@ -17736,7 +17721,7 @@ mal_uint64 mal_channel_router_read_deinterleaved(mal_channel_router* pRouter, ma
...
@@ -17736,7 +17721,7 @@ mal_uint64 mal_channel_router_read_deinterleaved(mal_channel_router* pRouter, ma
framesToReadRightNow
=
maxFramesToReadEachIteration
;
framesToReadRightNow
=
maxFramesToReadEachIteration
;
}
}
mal_uint32 framesJustRead = pRouter->onReadDeinterleaved(pRouter, (mal_uint32)framesToReadRightNow, (void**)ppTemp, pUserData);
mal_uint32
framesJustRead
=
pRouter
->
config
.
onReadDeinterleaved
(
pRouter
,
(
mal_uint32
)
framesToReadRightNow
,
(
void
**
)
ppTemp
,
pUserData
);
if
(
framesJustRead
==
0
)
{
if
(
framesJustRead
==
0
)
{
break
;
break
;
}
}
...
@@ -17754,7 +17739,7 @@ mal_uint64 mal_channel_router_read_deinterleaved(mal_channel_router* pRouter, ma
...
@@ -17754,7 +17739,7 @@ mal_uint64 mal_channel_router_read_deinterleaved(mal_channel_router* pRouter, ma
return
totalFramesRead
;
return
totalFramesRead
;
}
}
mal_channel_router_config mal_channel_router_config_init(mal_uint32 channelsIn, const mal_channel channelMapIn[MAL_MAX_CHANNELS], mal_uint32 channelsOut, const mal_channel channelMapOut[MAL_MAX_CHANNELS], mal_channel_mix_mode mixingMode)
mal_channel_router_config
mal_channel_router_config_init
(
mal_uint32
channelsIn
,
const
mal_channel
channelMapIn
[
MAL_MAX_CHANNELS
],
mal_uint32
channelsOut
,
const
mal_channel
channelMapOut
[
MAL_MAX_CHANNELS
],
mal_channel_mix_mode
mixingMode
,
mal_channel_router_read_deinterleaved_proc
onRead
,
void
*
pUserData
)
{
{
mal_channel_router_config
config
;
mal_channel_router_config
config
;
mal_zero_object
(
&
config
);
mal_zero_object
(
&
config
);
...
@@ -17770,6 +17755,8 @@ mal_channel_router_config mal_channel_router_config_init(mal_uint32 channelsIn,
...
@@ -17770,6 +17755,8 @@ mal_channel_router_config mal_channel_router_config_init(mal_uint32 channelsIn,
}
}
config
.
mixingMode
=
mixingMode
;
config
.
mixingMode
=
mixingMode
;
config
.
onReadDeinterleaved
=
onRead
;
config
.
pUserData
=
pUserData
;
return
config
;
return
config
;
}
}
...
@@ -18905,8 +18892,8 @@ mal_result mal_dsp_init(const mal_dsp_config* pConfig, mal_dsp_read_proc onRead,
...
@@ -18905,8 +18892,8 @@ mal_result mal_dsp_init(const mal_dsp_config* pConfig, mal_dsp_read_proc onRead,
// Channel conversion
// Channel conversion
mal_channel_router_config routerConfig = mal_channel_router_config_init(pConfig->channelsIn, pConfig->channelMapIn, pConfig->channelsOut, pConfig->channelMapOut, pConfig->channelMixMode);
mal_channel_router_config
routerConfig
=
mal_channel_router_config_init
(
pConfig
->
channelsIn
,
pConfig
->
channelMapIn
,
pConfig
->
channelsOut
,
pConfig
->
channelMapOut
,
pConfig
->
channelMixMode
,
mal_dsp__channel_router_on_read
,
pDSP
);
result = mal_channel_router_init_deinterleaved(&routerConfig,
mal_dsp__channel_router_on_read, pDSP,
&pDSP->channelRouter);
result
=
mal_channel_router_init_deinterleaved
(
&
routerConfig
,
&
pDSP
->
channelRouter
);
if
(
result
!=
MAL_SUCCESS
)
{
if
(
result
!=
MAL_SUCCESS
)
{
return
result
;
return
result
;
}
}
...
...
tests/mal_test_0.c
View file @
ac4c1109
This diff is collapsed.
Click to expand it.
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