aboutsummaryrefslogtreecommitdiff
path: root/src/volume.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/volume.c')
-rw-r--r--src/volume.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/src/volume.c b/src/volume.c
index b1f7f186..9fd33f01 100644
--- a/src/volume.c
+++ b/src/volume.c
@@ -79,8 +79,6 @@ 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) ;
@@ -91,17 +89,12 @@ static int
oss_find_mixer(const char *name)
{
const char *labels[SOUND_MIXER_NRDEVICES] = SOUND_DEVICE_LABELS;
+ size_t name_length = strlen(name);
for (unsigned i = 0; i < SOUND_MIXER_NRDEVICES; i++) {
- ssize_t len = strlen(labels[i]);
- char *duplicated = alloca(len + 1);
-
- /* eliminate spaces at the end */
- memcpy(duplicated, labels[i], len + 1);
- len -= 2;
- while (len >= 0 && duplicated[len] == ' ')
- duplicated[len--] = '\0';
- if (strcasecmp(duplicated, name) == 0)
+ if (strncasecmp(name, labels[i], name_length) == 0 &&
+ (labels[i][name_length] == 0 ||
+ labels[i][name_length] == ' '))
return i;
}