4 This file is part of polypaudio.
6 polypaudio is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published
8 by the Free Software Foundation; either version 2 of the License,
9 or (at your option) any later version.
11 polypaudio is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with polypaudio; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
31 #include "polyplib-scache.h"
32 #include "polyplib-internal.h"
33 #include "pstream-util.h"
35 void pa_stream_connect_upload(struct pa_stream
*s
, size_t length
) {
36 struct pa_tagstruct
*t
;
43 s
->state
= PA_STREAM_CREATING
;
44 s
->direction
= PA_STREAM_UPLOAD
;
46 t
= pa_tagstruct_new(NULL
, 0);
47 pa_tagstruct_putu32(t
, PA_COMMAND_CREATE_UPLOAD_STREAM
);
48 pa_tagstruct_putu32(t
, tag
= s
->context
->ctag
++);
49 pa_tagstruct_puts(t
, s
->name
);
50 pa_tagstruct_put_sample_spec(t
, &s
->sample_spec
);
51 pa_tagstruct_putu32(t
, length
);
52 pa_pstream_send_tagstruct(s
->context
->pstream
, t
);
53 pa_pdispatch_register_reply(s
->context
->pdispatch
, tag
, DEFAULT_TIMEOUT
, pa_create_stream_callback
, s
);
58 void pa_stream_finish_upload(struct pa_stream
*s
) {
59 struct pa_tagstruct
*t
;
63 if (!s
->channel_valid
|| !s
->context
->state
== PA_CONTEXT_READY
)
68 t
= pa_tagstruct_new(NULL
, 0);
71 pa_tagstruct_putu32(t
, PA_COMMAND_FINISH_UPLOAD_STREAM
);
72 pa_tagstruct_putu32(t
, tag
= s
->context
->ctag
++);
73 pa_tagstruct_putu32(t
, s
->channel
);
74 pa_pstream_send_tagstruct(s
->context
->pstream
, t
);
75 pa_pdispatch_register_reply(s
->context
->pdispatch
, tag
, DEFAULT_TIMEOUT
, pa_stream_disconnect_callback
, s
);
80 struct pa_operation
* pa_context_play_sample(struct pa_context
*c
, const char *name
, const char *dev
, uint32_t volume
, void (*cb
)(struct pa_context
*c
, int success
, void *userdata
), void *userdata
) {
81 struct pa_operation
*o
;
82 struct pa_tagstruct
*t
;
84 assert(c
&& name
&& *name
&& (!dev
|| *dev
));
86 o
= pa_operation_new(c
, NULL
);
88 o
->userdata
= userdata
;
91 dev
= c
->conf
->default_sink
;
93 t
= pa_tagstruct_new(NULL
, 0);
95 pa_tagstruct_putu32(t
, PA_COMMAND_PLAY_SAMPLE
);
96 pa_tagstruct_putu32(t
, tag
= c
->ctag
++);
97 pa_tagstruct_putu32(t
, (uint32_t) -1);
98 pa_tagstruct_puts(t
, dev
);
99 pa_tagstruct_putu32(t
, volume
);
100 pa_tagstruct_puts(t
, name
);
101 pa_pstream_send_tagstruct(c
->pstream
, t
);
102 pa_pdispatch_register_reply(c
->pdispatch
, tag
, DEFAULT_TIMEOUT
, pa_context_simple_ack_callback
, o
);
104 return pa_operation_ref(o
);
107 struct pa_operation
* pa_context_remove_sample(struct pa_context
*c
, const char *name
, void (*cb
)(struct pa_context
*c
, int success
, void *userdata
), void *userdata
) {
108 struct pa_operation
*o
;
109 struct pa_tagstruct
*t
;
113 o
= pa_operation_new(c
, NULL
);
115 o
->userdata
= userdata
;
117 t
= pa_tagstruct_new(NULL
, 0);
119 pa_tagstruct_putu32(t
, PA_COMMAND_REMOVE_SAMPLE
);
120 pa_tagstruct_putu32(t
, tag
= c
->ctag
++);
121 pa_tagstruct_puts(t
, name
);
122 pa_pstream_send_tagstruct(c
->pstream
, t
);
123 pa_pdispatch_register_reply(c
->pdispatch
, tag
, DEFAULT_TIMEOUT
, pa_context_simple_ack_callback
, o
);
125 return pa_operation_ref(o
);