diff options
author | Simon Gomizelj <simongmzlj@gmail.com> | 2012-08-11 00:47:31 -0400 |
---|---|---|
committer | Simon Gomizelj <simongmzlj@gmail.com> | 2012-08-11 03:24:17 -0400 |
commit | 1791a34332ab3dfaba362da5c96cad370f097aea (patch) | |
tree | 0cd65557b22e6c0c2abeebb7a173ad6919fd7546 | |
parent | 9c030ab19d695e8df258faf4330a9152b839b899 (diff) | |
download | mirror-ponymix-1791a34332ab3dfaba362da5c96cad370f097aea.tar.gz mirror-ponymix-1791a34332ab3dfaba362da5c96cad370f097aea.tar.bz2 mirror-ponymix-1791a34332ab3dfaba362da5c96cad370f097aea.zip |
name and desc should be copied to avoid corruption
-rw-r--r-- | pulsemix.c | 22 |
1 files changed, 10 insertions, 12 deletions
@@ -78,8 +78,8 @@ enum type { struct io_t { enum type type; uint32_t idx; - const char *name; - const char *desc; + char *name; + char *desc; pa_cvolume volume; int volume_percent; int mute; @@ -121,8 +121,8 @@ static struct io_t *sink_new(const pa_sink_info *info) sink->type = TYPE_SINK; sink->idx = info->index; - sink->name = info->name; - sink->desc = info->description; + sink->name = strdup(info->name); + sink->desc = strdup(info->description); memcpy(&sink->volume, &info->volume, sizeof(pa_cvolume)); sink->volume_percent = (int)(((double)pa_cvolume_avg(&sink->volume) * 100) / PA_VOLUME_NORM); @@ -138,20 +138,16 @@ static void sink_add_cb(pa_context UNUSED *c, const pa_sink_info *i, int eol, void *raw) { struct pulseaudio_t *pulse = raw; - struct io_t *s, *sink; + struct io_t *sink; if (eol) return; sink = sink_new(i); - if (pulse->head == NULL) - pulse->head = sink; - else { - s = pulse->head; - sink->next = s; - pulse->head = sink; - } + if (pulse->head != NULL) + sink->next = pulse->head; + pulse->head = sink; } static void server_info_cb(pa_context UNUSED *c, const pa_server_info *i, @@ -332,6 +328,8 @@ static void pulse_deinit(struct pulseaudio_t *pulse) while (node) { node = pulse->head->next; + free(pulse->head->name); + free(pulse->head->desc); free(pulse->head); pulse->head = node; } |