festival: don't leak rendered sample buffers.
authorKrisztian Litkey <kli@iki.fi>
Fri, 18 Apr 2014 20:51:01 +0000 (23:51 +0300)
committerKrisztian Litkey <kli@iki.fi>
Fri, 18 Apr 2014 20:51:01 +0000 (23:51 +0300)
src/plugins/text-to-speech/festival/festival-voice.c
src/plugins/text-to-speech/festival/pulse.c

index fd2d0fb..cbdd522 100644 (file)
@@ -77,10 +77,13 @@ static uint32_t festival_render(const char *msg, char **tags, int actor,
     if (carnival_synthesize(msg, &samples, &srate, &nchannel, &nsample) != 0)
         return SRS_VOICE_INVALID;
     else
-        return pulse_play_stream(f, samples, srate, nchannel, nsample, tags,
-                                 notify_events, stream_event_cb, NULL);
+        id = pulse_play_stream(f, samples, srate, nchannel, nsample, tags,
+                               notify_events, stream_event_cb, NULL);
 
-    return 0;
+    if (id == SRS_VOICE_INVALID)
+        mrp_free(samples);
+
+    return id;
 }
 
 
index bf17998..be6dd5d 100644 (file)
@@ -108,6 +108,8 @@ static void stream_destroy(stream_t *s)
         pa_stream_disconnect(s->s);
         pa_stream_unref(s->s);
         s->s = NULL;
+        mrp_free(s->buf);
+        s->buf = NULL;
     }
 
     mrp_free(s);