diff options
author | Dave Reisner <dreisner@archlinux.org> | 2012-08-14 18:08:37 -0400 |
---|---|---|
committer | Dave Reisner <dreisner@archlinux.org> | 2012-08-14 18:09:30 -0400 |
commit | 9424f1b4507accd1d323053691181b0307d1aca8 (patch) | |
tree | 235548067b20c410525682ec523c88b8d7981a43 | |
parent | 95452a7f21153e12a598a477b1af3feaa0605710 (diff) | |
download | mirror-ponymix-9424f1b4507accd1d323053691181b0307d1aca8.tar.gz mirror-ponymix-9424f1b4507accd1d323053691181b0307d1aca8.tar.bz2 mirror-ponymix-9424f1b4507accd1d323053691181b0307d1aca8.zip |
avoid reinventing wrapper around PA_CONTEXT_*
-rw-r--r-- | ponymix.c | 25 |
1 files changed, 5 insertions, 20 deletions
@@ -46,12 +46,6 @@ ((_x > _high) ? _high : ((_x < _low) ? _low : _x)); \ }) -enum connectstate { - STATE_CONNECTING = 0, - STATE_CONNECTED, - STATE_ERROR -}; - enum mode { MODE_DEVICE = 0, MODE_APP, @@ -293,17 +287,8 @@ static void source_info_cb(pa_context UNUSED *c, const pa_server_info *i, void * static void state_cb(pa_context *cxt, void *raw) { - enum connectstate *state = raw; - - switch (pa_context_get_state(cxt)) { - case PA_CONTEXT_READY: - *state = STATE_CONNECTED; - break; - case PA_CONTEXT_FAILED: - *state = STATE_ERROR; - default: - break; - } + enum pa_context_state *state = raw; + *state = pa_context_get_state(cxt); } static void success_cb(pa_context UNUSED *c, int success, void *raw) @@ -586,7 +571,7 @@ static int set_default(struct pulseaudio_t *pulse, struct io_t *dev) static int pulse_init(struct pulseaudio_t *pulse) { - enum connectstate state = STATE_CONNECTING; + enum pa_context_state state = PA_CONTEXT_CONNECTING; pulse->mainloop = pa_mainloop_new(); pulse->cxt = pa_context_new(pa_mainloop_get_api(pulse->mainloop), "bestpony"); @@ -594,10 +579,10 @@ static int pulse_init(struct pulseaudio_t *pulse) pa_context_set_state_callback(pulse->cxt, state_cb, &state); pa_context_connect(pulse->cxt, NULL, PA_CONTEXT_NOFLAGS, NULL); - while (state == STATE_CONNECTING) + while (state != PA_CONTEXT_READY && state != PA_CONTEXT_FAILED) pa_mainloop_iterate(pulse->mainloop, 1, NULL); - if (state == STATE_ERROR) { + if (state != PA_CONTEXT_READY) { fprintf(stderr, "failed to connect to pulse daemon: %s\n", pa_strerror(pa_context_errno(pulse->cxt))); return 1; |