diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/polyp/context.c | 43 | ||||
-rw-r--r-- | src/polyp/internal.h | 2 | ||||
-rw-r--r-- | src/polyp/introspect.c | 88 | ||||
-rw-r--r-- | src/polyp/scache.c | 16 | ||||
-rw-r--r-- | src/polyp/stream.c | 48 | ||||
-rw-r--r-- | src/polyp/subscribe.c | 4 |
6 files changed, 74 insertions, 127 deletions
diff --git a/src/polyp/context.c b/src/polyp/context.c index 15e6cd76..906a0d89 100644 --- a/src/polyp/context.c +++ b/src/polyp/context.c @@ -354,9 +354,7 @@ static void setup_complete_callback(pa_pdispatch *pd, uint32_t command, uint32_t switch(c->state) { case PA_CONTEXT_AUTHORIZING: { pa_tagstruct *reply; - reply = pa_tagstruct_new(NULL, 0); - pa_tagstruct_putu32(reply, PA_COMMAND_SET_CLIENT_NAME); - pa_tagstruct_putu32(reply, tag = c->ctag++); + reply = pa_tagstruct_command(c, PA_COMMAND_SET_CLIENT_NAME, &tag); pa_tagstruct_puts(reply, c->name); pa_pstream_send_tagstruct(c->pstream, reply); pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, setup_complete_callback, c); @@ -401,9 +399,7 @@ static void setup_context(pa_context *c, pa_iochannel *io) { goto finish; } - t = pa_tagstruct_new(NULL, 0); - pa_tagstruct_putu32(t, PA_COMMAND_AUTH); - pa_tagstruct_putu32(t, tag = c->ctag++); + t = pa_tagstruct_command(c, PA_COMMAND_AUTH, &tag); pa_tagstruct_put_arbitrary(t, c->conf->cookie, sizeof(c->conf->cookie)); pa_pstream_send_tagstruct(c->pstream, t); pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, setup_complete_callback, c); @@ -827,10 +823,8 @@ pa_operation* pa_context_exit_daemon(pa_context *c, pa_context_success_cb_t cb, PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); - - t = pa_tagstruct_new(NULL, 0); - pa_tagstruct_putu32(t, PA_COMMAND_EXIT); - pa_tagstruct_putu32(t, tag = c->ctag++); + + t = pa_tagstruct_command(c, PA_COMMAND_EXIT, &tag); pa_pstream_send_tagstruct(c->pstream, t); pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o)); @@ -849,9 +843,7 @@ pa_operation* pa_context_send_simple_command(pa_context *c, uint32_t command, pa o = pa_operation_new(c, NULL, cb, userdata); - t = pa_tagstruct_new(NULL, 0); - pa_tagstruct_putu32(t, command); - pa_tagstruct_putu32(t, tag = c->ctag++); + t = pa_tagstruct_command(c, command, &tag); pa_pstream_send_tagstruct(c->pstream, t); pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, internal_cb, pa_operation_ref(o)); @@ -870,9 +862,7 @@ pa_operation* pa_context_set_default_sink(pa_context *c, const char *name, pa_co o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); - t = pa_tagstruct_new(NULL, 0); - pa_tagstruct_putu32(t, PA_COMMAND_SET_DEFAULT_SINK); - pa_tagstruct_putu32(t, tag = c->ctag++); + t = pa_tagstruct_command(c, PA_COMMAND_SET_DEFAULT_SINK, &tag); pa_tagstruct_puts(t, name); pa_pstream_send_tagstruct(c->pstream, t); pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o)); @@ -892,9 +882,7 @@ pa_operation* pa_context_set_default_source(pa_context *c, const char *name, pa_ o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); - t = pa_tagstruct_new(NULL, 0); - pa_tagstruct_putu32(t, PA_COMMAND_SET_DEFAULT_SOURCE); - pa_tagstruct_putu32(t, tag = c->ctag++); + t = pa_tagstruct_command(c, PA_COMMAND_SET_DEFAULT_SOURCE, &tag); pa_tagstruct_puts(t, name); pa_pstream_send_tagstruct(c->pstream, t); pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o)); @@ -921,9 +909,7 @@ pa_operation* pa_context_set_name(pa_context *c, const char *name, pa_context_su o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); - t = pa_tagstruct_new(NULL, 0); - pa_tagstruct_putu32(t, PA_COMMAND_SET_CLIENT_NAME); - pa_tagstruct_putu32(t, tag = c->ctag++); + t = pa_tagstruct_command(c, PA_COMMAND_SET_CLIENT_NAME, &tag); pa_tagstruct_puts(t, name); pa_pstream_send_tagstruct(c->pstream, t); pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o)); @@ -949,3 +935,16 @@ const char* pa_context_get_server(pa_context *c) { return c->server; } + +pa_tagstruct *pa_tagstruct_command(pa_context *c, uint32_t command, uint32_t *tag) { + pa_tagstruct *t; + + assert(c); + assert(tag); + + t = pa_tagstruct_new(NULL, 0); + pa_tagstruct_putu32(t, command); + pa_tagstruct_putu32(t, *tag = c->ctag++); + + return t; +} diff --git a/src/polyp/internal.h b/src/polyp/internal.h index 9907fae0..2e4d859a 100644 --- a/src/polyp/internal.h +++ b/src/polyp/internal.h @@ -164,6 +164,8 @@ void pa_stream_set_state(pa_stream *s, pa_stream_state_t st); void pa_stream_trash_ipol(pa_stream *s); +pa_tagstruct *pa_tagstruct_command(pa_context *c, uint32_t command, uint32_t *tag); + #define PA_CHECK_VALIDITY(context, expression, error) do { \ if (!(expression)) \ return -pa_context_set_error((context), (error)); \ diff --git a/src/polyp/introspect.c b/src/polyp/introspect.c index 4fa23841..6a9917a7 100644 --- a/src/polyp/introspect.c +++ b/src/polyp/introspect.c @@ -189,9 +189,7 @@ pa_operation* pa_context_get_sink_info_by_index(pa_context *c, uint32_t idx, pa_ o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); - t = pa_tagstruct_new(NULL, 0); - pa_tagstruct_putu32(t, PA_COMMAND_GET_SINK_INFO); - pa_tagstruct_putu32(t, tag = c->ctag++); + t = pa_tagstruct_command(c, PA_COMMAND_GET_SINK_INFO, &tag); pa_tagstruct_putu32(t, idx); pa_tagstruct_puts(t, NULL); pa_pstream_send_tagstruct(c->pstream, t); @@ -214,9 +212,7 @@ pa_operation* pa_context_get_sink_info_by_name(pa_context *c, const char *name, o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); - t = pa_tagstruct_new(NULL, 0); - pa_tagstruct_putu32(t, PA_COMMAND_GET_SINK_INFO); - pa_tagstruct_putu32(t, tag = c->ctag++); + t = pa_tagstruct_command(c, PA_COMMAND_GET_SINK_INFO, &tag); pa_tagstruct_putu32(t, PA_INVALID_INDEX); pa_tagstruct_puts(t, name); pa_pstream_send_tagstruct(c->pstream, t); @@ -296,9 +292,7 @@ pa_operation* pa_context_get_source_info_by_index(pa_context *c, uint32_t idx, p o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); - t = pa_tagstruct_new(NULL, 0); - pa_tagstruct_putu32(t, PA_COMMAND_GET_SOURCE_INFO); - pa_tagstruct_putu32(t, tag = c->ctag++); + t = pa_tagstruct_command(c, PA_COMMAND_GET_SOURCE_INFO, &tag); pa_tagstruct_putu32(t, idx); pa_tagstruct_puts(t, NULL); pa_pstream_send_tagstruct(c->pstream, t); @@ -321,9 +315,7 @@ pa_operation* pa_context_get_source_info_by_name(pa_context *c, const char *name o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); - t = pa_tagstruct_new(NULL, 0); - pa_tagstruct_putu32(t, PA_COMMAND_GET_SOURCE_INFO); - pa_tagstruct_putu32(t, tag = c->ctag++); + t = pa_tagstruct_command(c, PA_COMMAND_GET_SOURCE_INFO, &tag); pa_tagstruct_putu32(t, PA_INVALID_INDEX); pa_tagstruct_puts(t, name); pa_pstream_send_tagstruct(c->pstream, t); @@ -392,9 +384,7 @@ pa_operation* pa_context_get_client_info(pa_context *c, uint32_t idx, pa_client_ o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); - t = pa_tagstruct_new(NULL, 0); - pa_tagstruct_putu32(t, PA_COMMAND_GET_CLIENT_INFO); - pa_tagstruct_putu32(t, tag = c->ctag++); + t = pa_tagstruct_command(c, PA_COMMAND_GET_CLIENT_INFO, &tag); pa_tagstruct_putu32(t, idx); pa_pstream_send_tagstruct(c->pstream, t); pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, context_get_client_info_callback, pa_operation_ref(o)); @@ -467,9 +457,7 @@ pa_operation* pa_context_get_module_info(pa_context *c, uint32_t idx, pa_module_ o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); - t = pa_tagstruct_new(NULL, 0); - pa_tagstruct_putu32(t, PA_COMMAND_GET_MODULE_INFO); - pa_tagstruct_putu32(t, tag = c->ctag++); + t = pa_tagstruct_command(c, PA_COMMAND_GET_MODULE_INFO, &tag); pa_tagstruct_putu32(t, idx); pa_pstream_send_tagstruct(c->pstream, t); pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, context_get_module_info_callback, pa_operation_ref(o)); @@ -550,9 +538,7 @@ pa_operation* pa_context_get_sink_input_info(pa_context *c, uint32_t idx, pa_sin o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); - t = pa_tagstruct_new(NULL, 0); - pa_tagstruct_putu32(t, PA_COMMAND_GET_SINK_INPUT_INFO); - pa_tagstruct_putu32(t, tag = c->ctag++); + t = pa_tagstruct_command(c, PA_COMMAND_GET_SINK_INPUT_INFO, &tag); pa_tagstruct_putu32(t, idx); pa_pstream_send_tagstruct(c->pstream, t); pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, context_get_sink_input_info_callback, pa_operation_ref(o)); @@ -632,9 +618,7 @@ pa_operation* pa_context_get_source_output_info(pa_context *c, uint32_t idx, pa_ o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); - t = pa_tagstruct_new(NULL, 0); - pa_tagstruct_putu32(t, PA_COMMAND_GET_SOURCE_OUTPUT_INFO); - pa_tagstruct_putu32(t, tag = c->ctag++); + t = pa_tagstruct_command(c, PA_COMMAND_GET_SOURCE_OUTPUT_INFO, &tag); pa_tagstruct_putu32(t, idx); pa_pstream_send_tagstruct(c->pstream, t); pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, context_get_source_output_info_callback, pa_operation_ref(o)); @@ -662,9 +646,7 @@ pa_operation* pa_context_set_sink_volume_by_index(pa_context *c, uint32_t idx, c o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); - t = pa_tagstruct_new(NULL, 0); - pa_tagstruct_putu32(t, PA_COMMAND_SET_SINK_VOLUME); - pa_tagstruct_putu32(t, tag = c->ctag++); + t = pa_tagstruct_command(c, PA_COMMAND_SET_SINK_VOLUME, &tag); pa_tagstruct_putu32(t, idx); pa_tagstruct_puts(t, NULL); pa_tagstruct_put_cvolume(t, volume); @@ -690,9 +672,7 @@ pa_operation* pa_context_set_sink_volume_by_name(pa_context *c, const char *name o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); - t = pa_tagstruct_new(NULL, 0); - pa_tagstruct_putu32(t, PA_COMMAND_SET_SINK_VOLUME); - pa_tagstruct_putu32(t, tag = c->ctag++); + t = pa_tagstruct_command(c, PA_COMMAND_SET_SINK_VOLUME, &tag); pa_tagstruct_putu32(t, PA_INVALID_INDEX); pa_tagstruct_puts(t, name); pa_tagstruct_put_cvolume(t, volume); @@ -717,9 +697,7 @@ pa_operation* pa_context_set_sink_input_volume(pa_context *c, uint32_t idx, cons o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); - t = pa_tagstruct_new(NULL, 0); - pa_tagstruct_putu32(t, PA_COMMAND_SET_SINK_INPUT_VOLUME); - pa_tagstruct_putu32(t, tag = c->ctag++); + t = pa_tagstruct_command(c, PA_COMMAND_SET_SINK_INPUT_VOLUME, &tag); pa_tagstruct_putu32(t, idx); pa_tagstruct_put_cvolume(t, volume); pa_pstream_send_tagstruct(c->pstream, t); @@ -742,9 +720,7 @@ pa_operation* pa_context_set_source_volume_by_index(pa_context *c, uint32_t idx, o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); - t = pa_tagstruct_new(NULL, 0); - pa_tagstruct_putu32(t, PA_COMMAND_SET_SOURCE_VOLUME); - pa_tagstruct_putu32(t, tag = c->ctag++); + t = pa_tagstruct_command(c, PA_COMMAND_SET_SOURCE_VOLUME, &tag); pa_tagstruct_putu32(t, idx); pa_tagstruct_puts(t, NULL); pa_tagstruct_put_cvolume(t, volume); @@ -770,9 +746,7 @@ pa_operation* pa_context_set_source_volume_by_name(pa_context *c, const char *na o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); - t = pa_tagstruct_new(NULL, 0); - pa_tagstruct_putu32(t, PA_COMMAND_SET_SOURCE_VOLUME); - pa_tagstruct_putu32(t, tag = c->ctag++); + t = pa_tagstruct_command(c, PA_COMMAND_SET_SOURCE_VOLUME, &tag); pa_tagstruct_putu32(t, PA_INVALID_INDEX); pa_tagstruct_puts(t, name); pa_tagstruct_put_cvolume(t, volume); @@ -848,9 +822,7 @@ pa_operation* pa_context_get_sample_info_by_name(pa_context *c, const char *name o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); - t = pa_tagstruct_new(NULL, 0); - pa_tagstruct_putu32(t, PA_COMMAND_GET_SAMPLE_INFO); - pa_tagstruct_putu32(t, tag = c->ctag++); + t = pa_tagstruct_command(c, PA_COMMAND_GET_SAMPLE_INFO, &tag); pa_tagstruct_putu32(t, PA_INVALID_INDEX); pa_tagstruct_puts(t, name); pa_pstream_send_tagstruct(c->pstream, t); @@ -873,9 +845,7 @@ pa_operation* pa_context_get_sample_info_by_index(pa_context *c, uint32_t idx, p o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); - t = pa_tagstruct_new(NULL, 0); - pa_tagstruct_putu32(t, PA_COMMAND_GET_SAMPLE_INFO); - pa_tagstruct_putu32(t, tag = c->ctag++); + t = pa_tagstruct_command(c, PA_COMMAND_GET_SAMPLE_INFO, &tag); pa_tagstruct_putu32(t, idx); pa_tagstruct_puts(t, NULL); pa_pstream_send_tagstruct(c->pstream, t); @@ -901,9 +871,7 @@ static pa_operation* command_kill(pa_context *c, uint32_t command, uint32_t idx, o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); - t = pa_tagstruct_new(NULL, 0); - pa_tagstruct_putu32(t, command); - pa_tagstruct_putu32(t, tag = c->ctag++); + t = pa_tagstruct_command(c, command, &tag); pa_tagstruct_putu32(t, idx); pa_pstream_send_tagstruct(c->pstream, t); pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o)); @@ -967,9 +935,7 @@ pa_operation* pa_context_load_module(pa_context *c, const char*name, const char o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); - t = pa_tagstruct_new(NULL, 0); - pa_tagstruct_putu32(t, PA_COMMAND_LOAD_MODULE); - pa_tagstruct_putu32(t, tag = c->ctag++); + t = pa_tagstruct_command(c, PA_COMMAND_LOAD_MODULE, &tag); pa_tagstruct_puts(t, name); pa_tagstruct_puts(t, argument); pa_pstream_send_tagstruct(c->pstream, t); @@ -1044,9 +1010,7 @@ pa_operation* pa_context_get_autoload_info_by_name(pa_context *c, const char *na o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); - t = pa_tagstruct_new(NULL, 0); - pa_tagstruct_putu32(t, PA_COMMAND_GET_AUTOLOAD_INFO); - pa_tagstruct_putu32(t, tag = c->ctag++); + t = pa_tagstruct_command(c, PA_COMMAND_GET_AUTOLOAD_INFO, &tag); pa_tagstruct_puts(t, name); pa_tagstruct_putu32(t, type); pa_pstream_send_tagstruct(c->pstream, t); @@ -1069,9 +1033,7 @@ pa_operation* pa_context_get_autoload_info_by_index(pa_context *c, uint32_t idx, o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); - t = pa_tagstruct_new(NULL, 0); - pa_tagstruct_putu32(t, PA_COMMAND_GET_AUTOLOAD_INFO); - pa_tagstruct_putu32(t, tag = c->ctag++); + t = pa_tagstruct_command(c, PA_COMMAND_GET_AUTOLOAD_INFO, &tag); pa_tagstruct_putu32(t, idx); pa_pstream_send_tagstruct(c->pstream, t); pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, context_get_autoload_info_callback, pa_operation_ref(o)); @@ -1098,9 +1060,7 @@ pa_operation* pa_context_add_autoload(pa_context *c, const char *name, pa_autolo o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); - t = pa_tagstruct_new(NULL, 0); - pa_tagstruct_putu32(t, PA_COMMAND_ADD_AUTOLOAD); - pa_tagstruct_putu32(t, tag = c->ctag++); + t = pa_tagstruct_command(c, PA_COMMAND_ADD_AUTOLOAD, &tag); pa_tagstruct_puts(t, name); pa_tagstruct_putu32(t, type); pa_tagstruct_puts(t, module); @@ -1125,9 +1085,7 @@ pa_operation* pa_context_remove_autoload_by_name(pa_context *c, const char *name o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); - t = pa_tagstruct_new(NULL, 0); - pa_tagstruct_putu32(t, PA_COMMAND_REMOVE_AUTOLOAD); - pa_tagstruct_putu32(t, tag = c->ctag++); + t = pa_tagstruct_command(c, PA_COMMAND_REMOVE_AUTOLOAD, &tag); pa_tagstruct_puts(t, name); pa_tagstruct_putu32(t, type); pa_pstream_send_tagstruct(c->pstream, t); @@ -1149,9 +1107,7 @@ pa_operation* pa_context_remove_autoload_by_index(pa_context *c, uint32_t idx, p o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); - t = pa_tagstruct_new(NULL, 0); - pa_tagstruct_putu32(t, PA_COMMAND_REMOVE_AUTOLOAD); - pa_tagstruct_putu32(t, tag = c->ctag++); + t = pa_tagstruct_command(c, PA_COMMAND_REMOVE_AUTOLOAD, &tag); pa_tagstruct_putu32(t, idx); pa_pstream_send_tagstruct(c->pstream, t); pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o)); diff --git a/src/polyp/scache.c b/src/polyp/scache.c index 792d7cbf..891798fb 100644 --- a/src/polyp/scache.c +++ b/src/polyp/scache.c @@ -47,9 +47,7 @@ int pa_stream_connect_upload(pa_stream *s, size_t length) { s->direction = PA_STREAM_UPLOAD; - t = pa_tagstruct_new(NULL, 0); - pa_tagstruct_putu32(t, PA_COMMAND_CREATE_UPLOAD_STREAM); - pa_tagstruct_putu32(t, tag = s->context->ctag++); + t = pa_tagstruct_command(s->context, PA_COMMAND_CREATE_UPLOAD_STREAM, &tag); pa_tagstruct_puts(t, s->name); pa_tagstruct_put_sample_spec(t, &s->sample_spec); pa_tagstruct_putu32(t, length); @@ -72,9 +70,7 @@ int pa_stream_finish_upload(pa_stream *s) { pa_stream_ref(s); - t = pa_tagstruct_new(NULL, 0); - pa_tagstruct_putu32(t, PA_COMMAND_FINISH_UPLOAD_STREAM); - pa_tagstruct_putu32(t, tag = s->context->ctag++); + t = pa_tagstruct_command(s->context, PA_COMMAND_FINISH_UPLOAD_STREAM, &tag); pa_tagstruct_putu32(t, s->channel); pa_pstream_send_tagstruct(s->context->pstream, t); pa_pdispatch_register_reply(s->context->pdispatch, tag, DEFAULT_TIMEOUT, pa_stream_disconnect_callback, s); @@ -100,9 +96,7 @@ pa_operation *pa_context_play_sample(pa_context *c, const char *name, const char if (!dev) dev = c->conf->default_sink; - t = pa_tagstruct_new(NULL, 0); - pa_tagstruct_putu32(t, PA_COMMAND_PLAY_SAMPLE); - pa_tagstruct_putu32(t, tag = c->ctag++); + t = pa_tagstruct_command(c, PA_COMMAND_PLAY_SAMPLE, &tag); pa_tagstruct_putu32(t, PA_INVALID_INDEX); pa_tagstruct_puts(t, dev); pa_tagstruct_putu32(t, volume); @@ -126,9 +120,7 @@ pa_operation* pa_context_remove_sample(pa_context *c, const char *name, pa_conte o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); - t = pa_tagstruct_new(NULL, 0); - pa_tagstruct_putu32(t, PA_COMMAND_REMOVE_SAMPLE); - pa_tagstruct_putu32(t, tag = c->ctag++); + t = pa_tagstruct_command(c, PA_COMMAND_REMOVE_SAMPLE, &tag); pa_tagstruct_puts(t, name); pa_pstream_send_tagstruct(c->pstream, t); pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o)); diff --git a/src/polyp/stream.c b/src/polyp/stream.c index 1ffb4c16..5ab91815 100644 --- a/src/polyp/stream.c +++ b/src/polyp/stream.c @@ -409,15 +409,16 @@ static int create_stream( s->buffer_attr.fragsize = s->buffer_attr.tlength/100; } - t = pa_tagstruct_new(NULL, 0); - if (!dev) dev = s->direction == PA_STREAM_PLAYBACK ? s->context->conf->default_sink : s->context->conf->default_source; + + t = pa_tagstruct_command( + s->context, + s->direction == PA_STREAM_PLAYBACK ? PA_COMMAND_CREATE_PLAYBACK_STREAM : PA_COMMAND_CREATE_RECORD_STREAM, + &tag); pa_tagstruct_put( t, - PA_TAG_U32, s->direction == PA_STREAM_PLAYBACK ? PA_COMMAND_CREATE_PLAYBACK_STREAM : PA_COMMAND_CREATE_RECORD_STREAM, - PA_TAG_U32, tag = s->context->ctag++, PA_TAG_STRING, s->name, PA_TAG_SAMPLE_SPEC, &s->sample_spec, PA_TAG_CHANNEL_MAP, &s->channel_map, @@ -599,9 +600,7 @@ pa_operation * pa_stream_drain(pa_stream *s, pa_stream_success_cb_t cb, void *us o = pa_operation_new(s->context, s, (pa_operation_cb_t) cb, userdata); - t = pa_tagstruct_new(NULL, 0); - pa_tagstruct_putu32(t, PA_COMMAND_DRAIN_PLAYBACK_STREAM); - pa_tagstruct_putu32(t, tag = s->context->ctag++); + t = pa_tagstruct_command(s->context, PA_COMMAND_DRAIN_PLAYBACK_STREAM, &tag); pa_tagstruct_putu32(t, s->channel); pa_pstream_send_tagstruct(s->context->pstream, t); pa_pdispatch_register_reply(s->context->pdispatch, tag, DEFAULT_TIMEOUT, pa_stream_simple_ack_callback, o); @@ -689,9 +688,10 @@ pa_operation* pa_stream_get_latency_info(pa_stream *s, pa_stream_get_latency_inf o = pa_operation_new(s->context, s, (pa_operation_cb_t) cb, userdata); - t = pa_tagstruct_new(NULL, 0); - pa_tagstruct_putu32(t, s->direction == PA_STREAM_PLAYBACK ? PA_COMMAND_GET_PLAYBACK_LATENCY : PA_COMMAND_GET_RECORD_LATENCY); - pa_tagstruct_putu32(t, tag = s->context->ctag++); + t = pa_tagstruct_command( + s->context, + s->direction == PA_STREAM_PLAYBACK ? PA_COMMAND_GET_PLAYBACK_LATENCY : PA_COMMAND_GET_RECORD_LATENCY, + &tag); pa_tagstruct_putu32(t, s->channel); pa_gettimeofday(&now); @@ -742,11 +742,11 @@ int pa_stream_disconnect(pa_stream *s) { pa_stream_ref(s); - t = pa_tagstruct_new(NULL, 0); - - pa_tagstruct_putu32(t, s->direction == PA_STREAM_PLAYBACK ? PA_COMMAND_DELETE_PLAYBACK_STREAM : - (s->direction == PA_STREAM_RECORD ? PA_COMMAND_DELETE_RECORD_STREAM : PA_COMMAND_DELETE_UPLOAD_STREAM)); - pa_tagstruct_putu32(t, tag = s->context->ctag++); + t = pa_tagstruct_command( + s->context, + s->direction == PA_STREAM_PLAYBACK ? PA_COMMAND_DELETE_PLAYBACK_STREAM : + (s->direction == PA_STREAM_RECORD ? PA_COMMAND_DELETE_RECORD_STREAM : PA_COMMAND_DELETE_UPLOAD_STREAM), + &tag); pa_tagstruct_putu32(t, s->channel); pa_pstream_send_tagstruct(s->context->pstream, t); pa_pdispatch_register_reply(s->context->pdispatch, tag, DEFAULT_TIMEOUT, pa_stream_disconnect_callback, s); @@ -848,9 +848,10 @@ pa_operation* pa_stream_cork(pa_stream *s, int b, pa_stream_success_cb_t cb, voi o = pa_operation_new(s->context, s, (pa_operation_cb_t) cb, userdata); - t = pa_tagstruct_new(NULL, 0); - pa_tagstruct_putu32(t, s->direction == PA_STREAM_PLAYBACK ? PA_COMMAND_CORK_PLAYBACK_STREAM : PA_COMMAND_CORK_RECORD_STREAM); - pa_tagstruct_putu32(t, tag = s->context->ctag++); + t = pa_tagstruct_command( + s->context, + s->direction == PA_STREAM_PLAYBACK ? PA_COMMAND_CORK_PLAYBACK_STREAM : PA_COMMAND_CORK_RECORD_STREAM, + &tag); pa_tagstruct_putu32(t, s->channel); pa_tagstruct_put_boolean(t, !!b); pa_pstream_send_tagstruct(s->context->pstream, t); @@ -873,9 +874,7 @@ static pa_operation* stream_send_simple_command(pa_stream *s, uint32_t command, o = pa_operation_new(s->context, s, (pa_operation_cb_t) cb, userdata); - t = pa_tagstruct_new(NULL, 0); - pa_tagstruct_putu32(t, command); - pa_tagstruct_putu32(t, tag = s->context->ctag++); + t = pa_tagstruct_command(s->context, command, &tag); pa_tagstruct_putu32(t, s->channel); pa_pstream_send_tagstruct(s->context->pstream, t); pa_pdispatch_register_reply(s->context->pdispatch, tag, DEFAULT_TIMEOUT, pa_stream_simple_ack_callback, o); @@ -930,9 +929,10 @@ pa_operation* pa_stream_set_name(pa_stream *s, const char *name, pa_stream_succe o = pa_operation_new(s->context, s, (pa_operation_cb_t) cb, userdata); - t = pa_tagstruct_new(NULL, 0); - pa_tagstruct_putu32(t, s->direction == PA_STREAM_RECORD ? PA_COMMAND_SET_RECORD_STREAM_NAME : PA_COMMAND_SET_PLAYBACK_STREAM_NAME); - pa_tagstruct_putu32(t, tag = s->context->ctag++); + t = pa_tagstruct_command( + s->context, + s->direction == PA_STREAM_RECORD ? PA_COMMAND_SET_RECORD_STREAM_NAME : PA_COMMAND_SET_PLAYBACK_STREAM_NAME, + &tag); pa_tagstruct_putu32(t, s->channel); pa_tagstruct_puts(t, name); pa_pstream_send_tagstruct(s->context->pstream, t); diff --git a/src/polyp/subscribe.c b/src/polyp/subscribe.c index 65849b6d..a4eadbc6 100644 --- a/src/polyp/subscribe.c +++ b/src/polyp/subscribe.c @@ -72,9 +72,7 @@ pa_operation* pa_context_subscribe(pa_context *c, pa_subscription_mask_t m, pa_c o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); - t = pa_tagstruct_new(NULL, 0); - pa_tagstruct_putu32(t, PA_COMMAND_SUBSCRIBE); - pa_tagstruct_putu32(t, tag = c->ctag++); + t = pa_tagstruct_command(c, PA_COMMAND_SUBSCRIBE, &tag); pa_tagstruct_putu32(t, m); pa_pstream_send_tagstruct(c->pstream, t); pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o)); |