diff options
author | Max Kellermann <max@duempel.org> | 2009-02-02 18:19:11 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-02-02 18:19:11 +0100 |
commit | 7a3628e797e1c86e1aa15f8211e090ad8ef1feb0 (patch) | |
tree | 1328436c9b4924ec2a853f38d25285e0985da0a6 /src/output | |
parent | 39f01632009e11a728afe440e58332b88490ba47 (diff) | |
download | mpd-7a3628e797e1c86e1aa15f8211e090ad8ef1feb0.tar.gz mpd-7a3628e797e1c86e1aa15f8211e090ad8ef1feb0.tar.xz mpd-7a3628e797e1c86e1aa15f8211e090ad8ef1feb0.zip |
shout_mp3: call lame_close() in clear_encoder() method
The shout_mp3 encoder had two bugs: when no song was ever played, MPD
segfaulted during cleanup. Second bug: memory leak, each time the
shout device was opened, lame_init() was called again, and
lame_close() is only called once during shutdown.
Fix this by shutting down LAME each time the clear_encoder() method is
called.
Diffstat (limited to 'src/output')
-rw-r--r-- | src/output/shout_mp3.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/output/shout_mp3.c b/src/output/shout_mp3.c index eb95c8b3e..1369f6c80 100644 --- a/src/output/shout_mp3.c +++ b/src/output/shout_mp3.c @@ -19,6 +19,8 @@ #include "shout_plugin.h" #include <lame/lame.h> + +#include <assert.h> #include <stdlib.h> struct lame_data { @@ -45,6 +47,9 @@ static int shout_mp3_encoder_clear_encoder(struct shout_data *sd) buf->len)) < 0) g_warning("error flushing lame buffers\n"); + lame_close(ld->gfp); + ld->gfp = NULL; + return (ret > 0); } @@ -52,8 +57,7 @@ static void shout_mp3_encoder_finish(struct shout_data *sd) { struct lame_data *ld = (struct lame_data *)sd->encoder_data; - lame_close(ld->gfp); - ld->gfp = NULL; + assert(ld->gfp == NULL); g_free(ld); } |