void pa_context_simple_ack_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) { pa_operation *o = userdata; int success = 1; pa_assert(pd); pa_assert(o); pa_assert(PA_REFCNT_VALUE(o) >= 1); if (!o->context) goto finish; if (command != PA_COMMAND_REPLY) { if (pa_context_handle_error(o->context, command, t, FALSE) < 0) goto finish; success = 0; } else if (!pa_tagstruct_eof(t)) { pa_context_fail(o->context, PA_ERR_PROTOCOL); goto finish; } if (o->callback) { pa_context_success_cb_t cb = (pa_context_success_cb_t) o->callback; cb(o->context, success, o->userdata); } finish: pa_operation_done(o); pa_operation_unref(o); }
static void set_dispatch_callbacks(pa_operation *o) { int done = 1; pa_assert(o); pa_assert(PA_REFCNT_VALUE(o) >= 1); pa_assert(o->context); pa_assert(PA_REFCNT_VALUE(o->context) >= 1); pa_assert(o->context->state == PA_CONTEXT_READY); pa_pstream_set_drain_callback(o->context->pstream, NULL, NULL); pa_pdispatch_set_drain_callback(o->context->pdispatch, NULL, NULL); if (pa_pdispatch_is_pending(o->context->pdispatch)) { pa_pdispatch_set_drain_callback(o->context->pdispatch, pdispatch_drain_callback, o); done = 0; } if (pa_pstream_is_pending(o->context->pstream)) { pa_pstream_set_drain_callback(o->context->pstream, pstream_drain_callback, o); done = 0; } if (done) { if (o->callback) { pa_context_notify_cb_t cb = (pa_context_notify_cb_t) o->callback; cb(o->context, o->userdata); } pa_operation_done(o); pa_operation_unref(o); } }
static void ext_device_manager_test_cb(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) { pa_operation *o = userdata; uint32_t version = PA_INVALID_INDEX; pa_assert(pd); pa_assert(o); pa_assert(PA_REFCNT_VALUE(o) >= 1); if (!o->context) goto finish; if (command != PA_COMMAND_REPLY) { if (pa_context_handle_error(o->context, command, t, false) < 0) goto finish; } else if (pa_tagstruct_getu32(t, &version) < 0 || !pa_tagstruct_eof(t)) { pa_context_fail(o->context, PA_ERR_PROTOCOL); goto finish; } if (o->callback) { pa_ext_device_manager_test_cb_t cb = (pa_ext_device_manager_test_cb_t) o->callback; cb(o->context, version, o->userdata); } finish: pa_operation_done(o); pa_operation_unref(o); }
static void play_sample_with_proplist_ack_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) { pa_operation *o = userdata; uint32_t idx; pa_assert(pd); pa_assert(o); pa_assert(PA_REFCNT_VALUE(o) >= 1); if (!o->context) goto finish; if (command != PA_COMMAND_REPLY) { if (pa_context_handle_error(o->context, command, t, FALSE) < 0) goto finish; idx = PA_INVALID_INDEX; } else if (pa_tagstruct_getu32(t, &idx) < 0 || !pa_tagstruct_eof(t)) { pa_context_fail(o->context, PA_ERR_PROTOCOL); goto finish; } if (o->callback) { pa_context_play_sample_cb_t cb = (pa_context_play_sample_cb_t) o->callback; cb(o->context, idx, o->userdata); } finish: pa_operation_done(o); pa_operation_unref(o); }
static void ext_stream_restore_read_cb(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) { pa_operation *o = userdata; int eol = 1; pa_assert(pd); pa_assert(o); pa_assert(PA_REFCNT_VALUE(o) >= 1); if (!o->context) goto finish; if (command != PA_COMMAND_REPLY) { if (pa_context_handle_error(o->context, command, t, FALSE) < 0) goto finish; eol = -1; } else { while (!pa_tagstruct_eof(t)) { pa_ext_stream_restore_info i; pa_bool_t mute = FALSE; memset(&i, 0, sizeof(i)); if (pa_tagstruct_gets(t, &i.name) < 0 || pa_tagstruct_get_channel_map(t, &i.channel_map) < 0 || pa_tagstruct_get_cvolume(t, &i.volume) < 0 || pa_tagstruct_gets(t, &i.device) < 0 || pa_tagstruct_get_boolean(t, &mute) < 0) { pa_context_fail(o->context, PA_ERR_PROTOCOL); goto finish; } i.mute = (int) mute; if (o->callback) { pa_ext_stream_restore_read_cb_t cb = (pa_ext_stream_restore_read_cb_t) o->callback; cb(o->context, &i, 0, o->userdata); } } } if (o->callback) { pa_ext_stream_restore_read_cb_t cb = (pa_ext_stream_restore_read_cb_t) o->callback; cb(o->context, NULL, eol, o->userdata); } finish: pa_operation_done(o); pa_operation_unref(o); }
static void ext_device_manager_read_cb(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) { pa_operation *o = userdata; int eol = 1; pa_assert(pd); pa_assert(o); pa_assert(PA_REFCNT_VALUE(o) >= 1); if (!o->context) goto finish; if (command != PA_COMMAND_REPLY) { if (pa_context_handle_error(o->context, command, t, false) < 0) goto finish; eol = -1; } else { while (!pa_tagstruct_eof(t)) { pa_ext_device_manager_info i; memset(&i, 0, sizeof(i)); if (pa_tagstruct_gets(t, &i.name) < 0 || pa_tagstruct_gets(t, &i.description) < 0 || pa_tagstruct_gets(t, &i.icon) < 0 || pa_tagstruct_getu32(t, &i.index) < 0 || pa_tagstruct_getu32(t, &i.n_role_priorities) < 0) { pa_context_fail(o->context, PA_ERR_PROTOCOL); goto finish; } if (i.n_role_priorities > 0) { uint32_t j; i.role_priorities = pa_xnew0(pa_ext_device_manager_role_priority_info, i.n_role_priorities+1); for (j = 0; j < i.n_role_priorities; j++) { if (pa_tagstruct_gets(t, &i.role_priorities[j].role) < 0 || pa_tagstruct_getu32(t, &i.role_priorities[j].priority) < 0) { pa_context_fail(o->context, PA_ERR_PROTOCOL); pa_xfree(i.role_priorities); goto finish; } } /* Terminate with an extra NULL entry, just to make sure */ i.role_priorities[j].role = NULL; i.role_priorities[j].priority = 0; } if (o->callback) { pa_ext_device_manager_read_cb_t cb = (pa_ext_device_manager_read_cb_t) o->callback; cb(o->context, &i, 0, o->userdata); } pa_xfree(i.role_priorities); } } if (o->callback) { pa_ext_device_manager_read_cb_t cb = (pa_ext_device_manager_read_cb_t) o->callback; cb(o->context, NULL, eol, o->userdata); } finish: pa_operation_done(o); pa_operation_unref(o); }