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
28 #include <pulse/xmalloc.h>
29 #include <pulsecore/macro.h>
33 pa_packet
* pa_packet_new(size_t length
) {
36 pa_assert(length
> 0);
38 p
= pa_xmalloc(PA_ALIGN(sizeof(pa_packet
)) + length
);
41 p
->data
= (uint8_t*) p
+ PA_ALIGN(sizeof(pa_packet
));
42 p
->type
= PA_PACKET_APPENDED
;
47 pa_packet
* pa_packet_new_dynamic(void* data
, size_t length
) {
51 pa_assert(length
> 0);
53 p
= pa_xnew(pa_packet
, 1);
57 p
->type
= PA_PACKET_DYNAMIC
;
62 pa_packet
* pa_packet_ref(pa_packet
*p
) {
64 pa_assert(PA_REFCNT_VALUE(p
) >= 1);
70 void pa_packet_unref(pa_packet
*p
) {
72 pa_assert(PA_REFCNT_VALUE(p
) >= 1);
74 if (PA_REFCNT_DEC(p
) <= 0) {
75 if (p
->type
== PA_PACKET_DYNAMIC
)