]> code.delx.au - pulseaudio/blob - src/pulsecore/pstream-util.c
09d6f2fa88a49531601dab1225aa406ae4e35ed4
[pulseaudio] / src / pulsecore / pstream-util.c
1 /* $Id$ */
2
3 /***
4 This file is part of PulseAudio.
5
6 PulseAudio is free software; you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation; either version 2.1 of the
9 License, or (at your option) any later version.
10
11 PulseAudio 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 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with PulseAudio; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19 USA.
20 ***/
21
22 #ifdef HAVE_CONFIG_H
23 #include <config.h>
24 #endif
25
26 #include <assert.h>
27
28 #include <pulsecore/native-common.h>
29
30 #include "pstream-util.h"
31
32 void pa_pstream_send_tagstruct_with_creds(pa_pstream *p, pa_tagstruct *t, const struct ucred *creds) {
33 size_t length;
34 uint8_t *data;
35 pa_packet *packet;
36 assert(p);
37 assert(t);
38
39 data = pa_tagstruct_free_data(t, &length);
40 assert(data && length);
41 packet = pa_packet_new_dynamic(data, length);
42 assert(packet);
43 pa_pstream_send_packet(p, packet, creds);
44 pa_packet_unref(packet);
45 }
46
47 void pa_pstream_send_error(pa_pstream *p, uint32_t tag, uint32_t error) {
48 pa_tagstruct *t = pa_tagstruct_new(NULL, 0);
49 assert(t);
50 pa_tagstruct_putu32(t, PA_COMMAND_ERROR);
51 pa_tagstruct_putu32(t, tag);
52 pa_tagstruct_putu32(t, error);
53 pa_pstream_send_tagstruct(p, t);
54 }
55
56 void pa_pstream_send_simple_ack(pa_pstream *p, uint32_t tag) {
57 pa_tagstruct *t = pa_tagstruct_new(NULL, 0);
58 assert(t);
59 pa_tagstruct_putu32(t, PA_COMMAND_REPLY);
60 pa_tagstruct_putu32(t, tag);
61 pa_pstream_send_tagstruct(p, t);
62 }