]> code.delx.au - pulseaudio/blob - src/pstream-util.c
main part of the native protocol
[pulseaudio] / src / pstream-util.c
1 #include <assert.h>
2
3 #include "protocol-native-spec.h"
4 #include "pstream-util.h"
5
6 void pstream_send_tagstruct(struct pstream *p, struct tagstruct *t) {
7 size_t length;
8 uint8_t *data;
9 struct packet *packet;
10 assert(p && t);
11
12 data = tagstruct_free_data(t, &length);
13 assert(data && length);
14 packet = packet_new_dynamic(data, length);
15 assert(packet);
16 pstream_send_packet(p, packet);
17 packet_unref(packet);
18 }
19
20 void pstream_send_error(struct pstream *p, uint32_t tag, uint32_t error) {
21 struct tagstruct *t = tagstruct_new(NULL, 0);
22 assert(t);
23 tagstruct_putu32(t, PA_COMMAND_ERROR);
24 tagstruct_putu32(t, tag);
25 tagstruct_putu32(t, error);
26 pstream_send_tagstruct(p, t);
27 }
28
29 void pstream_send_simple_ack(struct pstream *p, uint32_t tag) {
30 struct tagstruct *t = tagstruct_new(NULL, 0);
31 assert(t);
32 tagstruct_putu32(t, PA_COMMAND_REPLY);
33 tagstruct_putu32(t, tag);
34 pstream_send_tagstruct(p, t);
35 }