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
77751bd0
Commit
77751bd0
authored
Nov 11, 2017
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ALSA: Fix an error with channel mapping.
parent
5aadfef8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
3 deletions
+33
-3
mini_al.h
mini_al.h
+33
-3
No files found.
mini_al.h
View file @
77751bd0
...
@@ -6018,9 +6018,39 @@ static mal_result mal_device_init__alsa(mal_context* pContext, mal_device_type t
...
@@ -6018,9 +6018,39 @@ static mal_result mal_device_init__alsa(mal_context* pContext, mal_device_type t
// instead just do it ourselves.
// instead just do it ourselves.
snd_pcm_chmap_t
*
pChmap
=
((
mal_snd_pcm_get_chmap_proc
)
pContext
->
alsa
.
snd_pcm_get_chmap
)((
snd_pcm_t
*
)
pDevice
->
alsa
.
pPCM
);
snd_pcm_chmap_t
*
pChmap
=
((
mal_snd_pcm_get_chmap_proc
)
pContext
->
alsa
.
snd_pcm_get_chmap
)((
snd_pcm_t
*
)
pDevice
->
alsa
.
pPCM
);
if
(
pChmap
!=
NULL
)
{
if
(
pChmap
!=
NULL
)
{
mal_assert
(
pChmap
->
channels
==
pDevice
->
internalChannels
);
// There are cases where the returned channel map can have a different channel count than was returned by snd_pcm_hw_params_set_channels_near().
for
(
mal_uint32
iChannel
=
0
;
iChannel
<
pDevice
->
internalChannels
;
++
iChannel
)
{
if
(
pChmap
->
channels
>=
pDevice
->
internalChannels
)
{
pDevice
->
internalChannelMap
[
iChannel
]
=
mal_convert_alsa_channel_position_to_mal_channel
(
pChmap
->
pos
[
iChannel
]);
// Drop excess channels.
for
(
mal_uint32
iChannel
=
0
;
iChannel
<
pDevice
->
internalChannels
;
++
iChannel
)
{
pDevice
->
internalChannelMap
[
iChannel
]
=
mal_convert_alsa_channel_position_to_mal_channel
(
pChmap
->
pos
[
iChannel
]);
}
}
else
{
// Excess channels use defaults. Do an initial fill with defaults, overwrite the first pChmap->channels, validate to ensure there are no duplicate
// channels. If validation fails, fall back to defaults.
// Fill with defaults.
mal_get_default_channel_mapping
(
pDevice
->
pContext
->
backend
,
pDevice
->
internalChannels
,
pDevice
->
internalChannelMap
);
// Overwrite first pChmap->channels channels.
for
(
mal_uint32
iChannel
=
0
;
iChannel
<
pChmap
->
channels
;
++
iChannel
)
{
pDevice
->
internalChannelMap
[
iChannel
]
=
mal_convert_alsa_channel_position_to_mal_channel
(
pChmap
->
pos
[
iChannel
]);
}
// Validate.
mal_bool32
isValid
=
MAL_TRUE
;
for
(
mal_uint32
i
=
0
;
i
<
pDevice
->
internalChannels
&&
isValid
;
++
i
)
{
for
(
mal_uint32
j
=
i
+
1
;
j
<
pDevice
->
internalChannels
;
++
j
)
{
if
(
pDevice
->
internalChannelMap
[
i
]
==
pDevice
->
internalChannelMap
[
j
])
{
isValid
=
MAL_FALSE
;
break
;
}
}
}
// If our channel map is invalid, fall back to defaults.
if
(
!
isValid
)
{
mal_get_default_channel_mapping
(
pDevice
->
pContext
->
backend
,
pDevice
->
internalChannels
,
pDevice
->
internalChannelMap
);
}
}
}
free
(
pChmap
);
free
(
pChmap
);
...
...
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