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