From 596a9171c457771ba80b903acdebb7714391fecc Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 2 Oct 2014 10:13:14 +0200 Subject: Fix getMuted() to not actually *set* mute state. Fix out-of-memory segfault. --- src/audioio.cc | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/audioio.cc b/src/audioio.cc index eec9836..55e0b90 100644 --- a/src/audioio.cc +++ b/src/audioio.cc @@ -77,16 +77,13 @@ struct aio_t *aio_init(int *err, return NULL; } - struct aio_t *h = new aio_t; - memset(h, 0, sizeof(struct aio_t)); - h->magic = MAGIC; - - + struct aio_t *h = (struct aio_t*)calloc(sizeof(struct aio_t), 1); if(h == NULL) { *err = OUT_OF_MEMORY; return NULL; } + h->magic = MAGIC; h->device = new Device(device); if(playback_device != NULL && strlen(playback_device) > 0) { @@ -129,7 +126,7 @@ struct aio_t *aio_init(int *err, if(h->source_mixer) delete h->source_mixer; if(h->sink) delete h->sink; if(h->sink_mixer) delete h->sink_mixer; - delete h; + free(h); return NULL; } @@ -290,7 +287,7 @@ int aio_get_mute(struct aio_t *h, const char *name, int *muted) return NO_SUCH_CHANNEL; } - m->setMuted(muted); + *muted = m->muted()?1:0; return 0; } @@ -324,7 +321,7 @@ int aio_close(struct aio_t *h) if(h->source_mixer) delete h->source_mixer; if(h->sink) delete h->sink; if(h->sink_mixer) delete h->sink_mixer; - delete h; + free(h); return 0; } -- cgit v1.2.3