mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-07 13:30:03 -05:00
merge 'lennart' branch back into trunk.
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1971 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
6687dd0131
commit
a67c21f093
294 changed files with 79057 additions and 11614 deletions
|
|
@ -21,44 +21,56 @@
|
|||
USA.
|
||||
***/
|
||||
|
||||
#include <assert.h>
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <pulse/xmalloc.h>
|
||||
|
||||
#include <pulsecore/props.h>
|
||||
#include <pulsecore/macro.h>
|
||||
#include <pulsecore/log.h>
|
||||
#include <pulsecore/refcnt.h>
|
||||
|
||||
#include "authkey-prop.h"
|
||||
|
||||
struct authkey_data {
|
||||
int ref;
|
||||
PA_REFCNT_DECLARE;
|
||||
size_t length;
|
||||
};
|
||||
|
||||
int pa_authkey_prop_get(pa_core *c, const char *name, void *data, size_t len) {
|
||||
struct authkey_data *a;
|
||||
assert(c && name && data && len > 0);
|
||||
|
||||
pa_assert(c);
|
||||
pa_assert(name);
|
||||
pa_assert(data);
|
||||
pa_assert(len > 0);
|
||||
|
||||
if (!(a = pa_property_get(c, name)))
|
||||
return -1;
|
||||
|
||||
assert(a->length == len);
|
||||
memcpy(data, a+1, len);
|
||||
pa_assert(a->length == len);
|
||||
memcpy(data, (uint8_t*) a + PA_ALIGN(sizeof(struct authkey_data)), len);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pa_authkey_prop_put(pa_core *c, const char *name, const void *data, size_t len) {
|
||||
struct authkey_data *a;
|
||||
assert(c && name);
|
||||
|
||||
pa_assert(c);
|
||||
pa_assert(name);
|
||||
|
||||
if (pa_property_get(c, name))
|
||||
return -1;
|
||||
|
||||
a = pa_xmalloc(sizeof(struct authkey_data) + len);
|
||||
a->ref = 1;
|
||||
a = pa_xmalloc(PA_ALIGN(sizeof(struct authkey_data)) + len);
|
||||
PA_REFCNT_INIT(a);
|
||||
a->length = len;
|
||||
memcpy(a+1, data, len);
|
||||
memcpy((uint8_t*) a + PA_ALIGN(sizeof(struct authkey_data)), data, len);
|
||||
|
||||
pa_property_set(c, name, a);
|
||||
|
||||
|
|
@ -67,22 +79,27 @@ int pa_authkey_prop_put(pa_core *c, const char *name, const void *data, size_t l
|
|||
|
||||
void pa_authkey_prop_ref(pa_core *c, const char *name) {
|
||||
struct authkey_data *a;
|
||||
assert(c && name);
|
||||
|
||||
pa_assert(c);
|
||||
pa_assert(name);
|
||||
|
||||
a = pa_property_get(c, name);
|
||||
assert(a && a->ref >= 1);
|
||||
|
||||
a->ref++;
|
||||
pa_assert(a);
|
||||
pa_assert(PA_REFCNT_VALUE(a) >= 1);
|
||||
PA_REFCNT_INC(a);
|
||||
}
|
||||
|
||||
void pa_authkey_prop_unref(pa_core *c, const char *name) {
|
||||
struct authkey_data *a;
|
||||
assert(c && name);
|
||||
|
||||
pa_assert(c);
|
||||
pa_assert(name);
|
||||
|
||||
a = pa_property_get(c, name);
|
||||
assert(a && a->ref >= 1);
|
||||
pa_assert(a);
|
||||
pa_assert(PA_REFCNT_VALUE(a) >= 1);
|
||||
|
||||
if (!(--a->ref)) {
|
||||
if (PA_REFCNT_DEC(a) <= 0) {
|
||||
pa_property_remove(c, name);
|
||||
pa_xfree(a);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue