diff options
author | wm4 <wm4@nowhere> | 2013-05-09 17:34:17 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-05-12 21:24:57 +0200 |
commit | 34a139d49533386c104edbc1b0ed226201989bb9 (patch) | |
tree | 04d09bff621b9f8297d55afdee97cb6aedc805b9 | |
parent | 5c0c141a55b1c2928119cb1cfc604ca77013725d (diff) | |
download | mpv-34a139d49533386c104edbc1b0ed226201989bb9.tar.bz2 mpv-34a139d49533386c104edbc1b0ed226201989bb9.tar.xz |
ao_pulse: move format setup code
-rw-r--r-- | audio/out/ao_pulse.c | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/audio/out/ao_pulse.c b/audio/out/ao_pulse.c index 72844c3185..9422fa319d 100644 --- a/audio/out/ao_pulse.c +++ b/audio/out/ao_pulse.c @@ -253,6 +253,33 @@ static int init(struct ao *ao, char *params) priv->broken_pause = true; } + if (!(priv->mainloop = pa_threaded_mainloop_new())) { + mp_msg(MSGT_AO, MSGL_ERR, "AO: [pulse] Failed to allocate main loop\n"); + goto fail; + } + + if (!(priv->context = pa_context_new(pa_threaded_mainloop_get_api( + priv->mainloop), PULSE_CLIENT_NAME))) { + mp_msg(MSGT_AO, MSGL_ERR, "AO: [pulse] Failed to allocate context\n"); + goto fail; + } + + pa_context_set_state_callback(priv->context, context_state_cb, ao); + + if (pa_context_connect(priv->context, host, 0, NULL) < 0) + goto fail; + + pa_threaded_mainloop_lock(priv->mainloop); + + if (pa_threaded_mainloop_start(priv->mainloop) < 0) + goto unlock_and_fail; + + /* Wait until the context is ready */ + pa_threaded_mainloop_wait(priv->mainloop); + + if (pa_context_get_state(priv->context) != PA_CONTEXT_READY) + goto unlock_and_fail; + ss.channels = ao->channels.num; ss.rate = ao->samplerate; @@ -287,33 +314,6 @@ static int init(struct ao *ao, char *params) ao->bps = pa_bytes_per_second(&ss); - if (!(priv->mainloop = pa_threaded_mainloop_new())) { - mp_msg(MSGT_AO, MSGL_ERR, "AO: [pulse] Failed to allocate main loop\n"); - goto fail; - } - - if (!(priv->context = pa_context_new(pa_threaded_mainloop_get_api( - priv->mainloop), PULSE_CLIENT_NAME))) { - mp_msg(MSGT_AO, MSGL_ERR, "AO: [pulse] Failed to allocate context\n"); - goto fail; - } - - pa_context_set_state_callback(priv->context, context_state_cb, ao); - - if (pa_context_connect(priv->context, host, 0, NULL) < 0) - goto fail; - - pa_threaded_mainloop_lock(priv->mainloop); - - if (pa_threaded_mainloop_start(priv->mainloop) < 0) - goto unlock_and_fail; - - /* Wait until the context is ready */ - pa_threaded_mainloop_wait(priv->mainloop); - - if (pa_context_get_state(priv->context) != PA_CONTEXT_READY) - goto unlock_and_fail; - if (!(priv->stream = pa_stream_new(priv->context, "audio stream", &ss, &map))) goto unlock_and_fail; |