default: esd is obsolete, hence don't load it anymore by default
[pulseaudio-mirror.git] / src / pulsecore / packet.c
blobcee468bd919b6f3999061081b2c885f6df0cfcc8
1 /***
2 This file is part of PulseAudio.
4 Copyright 2004-2006 Lennart Poettering
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.
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.
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 ***/
22 #ifdef HAVE_CONFIG_H
23 #include <config.h>
24 #endif
26 #include <stdlib.h>
28 #include <pulse/xmalloc.h>
29 #include <pulsecore/macro.h>
31 #include "packet.h"
33 pa_packet* pa_packet_new(size_t length) {
34 pa_packet *p;
36 pa_assert(length > 0);
38 p = pa_xmalloc(PA_ALIGN(sizeof(pa_packet)) + length);
39 PA_REFCNT_INIT(p);
40 p->length = length;
41 p->data = (uint8_t*) p + PA_ALIGN(sizeof(pa_packet));
42 p->type = PA_PACKET_APPENDED;
44 return p;
47 pa_packet* pa_packet_new_dynamic(void* data, size_t length) {
48 pa_packet *p;
50 pa_assert(data);
51 pa_assert(length > 0);
53 p = pa_xnew(pa_packet, 1);
54 PA_REFCNT_INIT(p);
55 p->length = length;
56 p->data = data;
57 p->type = PA_PACKET_DYNAMIC;
59 return p;
62 pa_packet* pa_packet_ref(pa_packet *p) {
63 pa_assert(p);
64 pa_assert(PA_REFCNT_VALUE(p) >= 1);
66 PA_REFCNT_INC(p);
67 return p;
70 void pa_packet_unref(pa_packet *p) {
71 pa_assert(p);
72 pa_assert(PA_REFCNT_VALUE(p) >= 1);
74 if (PA_REFCNT_DEC(p) <= 0) {
75 if (p->type == PA_PACKET_DYNAMIC)
76 pa_xfree(p->data);
77 pa_xfree(p);