diff --git a/pulse/ctl_pulse.c b/pulse/ctl_pulse.c index 0b10628..8a5546c 100644 --- a/pulse/ctl_pulse.c +++ b/pulse/ctl_pulse.c @@ -728,14 +728,11 @@ SND_CTL_PLUGIN_DEFINE_FUNC(pulse) return 0; error: - if (ctl->source) - free(ctl->source); - if (ctl->sink) - free(ctl->sink); - if (ctl->p) pulse_free(ctl->p); + free(ctl->source); + free(ctl->sink); free(ctl); return err; diff --git a/pulse/pcm_pulse.c b/pulse/pcm_pulse.c index 9a50aff..3d15ff0 100644 --- a/pulse/pcm_pulse.c +++ b/pulse/pcm_pulse.c @@ -145,18 +145,15 @@ static int pulse_start(snd_pcm_ioplug_t * io) u = pa_stream_trigger(pcm->stream, pulse_stream_success_cb, pcm->p); - if (!u) { - pa_operation_unref(o); - err = -EIO; - goto finish; - } pcm->underrun = 0; err_o = pulse_wait_operation(pcm->p, o); - err_u = pulse_wait_operation(pcm->p, u); + if (u) + err_u = pulse_wait_operation(pcm->p, u); pa_operation_unref(o); - pa_operation_unref(u); + if (u) + pa_operation_unref(u); if (err_o < 0 || err_u < 0) { err = -EIO; @@ -917,6 +914,7 @@ error: if (pcm->p) pulse_free(pcm->p); + free(pcm->device); free(pcm); return err; diff --git a/pulse/pulse.c b/pulse/pulse.c index 617851e..3940238 100644 --- a/pulse/pulse.c +++ b/pulse/pulse.c @@ -188,9 +188,6 @@ snd_pulse_t *pulse_new(void) if (!p->mainloop) goto fail; - if (pa_threaded_mainloop_start(p->mainloop) < 0) - goto fail; - if (pa_get_binary_name(proc, sizeof(proc))) snprintf(buf, sizeof(buf), "ALSA plug-in [%s]", pa_path_get_filename(proc)); @@ -204,10 +201,19 @@ snd_pulse_t *pulse_new(void) pa_context_set_state_callback(p->context, context_state_cb, p); + if (pa_threaded_mainloop_start(p->mainloop) < 0) + goto fail; + return p; fail: if (p->mainloop) + pa_threaded_mainloop_stop(p->mainloop); + + if (p->context) + pa_context_unref(p->context); + + if (p->mainloop) pa_threaded_mainloop_free(p->mainloop); if (p->main_fd >= 0)