output/pulse: use _delete_context()

Eliminate duplicate code.
This commit is contained in:
Max Kellermann 2011-08-31 20:58:36 +02:00
parent 3d12d7de62
commit 042c1abc6e
1 changed files with 15 additions and 16 deletions

View File

@ -224,6 +224,20 @@ pulse_output_connect(struct pulse_output *po, GError **error_r)
return true;
}
/**
* Frees and clears the context.
*/
static void
pulse_output_delete_context(struct pulse_output *po)
{
assert(po != NULL);
assert(po->context != NULL);
pa_context_disconnect(po->context);
pa_context_unref(po->context);
po->context = NULL;
}
/**
* Create, set up and connect a context.
*
@ -249,28 +263,13 @@ pulse_output_setup_context(struct pulse_output *po, GError **error_r)
pulse_output_subscribe_cb, po);
if (!pulse_output_connect(po, error_r)) {
pa_context_unref(po->context);
po->context = NULL;
pulse_output_delete_context(po);
return false;
}
return true;
}
/**
* Frees and clears the context.
*/
static void
pulse_output_delete_context(struct pulse_output *po)
{
assert(po != NULL);
assert(po->context != NULL);
pa_context_disconnect(po->context);
pa_context_unref(po->context);
po->context = NULL;
}
static void *
pulse_output_init(G_GNUC_UNUSED const struct audio_format *audio_format,
const struct config_param *param,