mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -05:00
partial implementation of native protocol
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@30 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
a84f38e611
commit
eecf602476
16 changed files with 683 additions and 113 deletions
21
src/packet.c
21
src/packet.c
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "packet.h"
|
||||
|
||||
struct packet* packet_new(uint32_t length) {
|
||||
struct packet* packet_new(size_t length) {
|
||||
struct packet *p;
|
||||
assert(length);
|
||||
p = malloc(sizeof(struct packet)+length);
|
||||
|
|
@ -11,9 +11,23 @@ struct packet* packet_new(uint32_t length) {
|
|||
|
||||
p->ref = 1;
|
||||
p->length = length;
|
||||
p->data = (uint8_t*) (p+1);
|
||||
p->type = PACKET_APPENDED;
|
||||
return p;
|
||||
}
|
||||
|
||||
struct packet* packet_dynamic(uint8_t* data, size_t length) {
|
||||
struct packet *p;
|
||||
assert(data && length);
|
||||
p = malloc(sizeof(struct packet));
|
||||
assert(p);
|
||||
|
||||
p->ref = 1;
|
||||
p->length = length;
|
||||
p->data = data;
|
||||
p->type = PACKET_DYNAMIC;
|
||||
}
|
||||
|
||||
struct packet* packet_ref(struct packet *p) {
|
||||
assert(p && p->ref >= 1);
|
||||
p->ref++;
|
||||
|
|
@ -24,6 +38,9 @@ void packet_unref(struct packet *p) {
|
|||
assert(p && p->ref >= 1);
|
||||
p->ref--;
|
||||
|
||||
if (p->ref == 0)
|
||||
if (p->ref == 0) {
|
||||
if (p->type == PACKET_DYNAMIC)
|
||||
free(p->data);
|
||||
free(p);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue