4 This file is part of PulseAudio.
6 Copyright 2004-2006 Lennart Poettering
8 PulseAudio is free software; you can redistribute it and/or modify
9 it under the terms of the GNU Lesser General Public License as published
10 by the Free Software Foundation; either version 2 of the License,
11 or (at your option) any later version.
13 PulseAudio is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public License
19 along with PulseAudio; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
33 #include <pulsecore/pstream-util.h>
39 int pa_stream_connect_upload(pa_stream *s, size_t length) {
45 PA_CHECK_VALIDITY(s->context, s->state == PA_STREAM_UNCONNECTED, PA_ERR_BADSTATE);
46 PA_CHECK_VALIDITY(s->context, length > 0, PA_ERR_INVALID);
50 s->direction = PA_STREAM_UPLOAD;
52 t = pa_tagstruct_command(s->context, PA_COMMAND_CREATE_UPLOAD_STREAM, &tag);
53 pa_tagstruct_puts(t, s->name);
54 pa_tagstruct_put_sample_spec(t, &s->sample_spec);
55 pa_tagstruct_put_channel_map(t, &s->channel_map);
56 pa_tagstruct_putu32(t, length);
57 pa_pstream_send_tagstruct(s->context->pstream, t);
58 pa_pdispatch_register_reply(s->context->pdispatch, tag, DEFAULT_TIMEOUT, pa_create_stream_callback, s, NULL);
60 pa_stream_set_state(s, PA_STREAM_CREATING);
66 int pa_stream_finish_upload(pa_stream *s) {
71 PA_CHECK_VALIDITY(s->context, s->channel_valid, PA_ERR_BADSTATE);
72 PA_CHECK_VALIDITY(s->context, s->context->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
76 t = pa_tagstruct_command(s->context, PA_COMMAND_FINISH_UPLOAD_STREAM, &tag);
77 pa_tagstruct_putu32(t, s->channel);
78 pa_pstream_send_tagstruct(s->context->pstream, t);
79 pa_pdispatch_register_reply(s->context->pdispatch, tag, DEFAULT_TIMEOUT, pa_stream_disconnect_callback, s, NULL);
85 pa_operation *pa_context_play_sample(pa_context *c, const char *name, const char *dev, pa_volume_t volume, pa_context_success_cb_t cb, void *userdata) {
93 PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
94 PA_CHECK_VALIDITY_RETURN_NULL(c, name && *name, PA_ERR_INVALID);
95 PA_CHECK_VALIDITY_RETURN_NULL(c, !dev || *dev, PA_ERR_INVALID);
97 o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
100 dev = c->conf->default_sink;
102 t = pa_tagstruct_command(c, PA_COMMAND_PLAY_SAMPLE, &tag);
103 pa_tagstruct_putu32(t, PA_INVALID_INDEX);
104 pa_tagstruct_puts(t, dev);
105 pa_tagstruct_putu32(t, volume);
106 pa_tagstruct_puts(t, name);
107 pa_pstream_send_tagstruct(c->pstream, t);
108 pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
113 pa_operation* pa_context_remove_sample(pa_context *c, const char *name, pa_context_success_cb_t cb, void *userdata) {
121 PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
122 PA_CHECK_VALIDITY_RETURN_NULL(c, name && *name, PA_ERR_INVALID);
124 o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
126 t = pa_tagstruct_command(c, PA_COMMAND_REMOVE_SAMPLE, &tag);
127 pa_tagstruct_puts(t, name);
128 pa_pstream_send_tagstruct(c->pstream, t);
129 pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);