Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
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
Иван Мажукин
mpd
Commits
9f441f25
Commit
9f441f25
authored
Sep 23, 2008
by
Eric Wong
Committed by
Max Kellermann
Sep 23, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
oss: avoid heap allocations when configuring mixer
Noticed-by: Courtney Cavin
parent
d095d52e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
13 deletions
+13
-13
volume.c
src/volume.c
+13
-13
No files found.
src/volume.c
View file @
9f441f25
...
...
@@ -31,6 +31,7 @@
#ifdef HAVE_ALSA
#include <alsa/asoundlib.h>
#endif
#include <alloca.h>
#define VOLUME_MIXER_TYPE_SOFTWARE 0
#define VOLUME_MIXER_TYPE_OSS 1
...
...
@@ -75,6 +76,8 @@ static int volume_alsaSet = -1;
#ifdef HAVE_OSS
#include <alloca.h>
/* only alloca user in mpd atm, may change ... */
static
void
closeOssMixer
(
void
)
{
while
(
close
(
volume_ossFd
)
&&
errno
==
EINTR
)
;
...
...
@@ -90,12 +93,9 @@ static int prepOssMixer(const char *device)
return
-
1
;
}
param
=
getConfigParam
(
CONF_MIXER_CONTROL
);
if
(
param
)
{
if
((
param
=
getConfigParam
(
CONF_MIXER_CONTROL
)))
{
const
char
*
labels
[
SOUND_MIXER_NRDEVICES
]
=
SOUND_DEVICE_LABELS
;
char
*
duplicated
;
int
i
,
j
;
int
i
;
int
devmask
=
0
;
if
(
ioctl
(
volume_ossFd
,
SOUND_MIXER_READ_DEVMASK
,
&
devmask
)
<
0
)
{
...
...
@@ -105,16 +105,16 @@ static int prepOssMixer(const char *device)
}
for
(
i
=
0
;
i
<
SOUND_MIXER_NRDEVICES
;
i
++
)
{
duplicated
=
xstrdup
(
labels
[
i
]);
ssize_t
len
=
strlen
(
labels
[
i
]);
char
*
duplicated
=
alloca
(
len
+
1
);
/* eliminate spaces at the end */
j
=
strlen
(
duplicated
)
-
1
;
while
(
j
>=
0
&&
duplicated
[
j
]
==
' '
)
duplicated
[
j
--
]
=
'\0'
;
if
(
strcasecmp
(
duplicated
,
param
->
value
)
==
0
)
{
free
(
duplicated
);
memcpy
(
duplicated
,
labels
[
i
],
len
+
1
)
;
len
-=
2
;
while
(
len
>=
0
&&
duplicated
[
len
]
==
' '
)
duplicated
[
len
--
]
=
'\0'
;
if
(
strcasecmp
(
duplicated
,
param
->
value
)
==
0
)
break
;
}
free
(
duplicated
);
}
if
(
i
>=
SOUND_MIXER_NRDEVICES
)
{
...
...
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