diff options
author | Eric Wong <normalperson@yhbt.net> | 2006-07-30 03:43:38 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2006-07-30 03:43:38 +0000 |
commit | 4cf5d04ca15bc28ee4636d1dccb858763513e571 (patch) | |
tree | 7898902e786f5763643a513ea96bcada8a2559cc /src/volume.c | |
parent | 4d5b8509eb46cff40890b781018669233a79e414 (diff) |
interface/connection malloc reductions from mpd-ke
This patch massively reduces the amount of heap allocations at
the interface/command layer. Most commands with minimal output
should not allocate memory from the heap at all. Things like
repeatedly polling status, currentsong, and volume changes
should be faster as a result, and more importantly, not a source
of memory fragmentation.
These changes should be safe in that there's no way for a
remote-client to corrupt memory or otherwise do bad stuff to
MPD, but an extra set of eyes to review would be good. Of
course there's never any warranty :)
No longer do we use FILE * structures in the interface, which means
we don't have to allocate any new memory for most connections.
Now, before you go on about losing the buffering that FILE *
+implies+, remember that myfprintf() never took advantage of
any of the stdio buffering features.
To reduce the diff and make bugs easier to spot in the diff,
I've kept myfprintf in places where we write to files (and not
network interfaces). Expect myfprintf to go away entirely soon
(we'll use fprintf for writing regular files).
git-svn-id: https://svn.musicpd.org/mpd/trunk@4483 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/volume.c')
-rw-r--r-- | src/volume.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/volume.c b/src/volume.c index 32b56bd66..adff103ad 100644 --- a/src/volume.c +++ b/src/volume.c @@ -169,7 +169,7 @@ static int getOssVolumeLevel(void) return left; } -static int changeOssVolumeLevel(FILE * fp, int change, int rel) +static int changeOssVolumeLevel(int fd, int change, int rel) { int current; int new; @@ -177,7 +177,7 @@ static int changeOssVolumeLevel(FILE * fp, int change, int rel) if (rel) { if ((current = getOssVolumeLevel()) < 0) { - commandError(fp, ACK_ERROR_SYSTEM, + commandError(fd, ACK_ERROR_SYSTEM, "problem getting current volume", NULL); return -1; } @@ -198,7 +198,7 @@ static int changeOssVolumeLevel(FILE * fp, int change, int rel) if (ioctl(volume_ossFd, MIXER_WRITE(volume_ossControl), &level) < 0) { closeOssMixer(); - commandError(fp, ACK_ERROR_SYSTEM, "problems setting volume", + commandError(fd, ACK_ERROR_SYSTEM, "problems setting volume", NULL); return -1; } @@ -328,7 +328,7 @@ static int getAlsaVolumeLevel(void) return ret; } -static int changeAlsaVolumeLevel(FILE * fp, int change, int rel) +static int changeAlsaVolumeLevel(int fd, int change, int rel) { float vol; long level; @@ -361,7 +361,7 @@ static int changeAlsaVolumeLevel(FILE * fp, int change, int rel) if ((err = snd_mixer_selem_set_playback_volume_all(volume_alsaElem, level)) < 0) { - commandError(fp, ACK_ERROR_SYSTEM, "problems setting volume", + commandError(fd, ACK_ERROR_SYSTEM, "problems setting volume", NULL); WARNING("problems setting alsa volume: %s\n", snd_strerror(err)); @@ -471,7 +471,7 @@ int getVolumeLevel(void) } } -static int changeSoftwareVolume(FILE * fp, int change, int rel) +static int changeSoftwareVolume(int fd, int change, int rel) { int new = change; @@ -499,19 +499,19 @@ static int changeSoftwareVolume(FILE * fp, int change, int rel) return 0; } -int changeVolumeLevel(FILE * fp, int change, int rel) +int changeVolumeLevel(int fd, int change, int rel) { switch (volume_mixerType) { #ifdef HAVE_ALSA case VOLUME_MIXER_TYPE_ALSA: - return changeAlsaVolumeLevel(fp, change, rel); + return changeAlsaVolumeLevel(fd, change, rel); #endif #ifdef HAVE_OSS case VOLUME_MIXER_TYPE_OSS: - return changeOssVolumeLevel(fp, change, rel); + return changeOssVolumeLevel(fd, change, rel); #endif case VOLUME_MIXER_TYPE_SOFTWARE: - return changeSoftwareVolume(fp, change, rel); + return changeSoftwareVolume(fd, change, rel); default: return 0; break; |