* remove a lot of compiler warnings introduced by using some new GCC flags

* add typedefs for public structs and enums and drop the struct/enum prefixs from all uses where it makes sense


git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@447 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
Lennart Poettering 2006-01-11 01:17:39 +00:00
parent 6c512fb5a3
commit 1f0961368f
200 changed files with 3582 additions and 3468 deletions

View file

@ -42,7 +42,7 @@ endif
# Compiler/linker flags #
###################################
AM_CFLAGS = -D_GNU_SOURCE -I$(top_srcdir)
AM_CFLAGS = -I$(top_srcdir)
AM_CFLAGS += $(PTHREAD_CFLAGS) -D_POSIX_PTHREAD_SEMANTICS
AM_CFLAGS += $(LTDLINCL)
AM_CFLAGS += $(LIBSAMPLERATE_CFLAGS) $(LIBSNDFILE_CFLAGS)
@ -224,12 +224,12 @@ voltest_CFLAGS = $(AM_CFLAGS)
voltest_LDADD = $(AM_LDADD)
voltest_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
cpulimit_test_SOURCES = cpulimit-test.c cpulimit.c util.c log.c cpulimit.h util.h log.h
cpulimit_test_SOURCES = cpulimit-test.c cpulimit.c util.c log.c cpulimit.h util.h log.h idxset.c idxset.h
cpulimit_test_CFLAGS = $(AM_CFLAGS)
cpulimit_test_LDADD = $(AM_LDADD) libpolyp-mainloop-@PA_MAJORMINOR@.la
cpulimit_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
cpulimit_test2_SOURCES = cpulimit-test.c cpulimit.c util.c log.c cpulimit.h util.h log.h
cpulimit_test2_SOURCES = cpulimit-test.c cpulimit.c util.c log.c cpulimit.h util.h log.h idxset.c idxset.h
cpulimit_test2_CFLAGS = $(AM_CFLAGS) -DTEST2
cpulimit_test2_LDADD = $(AM_LDADD) libpolyp-mainloop-@PA_MAJORMINOR@.la
cpulimit_test2_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)

View file

@ -33,7 +33,7 @@
/* Set the hardware parameters of the given ALSA device. Returns the
* selected fragment settings in *period and *period_size */
int pa_alsa_set_hw_params(snd_pcm_t *pcm_handle, const struct pa_sample_spec *ss, uint32_t *periods, snd_pcm_uframes_t *period_size) {
int pa_alsa_set_hw_params(snd_pcm_t *pcm_handle, const pa_sample_spec *ss, uint32_t *periods, snd_pcm_uframes_t *period_size) {
int ret = -1;
snd_pcm_uframes_t buffer_size;
snd_pcm_hw_params_t *hwparams = NULL;
@ -85,10 +85,10 @@ finish:
* *io_events. Store the length of that array in *n_io_events. Use the
* specified callback function and userdata. The array has to be freed
* with pa_free_io_events(). */
int pa_create_io_events(snd_pcm_t *pcm_handle, struct pa_mainloop_api* m, struct pa_io_event ***io_events, unsigned *n_io_events, void (*cb)(struct pa_mainloop_api*a, struct pa_io_event *e, int fd, enum pa_io_event_flags events, void *userdata), void *userdata) {
int pa_create_io_events(snd_pcm_t *pcm_handle, pa_mainloop_api* m, pa_io_event ***io_events, unsigned *n_io_events, void (*cb)(pa_mainloop_api*a, pa_io_event *e, int fd, pa_io_event_flags events, void *userdata), void *userdata) {
unsigned i;
struct pollfd *pfds, *ppfd;
struct pa_io_event **ios;
pa_io_event **ios;
assert(pcm_handle && m && io_events && n_io_events && cb);
*n_io_events = snd_pcm_poll_descriptors_count(pcm_handle);
@ -113,9 +113,9 @@ int pa_create_io_events(snd_pcm_t *pcm_handle, struct pa_mainloop_api* m, struct
}
/* Free the memory allocated by pa_create_io_events() */
void pa_free_io_events(struct pa_mainloop_api* m, struct pa_io_event **io_events, unsigned n_io_events) {
void pa_free_io_events(pa_mainloop_api* m, pa_io_event **io_events, unsigned n_io_events) {
unsigned i;
struct pa_io_event **ios;
pa_io_event **ios;
assert(m && io_events);
for (ios = io_events, i = 0; i < n_io_events; i++, ios++)

View file

@ -27,9 +27,9 @@
#include "sample.h"
#include "mainloop-api.h"
int pa_alsa_set_hw_params(snd_pcm_t *pcm_handle, const struct pa_sample_spec *ss, uint32_t *periods, snd_pcm_uframes_t *period_size);
int pa_alsa_set_hw_params(snd_pcm_t *pcm_handle, const pa_sample_spec *ss, uint32_t *periods, snd_pcm_uframes_t *period_size);
int pa_create_io_events(snd_pcm_t *pcm_handle, struct pa_mainloop_api *m, struct pa_io_event ***io_events, unsigned *n_io_events, void (*cb)(struct pa_mainloop_api*a, struct pa_io_event *e, int fd, enum pa_io_event_flags events, void *userdata), void *userdata);
void pa_free_io_events(struct pa_mainloop_api* m, struct pa_io_event **io_sources, unsigned n_io_sources);
int pa_create_io_events(snd_pcm_t *pcm_handle, pa_mainloop_api *m, pa_io_event ***io_events, unsigned *n_io_events, void (*cb)(pa_mainloop_api*a, pa_io_event *e, int fd, pa_io_event_flags events, void *userdata), void *userdata);
void pa_free_io_events(pa_mainloop_api* m, pa_io_event **io_sources, unsigned n_io_sources);
#endif

View file

@ -32,7 +32,7 @@ struct authkey_data {
size_t length;
};
int pa_authkey_prop_get(struct pa_core *c, const char *name, void *data, size_t len) {
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);
@ -44,7 +44,7 @@ int pa_authkey_prop_get(struct pa_core *c, const char *name, void *data, size_t
return 0;
}
int pa_authkey_prop_put(struct pa_core *c, const char *name, const void *data, size_t len) {
int pa_authkey_prop_put(pa_core *c, const char *name, const void *data, size_t len) {
struct authkey_data *a;
assert(c && name);
@ -61,7 +61,7 @@ int pa_authkey_prop_put(struct pa_core *c, const char *name, const void *data, s
return 0;
}
void pa_authkey_prop_ref(struct pa_core *c, const char *name) {
void pa_authkey_prop_ref(pa_core *c, const char *name) {
struct authkey_data *a;
assert(c && name);
@ -71,7 +71,7 @@ void pa_authkey_prop_ref(struct pa_core *c, const char *name) {
a->ref++;
}
void pa_authkey_prop_unref(struct pa_core *c, const char *name) {
void pa_authkey_prop_unref(pa_core *c, const char *name) {
struct authkey_data *a;
assert(c && name);

View file

@ -29,15 +29,15 @@
* several modules. */
/* Return the data of the specified authorization key property. Doesn't alter the refernce count of the key */
int pa_authkey_prop_get(struct pa_core *c, const char *name, void *data, size_t len);
int pa_authkey_prop_get(pa_core *c, const char *name, void *data, size_t len);
/* Store data in the specified authorization key property. The initial reference count is set to 1 */
int pa_authkey_prop_put(struct pa_core *c, const char *name, const void *data, size_t len);
int pa_authkey_prop_put(pa_core *c, const char *name, const void *data, size_t len);
/* Increase the reference count of the specified authorization key */
void pa_authkey_prop_ref(struct pa_core *c, const char *name);
void pa_authkey_prop_ref(pa_core *c, const char *name);
/* Decrease the reference count of the specified authorization key */
void pa_authkey_prop_unref(struct pa_core *c, const char *name);
void pa_authkey_prop_unref(pa_core *c, const char *name);
#endif

View file

@ -36,7 +36,7 @@
#include "scache.h"
#include "subscribe.h"
static void entry_free(struct pa_autoload_entry *e) {
static void entry_free(pa_autoload_entry *e) {
assert(e);
pa_subscription_post(e->core, PA_SUBSCRIPTION_EVENT_AUTOLOAD|PA_SUBSCRIPTION_EVENT_REMOVE, PA_INVALID_INDEX);
pa_xfree(e->name);
@ -45,7 +45,7 @@ static void entry_free(struct pa_autoload_entry *e) {
pa_xfree(e);
}
static void entry_remove_and_free(struct pa_autoload_entry *e) {
static void entry_remove_and_free(pa_autoload_entry *e) {
assert(e && e->core);
pa_idxset_remove_by_data(e->core->autoload_idxset, e, NULL);
@ -53,14 +53,14 @@ static void entry_remove_and_free(struct pa_autoload_entry *e) {
entry_free(e);
}
static struct pa_autoload_entry* entry_new(struct pa_core *c, const char *name) {
struct pa_autoload_entry *e = NULL;
static pa_autoload_entry* entry_new(pa_core *c, const char *name) {
pa_autoload_entry *e = NULL;
assert(c && name);
if (c->autoload_hashmap && (e = pa_hashmap_get(c->autoload_hashmap, name)))
return NULL;
e = pa_xmalloc(sizeof(struct pa_autoload_entry));
e = pa_xmalloc(sizeof(pa_autoload_entry));
e->core = c;
e->name = pa_xstrdup(name);
e->module = e->argument = NULL;
@ -81,8 +81,8 @@ static struct pa_autoload_entry* entry_new(struct pa_core *c, const char *name)
return e;
}
int pa_autoload_add(struct pa_core *c, const char*name, enum pa_namereg_type type, const char*module, const char *argument, uint32_t *index) {
struct pa_autoload_entry *e = NULL;
int pa_autoload_add(pa_core *c, const char*name, pa_namereg_type type, const char*module, const char *argument, uint32_t *idx) {
pa_autoload_entry *e = NULL;
assert(c && name && module && (type == PA_NAMEREG_SINK || type == PA_NAMEREG_SOURCE));
if (!(e = entry_new(c, name)))
@ -92,14 +92,14 @@ int pa_autoload_add(struct pa_core *c, const char*name, enum pa_namereg_type typ
e->argument = pa_xstrdup(argument);
e->type = type;
if (index)
*index = e->index;
if (idx)
*idx = e->index;
return 0;
}
int pa_autoload_remove_by_name(struct pa_core *c, const char*name, enum pa_namereg_type type) {
struct pa_autoload_entry *e;
int pa_autoload_remove_by_name(pa_core *c, const char*name, pa_namereg_type type) {
pa_autoload_entry *e;
assert(c && name && type);
if (!c->autoload_hashmap || !(e = pa_hashmap_get(c->autoload_hashmap, name)) || e->type != type)
@ -109,20 +109,20 @@ int pa_autoload_remove_by_name(struct pa_core *c, const char*name, enum pa_namer
return 0;
}
int pa_autoload_remove_by_index(struct pa_core *c, uint32_t index) {
struct pa_autoload_entry *e;
assert(c && index != PA_IDXSET_INVALID);
int pa_autoload_remove_by_index(pa_core *c, uint32_t idx) {
pa_autoload_entry *e;
assert(c && idx != PA_IDXSET_INVALID);
if (!c->autoload_idxset || !(e = pa_idxset_get_by_index(c->autoload_idxset, index)))
if (!c->autoload_idxset || !(e = pa_idxset_get_by_index(c->autoload_idxset, idx)))
return -1;
entry_remove_and_free(e);
return 0;
}
void pa_autoload_request(struct pa_core *c, const char *name, enum pa_namereg_type type) {
struct pa_autoload_entry *e;
struct pa_module *m;
void pa_autoload_request(pa_core *c, const char *name, pa_namereg_type type) {
pa_autoload_entry *e;
pa_module *m;
assert(c && name);
if (!c->autoload_hashmap || !(e = pa_hashmap_get(c->autoload_hashmap, name)) || (e->type != type))
@ -141,13 +141,13 @@ void pa_autoload_request(struct pa_core *c, const char *name, enum pa_namereg_ty
e->in_action = 0;
}
static void free_func(void *p, void *userdata) {
struct pa_autoload_entry *e = p;
static void free_func(void *p, PA_GCC_UNUSED void *userdata) {
pa_autoload_entry *e = p;
pa_idxset_remove_by_data(e->core->autoload_idxset, e, NULL);
entry_free(e);
}
void pa_autoload_free(struct pa_core *c) {
void pa_autoload_free(pa_core *c) {
if (c->autoload_hashmap) {
pa_hashmap_free(c->autoload_hashmap, free_func, NULL);
c->autoload_hashmap = NULL;
@ -159,8 +159,8 @@ void pa_autoload_free(struct pa_core *c) {
}
}
const struct pa_autoload_entry* pa_autoload_get_by_name(struct pa_core *c, const char*name, enum pa_namereg_type type) {
struct pa_autoload_entry *e;
const pa_autoload_entry* pa_autoload_get_by_name(pa_core *c, const char*name, pa_namereg_type type) {
pa_autoload_entry *e;
assert(c && name);
if (!c->autoload_hashmap || !(e = pa_hashmap_get(c->autoload_hashmap, name)) || e->type != type)
@ -169,11 +169,11 @@ const struct pa_autoload_entry* pa_autoload_get_by_name(struct pa_core *c, const
return e;
}
const struct pa_autoload_entry* pa_autoload_get_by_index(struct pa_core *c, uint32_t index) {
struct pa_autoload_entry *e;
assert(c && index != PA_IDXSET_INVALID);
const pa_autoload_entry* pa_autoload_get_by_index(pa_core *c, uint32_t idx) {
pa_autoload_entry *e;
assert(c && idx != PA_IDXSET_INVALID);
if (!c->autoload_idxset || !(e = pa_idxset_get_by_index(c->autoload_idxset, index)))
if (!c->autoload_idxset || !(e = pa_idxset_get_by_index(c->autoload_idxset, idx)))
return NULL;
return e;

View file

@ -30,29 +30,29 @@
* specified module is loaded. */
/* An autoload entry, or "ghost" sink/source */
struct pa_autoload_entry {
struct pa_core *core;
typedef struct pa_autoload_entry {
pa_core *core;
uint32_t index;
char *name;
enum pa_namereg_type type; /* Type of the autoload entry */
pa_namereg_type type; /* Type of the autoload entry */
int in_action; /* Currently loaded */
char *module, *argument;
};
} pa_autoload_entry;
/* Add a new autoload entry of the given time, with the speicified
* sink/source name, module name and argument. Return the entry's
* index in *index */
int pa_autoload_add(struct pa_core *c, const char*name, enum pa_namereg_type type, const char*module, const char *argument, uint32_t *index);
int pa_autoload_add(pa_core *c, const char*name, pa_namereg_type type, const char*module, const char *argument, uint32_t *idx);
/* Free all autoload entries */
void pa_autoload_free(struct pa_core *c);
int pa_autoload_remove_by_name(struct pa_core *c, const char*name, enum pa_namereg_type type);
int pa_autoload_remove_by_index(struct pa_core *c, uint32_t index);
void pa_autoload_free(pa_core *c);
int pa_autoload_remove_by_name(pa_core *c, const char*name, pa_namereg_type type);
int pa_autoload_remove_by_index(pa_core *c, uint32_t idx);
/* Request an autoload entry by its name, effectively causing a module to be loaded */
void pa_autoload_request(struct pa_core *c, const char *name, enum pa_namereg_type type);
void pa_autoload_request(pa_core *c, const char *name, pa_namereg_type type);
const struct pa_autoload_entry* pa_autoload_get_by_name(struct pa_core *c, const char*name, enum pa_namereg_type type);
const struct pa_autoload_entry* pa_autoload_get_by_index(struct pa_core *c, uint32_t index);
const pa_autoload_entry* pa_autoload_get_by_name(pa_core *c, const char*name, pa_namereg_type type);
const pa_autoload_entry* pa_autoload_get_by_index(pa_core *c, uint32_t idx);
#endif

View file

@ -52,7 +52,7 @@
struct command {
const char *name;
int (*proc) (struct pa_core *c, struct pa_tokenizer*t, struct pa_strbuf *buf, int *fail);
int (*proc) (pa_core *c, pa_tokenizer*t, pa_strbuf *buf, int *fail);
const char *help;
unsigned args;
};
@ -62,36 +62,36 @@ struct command {
#define NOFAIL_META ".nofail"
/* Prototypes for all available commands */
static int pa_cli_command_exit(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail);
static int pa_cli_command_help(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail);
static int pa_cli_command_modules(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail);
static int pa_cli_command_clients(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail);
static int pa_cli_command_sinks(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail);
static int pa_cli_command_sources(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail);
static int pa_cli_command_sink_inputs(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail);
static int pa_cli_command_source_outputs(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail);
static int pa_cli_command_stat(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail);
static int pa_cli_command_info(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail);
static int pa_cli_command_load(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail);
static int pa_cli_command_unload(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail);
static int pa_cli_command_sink_volume(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail);
static int pa_cli_command_sink_input_volume(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail);
static int pa_cli_command_sink_default(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail);
static int pa_cli_command_source_default(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail);
static int pa_cli_command_kill_client(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail);
static int pa_cli_command_kill_sink_input(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail);
static int pa_cli_command_kill_source_output(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail);
static int pa_cli_command_scache_play(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail);
static int pa_cli_command_scache_remove(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail);
static int pa_cli_command_scache_list(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail);
static int pa_cli_command_scache_load(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail);
static int pa_cli_command_scache_load_dir(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail);
static int pa_cli_command_play_file(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail);
static int pa_cli_command_autoload_list(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail);
static int pa_cli_command_autoload_add(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail);
static int pa_cli_command_autoload_remove(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail);
static int pa_cli_command_dump(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail);
static int pa_cli_command_list_props(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail);
static int pa_cli_command_exit(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, int *fail);
static int pa_cli_command_help(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, int *fail);
static int pa_cli_command_modules(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, int *fail);
static int pa_cli_command_clients(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, int *fail);
static int pa_cli_command_sinks(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, int *fail);
static int pa_cli_command_sources(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, int *fail);
static int pa_cli_command_sink_inputs(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, int *fail);
static int pa_cli_command_source_outputs(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, int *fail);
static int pa_cli_command_stat(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, int *fail);
static int pa_cli_command_info(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, int *fail);
static int pa_cli_command_load(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, int *fail);
static int pa_cli_command_unload(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, int *fail);
static int pa_cli_command_sink_volume(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, int *fail);
static int pa_cli_command_sink_input_volume(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, int *fail);
static int pa_cli_command_sink_default(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, int *fail);
static int pa_cli_command_source_default(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, int *fail);
static int pa_cli_command_kill_client(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, int *fail);
static int pa_cli_command_kill_sink_input(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, int *fail);
static int pa_cli_command_kill_source_output(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, int *fail);
static int pa_cli_command_scache_play(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, int *fail);
static int pa_cli_command_scache_remove(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, int *fail);
static int pa_cli_command_scache_list(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, int *fail);
static int pa_cli_command_scache_load(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, int *fail);
static int pa_cli_command_scache_load_dir(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, int *fail);
static int pa_cli_command_play_file(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, int *fail);
static int pa_cli_command_autoload_list(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, int *fail);
static int pa_cli_command_autoload_add(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, int *fail);
static int pa_cli_command_autoload_remove(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, int *fail);
static int pa_cli_command_dump(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, int *fail);
static int pa_cli_command_list_props(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, int *fail);
/* A method table for all available commands */
@ -139,21 +139,21 @@ static const char whitespace[] = " \t\n\r";
static const char linebreak[] = "\n\r";
static uint32_t parse_index(const char *n) {
uint32_t index;
uint32_t idx;
if (pa_atou(n, &index) < 0)
if (pa_atou(n, &idx) < 0)
return (uint32_t) PA_IDXSET_INVALID;
return index;
return idx;
}
static int pa_cli_command_exit(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail) {
static int pa_cli_command_exit(pa_core *c, pa_tokenizer *t, PA_GCC_UNUSED pa_strbuf *buf, PA_GCC_UNUSED int *fail) {
assert(c && c->mainloop && t);
c->mainloop->quit(c->mainloop, 0);
return 0;
}
static int pa_cli_command_help(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail) {
static int pa_cli_command_help(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, PA_GCC_UNUSED int *fail) {
const struct command*command;
assert(c && t && buf);
@ -165,7 +165,7 @@ static int pa_cli_command_help(struct pa_core *c, struct pa_tokenizer *t, struct
return 0;
}
static int pa_cli_command_modules(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail) {
static int pa_cli_command_modules(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, PA_GCC_UNUSED int *fail) {
char *s;
assert(c && t);
s = pa_module_list_to_string(c);
@ -175,7 +175,7 @@ static int pa_cli_command_modules(struct pa_core *c, struct pa_tokenizer *t, str
return 0;
}
static int pa_cli_command_clients(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail) {
static int pa_cli_command_clients(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, PA_GCC_UNUSED int *fail) {
char *s;
assert(c && t);
s = pa_client_list_to_string(c);
@ -185,7 +185,7 @@ static int pa_cli_command_clients(struct pa_core *c, struct pa_tokenizer *t, str
return 0;
}
static int pa_cli_command_sinks(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail) {
static int pa_cli_command_sinks(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, PA_GCC_UNUSED int *fail) {
char *s;
assert(c && t);
s = pa_sink_list_to_string(c);
@ -195,7 +195,7 @@ static int pa_cli_command_sinks(struct pa_core *c, struct pa_tokenizer *t, struc
return 0;
}
static int pa_cli_command_sources(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail) {
static int pa_cli_command_sources(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, PA_GCC_UNUSED int *fail) {
char *s;
assert(c && t);
s = pa_source_list_to_string(c);
@ -205,7 +205,7 @@ static int pa_cli_command_sources(struct pa_core *c, struct pa_tokenizer *t, str
return 0;
}
static int pa_cli_command_sink_inputs(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail) {
static int pa_cli_command_sink_inputs(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, PA_GCC_UNUSED int *fail) {
char *s;
assert(c && t);
s = pa_sink_input_list_to_string(c);
@ -215,7 +215,7 @@ static int pa_cli_command_sink_inputs(struct pa_core *c, struct pa_tokenizer *t,
return 0;
}
static int pa_cli_command_source_outputs(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail) {
static int pa_cli_command_source_outputs(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, PA_GCC_UNUSED int *fail) {
char *s;
assert(c && t);
s = pa_source_output_list_to_string(c);
@ -225,7 +225,7 @@ static int pa_cli_command_source_outputs(struct pa_core *c, struct pa_tokenizer
return 0;
}
static int pa_cli_command_stat(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail) {
static int pa_cli_command_stat(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, PA_GCC_UNUSED int *fail) {
char s[256];
assert(c && t);
@ -253,7 +253,7 @@ static int pa_cli_command_stat(struct pa_core *c, struct pa_tokenizer *t, struct
return 0;
}
static int pa_cli_command_info(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail) {
static int pa_cli_command_info(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, int *fail) {
assert(c && t);
pa_cli_command_stat(c, t, buf, fail);
pa_cli_command_modules(c, t, buf, fail);
@ -267,8 +267,8 @@ static int pa_cli_command_info(struct pa_core *c, struct pa_tokenizer *t, struct
return 0;
}
static int pa_cli_command_load(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail) {
struct pa_module *m;
static int pa_cli_command_load(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, PA_GCC_UNUSED int *fail) {
pa_module *m;
const char *name;
assert(c && t);
@ -285,9 +285,9 @@ static int pa_cli_command_load(struct pa_core *c, struct pa_tokenizer *t, struct
return 0;
}
static int pa_cli_command_unload(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail) {
struct pa_module *m;
uint32_t index;
static int pa_cli_command_unload(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, PA_GCC_UNUSED int *fail) {
pa_module *m;
uint32_t idx;
const char *i;
char *e;
assert(c && t);
@ -297,8 +297,8 @@ static int pa_cli_command_unload(struct pa_core *c, struct pa_tokenizer *t, stru
return -1;
}
index = (uint32_t) strtoul(i, &e, 10);
if (*e || !(m = pa_idxset_get_by_index(c->modules, index))) {
idx = (uint32_t) strtoul(i, &e, 10);
if (*e || !(m = pa_idxset_get_by_index(c->modules, idx))) {
pa_strbuf_puts(buf, "Invalid module index.\n");
return -1;
}
@ -307,9 +307,9 @@ static int pa_cli_command_unload(struct pa_core *c, struct pa_tokenizer *t, stru
return 0;
}
static int pa_cli_command_sink_volume(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail) {
static int pa_cli_command_sink_volume(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, PA_GCC_UNUSED int *fail) {
const char *n, *v;
struct pa_sink *sink;
pa_sink *sink;
uint32_t volume;
if (!(n = pa_tokenizer_get(t, 1))) {
@ -336,18 +336,18 @@ static int pa_cli_command_sink_volume(struct pa_core *c, struct pa_tokenizer *t,
return 0;
}
static int pa_cli_command_sink_input_volume(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail) {
static int pa_cli_command_sink_input_volume(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, PA_GCC_UNUSED int *fail) {
const char *n, *v;
struct pa_sink_input *si;
pa_sink_input *si;
uint32_t volume;
uint32_t index;
uint32_t idx;
if (!(n = pa_tokenizer_get(t, 1))) {
pa_strbuf_puts(buf, "You need to specify a sink input by its index.\n");
return -1;
}
if ((index = parse_index(n)) == PA_IDXSET_INVALID) {
if ((idx = parse_index(n)) == PA_IDXSET_INVALID) {
pa_strbuf_puts(buf, "Failed to parse index.\n");
return -1;
}
@ -362,7 +362,7 @@ static int pa_cli_command_sink_input_volume(struct pa_core *c, struct pa_tokeniz
return -1;
}
if (!(si = pa_idxset_get_by_index(c->sink_inputs, (uint32_t) index))) {
if (!(si = pa_idxset_get_by_index(c->sink_inputs, (uint32_t) idx))) {
pa_strbuf_puts(buf, "No sink input found with this index.\n");
return -1;
}
@ -371,7 +371,7 @@ static int pa_cli_command_sink_input_volume(struct pa_core *c, struct pa_tokeniz
return 0;
}
static int pa_cli_command_sink_default(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail) {
static int pa_cli_command_sink_default(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, PA_GCC_UNUSED int *fail) {
const char *n;
assert(c && t);
@ -384,7 +384,7 @@ static int pa_cli_command_sink_default(struct pa_core *c, struct pa_tokenizer *t
return 0;
}
static int pa_cli_command_source_default(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail) {
static int pa_cli_command_source_default(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, PA_GCC_UNUSED int *fail) {
const char *n;
assert(c && t);
@ -397,10 +397,10 @@ static int pa_cli_command_source_default(struct pa_core *c, struct pa_tokenizer
return 0;
}
static int pa_cli_command_kill_client(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail) {
static int pa_cli_command_kill_client(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, PA_GCC_UNUSED int *fail) {
const char *n;
struct pa_client *client;
uint32_t index;
pa_client *client;
uint32_t idx;
assert(c && t);
if (!(n = pa_tokenizer_get(t, 1))) {
@ -408,12 +408,12 @@ static int pa_cli_command_kill_client(struct pa_core *c, struct pa_tokenizer *t,
return -1;
}
if ((index = parse_index(n)) == PA_IDXSET_INVALID) {
if ((idx = parse_index(n)) == PA_IDXSET_INVALID) {
pa_strbuf_puts(buf, "Failed to parse index.\n");
return -1;
}
if (!(client = pa_idxset_get_by_index(c->clients, index))) {
if (!(client = pa_idxset_get_by_index(c->clients, idx))) {
pa_strbuf_puts(buf, "No client found by this index.\n");
return -1;
}
@ -422,10 +422,10 @@ static int pa_cli_command_kill_client(struct pa_core *c, struct pa_tokenizer *t,
return 0;
}
static int pa_cli_command_kill_sink_input(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail) {
static int pa_cli_command_kill_sink_input(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, PA_GCC_UNUSED int *fail) {
const char *n;
struct pa_sink_input *sink_input;
uint32_t index;
pa_sink_input *sink_input;
uint32_t idx;
assert(c && t);
if (!(n = pa_tokenizer_get(t, 1))) {
@ -433,12 +433,12 @@ static int pa_cli_command_kill_sink_input(struct pa_core *c, struct pa_tokenizer
return -1;
}
if ((index = parse_index(n)) == PA_IDXSET_INVALID) {
if ((idx = parse_index(n)) == PA_IDXSET_INVALID) {
pa_strbuf_puts(buf, "Failed to parse index.\n");
return -1;
}
if (!(sink_input = pa_idxset_get_by_index(c->sink_inputs, index))) {
if (!(sink_input = pa_idxset_get_by_index(c->sink_inputs, idx))) {
pa_strbuf_puts(buf, "No sink input found by this index.\n");
return -1;
}
@ -447,10 +447,10 @@ static int pa_cli_command_kill_sink_input(struct pa_core *c, struct pa_tokenizer
return 0;
}
static int pa_cli_command_kill_source_output(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail) {
static int pa_cli_command_kill_source_output(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, PA_GCC_UNUSED int *fail) {
const char *n;
struct pa_source_output *source_output;
uint32_t index;
pa_source_output *source_output;
uint32_t idx;
assert(c && t);
if (!(n = pa_tokenizer_get(t, 1))) {
@ -458,12 +458,12 @@ static int pa_cli_command_kill_source_output(struct pa_core *c, struct pa_tokeni
return -1;
}
if ((index = parse_index(n)) == PA_IDXSET_INVALID) {
if ((idx = parse_index(n)) == PA_IDXSET_INVALID) {
pa_strbuf_puts(buf, "Failed to parse index.\n");
return -1;
}
if (!(source_output = pa_idxset_get_by_index(c->source_outputs, index))) {
if (!(source_output = pa_idxset_get_by_index(c->source_outputs, idx))) {
pa_strbuf_puts(buf, "No source output found by this index.\n");
return -1;
}
@ -472,7 +472,7 @@ static int pa_cli_command_kill_source_output(struct pa_core *c, struct pa_tokeni
return 0;
}
static int pa_cli_command_scache_list(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail) {
static int pa_cli_command_scache_list(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, PA_GCC_UNUSED int *fail) {
char *s;
assert(c && t);
s = pa_scache_list_to_string(c);
@ -482,9 +482,9 @@ static int pa_cli_command_scache_list(struct pa_core *c, struct pa_tokenizer *t,
return 0;
}
static int pa_cli_command_scache_play(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail) {
static int pa_cli_command_scache_play(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, int *fail) {
const char *n, *sink_name;
struct pa_sink *sink;
pa_sink *sink;
assert(c && t && buf && fail);
if (!(n = pa_tokenizer_get(t, 1)) || !(sink_name = pa_tokenizer_get(t, 2))) {
@ -505,7 +505,7 @@ static int pa_cli_command_scache_play(struct pa_core *c, struct pa_tokenizer *t,
return 0;
}
static int pa_cli_command_scache_remove(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail) {
static int pa_cli_command_scache_remove(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, int *fail) {
const char *n;
assert(c && t && buf && fail);
@ -522,7 +522,7 @@ static int pa_cli_command_scache_remove(struct pa_core *c, struct pa_tokenizer *
return 0;
}
static int pa_cli_command_scache_load(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail) {
static int pa_cli_command_scache_load(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, int *fail) {
const char *fname, *n;
int r;
assert(c && t && buf && fail);
@ -543,7 +543,7 @@ static int pa_cli_command_scache_load(struct pa_core *c, struct pa_tokenizer *t,
return 0;
}
static int pa_cli_command_scache_load_dir(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail) {
static int pa_cli_command_scache_load_dir(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, int *fail) {
const char *pname;
assert(c && t && buf && fail);
@ -560,9 +560,9 @@ static int pa_cli_command_scache_load_dir(struct pa_core *c, struct pa_tokenizer
return 0;
}
static int pa_cli_command_play_file(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail) {
static int pa_cli_command_play_file(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, int *fail) {
const char *fname, *sink_name;
struct pa_sink *sink;
pa_sink *sink;
assert(c && t && buf && fail);
if (!(fname = pa_tokenizer_get(t, 1)) || !(sink_name = pa_tokenizer_get(t, 2))) {
@ -579,7 +579,7 @@ static int pa_cli_command_play_file(struct pa_core *c, struct pa_tokenizer *t, s
return pa_play_file(sink, fname, PA_VOLUME_NORM);
}
static int pa_cli_command_autoload_add(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail) {
static int pa_cli_command_autoload_add(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, int *fail) {
const char *a, *b;
assert(c && t && buf && fail);
@ -593,7 +593,7 @@ static int pa_cli_command_autoload_add(struct pa_core *c, struct pa_tokenizer *t
return 0;
}
static int pa_cli_command_autoload_remove(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail) {
static int pa_cli_command_autoload_remove(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, int *fail) {
const char *name;
assert(c && t && buf && fail);
@ -610,7 +610,7 @@ static int pa_cli_command_autoload_remove(struct pa_core *c, struct pa_tokenizer
return 0;
}
static int pa_cli_command_autoload_list(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail) {
static int pa_cli_command_autoload_list(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, PA_GCC_UNUSED int *fail) {
char *s;
assert(c && t);
s = pa_autoload_list_to_string(c);
@ -620,22 +620,22 @@ static int pa_cli_command_autoload_list(struct pa_core *c, struct pa_tokenizer *
return 0;
}
static int pa_cli_command_list_props(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail) {
static int pa_cli_command_list_props(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, PA_GCC_UNUSED int *fail) {
assert(c && t);
pa_property_dump(c, buf);
return 0;
}
static int pa_cli_command_dump(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail) {
struct pa_module *m;
struct pa_sink *s;
static int pa_cli_command_dump(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, PA_GCC_UNUSED int *fail) {
pa_module *m;
pa_sink *s;
int nl;
const char *p;
uint32_t index;
uint32_t idx;
char txt[256];
time_t now;
void *i;
struct pa_autoload_entry *a;
pa_autoload_entry *a;
assert(c && t);
@ -648,7 +648,7 @@ static int pa_cli_command_dump(struct pa_core *c, struct pa_tokenizer *t, struct
#endif
for (m = pa_idxset_first(c->modules, &index); m; m = pa_idxset_next(c->modules, &index)) {
for (m = pa_idxset_first(c->modules, &idx); m; m = pa_idxset_next(c->modules, &idx)) {
if (m->auto_unload)
continue;
@ -662,7 +662,7 @@ static int pa_cli_command_dump(struct pa_core *c, struct pa_tokenizer *t, struct
nl = 0;
for (s = pa_idxset_first(c->sinks, &index); s; s = pa_idxset_next(c->sinks, &index)) {
for (s = pa_idxset_first(c->sinks, &idx); s; s = pa_idxset_next(c->sinks, &idx)) {
if (s->volume == PA_VOLUME_NORM)
continue;
@ -722,7 +722,7 @@ static int pa_cli_command_dump(struct pa_core *c, struct pa_tokenizer *t, struct
}
int pa_cli_command_execute_line(struct pa_core *c, const char *s, struct pa_strbuf *buf, int *fail) {
int pa_cli_command_execute_line(pa_core *c, const char *s, pa_strbuf *buf, int *fail) {
const char *cs;
cs = s+strspn(s, whitespace);
@ -758,7 +758,7 @@ int pa_cli_command_execute_line(struct pa_core *c, const char *s, struct pa_strb
for (command = commands; command->name; command++)
if (strlen(command->name) == l && !strncmp(cs, command->name, l)) {
int ret;
struct pa_tokenizer *t = pa_tokenizer_new(cs, command->args);
pa_tokenizer *t = pa_tokenizer_new(cs, command->args);
assert(t);
ret = command->proc(c, t, buf, fail);
pa_tokenizer_free(t);
@ -780,7 +780,7 @@ int pa_cli_command_execute_line(struct pa_core *c, const char *s, struct pa_strb
return 0;
}
int pa_cli_command_execute_file(struct pa_core *c, const char *fn, struct pa_strbuf *buf, int *fail) {
int pa_cli_command_execute_file(pa_core *c, const char *fn, pa_strbuf *buf, int *fail) {
char line[256];
FILE *f = NULL;
int ret = -1;
@ -810,7 +810,7 @@ fail:
return ret;
}
int pa_cli_command_execute(struct pa_core *c, const char *s, struct pa_strbuf *buf, int *fail) {
int pa_cli_command_execute(pa_core *c, const char *s, pa_strbuf *buf, int *fail) {
const char *p;
assert(c && s && buf && fail);

View file

@ -29,12 +29,12 @@
* buffer *buf. If *fail is non-zero the function will return -1 when
* one or more of the executed commands failed. *fail
* may be modified by the function call. */
int pa_cli_command_execute_line(struct pa_core *c, const char *s, struct pa_strbuf *buf, int *fail);
int pa_cli_command_execute_line(pa_core *c, const char *s, pa_strbuf *buf, int *fail);
/* Execute a whole file of CLI commands */
int pa_cli_command_execute_file(struct pa_core *c, const char *fn, struct pa_strbuf *buf, int *fail);
int pa_cli_command_execute_file(pa_core *c, const char *fn, pa_strbuf *buf, int *fail);
/* Split the specified string into lines and run pa_cli_command_execute_line() for each. */
int pa_cli_command_execute(struct pa_core *c, const char *s, struct pa_strbuf *buf, int *fail);
int pa_cli_command_execute(pa_core *c, const char *s, pa_strbuf *buf, int *fail);
#endif

View file

@ -39,36 +39,36 @@
#include "autoload.h"
#include "xmalloc.h"
char *pa_module_list_to_string(struct pa_core *c) {
struct pa_strbuf *s;
struct pa_module *m;
uint32_t index = PA_IDXSET_INVALID;
char *pa_module_list_to_string(pa_core *c) {
pa_strbuf *s;
pa_module *m;
uint32_t idx = PA_IDXSET_INVALID;
assert(c);
s = pa_strbuf_new();
assert(s);
pa_strbuf_printf(s, "%u module(s) loaded.\n", pa_idxset_ncontents(c->modules));
pa_strbuf_printf(s, "%u module(s) loaded.\n", pa_idxset_size(c->modules));
for (m = pa_idxset_first(c->modules, &index); m; m = pa_idxset_next(c->modules, &index))
for (m = pa_idxset_first(c->modules, &idx); m; m = pa_idxset_next(c->modules, &idx))
pa_strbuf_printf(s, " index: %u\n\tname: <%s>\n\targument: <%s>\n\tused: %i\n\tauto unload: %s\n", m->index, m->name, m->argument, m->n_used, m->auto_unload ? "yes" : "no");
return pa_strbuf_tostring_free(s);
}
char *pa_client_list_to_string(struct pa_core *c) {
struct pa_strbuf *s;
struct pa_client *client;
uint32_t index = PA_IDXSET_INVALID;
char *pa_client_list_to_string(pa_core *c) {
pa_strbuf *s;
pa_client *client;
uint32_t idx = PA_IDXSET_INVALID;
char tid[5];
assert(c);
s = pa_strbuf_new();
assert(s);
pa_strbuf_printf(s, "%u client(s) logged in.\n", pa_idxset_ncontents(c->clients));
pa_strbuf_printf(s, "%u client(s) logged in.\n", pa_idxset_size(c->clients));
for (client = pa_idxset_first(c->clients, &index); client; client = pa_idxset_next(c->clients, &index)) {
for (client = pa_idxset_first(c->clients, &idx); client; client = pa_idxset_next(c->clients, &idx)) {
pa_strbuf_printf(s, " index: %u\n\tname: <%s>\n\ttype: <%s>\n", client->index, client->name, pa_typeid_to_string(client->typeid, tid, sizeof(tid)));
if (client->owner)
@ -78,19 +78,19 @@ char *pa_client_list_to_string(struct pa_core *c) {
return pa_strbuf_tostring_free(s);
}
char *pa_sink_list_to_string(struct pa_core *c) {
struct pa_strbuf *s;
struct pa_sink *sink;
uint32_t index = PA_IDXSET_INVALID;
char *pa_sink_list_to_string(pa_core *c) {
pa_strbuf *s;
pa_sink *sink;
uint32_t idx = PA_IDXSET_INVALID;
char tid[5];
assert(c);
s = pa_strbuf_new();
assert(s);
pa_strbuf_printf(s, "%u sink(s) available.\n", pa_idxset_ncontents(c->sinks));
pa_strbuf_printf(s, "%u sink(s) available.\n", pa_idxset_size(c->sinks));
for (sink = pa_idxset_first(c->sinks, &index); sink; sink = pa_idxset_next(c->sinks, &index)) {
for (sink = pa_idxset_first(c->sinks, &idx); sink; sink = pa_idxset_next(c->sinks, &idx)) {
char ss[PA_SAMPLE_SPEC_SNPRINT_MAX];
pa_sample_spec_snprint(ss, sizeof(ss), &sink->sample_spec);
assert(sink->monitor_source);
@ -102,7 +102,7 @@ char *pa_sink_list_to_string(struct pa_core *c) {
pa_typeid_to_string(sink->typeid, tid, sizeof(tid)),
(unsigned) sink->volume,
pa_volume_to_dB(sink->volume),
(float) pa_sink_get_latency(sink),
(double) pa_sink_get_latency(sink),
sink->monitor_source->index,
ss);
@ -115,19 +115,19 @@ char *pa_sink_list_to_string(struct pa_core *c) {
return pa_strbuf_tostring_free(s);
}
char *pa_source_list_to_string(struct pa_core *c) {
struct pa_strbuf *s;
struct pa_source *source;
uint32_t index = PA_IDXSET_INVALID;
char *pa_source_list_to_string(pa_core *c) {
pa_strbuf *s;
pa_source *source;
uint32_t idx = PA_IDXSET_INVALID;
char tid[5];
assert(c);
s = pa_strbuf_new();
assert(s);
pa_strbuf_printf(s, "%u source(s) available.\n", pa_idxset_ncontents(c->sources));
pa_strbuf_printf(s, "%u source(s) available.\n", pa_idxset_size(c->sources));
for (source = pa_idxset_first(c->sources, &index); source; source = pa_idxset_next(c->sources, &index)) {
for (source = pa_idxset_first(c->sources, &idx); source; source = pa_idxset_next(c->sources, &idx)) {
char ss[PA_SAMPLE_SPEC_SNPRINT_MAX];
pa_sample_spec_snprint(ss, sizeof(ss), &source->sample_spec);
pa_strbuf_printf(s, " %c index: %u\n\tname: <%s>\n\ttype: <%s>\n\tlatency: <%0.0f usec>\n\tsample_spec: <%s>\n",
@ -135,7 +135,7 @@ char *pa_source_list_to_string(struct pa_core *c) {
source->index,
source->name,
pa_typeid_to_string(source->typeid, tid, sizeof(tid)),
(float) pa_source_get_latency(source),
(double) pa_source_get_latency(source),
ss);
if (source->monitor_of)
@ -150,10 +150,10 @@ char *pa_source_list_to_string(struct pa_core *c) {
}
char *pa_source_output_list_to_string(struct pa_core *c) {
struct pa_strbuf *s;
struct pa_source_output *o;
uint32_t index = PA_IDXSET_INVALID;
char *pa_source_output_list_to_string(pa_core *c) {
pa_strbuf *s;
pa_source_output *o;
uint32_t idx = PA_IDXSET_INVALID;
char tid[5];
static const char* const state_table[] = {
"RUNNING",
@ -165,9 +165,9 @@ char *pa_source_output_list_to_string(struct pa_core *c) {
s = pa_strbuf_new();
assert(s);
pa_strbuf_printf(s, "%u source outputs(s) available.\n", pa_idxset_ncontents(c->source_outputs));
pa_strbuf_printf(s, "%u source outputs(s) available.\n", pa_idxset_size(c->source_outputs));
for (o = pa_idxset_first(c->source_outputs, &index); o; o = pa_idxset_next(c->source_outputs, &index)) {
for (o = pa_idxset_first(c->source_outputs, &idx); o; o = pa_idxset_next(c->source_outputs, &idx)) {
char ss[PA_SAMPLE_SPEC_SNPRINT_MAX];
const char *rm;
pa_sample_spec_snprint(ss, sizeof(ss), &o->sample_spec);
@ -194,10 +194,10 @@ char *pa_source_output_list_to_string(struct pa_core *c) {
return pa_strbuf_tostring_free(s);
}
char *pa_sink_input_list_to_string(struct pa_core *c) {
struct pa_strbuf *s;
struct pa_sink_input *i;
uint32_t index = PA_IDXSET_INVALID;
char *pa_sink_input_list_to_string(pa_core *c) {
pa_strbuf *s;
pa_sink_input *i;
uint32_t idx = PA_IDXSET_INVALID;
char tid[5];
static const char* const state_table[] = {
"RUNNING",
@ -209,9 +209,9 @@ char *pa_sink_input_list_to_string(struct pa_core *c) {
s = pa_strbuf_new();
assert(s);
pa_strbuf_printf(s, "%u sink input(s) available.\n", pa_idxset_ncontents(c->sink_inputs));
pa_strbuf_printf(s, "%u sink input(s) available.\n", pa_idxset_size(c->sink_inputs));
for (i = pa_idxset_first(c->sink_inputs, &index); i; i = pa_idxset_next(c->sink_inputs, &index)) {
for (i = pa_idxset_first(c->sink_inputs, &idx); i; i = pa_idxset_next(c->sink_inputs, &idx)) {
char ss[PA_SAMPLE_SPEC_SNPRINT_MAX];
const char *rm;
@ -229,7 +229,7 @@ char *pa_sink_input_list_to_string(struct pa_core *c) {
i->sink->index, i->sink->name,
(unsigned) i->volume,
pa_volume_to_dB(i->volume),
(float) pa_sink_input_get_latency(i),
(double) pa_sink_input_get_latency(i),
ss,
rm);
@ -242,20 +242,20 @@ char *pa_sink_input_list_to_string(struct pa_core *c) {
return pa_strbuf_tostring_free(s);
}
char *pa_scache_list_to_string(struct pa_core *c) {
struct pa_strbuf *s;
char *pa_scache_list_to_string(pa_core *c) {
pa_strbuf *s;
assert(c);
s = pa_strbuf_new();
assert(s);
pa_strbuf_printf(s, "%u cache entries available.\n", c->scache ? pa_idxset_ncontents(c->scache) : 0);
pa_strbuf_printf(s, "%u cache entries available.\n", c->scache ? pa_idxset_size(c->scache) : 0);
if (c->scache) {
struct pa_scache_entry *e;
uint32_t index = PA_IDXSET_INVALID;
pa_scache_entry *e;
uint32_t idx = PA_IDXSET_INVALID;
for (e = pa_idxset_first(c->scache, &index); e; e = pa_idxset_next(c->scache, &index)) {
for (e = pa_idxset_first(c->scache, &idx); e; e = pa_idxset_next(c->scache, &idx)) {
double l = 0;
char ss[PA_SAMPLE_SPEC_SNPRINT_MAX] = "n/a";
@ -280,17 +280,17 @@ char *pa_scache_list_to_string(struct pa_core *c) {
return pa_strbuf_tostring_free(s);
}
char *pa_autoload_list_to_string(struct pa_core *c) {
struct pa_strbuf *s;
char *pa_autoload_list_to_string(pa_core *c) {
pa_strbuf *s;
assert(c);
s = pa_strbuf_new();
assert(s);
pa_strbuf_printf(s, "%u autoload entries available.\n", c->autoload_hashmap ? pa_hashmap_ncontents(c->autoload_hashmap) : 0);
pa_strbuf_printf(s, "%u autoload entries available.\n", c->autoload_hashmap ? pa_hashmap_size(c->autoload_hashmap) : 0);
if (c->autoload_hashmap) {
struct pa_autoload_entry *e;
pa_autoload_entry *e;
void *state = NULL;
while ((e = pa_hashmap_iterate(c->autoload_hashmap, &state, NULL))) {
@ -308,8 +308,8 @@ char *pa_autoload_list_to_string(struct pa_core *c) {
return pa_strbuf_tostring_free(s);
}
char *pa_full_status_string(struct pa_core *c) {
struct pa_strbuf *s;
char *pa_full_status_string(pa_core *c) {
pa_strbuf *s;
int i;
s = pa_strbuf_new();

View file

@ -27,16 +27,16 @@
/* Some functions to generate pretty formatted listings of
* entities. The returned strings have to be freed manually. */
char *pa_sink_input_list_to_string(struct pa_core *c);
char *pa_source_output_list_to_string(struct pa_core *c);
char *pa_sink_list_to_string(struct pa_core *core);
char *pa_source_list_to_string(struct pa_core *c);
char *pa_client_list_to_string(struct pa_core *c);
char *pa_module_list_to_string(struct pa_core *c);
char *pa_scache_list_to_string(struct pa_core *c);
char *pa_autoload_list_to_string(struct pa_core *c);
char *pa_sink_input_list_to_string(pa_core *c);
char *pa_source_output_list_to_string(pa_core *c);
char *pa_sink_list_to_string(pa_core *core);
char *pa_source_list_to_string(pa_core *c);
char *pa_client_list_to_string(pa_core *c);
char *pa_module_list_to_string(pa_core *c);
char *pa_scache_list_to_string(pa_core *c);
char *pa_autoload_list_to_string(pa_core *c);
char *pa_full_status_string(struct pa_core *c);
char *pa_full_status_string(pa_core *c);
#endif

View file

@ -48,26 +48,26 @@
#define PA_TYPEID_CLI PA_TYPEID_MAKE('C', 'L', 'I', '_')
struct pa_cli {
struct pa_core *core;
struct pa_ioline *line;
pa_core *core;
pa_ioline *line;
void (*eof_callback)(struct pa_cli *c, void *userdata);
void (*eof_callback)(pa_cli *c, void *userdata);
void *userdata;
struct pa_client *client;
pa_client *client;
int fail, kill_requested, defer_kill;
};
static void line_callback(struct pa_ioline *line, const char *s, void *userdata);
static void client_kill(struct pa_client *c);
static void line_callback(pa_ioline *line, const char *s, void *userdata);
static void client_kill(pa_client *c);
struct pa_cli* pa_cli_new(struct pa_core *core, struct pa_iochannel *io, struct pa_module *m) {
pa_cli* pa_cli_new(pa_core *core, pa_iochannel *io, pa_module *m) {
char cname[256];
struct pa_cli *c;
pa_cli *c;
assert(io);
c = pa_xmalloc(sizeof(struct pa_cli));
c = pa_xmalloc(sizeof(pa_cli));
c->core = core;
c->line = pa_ioline_new(io);
assert(c->line);
@ -90,7 +90,7 @@ struct pa_cli* pa_cli_new(struct pa_core *core, struct pa_iochannel *io, struct
return c;
}
void pa_cli_free(struct pa_cli *c) {
void pa_cli_free(pa_cli *c) {
assert(c);
pa_ioline_close(c->line);
pa_ioline_unref(c->line);
@ -98,8 +98,8 @@ void pa_cli_free(struct pa_cli *c) {
pa_xfree(c);
}
static void client_kill(struct pa_client *client) {
struct pa_cli *c;
static void client_kill(pa_client *client) {
pa_cli *c;
assert(client && client->userdata);
c = client->userdata;
@ -112,9 +112,9 @@ static void client_kill(struct pa_client *client) {
}
}
static void line_callback(struct pa_ioline *line, const char *s, void *userdata) {
struct pa_strbuf *buf;
struct pa_cli *c = userdata;
static void line_callback(pa_ioline *line, const char *s, void *userdata) {
pa_strbuf *buf;
pa_cli *c = userdata;
char *p;
assert(line && c);
@ -141,7 +141,7 @@ static void line_callback(struct pa_ioline *line, const char *s, void *userdata)
pa_ioline_puts(line, PROMPT);
}
void pa_cli_set_eof_callback(struct pa_cli *c, void (*cb)(struct pa_cli*c, void *userdata), void *userdata) {
void pa_cli_set_eof_callback(pa_cli *c, void (*cb)(pa_cli*c, void *userdata), void *userdata) {
assert(c);
c->eof_callback = cb;
c->userdata = userdata;

View file

@ -26,13 +26,13 @@
#include "core.h"
#include "module.h"
struct pa_cli;
typedef struct pa_cli pa_cli;
/* Create a new command line session on the specified io channel owned by the specified module */
struct pa_cli* pa_cli_new(struct pa_core *core, struct pa_iochannel *io, struct pa_module *m);
void pa_cli_free(struct pa_cli *cli);
pa_cli* pa_cli_new(pa_core *core, pa_iochannel *io, pa_module *m);
void pa_cli_free(pa_cli *cli);
/* Set a callback function that is called whenever the command line session is terminated */
void pa_cli_set_eof_callback(struct pa_cli *cli, void (*cb)(struct pa_cli*c, void *userdata), void *userdata);
void pa_cli_set_eof_callback(pa_cli *cli, void (*cb)(pa_cli*c, void *userdata), void *userdata);
#endif

View file

@ -35,7 +35,7 @@
#include "xmalloc.h"
#include "util.h"
int pa_client_conf_from_x11(struct pa_client_conf *c, const char *dname) {
int pa_client_conf_from_x11(pa_client_conf *c, const char *dname) {
Display *d = NULL;
int ret = -1;
char t[1024];

View file

@ -26,6 +26,6 @@
/* Load client configuration data from the specified X11 display,
* overwriting the current settings in *c */
int pa_client_conf_from_x11(struct pa_client_conf *c, const char *display);
int pa_client_conf_from_x11(pa_client_conf *c, const char *display);
#endif

View file

@ -60,7 +60,7 @@
#define ENV_DAEMON_BINARY "POLYP_BINARY"
#define ENV_COOKIE_FILE "POLYP_COOKIE"
static const struct pa_client_conf default_conf = {
static const pa_client_conf default_conf = {
.daemon_binary = NULL,
.extra_arguments = NULL,
.default_sink = NULL,
@ -71,8 +71,8 @@ static const struct pa_client_conf default_conf = {
.cookie_valid = 0
};
struct pa_client_conf *pa_client_conf_new(void) {
struct pa_client_conf *c = pa_xmemdup(&default_conf, sizeof(default_conf));
pa_client_conf *pa_client_conf_new(void) {
pa_client_conf *c = pa_xmemdup(&default_conf, sizeof(default_conf));
c->daemon_binary = pa_xstrdup(POLYPAUDIO_BINARY);
c->extra_arguments = pa_xstrdup("--log-target=syslog --exit-idle-time=5");
@ -81,7 +81,7 @@ struct pa_client_conf *pa_client_conf_new(void) {
return c;
}
void pa_client_conf_free(struct pa_client_conf *c) {
void pa_client_conf_free(pa_client_conf *c) {
assert(c);
pa_xfree(c->daemon_binary);
pa_xfree(c->extra_arguments);
@ -91,13 +91,13 @@ void pa_client_conf_free(struct pa_client_conf *c) {
pa_xfree(c->cookie_file);
pa_xfree(c);
}
int pa_client_conf_load(struct pa_client_conf *c, const char *filename) {
int pa_client_conf_load(pa_client_conf *c, const char *filename) {
FILE *f = NULL;
char *fn = NULL;
int r = -1;
/* Prepare the configuration parse table */
struct pa_config_item table[] = {
pa_config_item table[] = {
{ "daemon-binary", pa_config_parse_string, NULL },
{ "extra-arguments", pa_config_parse_string, NULL },
{ "default-sink", pa_config_parse_string, NULL },
@ -140,7 +140,7 @@ finish:
return r;
}
int pa_client_conf_env(struct pa_client_conf *c) {
int pa_client_conf_env(pa_client_conf *c) {
char *e;
if ((e = getenv(ENV_DEFAULT_SINK))) {
@ -173,7 +173,7 @@ int pa_client_conf_env(struct pa_client_conf *c) {
return 0;
}
int pa_client_conf_load_cookie(struct pa_client_conf* c) {
int pa_client_conf_load_cookie(pa_client_conf* c) {
assert(c);
c->cookie_valid = 0;

View file

@ -26,27 +26,27 @@
/* A structure containing configuration data for polypaudio clients. */
struct pa_client_conf {
typedef struct pa_client_conf {
char *daemon_binary, *extra_arguments, *default_sink, *default_source, *default_server, *cookie_file;
int autospawn;
uint8_t cookie[PA_NATIVE_COOKIE_LENGTH];
int cookie_valid; /* non-zero, when cookie is valid */
};
} pa_client_conf;
/* Create a new configuration data object and reset it to defaults */
struct pa_client_conf *pa_client_conf_new(void);
void pa_client_conf_free(struct pa_client_conf *c);
pa_client_conf *pa_client_conf_new(void);
void pa_client_conf_free(pa_client_conf *c);
/* Load the configuration data from the speicified file, overwriting
* the current settings in *c. When the filename is NULL, the
* default client configuration file name is used. */
int pa_client_conf_load(struct pa_client_conf *c, const char *filename);
int pa_client_conf_load(pa_client_conf *c, const char *filename);
/* Load the configuration data from the environment of the current
process, overwriting the current settings in *c. */
int pa_client_conf_env(struct pa_client_conf *c);
int pa_client_conf_env(pa_client_conf *c);
/* Load cookie data from c->cookie_file into c->cookie */
int pa_client_conf_load_cookie(struct pa_client_conf* c);
int pa_client_conf_load_cookie(pa_client_conf* c);
#endif

View file

@ -33,12 +33,12 @@
#include "subscribe.h"
#include "log.h"
struct pa_client *pa_client_new(struct pa_core *core, pa_typeid_t typeid, const char *name) {
struct pa_client *c;
pa_client *pa_client_new(pa_core *core, pa_typeid_t typeid, const char *name) {
pa_client *c;
int r;
assert(core);
c = pa_xmalloc(sizeof(struct pa_client));
c = pa_xmalloc(sizeof(pa_client));
c->name = pa_xstrdup(name);
c->owner = NULL;
c->core = core;
@ -58,7 +58,7 @@ struct pa_client *pa_client_new(struct pa_core *core, pa_typeid_t typeid, const
return c;
}
void pa_client_free(struct pa_client *c) {
void pa_client_free(pa_client *c) {
assert(c && c->core);
pa_idxset_remove_by_data(c->core->clients, c, NULL);
@ -72,7 +72,7 @@ void pa_client_free(struct pa_client *c) {
}
void pa_client_kill(struct pa_client *c) {
void pa_client_kill(pa_client *c) {
assert(c);
if (!c->kill) {
pa_log_warn(__FILE__": kill() operation not implemented for client %u\n", c->index);
@ -82,7 +82,7 @@ void pa_client_kill(struct pa_client *c) {
c->kill(c);
}
void pa_client_set_name(struct pa_client *c, const char *name) {
void pa_client_set_name(pa_client *c, const char *name) {
assert(c);
pa_xfree(c->name);
c->name = pa_xstrdup(name);

View file

@ -30,28 +30,30 @@
* attached. That way the user may generate a listing of all connected
* clients easily and kill them if he wants.*/
typedef struct pa_client pa_client;
struct pa_client {
uint32_t index;
pa_typeid_t typeid;
struct pa_module *owner;
pa_module *owner;
char *name;
struct pa_core *core;
pa_core *core;
void (*kill)(struct pa_client *c);
void (*kill)(pa_client *c);
void *userdata;
};
struct pa_client *pa_client_new(struct pa_core *c, pa_typeid_t typeid, const char *name);
pa_client *pa_client_new(pa_core *c, pa_typeid_t typeid, const char *name);
/* This function should be called only by the code that created the client */
void pa_client_free(struct pa_client *c);
void pa_client_free(pa_client *c);
/* Code that didn't create the client should call this function to
* request destruction of the client */
void pa_client_kill(struct pa_client *c);
void pa_client_kill(pa_client *c);
/* Rename the client */
void pa_client_set_name(struct pa_client *c, const char *name);
void pa_client_set_name(pa_client *c, const char *name);
#endif

View file

@ -135,8 +135,8 @@ void pa_cmdline_help(const char *argv0) {
" -n Don't load default script file\n", e);
}
int pa_cmdline_parse(struct pa_daemon_conf *conf, int argc, char *const argv [], int *d) {
struct pa_strbuf *buf = NULL;
int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d) {
pa_strbuf *buf = NULL;
int c;
assert(conf && argc && argv);

View file

@ -26,7 +26,7 @@
/* Parese the command line and store its data in *c. Return the index
* of the first unparsed argument in *d. */
int pa_cmdline_parse(struct pa_daemon_conf*c, int argc, char *const argv [], int *d);
int pa_cmdline_parse(pa_daemon_conf*c, int argc, char *const argv [], int *d);
/* Show the command line help. The command name is extracted from
* argv[0] which should be passed in argv0. */

View file

@ -37,7 +37,7 @@
#define COMMENTS "#;\n"
/* Run the user supplied parser for an assignment */
static int next_assignment(const char *filename, unsigned line, const struct pa_config_item *t, const char *lvalue, const char *rvalue, void *userdata) {
static int next_assignment(const char *filename, unsigned line, const pa_config_item *t, const char *lvalue, const char *rvalue, void *userdata) {
assert(filename && t && lvalue && rvalue);
for (; t->parse; t++)
@ -77,7 +77,7 @@ static char *strip(char *s) {
}
/* Parse a variable assignment line */
static int parse_line(const char *filename, unsigned line, const struct pa_config_item *t, char *l, void *userdata) {
static int parse_line(const char *filename, unsigned line, const pa_config_item *t, char *l, void *userdata) {
char *e, *c, *b = l+strspn(l, WHITESPACE);
if ((c = strpbrk(b, COMMENTS)))
@ -98,7 +98,7 @@ static int parse_line(const char *filename, unsigned line, const struct pa_confi
}
/* Go through the file and parse each line */
int pa_config_parse(const char *filename, FILE *f, const struct pa_config_item *t, void *userdata) {
int pa_config_parse(const char *filename, FILE *f, const pa_config_item *t, void *userdata) {
int r = -1;
unsigned line = 0;
int do_close = !f;
@ -138,7 +138,7 @@ finish:
return r;
}
int pa_config_parse_int(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata) {
int pa_config_parse_int(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, PA_GCC_UNUSED void *userdata) {
int *i = data;
int32_t k;
assert(filename && lvalue && rvalue && data);
@ -152,7 +152,7 @@ int pa_config_parse_int(const char *filename, unsigned line, const char *lvalue,
return 0;
}
int pa_config_parse_bool(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata) {
int pa_config_parse_bool(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, PA_GCC_UNUSED void *userdata) {
int *b = data, k;
assert(filename && lvalue && rvalue && data);
@ -166,7 +166,7 @@ int pa_config_parse_bool(const char *filename, unsigned line, const char *lvalue
return 0;
}
int pa_config_parse_string(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata) {
int pa_config_parse_string(const char *filename, PA_GCC_UNUSED unsigned line, const char *lvalue, const char *rvalue, void *data, PA_GCC_UNUSED void *userdata) {
char **s = data;
assert(filename && lvalue && rvalue && data);

View file

@ -28,16 +28,16 @@
* files consisting of variable assignments only. */
/* Wraps info for parsing a specific configuration variable */
struct pa_config_item {
typedef struct pa_config_item {
const char *lvalue; /* name of the variable */
int (*parse)(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata); /* Function that is called to parse the variable's value */
void *data; /* Where to store the variable's data */
};
} pa_config_item;
/* The configuration file parsing routine. Expects a table of
* pa_config_items in *t that is terminated by an item where lvalue is
* NULL */
int pa_config_parse(const char *filename, FILE *f, const struct pa_config_item *t, void *userdata);
int pa_config_parse(const char *filename, FILE *f, const pa_config_item *t, void *userdata);
/* Generic parsers for integers, booleans and strings */
int pa_config_parse_int(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata);

View file

@ -41,9 +41,9 @@
#include "props.h"
#include "random.h"
struct pa_core* pa_core_new(struct pa_mainloop_api *m) {
struct pa_core* c;
c = pa_xmalloc(sizeof(struct pa_core));
pa_core* pa_core_new(pa_mainloop_api *m) {
pa_core* c;
c = pa_xmalloc(sizeof(pa_core));
c->mainloop = m;
c->clients = pa_idxset_new(NULL, NULL);
@ -95,7 +95,7 @@ struct pa_core* pa_core_new(struct pa_mainloop_api *m) {
return c;
}
void pa_core_free(struct pa_core *c) {
void pa_core_free(pa_core *c) {
assert(c);
pa_module_unload_all(c);
@ -134,22 +134,22 @@ void pa_core_free(struct pa_core *c) {
pa_xfree(c);
}
static void quit_callback(struct pa_mainloop_api*m, struct pa_time_event *e, const struct timeval *tv, void *userdata) {
struct pa_core *c = userdata;
static void quit_callback(pa_mainloop_api*m, pa_time_event *e, PA_GCC_UNUSED const struct timeval *tv, void *userdata) {
pa_core *c = userdata;
assert(c->quit_event = e);
m->quit(m, 0);
}
void pa_core_check_quit(struct pa_core *c) {
void pa_core_check_quit(pa_core *c) {
assert(c);
if (!c->quit_event && c->exit_idle_time >= 0 && pa_idxset_ncontents(c->clients) == 0) {
if (!c->quit_event && c->exit_idle_time >= 0 && pa_idxset_size(c->clients) == 0) {
struct timeval tv;
pa_gettimeofday(&tv);
tv.tv_sec+= c->exit_idle_time;
c->quit_event = c->mainloop->time_new(c->mainloop, &tv, quit_callback, c);
} else if (c->quit_event && pa_idxset_ncontents(c->clients) > 0) {
} else if (c->quit_event && pa_idxset_size(c->clients) > 0) {
c->mainloop->time_free(c->quit_event);
c->quit_event = NULL;
}

View file

@ -22,12 +22,16 @@
USA.
***/
typedef struct pa_core pa_core;
#include "idxset.h"
#include "hashmap.h"
#include "mainloop-api.h"
#include "sample.h"
#include "memblock.h"
#include "resampler.h"
#include "queue.h"
#include "subscribe.h"
/* The core structure of polypaudio. Every polypaudio daemon contains
* exactly one of these. It is used for storing kind of global
@ -38,41 +42,41 @@ struct pa_core {
* polypaudio. Not cryptographically secure in any way. */
uint32_t cookie;
struct pa_mainloop_api *mainloop;
pa_mainloop_api *mainloop;
/* idxset of all kinds of entities */
struct pa_idxset *clients, *sinks, *sources, *sink_inputs, *source_outputs, *modules, *scache, *autoload_idxset;
pa_idxset *clients, *sinks, *sources, *sink_inputs, *source_outputs, *modules, *scache, *autoload_idxset;
/* Some hashmaps for all sorts of entities */
struct pa_hashmap *namereg, *autoload_hashmap, *properties;
pa_hashmap *namereg, *autoload_hashmap, *properties;
/* The name of the default sink/source */
char *default_source_name, *default_sink_name;
struct pa_sample_spec default_sample_spec;
struct pa_time_event *module_auto_unload_event;
struct pa_defer_event *module_defer_unload_event;
pa_sample_spec default_sample_spec;
pa_time_event *module_auto_unload_event;
pa_defer_event *module_defer_unload_event;
struct pa_defer_event *subscription_defer_event;
struct pa_queue *subscription_event_queue;
struct pa_subscription *subscriptions;
pa_defer_event *subscription_defer_event;
pa_queue *subscription_event_queue;
pa_subscription *subscriptions;
struct pa_memblock_stat *memblock_stat;
pa_memblock_stat *memblock_stat;
int disallow_module_loading, running_as_daemon;
int exit_idle_time, module_idle_time, scache_idle_time;
struct pa_time_event *quit_event;
pa_time_event *quit_event;
struct pa_time_event *scache_auto_unload_event;
pa_time_event *scache_auto_unload_event;
enum pa_resample_method resample_method;
pa_resample_method resample_method;
};
struct pa_core* pa_core_new(struct pa_mainloop_api *m);
void pa_core_free(struct pa_core*c);
pa_core* pa_core_new(pa_mainloop_api *m);
void pa_core_free(pa_core*c);
/* Check whether noone is connected to this core */
void pa_core_check_quit(struct pa_core *c);
void pa_core_check_quit(pa_core *c);
#endif

View file

@ -31,6 +31,7 @@
#include "cpulimit.h"
#include "mainloop.h"
#include "gccmacro.h"
#ifdef TEST2
#include "mainloop-signal.h"
@ -42,7 +43,7 @@ static time_t start;
#ifdef TEST2
static void func(struct pa_mainloop_api *m, struct pa_signal_event *e, int sig, void *userdata) {
static void func(pa_mainloop_api *m, PA_GCC_UNUSED pa_signal_event *e, PA_GCC_UNUSED int sig, PA_GCC_UNUSED void *userdata) {
time_t now;
time(&now);
@ -55,8 +56,8 @@ static void func(struct pa_mainloop_api *m, struct pa_signal_event *e, int sig,
#endif
int main() {
struct pa_mainloop *m;
int main(PA_GCC_UNUSED int argc, PA_GCC_UNUSED char *argv[]) {
pa_mainloop *m;
m = pa_mainloop_new();
assert(m);

View file

@ -23,6 +23,10 @@
#include <config.h>
#endif
#include "cpulimit.h"
#include "util.h"
#include "log.h"
#ifdef HAVE_SIGXCPU
#include <errno.h>
@ -37,11 +41,6 @@
#include <sys/resource.h>
#endif
#include "cpulimit.h"
#include "util.h"
#include "log.h"
/* This module implements a watchdog that makes sure that the current
* process doesn't consume more than 70% CPU time for 10 seconds. This
* is very useful when using SCHED_FIFO scheduling which effectively
@ -70,8 +69,8 @@ static time_t last_time = 0;
static int the_pipe[2] = {-1, -1};
/* Main event loop and IO event for the FIFO */
static struct pa_mainloop_api *api = NULL;
static struct pa_io_event *io_event = NULL;
static pa_mainloop_api *api = NULL;
static pa_io_event *io_event = NULL;
/* Saved sigaction struct for SIGXCPU */
static struct sigaction sigaction_prev;
@ -153,7 +152,7 @@ static void signal_handler(int sig) {
}
/* Callback for IO events on the FIFO */
static void callback(struct pa_mainloop_api*m, struct pa_io_event*e, int fd, enum pa_io_event_flags f, void *userdata) {
static void callback(pa_mainloop_api*m, pa_io_event*e, int fd, pa_io_event_flags f, void *userdata) {
char c;
assert(m && e && f == PA_IO_EVENT_INPUT && e == io_event && fd == the_pipe[0]);
read(the_pipe[0], &c, sizeof(c));
@ -161,7 +160,7 @@ static void callback(struct pa_mainloop_api*m, struct pa_io_event*e, int fd, enu
}
/* Initializes CPU load limiter */
int pa_cpu_limit_init(struct pa_mainloop_api *m) {
int pa_cpu_limit_init(pa_mainloop_api *m) {
struct sigaction sa;
assert(m && !api && !io_event && the_pipe[0] == -1 && the_pipe[1] == -1 && !installed);
@ -227,9 +226,7 @@ void pa_cpu_limit_done(void) {
#else /* HAVE_SIGXCPU */
struct pa_mainloop_api;
int pa_cpu_limit_init(struct pa_mainloop_api *m) {
int pa_cpu_limit_init(PA_GCC_UNUSED pa_mainloop_api *m) {
return 0;
}

View file

@ -28,7 +28,7 @@
* CPU time. This is build around setrlimit() and SIGXCPU. It is handy
* in case of using SCHED_FIFO which may freeze the whole machine */
int pa_cpu_limit_init(struct pa_mainloop_api *m);
int pa_cpu_limit_init(pa_mainloop_api *m);
void pa_cpu_limit_done(void);
#endif

View file

@ -59,7 +59,7 @@
#define ENV_CONFIG_FILE "POLYP_CONFIG"
#define ENV_DL_SEARCH_PATH "POLYP_DLPATH"
static const struct pa_daemon_conf default_conf = {
static const pa_daemon_conf default_conf = {
.cmd = PA_CMD_DAEMON,
.daemonize = 0,
.fail = 1,
@ -79,9 +79,9 @@ static const struct pa_daemon_conf default_conf = {
.use_pid_file = 1
};
struct pa_daemon_conf* pa_daemon_conf_new(void) {
pa_daemon_conf* pa_daemon_conf_new(void) {
FILE *f;
struct pa_daemon_conf *c = pa_xmemdup(&default_conf, sizeof(default_conf));
pa_daemon_conf *c = pa_xmemdup(&default_conf, sizeof(default_conf));
if ((f = pa_open_config_file(DEFAULT_SCRIPT_FILE, DEFAULT_SCRIPT_FILE_USER, ENV_SCRIPT_FILE, &c->default_script_file)))
fclose(f);
@ -92,7 +92,7 @@ struct pa_daemon_conf* pa_daemon_conf_new(void) {
return c;
}
void pa_daemon_conf_free(struct pa_daemon_conf *c) {
void pa_daemon_conf_free(pa_daemon_conf *c) {
assert(c);
pa_xfree(c->script_commands);
pa_xfree(c->dl_search_path);
@ -101,7 +101,7 @@ void pa_daemon_conf_free(struct pa_daemon_conf *c) {
pa_xfree(c);
}
int pa_daemon_conf_set_log_target(struct pa_daemon_conf *c, const char *string) {
int pa_daemon_conf_set_log_target(pa_daemon_conf *c, const char *string) {
assert(c && string);
if (!strcmp(string, "auto"))
@ -118,7 +118,7 @@ int pa_daemon_conf_set_log_target(struct pa_daemon_conf *c, const char *string)
return 0;
}
int pa_daemon_conf_set_log_level(struct pa_daemon_conf *c, const char *string) {
int pa_daemon_conf_set_log_level(pa_daemon_conf *c, const char *string) {
uint32_t u;
assert(c && string);
@ -126,7 +126,7 @@ int pa_daemon_conf_set_log_level(struct pa_daemon_conf *c, const char *string) {
if (u >= PA_LOG_LEVEL_MAX)
return -1;
c->log_level = (enum pa_log_level) u;
c->log_level = (pa_log_level) u;
} else if (pa_startswith(string, "debug"))
c->log_level = PA_LOG_DEBUG;
else if (pa_startswith(string, "info"))
@ -143,7 +143,7 @@ int pa_daemon_conf_set_log_level(struct pa_daemon_conf *c, const char *string) {
return 0;
}
int pa_daemon_conf_set_resample_method(struct pa_daemon_conf *c, const char *string) {
int pa_daemon_conf_set_resample_method(pa_daemon_conf *c, const char *string) {
int m;
assert(c && string);
@ -154,8 +154,8 @@ int pa_daemon_conf_set_resample_method(struct pa_daemon_conf *c, const char *str
return 0;
}
static int parse_log_target(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata) {
struct pa_daemon_conf *c = data;
static int parse_log_target(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, PA_GCC_UNUSED void *userdata) {
pa_daemon_conf *c = data;
assert(filename && lvalue && rvalue && data);
if (pa_daemon_conf_set_log_target(c, rvalue) < 0) {
@ -166,8 +166,8 @@ static int parse_log_target(const char *filename, unsigned line, const char *lva
return 0;
}
static int parse_log_level(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata) {
struct pa_daemon_conf *c = data;
static int parse_log_level(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, PA_GCC_UNUSED void *userdata) {
pa_daemon_conf *c = data;
assert(filename && lvalue && rvalue && data);
if (pa_daemon_conf_set_log_level(c, rvalue) < 0) {
@ -178,8 +178,8 @@ static int parse_log_level(const char *filename, unsigned line, const char *lval
return 0;
}
static int parse_resample_method(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata) {
struct pa_daemon_conf *c = data;
static int parse_resample_method(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, PA_GCC_UNUSED void *userdata) {
pa_daemon_conf *c = data;
assert(filename && lvalue && rvalue && data);
if (pa_daemon_conf_set_resample_method(c, rvalue) < 0) {
@ -190,11 +190,11 @@ static int parse_resample_method(const char *filename, unsigned line, const char
return 0;
}
int pa_daemon_conf_load(struct pa_daemon_conf *c, const char *filename) {
int pa_daemon_conf_load(pa_daemon_conf *c, const char *filename) {
int r = -1;
FILE *f = NULL;
struct pa_config_item table[] = {
pa_config_item table[] = {
{ "daemonize", pa_config_parse_bool, NULL },
{ "fail", pa_config_parse_bool, NULL },
{ "high-priority", pa_config_parse_bool, NULL },
@ -248,7 +248,7 @@ finish:
return r;
}
int pa_daemon_conf_env(struct pa_daemon_conf *c) {
int pa_daemon_conf_env(pa_daemon_conf *c) {
char *e;
if ((e = getenv(ENV_DL_SEARCH_PATH))) {
@ -271,8 +271,8 @@ static const char* const log_level_to_string[] = {
[PA_LOG_ERROR] = "error"
};
char *pa_daemon_conf_dump(struct pa_daemon_conf *c) {
struct pa_strbuf *s = pa_strbuf_new();
char *pa_daemon_conf_dump(pa_daemon_conf *c) {
pa_strbuf *s = pa_strbuf_new();
if (c->config_file)
pa_strbuf_printf(s, "### Read from configuration file: %s ###\n", c->config_file);

View file

@ -25,7 +25,7 @@
#include "log.h"
/* The actual command to execute */
enum pa_daemon_conf_cmd {
typedef enum pa_daemon_conf_cmd {
PA_CMD_DAEMON, /* the default */
PA_CMD_HELP,
PA_CMD_VERSION,
@ -33,11 +33,11 @@ enum pa_daemon_conf_cmd {
PA_CMD_DUMP_MODULES,
PA_CMD_KILL,
PA_CMD_CHECK
};
} pa_daemon_conf_cmd;
/* A structure containing configuration data for the Polypaudio server . */
struct pa_daemon_conf {
enum pa_daemon_conf_cmd cmd;
typedef struct pa_daemon_conf {
pa_daemon_conf_cmd cmd;
int daemonize,
fail,
high_priority,
@ -48,33 +48,33 @@ struct pa_daemon_conf {
auto_log_target,
use_pid_file;
char *script_commands, *dl_search_path, *default_script_file;
enum pa_log_target log_target;
enum pa_log_level log_level;
pa_log_target log_target;
pa_log_level log_level;
int resample_method;
char *config_file;
};
} pa_daemon_conf;
/* Allocate a new structure and fill it with sane defaults */
struct pa_daemon_conf* pa_daemon_conf_new(void);
void pa_daemon_conf_free(struct pa_daemon_conf*c);
pa_daemon_conf* pa_daemon_conf_new(void);
void pa_daemon_conf_free(pa_daemon_conf*c);
/* Load configuration data from the specified file overwriting the
* current settings in *c. If filename is NULL load the default daemon
* configuration file */
int pa_daemon_conf_load(struct pa_daemon_conf *c, const char *filename);
int pa_daemon_conf_load(pa_daemon_conf *c, const char *filename);
/* Pretty print the current configuration data of the daemon. The
* returned string has to be freed manually. The output of this
* function may be parsed with pa_daemon_conf_load(). */
char *pa_daemon_conf_dump(struct pa_daemon_conf *c);
char *pa_daemon_conf_dump(pa_daemon_conf *c);
/* Load the configuration data from the process' environment
* overwriting the current settings in *c. */
int pa_daemon_conf_env(struct pa_daemon_conf *c);
int pa_daemon_conf_env(pa_daemon_conf *c);
/* Set these configuration variables in the structure by passing a string */
int pa_daemon_conf_set_log_target(struct pa_daemon_conf *c, const char *string);
int pa_daemon_conf_set_log_level(struct pa_daemon_conf *c, const char *string);
int pa_daemon_conf_set_resample_method(struct pa_daemon_conf *c, const char *string);
int pa_daemon_conf_set_log_target(pa_daemon_conf *c, const char *string);
int pa_daemon_conf_set_log_level(pa_daemon_conf *c, const char *string);
int pa_daemon_conf_set_resample_method(pa_daemon_conf *c, const char *string);
#endif

View file

@ -35,12 +35,12 @@
#define PREFIX "module-"
static void short_info(const char *name, const char *path, struct pa_modinfo *i) {
static void short_info(const char *name, PA_GCC_UNUSED const char *path, pa_modinfo *i) {
assert(name && i);
printf("%-40s%s\n", name, i->description ? i->description : "n/a");
}
static void long_info(const char *name, const char *path, struct pa_modinfo *i) {
static void long_info(const char *name, const char *path, pa_modinfo *i) {
static int nl = 0;
assert(name && i);
@ -68,8 +68,8 @@ static void long_info(const char *name, const char *path, struct pa_modinfo *i)
printf("Path: %s\n", path);
}
static void show_info(const char *name, const char *path, void (*info)(const char *name, const char *path, struct pa_modinfo*i)) {
struct pa_modinfo *i;
static void show_info(const char *name, const char *path, void (*info)(const char *name, const char *path, pa_modinfo*i)) {
pa_modinfo *i;
if ((i = pa_modinfo_get_by_name(path ? path : name))) {
info(name, path, i);
@ -79,7 +79,7 @@ static void show_info(const char *name, const char *path, void (*info)(const cha
static int callback(const char *path, lt_ptr data) {
const char *e;
struct pa_daemon_conf *c = (data);
pa_daemon_conf *c = (data);
e = pa_path_get_filename(path);
@ -89,7 +89,7 @@ static int callback(const char *path, lt_ptr data) {
return 0;
}
void pa_dump_modules(struct pa_daemon_conf *c, int argc, char * const argv[]) {
void pa_dump_modules(pa_daemon_conf *c, int argc, char * const argv[]) {
if (argc > 0) {
int i;
for (i = 0; i < argc; i++)

View file

@ -26,6 +26,6 @@
/* Dump all available modules to STDOUT. If argc > 0 print information
* about the modules specified in argv[] instead. */
void pa_dump_modules(struct pa_daemon_conf *c, int argc, char * const argv[]);
void pa_dump_modules(pa_daemon_conf *c, int argc, char * const argv[]);
#endif

View file

@ -38,16 +38,16 @@ struct pa_dynarray {
unsigned n_allocated, n_entries;
};
struct pa_dynarray* pa_dynarray_new(void) {
struct pa_dynarray *a;
a = pa_xmalloc(sizeof(struct pa_dynarray));
pa_dynarray* pa_dynarray_new(void) {
pa_dynarray *a;
a = pa_xnew(pa_dynarray, 1);
a->data = NULL;
a->n_entries = 0;
a->n_allocated = 0;
return a;
}
void pa_dynarray_free(struct pa_dynarray* a, void (*func)(void *p, void *userdata), void *userdata) {
void pa_dynarray_free(pa_dynarray* a, void (*func)(void *p, void *userdata), void *userdata) {
unsigned i;
assert(a);
@ -60,7 +60,7 @@ void pa_dynarray_free(struct pa_dynarray* a, void (*func)(void *p, void *userdat
pa_xfree(a);
}
void pa_dynarray_put(struct pa_dynarray*a, unsigned i, void *p) {
void pa_dynarray_put(pa_dynarray*a, unsigned i, void *p) {
assert(a);
if (i >= a->n_allocated) {
@ -81,13 +81,13 @@ void pa_dynarray_put(struct pa_dynarray*a, unsigned i, void *p) {
a->n_entries = i+1;
}
unsigned pa_dynarray_append(struct pa_dynarray*a, void *p) {
unsigned pa_dynarray_append(pa_dynarray*a, void *p) {
unsigned i = a->n_entries;
pa_dynarray_put(a, i, p);
return i;
}
void *pa_dynarray_get(struct pa_dynarray*a, unsigned i) {
void *pa_dynarray_get(pa_dynarray*a, unsigned i) {
assert(a);
if (i >= a->n_allocated)
return NULL;
@ -96,7 +96,7 @@ void *pa_dynarray_get(struct pa_dynarray*a, unsigned i) {
return a->data[i];
}
unsigned pa_dynarray_ncontents(struct pa_dynarray*a) {
unsigned pa_dynarray_size(pa_dynarray*a) {
assert(a);
return a->n_entries;
}

View file

@ -22,28 +22,28 @@
USA.
***/
struct pa_dynarray;
typedef struct pa_dynarray pa_dynarray;
/* Implementation of a simple dynamically sized array. The array
* expands if required, but doesn't shrink if possible. Memory
* management of the array's entries is the user's job. */
struct pa_dynarray* pa_dynarray_new(void);
pa_dynarray* pa_dynarray_new(void);
/* Free the array calling the specified function for every entry in
* the array. The function may be NULL. */
void pa_dynarray_free(struct pa_dynarray* a, void (*func)(void *p, void *userdata), void *userdata);
void pa_dynarray_free(pa_dynarray* a, void (*func)(void *p, void *userdata), void *userdata);
/* Store p at position i in the array */
void pa_dynarray_put(struct pa_dynarray*a, unsigned i, void *p);
void pa_dynarray_put(pa_dynarray*a, unsigned i, void *p);
/* Store p a the first free position in the array. Returns the index
* of that entry. If entries are removed from the array their position
* are not filled any more by this function. */
unsigned pa_dynarray_append(struct pa_dynarray*a, void *p);
unsigned pa_dynarray_append(pa_dynarray*a, void *p);
void *pa_dynarray_get(struct pa_dynarray*a, unsigned i);
void *pa_dynarray_get(pa_dynarray*a, unsigned i);
unsigned pa_dynarray_ncontents(struct pa_dynarray*a);
unsigned pa_dynarray_size(pa_dynarray*a);
#endif

View file

@ -1,5 +1,5 @@
#ifndef foogccprintfhfoo
#define foogccprintfhfoo
#ifndef foogccmacrohfoo
#define foogccmacrohfoo
/* $Id$ */
@ -22,12 +22,32 @@
USA.
***/
/* If we're in GNU C, use some magic for detecting invalid format strings */
#ifdef __GNUC__
#define PA_GCC_PRINTF_ATTR(a,b) __attribute__ ((format (printf, a, b)))
#else
/** If we're in GNU C, use some magic for detecting invalid format strings */
#define PA_GCC_PRINTF_ATTR(a,b)
#endif
#if defined(__GNUC__) && (__GNUC__ >= 4)
#define PA_GCC_SENTINEL __attribute__ ((sentinel))
#else
/** Macro for usage of GCC's sentinel compilation warnings */
#define PA_GCC_SENTINEL
#endif
#ifdef __GNUC__
#define PA_GCC_NORETURN __attribute__((noreturn))
#else
/** Macro for no-return functions */
#define PA_GCC_NORETURN
#endif
#ifdef __GNUC__
#define PA_GCC_UNUSED __attribute__ ((unused))
#else
/** Macro for not used parameter */
#define PA_GCC_UNUSED
#endif
#endif

View file

@ -28,62 +28,64 @@
#include "glib-mainloop.h"
#include "idxset.h"
#include "xmalloc.h"
#include "glib.h"
#include "util.h"
struct pa_io_event {
struct pa_glib_mainloop *mainloop;
struct pa_io_event {
pa_glib_mainloop *mainloop;
int dead;
GIOChannel *io_channel;
GSource *source;
GIOCondition io_condition;
int fd;
void (*callback) (struct pa_mainloop_api*m, struct pa_io_event *e, int fd, enum pa_io_event_flags f, void *userdata);
void (*callback) (pa_mainloop_api*m, pa_io_event *e, int fd, pa_io_event_flags f, void *userdata);
void *userdata;
void (*destroy_callback) (struct pa_mainloop_api *m, struct pa_io_event*e, void *userdata);
struct pa_io_event *next, *prev;
void (*destroy_callback) (pa_mainloop_api *m, pa_io_event*e, void *userdata);
pa_io_event *next, *prev;
};
struct pa_time_event {
struct pa_glib_mainloop *mainloop;
pa_glib_mainloop *mainloop;
int dead;
GSource *source;
struct timeval timeval;
void (*callback) (struct pa_mainloop_api*m, struct pa_time_event *e, const struct timeval *tv, void *userdata);
void (*callback) (pa_mainloop_api*m, pa_time_event *e, const struct timeval *tv, void *userdata);
void *userdata;
void (*destroy_callback) (struct pa_mainloop_api *m, struct pa_time_event*e, void *userdata);
struct pa_time_event *next, *prev;
void (*destroy_callback) (pa_mainloop_api *m, pa_time_event*e, void *userdata);
pa_time_event *next, *prev;
};
struct pa_defer_event {
struct pa_glib_mainloop *mainloop;
pa_glib_mainloop *mainloop;
int dead;
GSource *source;
void (*callback) (struct pa_mainloop_api*m, struct pa_defer_event *e, void *userdata);
void (*callback) (pa_mainloop_api*m, pa_defer_event *e, void *userdata);
void *userdata;
void (*destroy_callback) (struct pa_mainloop_api *m, struct pa_defer_event*e, void *userdata);
struct pa_defer_event *next, *prev;
void (*destroy_callback) (pa_mainloop_api *m, pa_defer_event*e, void *userdata);
pa_defer_event *next, *prev;
};
struct pa_glib_mainloop {
GMainContext *glib_main_context;
struct pa_mainloop_api api;
pa_mainloop_api api;
GSource *cleanup_source;
struct pa_io_event *io_events, *dead_io_events;
struct pa_time_event *time_events, *dead_time_events;
struct pa_defer_event *defer_events, *dead_defer_events;
pa_io_event *io_events, *dead_io_events;
pa_time_event *time_events, *dead_time_events;
pa_defer_event *defer_events, *dead_defer_events;
};
static void schedule_free_dead_events(struct pa_glib_mainloop *g);
static void schedule_free_dead_events(pa_glib_mainloop *g);
static void glib_io_enable(struct pa_io_event*e, enum pa_io_event_flags f);
static void glib_io_enable(pa_io_event*e, pa_io_event_flags f);
static struct pa_io_event* glib_io_new(struct pa_mainloop_api*m, int fd, enum pa_io_event_flags f, void (*callback) (struct pa_mainloop_api*m, struct pa_io_event*e, int fd, enum pa_io_event_flags f, void *userdata), void *userdata) {
struct pa_io_event *e;
struct pa_glib_mainloop *g;
static pa_io_event* glib_io_new(pa_mainloop_api*m, int fd, pa_io_event_flags f, void (*callback) (pa_mainloop_api*m, pa_io_event*e, int fd, pa_io_event_flags f, void *userdata), void *userdata) {
pa_io_event *e;
pa_glib_mainloop *g;
assert(m && m->userdata && fd >= 0 && callback);
g = m->userdata;
e = pa_xmalloc(sizeof(struct pa_io_event));
e = pa_xmalloc(sizeof(pa_io_event));
e->mainloop = m->userdata;
e->dead = 0;
e->fd = fd;
@ -108,8 +110,8 @@ static struct pa_io_event* glib_io_new(struct pa_mainloop_api*m, int fd, enum pa
/* The callback GLIB calls whenever an IO condition is met */
static gboolean io_cb(GIOChannel *source, GIOCondition condition, gpointer data) {
struct pa_io_event *e = data;
enum pa_io_event_flags f;
pa_io_event *e = data;
pa_io_event_flags f;
assert(source && e && e->io_channel == source);
f = (condition & G_IO_IN ? PA_IO_EVENT_INPUT : 0) |
@ -121,7 +123,7 @@ static gboolean io_cb(GIOChannel *source, GIOCondition condition, gpointer data)
return TRUE;
}
static void glib_io_enable(struct pa_io_event*e, enum pa_io_event_flags f) {
static void glib_io_enable(pa_io_event*e, pa_io_event_flags f) {
GIOCondition c;
assert(e && !e->dead);
@ -145,7 +147,7 @@ static void glib_io_enable(struct pa_io_event*e, enum pa_io_event_flags f) {
e->io_condition = c;
}
static void glib_io_free(struct pa_io_event*e) {
static void glib_io_free(pa_io_event*e) {
assert(e && !e->dead);
if (e->source) {
@ -172,23 +174,23 @@ static void glib_io_free(struct pa_io_event*e) {
schedule_free_dead_events(e->mainloop);
}
static void glib_io_set_destroy(struct pa_io_event*e, void (*callback)(struct pa_mainloop_api*m, struct pa_io_event *e, void *userdata)) {
static void glib_io_set_destroy(pa_io_event*e, void (*callback)(pa_mainloop_api*m, pa_io_event *e, void *userdata)) {
assert(e);
e->destroy_callback = callback;
}
/* Time sources */
static void glib_time_restart(struct pa_time_event*e, const struct timeval *tv);
static void glib_time_restart(pa_time_event*e, const struct timeval *tv);
static struct pa_time_event* glib_time_new(struct pa_mainloop_api*m, const struct timeval *tv, void (*callback) (struct pa_mainloop_api*m, struct pa_time_event*e, const struct timeval *tv, void *userdata), void *userdata) {
struct pa_glib_mainloop *g;
struct pa_time_event *e;
static pa_time_event* glib_time_new(pa_mainloop_api*m, const struct timeval *tv, void (*callback) (pa_mainloop_api*m, pa_time_event*e, const struct timeval *tv, void *userdata), void *userdata) {
pa_glib_mainloop *g;
pa_time_event *e;
assert(m && m->userdata && tv && callback);
g = m->userdata;
e = pa_xmalloc(sizeof(struct pa_time_event));
e = pa_xmalloc(sizeof(pa_time_event));
e->mainloop = g;
e->dead = 0;
e->callback = callback;
@ -227,7 +229,7 @@ static guint msec_diff(const struct timeval *a, const struct timeval *b) {
}
static gboolean time_cb(gpointer data) {
struct pa_time_event* e = data;
pa_time_event* e = data;
assert(e && e->mainloop && e->source);
g_source_unref(e->source);
@ -237,7 +239,7 @@ static gboolean time_cb(gpointer data) {
return FALSE;
}
static void glib_time_restart(struct pa_time_event*e, const struct timeval *tv) {
static void glib_time_restart(pa_time_event*e, const struct timeval *tv) {
struct timeval now;
assert(e && e->mainloop && !e->dead);
@ -258,7 +260,7 @@ static void glib_time_restart(struct pa_time_event*e, const struct timeval *tv)
e->source = NULL;
}
static void glib_time_free(struct pa_time_event *e) {
static void glib_time_free(pa_time_event *e) {
assert(e && e->mainloop && !e->dead);
if (e->source) {
@ -285,23 +287,23 @@ static void glib_time_free(struct pa_time_event *e) {
schedule_free_dead_events(e->mainloop);
}
static void glib_time_set_destroy(struct pa_time_event *e, void (*callback)(struct pa_mainloop_api*m, struct pa_time_event*e, void *userdata)) {
static void glib_time_set_destroy(pa_time_event *e, void (*callback)(pa_mainloop_api*m, pa_time_event*e, void *userdata)) {
assert(e);
e->destroy_callback = callback;
}
/* Deferred sources */
static void glib_defer_enable(struct pa_defer_event *e, int b);
static void glib_defer_enable(pa_defer_event *e, int b);
static struct pa_defer_event* glib_defer_new(struct pa_mainloop_api*m, void (*callback) (struct pa_mainloop_api*m, struct pa_defer_event *e, void *userdata), void *userdata) {
struct pa_defer_event *e;
struct pa_glib_mainloop *g;
static pa_defer_event* glib_defer_new(pa_mainloop_api*m, void (*callback) (pa_mainloop_api*m, pa_defer_event *e, void *userdata), void *userdata) {
pa_defer_event *e;
pa_glib_mainloop *g;
assert(m && m->userdata && callback);
g = m->userdata;
e = pa_xmalloc(sizeof(struct pa_defer_event));
e = pa_xmalloc(sizeof(pa_defer_event));
e->mainloop = g;
e->dead = 0;
e->callback = callback;
@ -319,14 +321,14 @@ static struct pa_defer_event* glib_defer_new(struct pa_mainloop_api*m, void (*ca
}
static gboolean idle_cb(gpointer data) {
struct pa_defer_event* e = data;
pa_defer_event* e = data;
assert(e && e->mainloop && e->source);
e->callback(&e->mainloop->api, e, e->userdata);
return TRUE;
}
static void glib_defer_enable(struct pa_defer_event *e, int b) {
static void glib_defer_enable(pa_defer_event *e, int b) {
assert(e && e->mainloop);
if (e->source && !b) {
@ -342,7 +344,7 @@ static void glib_defer_enable(struct pa_defer_event *e, int b) {
}
}
static void glib_defer_free(struct pa_defer_event *e) {
static void glib_defer_free(pa_defer_event *e) {
assert(e && e->mainloop && !e->dead);
if (e->source) {
@ -369,22 +371,22 @@ static void glib_defer_free(struct pa_defer_event *e) {
schedule_free_dead_events(e->mainloop);
}
static void glib_defer_set_destroy(struct pa_defer_event *e, void (*callback)(struct pa_mainloop_api *m, struct pa_defer_event *e, void *userdata)) {
static void glib_defer_set_destroy(pa_defer_event *e, void (*callback)(pa_mainloop_api *m, pa_defer_event *e, void *userdata)) {
assert(e);
e->destroy_callback = callback;
}
/* quit() */
static void glib_quit(struct pa_mainloop_api*a, int retval) {
struct pa_glib_mainloop *g;
static void glib_quit(pa_mainloop_api*a, PA_GCC_UNUSED int retval) {
pa_glib_mainloop *g;
assert(a && a->userdata);
g = a->userdata;
/* NOOP */
}
static const struct pa_mainloop_api vtable = {
static const pa_mainloop_api vtable = {
.userdata = NULL,
.io_new = glib_io_new,
@ -405,10 +407,10 @@ static const struct pa_mainloop_api vtable = {
.quit = glib_quit,
};
struct pa_glib_mainloop *pa_glib_mainloop_new(GMainContext *c) {
struct pa_glib_mainloop *g;
pa_glib_mainloop *pa_glib_mainloop_new(GMainContext *c) {
pa_glib_mainloop *g;
g = pa_xmalloc(sizeof(struct pa_glib_mainloop));
g = pa_xmalloc(sizeof(pa_glib_mainloop));
if (c) {
g->glib_main_context = c;
g_main_context_ref(c);
@ -426,9 +428,9 @@ struct pa_glib_mainloop *pa_glib_mainloop_new(GMainContext *c) {
return g;
}
static void free_io_events(struct pa_io_event *e) {
static void free_io_events(pa_io_event *e) {
while (e) {
struct pa_io_event *r = e;
pa_io_event *r = e;
e = r->next;
if (r->source) {
@ -446,9 +448,9 @@ static void free_io_events(struct pa_io_event *e) {
}
}
static void free_time_events(struct pa_time_event *e) {
static void free_time_events(pa_time_event *e) {
while (e) {
struct pa_time_event *r = e;
pa_time_event *r = e;
e = r->next;
if (r->source) {
@ -463,9 +465,9 @@ static void free_time_events(struct pa_time_event *e) {
}
}
static void free_defer_events(struct pa_defer_event *e) {
static void free_defer_events(pa_defer_event *e) {
while (e) {
struct pa_defer_event *r = e;
pa_defer_event *r = e;
e = r->next;
if (r->source) {
@ -480,7 +482,7 @@ static void free_defer_events(struct pa_defer_event *e) {
}
}
void pa_glib_mainloop_free(struct pa_glib_mainloop* g) {
void pa_glib_mainloop_free(pa_glib_mainloop* g) {
assert(g);
free_io_events(g->io_events);
@ -499,13 +501,13 @@ void pa_glib_mainloop_free(struct pa_glib_mainloop* g) {
pa_xfree(g);
}
struct pa_mainloop_api* pa_glib_mainloop_get_api(struct pa_glib_mainloop *g) {
pa_mainloop_api* pa_glib_mainloop_get_api(pa_glib_mainloop *g) {
assert(g);
return &g->api;
}
static gboolean free_dead_events(gpointer p) {
struct pa_glib_mainloop *g = p;
pa_glib_mainloop *g = p;
assert(g);
free_io_events(g->dead_io_events);
@ -523,7 +525,7 @@ static gboolean free_dead_events(gpointer p) {
return FALSE;
}
static void schedule_free_dead_events(struct pa_glib_mainloop *g) {
static void schedule_free_dead_events(pa_glib_mainloop *g) {
assert(g && g->glib_main_context);
if (g->cleanup_source)

View file

@ -32,23 +32,23 @@
PA_C_DECL_BEGIN
/** \struct pa_glib_mainloop
/** \pa_glib_mainloop
* An opaque GLIB main loop object */
struct pa_glib_mainloop;
typedef struct pa_glib_mainloop pa_glib_mainloop;
/** Create a new GLIB main loop object for the specified GLIB main loop context. If c is NULL the default context is used. */
#if GLIB_MAJOR_VERSION >= 2
struct pa_glib_mainloop *pa_glib_mainloop_new(GMainContext *c);
pa_glib_mainloop *pa_glib_mainloop_new(GMainContext *c);
#else
struct pa_glib_mainloop *pa_glib_mainloop_new(void);
pa_glib_mainloop *pa_glib_mainloop_new(void);
#endif
/** Free the GLIB main loop object */
void pa_glib_mainloop_free(struct pa_glib_mainloop* g);
void pa_glib_mainloop_free(pa_glib_mainloop* g);
/** Return the abstract main loop API vtable for the GLIB main loop object */
struct pa_mainloop_api* pa_glib_mainloop_get_api(struct pa_glib_mainloop *g);
pa_mainloop_api* pa_glib_mainloop_get_api(pa_glib_mainloop *g);
PA_C_DECL_END

View file

@ -28,63 +28,64 @@
#include "glib-mainloop.h"
#include "idxset.h"
#include "xmalloc.h"
#include "util.h"
/* A mainloop implementation based on GLIB 1.2 */
struct pa_io_event {
struct pa_glib_mainloop *mainloop;
pa_glib_mainloop *mainloop;
int dead;
GIOChannel *io_channel;
guint source;
GIOCondition io_condition;
int fd;
void (*callback) (struct pa_mainloop_api*m, struct pa_io_event *e, int fd, enum pa_io_event_flags f, void *userdata);
void (*callback) (pa_mainloop_api*m, pa_io_event *e, int fd, pa_io_event_flags f, void *userdata);
void *userdata;
void (*destroy_callback) (struct pa_mainloop_api *m, struct pa_io_event*e, void *userdata);
struct pa_io_event *next, *prev;
void (*destroy_callback) (pa_mainloop_api *m, pa_io_event*e, void *userdata);
pa_io_event *next, *prev;
};
struct pa_time_event {
struct pa_glib_mainloop *mainloop;
pa_glib_mainloop *mainloop;
int dead;
guint source;
struct timeval timeval;
void (*callback) (struct pa_mainloop_api*m, struct pa_time_event *e, const struct timeval *tv, void *userdata);
void (*callback) (pa_mainloop_api*m, pa_time_event *e, const struct timeval *tv, void *userdata);
void *userdata;
void (*destroy_callback) (struct pa_mainloop_api *m, struct pa_time_event*e, void *userdata);
struct pa_time_event *next, *prev;
void (*destroy_callback) (pa_mainloop_api *m, pa_time_event*e, void *userdata);
pa_time_event *next, *prev;
};
struct pa_defer_event {
struct pa_glib_mainloop *mainloop;
pa_glib_mainloop *mainloop;
int dead;
guint source;
void (*callback) (struct pa_mainloop_api*m, struct pa_defer_event *e, void *userdata);
void (*callback) (pa_mainloop_api*m, pa_defer_event *e, void *userdata);
void *userdata;
void (*destroy_callback) (struct pa_mainloop_api *m, struct pa_defer_event*e, void *userdata);
struct pa_defer_event *next, *prev;
void (*destroy_callback) (pa_mainloop_api *m, pa_defer_event*e, void *userdata);
pa_defer_event *next, *prev;
};
struct pa_glib_mainloop {
struct pa_mainloop_api api;
pa_mainloop_api api;
guint cleanup_source;
struct pa_io_event *io_events, *dead_io_events;
struct pa_time_event *time_events, *dead_time_events;
struct pa_defer_event *defer_events, *dead_defer_events;
pa_io_event *io_events, *dead_io_events;
pa_time_event *time_events, *dead_time_events;
pa_defer_event *defer_events, *dead_defer_events;
};
static void schedule_free_dead_events(struct pa_glib_mainloop *g);
static void schedule_free_dead_events(pa_glib_mainloop *g);
static void glib_io_enable(struct pa_io_event*e, enum pa_io_event_flags f);
static void glib_io_enable(pa_io_event*e, pa_io_event_flags f);
static struct pa_io_event* glib_io_new(struct pa_mainloop_api*m, int fd, enum pa_io_event_flags f, void (*callback) (struct pa_mainloop_api*m, struct pa_io_event*e, int fd, enum pa_io_event_flags f, void *userdata), void *userdata) {
struct pa_io_event *e;
struct pa_glib_mainloop *g;
static pa_io_event* glib_io_new(pa_mainloop_api*m, int fd, pa_io_event_flags f, void (*callback) (pa_mainloop_api*m, pa_io_event*e, int fd, pa_io_event_flags f, void *userdata), void *userdata) {
pa_io_event *e;
pa_glib_mainloop *g;
assert(m && m->userdata && fd >= 0 && callback);
g = m->userdata;
e = pa_xmalloc(sizeof(struct pa_io_event));
e = pa_xmalloc(sizeof(pa_io_event));
e->mainloop = m->userdata;
e->dead = 0;
e->fd = fd;
@ -108,8 +109,8 @@ static struct pa_io_event* glib_io_new(struct pa_mainloop_api*m, int fd, enum pa
}
static gboolean io_cb(GIOChannel *source, GIOCondition condition, gpointer data) {
struct pa_io_event *e = data;
enum pa_io_event_flags f;
pa_io_event *e = data;
pa_io_event_flags f;
assert(source && e && e->io_channel == source);
f = (condition & G_IO_IN ? PA_IO_EVENT_INPUT : 0) |
@ -121,7 +122,7 @@ static gboolean io_cb(GIOChannel *source, GIOCondition condition, gpointer data)
return TRUE;
}
static void glib_io_enable(struct pa_io_event*e, enum pa_io_event_flags f) {
static void glib_io_enable(pa_io_event*e, pa_io_event_flags f) {
GIOCondition c;
assert(e && !e->dead);
@ -138,7 +139,7 @@ static void glib_io_enable(struct pa_io_event*e, enum pa_io_event_flags f) {
e->io_condition = c;
}
static void glib_io_free(struct pa_io_event*e) {
static void glib_io_free(pa_io_event*e) {
assert(e && !e->dead);
if (e->source != (guint) -1) {
@ -164,23 +165,23 @@ static void glib_io_free(struct pa_io_event*e) {
schedule_free_dead_events(e->mainloop);
}
static void glib_io_set_destroy(struct pa_io_event*e, void (*callback)(struct pa_mainloop_api*m, struct pa_io_event *e, void *userdata)) {
static void glib_io_set_destroy(pa_io_event*e, void (*callback)(pa_mainloop_api*m, pa_io_event *e, void *userdata)) {
assert(e);
e->destroy_callback = callback;
}
/* Time sources */
static void glib_time_restart(struct pa_time_event*e, const struct timeval *tv);
static void glib_time_restart(pa_time_event*e, const struct timeval *tv);
static struct pa_time_event* glib_time_new(struct pa_mainloop_api*m, const struct timeval *tv, void (*callback) (struct pa_mainloop_api*m, struct pa_time_event*e, const struct timeval *tv, void *userdata), void *userdata) {
struct pa_glib_mainloop *g;
struct pa_time_event *e;
static pa_time_event* glib_time_new(pa_mainloop_api*m, const struct timeval *tv, void (*callback) (pa_mainloop_api*m, pa_time_event*e, const struct timeval *tv, void *userdata), void *userdata) {
pa_glib_mainloop *g;
pa_time_event *e;
assert(m && m->userdata && tv && callback);
g = m->userdata;
e = pa_xmalloc(sizeof(struct pa_time_event));
e = pa_xmalloc(sizeof(pa_time_event));
e->mainloop = g;
e->dead = 0;
e->callback = callback;
@ -219,7 +220,7 @@ static guint msec_diff(const struct timeval *a, const struct timeval *b) {
}
static gboolean time_cb(gpointer data) {
struct pa_time_event* e = data;
pa_time_event* e = data;
assert(e && e->mainloop && e->source != (guint) -1);
g_source_remove(e->source);
@ -229,7 +230,7 @@ static gboolean time_cb(gpointer data) {
return FALSE;
}
static void glib_time_restart(struct pa_time_event*e, const struct timeval *tv) {
static void glib_time_restart(pa_time_event*e, const struct timeval *tv) {
struct timeval now;
assert(e && e->mainloop && !e->dead);
@ -245,7 +246,7 @@ static void glib_time_restart(struct pa_time_event*e, const struct timeval *tv)
e->source = (guint) -1;
}
static void glib_time_free(struct pa_time_event *e) {
static void glib_time_free(pa_time_event *e) {
assert(e && e->mainloop && !e->dead);
if (e->source != (guint) -1) {
@ -271,23 +272,23 @@ static void glib_time_free(struct pa_time_event *e) {
schedule_free_dead_events(e->mainloop);
}
static void glib_time_set_destroy(struct pa_time_event *e, void (*callback)(struct pa_mainloop_api*m, struct pa_time_event*e, void *userdata)) {
static void glib_time_set_destroy(pa_time_event *e, void (*callback)(pa_mainloop_api*m, pa_time_event*e, void *userdata)) {
assert(e);
e->destroy_callback = callback;
}
/* Deferred sources */
static void glib_defer_enable(struct pa_defer_event *e, int b);
static void glib_defer_enable(pa_defer_event *e, int b);
static struct pa_defer_event* glib_defer_new(struct pa_mainloop_api*m, void (*callback) (struct pa_mainloop_api*m, struct pa_defer_event *e, void *userdata), void *userdata) {
struct pa_defer_event *e;
struct pa_glib_mainloop *g;
static pa_defer_event* glib_defer_new(pa_mainloop_api*m, void (*callback) (pa_mainloop_api*m, pa_defer_event *e, void *userdata), void *userdata) {
pa_defer_event *e;
pa_glib_mainloop *g;
assert(m && m->userdata && callback);
g = m->userdata;
e = pa_xmalloc(sizeof(struct pa_defer_event));
e = pa_xmalloc(sizeof(pa_defer_event));
e->mainloop = g;
e->dead = 0;
e->callback = callback;
@ -305,14 +306,14 @@ static struct pa_defer_event* glib_defer_new(struct pa_mainloop_api*m, void (*ca
}
static gboolean idle_cb(gpointer data) {
struct pa_defer_event* e = data;
pa_defer_event* e = data;
assert(e && e->mainloop && e->source != (guint) -1);
e->callback(&e->mainloop->api, e, e->userdata);
return TRUE;
}
static void glib_defer_enable(struct pa_defer_event *e, int b) {
static void glib_defer_enable(pa_defer_event *e, int b) {
assert(e && e->mainloop);
if (e->source != (guint) -1 && !b) {
@ -324,7 +325,7 @@ static void glib_defer_enable(struct pa_defer_event *e, int b) {
}
}
static void glib_defer_free(struct pa_defer_event *e) {
static void glib_defer_free(pa_defer_event *e) {
assert(e && e->mainloop && !e->dead);
if (e->source != (guint) -1) {
@ -350,22 +351,22 @@ static void glib_defer_free(struct pa_defer_event *e) {
schedule_free_dead_events(e->mainloop);
}
static void glib_defer_set_destroy(struct pa_defer_event *e, void (*callback)(struct pa_mainloop_api *m, struct pa_defer_event *e, void *userdata)) {
static void glib_defer_set_destroy(pa_defer_event *e, void (*callback)(pa_mainloop_api *m, pa_defer_event *e, void *userdata)) {
assert(e);
e->destroy_callback = callback;
}
/* quit() */
static void glib_quit(struct pa_mainloop_api*a, int retval) {
struct pa_glib_mainloop *g;
static void glib_quit(pa_mainloop_api*a, PA_GCC_UNUSED int retval) {
pa_glib_mainloop *g;
assert(a && a->userdata);
g = a->userdata;
/* NOOP */
}
static const struct pa_mainloop_api vtable = {
static const pa_mainloop_api vtable = {
.userdata = NULL,
.io_new = glib_io_new,
@ -386,10 +387,10 @@ static const struct pa_mainloop_api vtable = {
.quit = glib_quit,
};
struct pa_glib_mainloop *pa_glib_mainloop_new(void) {
struct pa_glib_mainloop *g;
pa_glib_mainloop *pa_glib_mainloop_new(void) {
pa_glib_mainloop *g;
g = pa_xmalloc(sizeof(struct pa_glib_mainloop));
g = pa_xmalloc(sizeof(pa_glib_mainloop));
g->api = vtable;
g->api.userdata = g;
@ -402,9 +403,9 @@ struct pa_glib_mainloop *pa_glib_mainloop_new(void) {
return g;
}
static void free_io_events(struct pa_io_event *e) {
static void free_io_events(pa_io_event *e) {
while (e) {
struct pa_io_event *r = e;
pa_io_event *r = e;
e = r->next;
if (r->source != (guint) -1)
@ -420,9 +421,9 @@ static void free_io_events(struct pa_io_event *e) {
}
}
static void free_time_events(struct pa_time_event *e) {
static void free_time_events(pa_time_event *e) {
while (e) {
struct pa_time_event *r = e;
pa_time_event *r = e;
e = r->next;
if (r->source != (guint) -1)
@ -435,9 +436,9 @@ static void free_time_events(struct pa_time_event *e) {
}
}
static void free_defer_events(struct pa_defer_event *e) {
static void free_defer_events(pa_defer_event *e) {
while (e) {
struct pa_defer_event *r = e;
pa_defer_event *r = e;
e = r->next;
if (r->source != (guint) -1)
@ -450,7 +451,7 @@ static void free_defer_events(struct pa_defer_event *e) {
}
}
void pa_glib_mainloop_free(struct pa_glib_mainloop* g) {
void pa_glib_mainloop_free(pa_glib_mainloop* g) {
assert(g);
free_io_events(g->io_events);
@ -466,13 +467,13 @@ void pa_glib_mainloop_free(struct pa_glib_mainloop* g) {
pa_xfree(g);
}
struct pa_mainloop_api* pa_glib_mainloop_get_api(struct pa_glib_mainloop *g) {
pa_mainloop_api* pa_glib_mainloop_get_api(pa_glib_mainloop *g) {
assert(g);
return &g->api;
}
static gboolean free_dead_events(gpointer p) {
struct pa_glib_mainloop *g = p;
pa_glib_mainloop *g = p;
assert(g);
free_io_events(g->dead_io_events);
@ -489,7 +490,7 @@ static gboolean free_dead_events(gpointer p) {
return FALSE;
}
static void schedule_free_dead_events(struct pa_glib_mainloop *g) {
static void schedule_free_dead_events(pa_glib_mainloop *g) {
assert(g);
if (g->cleanup_source != (guint) -1)

View file

@ -51,9 +51,9 @@ struct pa_hashmap {
int (*compare_func) (const void*a, const void*b);
};
struct pa_hashmap *pa_hashmap_new(unsigned (*hash_func) (const void *p), int (*compare_func) (const void*a, const void*b)) {
struct pa_hashmap *h;
h = pa_xmalloc(sizeof(struct pa_hashmap));
pa_hashmap *pa_hashmap_new(unsigned (*hash_func) (const void *p), int (*compare_func) (const void*a, const void*b)) {
pa_hashmap *h;
h = pa_xmalloc(sizeof(pa_hashmap));
h->data = pa_xmalloc0(sizeof(struct hashmap_entry*)*(h->size = BUCKETS));
h->first_entry = NULL;
h->n_entries = 0;
@ -62,7 +62,7 @@ struct pa_hashmap *pa_hashmap_new(unsigned (*hash_func) (const void *p), int (*c
return h;
}
static void remove(struct pa_hashmap *h, struct hashmap_entry *e) {
static void remove(pa_hashmap *h, struct hashmap_entry *e) {
assert(e);
if (e->next)
@ -85,7 +85,7 @@ static void remove(struct pa_hashmap *h, struct hashmap_entry *e) {
h->n_entries--;
}
void pa_hashmap_free(struct pa_hashmap*h, void (*free_func)(void *p, void *userdata), void *userdata) {
void pa_hashmap_free(pa_hashmap*h, void (*free_func)(void *p, void *userdata), void *userdata) {
assert(h);
while (h->first_entry) {
@ -98,7 +98,7 @@ void pa_hashmap_free(struct pa_hashmap*h, void (*free_func)(void *p, void *userd
pa_xfree(h);
}
static struct hashmap_entry *get(struct pa_hashmap *h, unsigned hash, const void *key) {
static struct hashmap_entry *get(pa_hashmap *h, unsigned hash, const void *key) {
struct hashmap_entry *e;
assert(h && hash < h->size);
@ -109,7 +109,7 @@ static struct hashmap_entry *get(struct pa_hashmap *h, unsigned hash, const void
return NULL;
}
int pa_hashmap_put(struct pa_hashmap *h, const void *key, void *value) {
int pa_hashmap_put(pa_hashmap *h, const void *key, void *value) {
struct hashmap_entry *e;
unsigned hash;
assert(h);
@ -140,7 +140,7 @@ int pa_hashmap_put(struct pa_hashmap *h, const void *key, void *value) {
return 0;
}
void* pa_hashmap_get(struct pa_hashmap *h, const void *key) {
void* pa_hashmap_get(pa_hashmap *h, const void *key) {
unsigned hash;
struct hashmap_entry *e;
assert(h && key);
@ -153,7 +153,7 @@ void* pa_hashmap_get(struct pa_hashmap *h, const void *key) {
return e->value;
}
void* pa_hashmap_remove(struct pa_hashmap *h, const void *key) {
void* pa_hashmap_remove(pa_hashmap *h, const void *key) {
struct hashmap_entry *e;
unsigned hash;
void *data;
@ -169,11 +169,11 @@ void* pa_hashmap_remove(struct pa_hashmap *h, const void *key) {
return data;
}
unsigned pa_hashmap_ncontents(struct pa_hashmap *h) {
unsigned pa_hashmap_size(pa_hashmap *h) {
return h->n_entries;
}
void *pa_hashmap_iterate(struct pa_hashmap *h, void **state, const void **key) {
void *pa_hashmap_iterate(pa_hashmap *h, void **state, const void **key) {
assert(h && state);
if (!*state)

View file

@ -26,28 +26,28 @@
* user's job. It's a good idea to have the key pointer point to a
* string in the value data. */
struct pa_hashmap;
typedef struct pa_hashmap pa_hashmap;
/* Create a new hashmap. Use the specified functions for hashing and comparing objects in the map */
struct pa_hashmap *pa_hashmap_new(unsigned (*hash_func) (const void *p), int (*compare_func) (const void*a, const void*b));
pa_hashmap *pa_hashmap_new(unsigned (*hash_func) (const void *p), int (*compare_func) (const void*a, const void*b));
/* Free the hash table. Calls the specified function for every value in the table. The function may be NULL */
void pa_hashmap_free(struct pa_hashmap*, void (*free_func)(void *p, void *userdata), void *userdata);
void pa_hashmap_free(pa_hashmap*, void (*free_func)(void *p, void *userdata), void *userdata);
/* Returns non-zero when the entry already exists */
int pa_hashmap_put(struct pa_hashmap *h, const void *key, void *value);
void* pa_hashmap_get(struct pa_hashmap *h, const void *key);
int pa_hashmap_put(pa_hashmap *h, const void *key, void *value);
void* pa_hashmap_get(pa_hashmap *h, const void *key);
/* Returns the data of the entry while removing */
void* pa_hashmap_remove(struct pa_hashmap *h, const void *key);
void* pa_hashmap_remove(pa_hashmap *h, const void *key);
unsigned pa_hashmap_ncontents(struct pa_hashmap *h);
unsigned pa_hashmap_size(pa_hashmap *h);
/* May be used to iterate through the hashmap. Initially the opaque
pointer *state has to be set to NULL. The hashmap may not be
modified during iteration. The key of the entry is returned in
*key, if key is non-NULL. After the last entry in the hashmap NULL
is returned. */
void *pa_hashmap_iterate(struct pa_hashmap *h, void **state, const void**key);
void *pa_hashmap_iterate(pa_hashmap *h, void **state, const void**key);
#endif

View file

@ -28,17 +28,17 @@
#define HOWL_PROPERTY "howl"
struct pa_howl_wrapper {
struct pa_core *core;
pa_howl_wrapper {
pa_core *core;
int ref;
struct pa_io_event *io_event;
pa_io_event *io_event;
sw_discovery discovery;
};
static void howl_io_event(struct pa_mainloop_api*m, struct pa_io_event *e, int fd, enum pa_io_event_flags f, void *userdata) {
struct pa_howl_wrapper *w = userdata;
static void howl_io_event(pa_mainloop_api*m, pa_io_event *e, int fd, pa_io_event_flags f, void *userdata) {
pa_howl_wrapper *w = userdata;
assert(m && e && fd >= 0 && w && w->ref >= 1);
if (f & (PA_IO_EVENT_HANGUP|PA_IO_EVENT_ERROR))
@ -55,8 +55,8 @@ fail:
w->io_event = NULL;
}
static struct pa_howl_wrapper* howl_wrapper_new(struct pa_core *c) {
struct pa_howl_wrapper *h;
static pa_howl_wrapper* howl_wrapper_new(pa_core *c) {
pa_howl_wrapper *h;
sw_discovery session;
assert(c);
@ -65,7 +65,7 @@ static struct pa_howl_wrapper* howl_wrapper_new(struct pa_core *c) {
return NULL;
}
h = pa_xmalloc(sizeof(struct pa_howl_wrapper));
h = pa_xmalloc(sizeof(pa_howl_wrapper));
h->core = c;
h->ref = 1;
h->discovery = session;
@ -75,7 +75,7 @@ static struct pa_howl_wrapper* howl_wrapper_new(struct pa_core *c) {
return h;
}
static void howl_wrapper_free(struct pa_howl_wrapper *h) {
static void howl_wrapper_free(pa_howl_wrapper *h) {
assert(h);
sw_discovery_fina(h->discovery);
@ -86,8 +86,8 @@ static void howl_wrapper_free(struct pa_howl_wrapper *h) {
pa_xfree(h);
}
struct pa_howl_wrapper* pa_howl_wrapper_get(struct pa_core *c) {
struct pa_howl_wrapper *h;
pa_howl_wrapper* pa_howl_wrapper_get(pa_core *c) {
pa_howl_wrapper *h;
assert(c);
if ((h = pa_property_get(c, HOWL_PROPERTY)))
@ -96,19 +96,19 @@ struct pa_howl_wrapper* pa_howl_wrapper_get(struct pa_core *c) {
return howl_wrapper_new(c);
}
struct pa_howl_wrapper* pa_howl_wrapper_ref(struct pa_howl_wrapper *h) {
pa_howl_wrapper* pa_howl_wrapper_ref(pa_howl_wrapper *h) {
assert(h && h->ref >= 1);
h->ref++;
return h;
}
void pa_howl_wrapper_unref(struct pa_howl_wrapper *h) {
void pa_howl_wrapper_unref(pa_howl_wrapper *h) {
assert(h && h->ref >= 1);
if (!(--h->ref))
howl_wrapper_free(h);
}
sw_discovery pa_howl_wrapper_get_discovery(struct pa_howl_wrapper *h) {
sw_discovery pa_howl_wrapper_get_discovery(pa_howl_wrapper *h) {
assert(h && h->ref >= 1);
return h->discovery;

View file

@ -26,12 +26,12 @@
#include "core.h"
struct pa_howl_wrapper;
pa_howl_wrapper;
struct pa_howl_wrapper* pa_howl_wrapper_get(struct pa_core *c);
struct pa_howl_wrapper* pa_howl_wrapper_ref(struct pa_howl_wrapper *h);
void pa_howl_wrapper_unref(struct pa_howl_wrapper *h);
pa_howl_wrapper* pa_howl_wrapper_get(pa_core *c);
pa_howl_wrapper* pa_howl_wrapper_ref(pa_howl_wrapper *h);
void pa_howl_wrapper_unref(pa_howl_wrapper *h);
sw_discovery pa_howl_wrapper_get_discovery(struct pa_howl_wrapper *h);
sw_discovery pa_howl_wrapper_get_discovery(pa_howl_wrapper *h);
#endif

View file

@ -31,21 +31,21 @@
#include "idxset.h"
#include "xmalloc.h"
struct idxset_entry {
typedef struct idxset_entry {
void *data;
uint32_t index;
unsigned hash_value;
struct idxset_entry *hash_prev, *hash_next;
struct idxset_entry* iterate_prev, *iterate_next;
};
} idxset_entry;
struct pa_idxset {
unsigned (*hash_func) (const void *p);
int (*compare_func)(const void *a, const void *b);
unsigned hash_table_size, n_entries;
struct idxset_entry **hash_table, **array, *iterate_list_head, *iterate_list_tail;
idxset_entry **hash_table, **array, *iterate_list_head, *iterate_list_tail;
uint32_t index, start_index, array_size;
};
@ -71,14 +71,14 @@ int pa_idxset_trivial_compare_func(const void *a, const void *b) {
return a != b;
}
struct pa_idxset* pa_idxset_new(unsigned (*hash_func) (const void *p), int (*compare_func) (const void*a, const void*b)) {
struct pa_idxset *s;
pa_idxset* pa_idxset_new(unsigned (*hash_func) (const void *p), int (*compare_func) (const void*a, const void*b)) {
pa_idxset *s;
s = pa_xmalloc(sizeof(struct pa_idxset));
s = pa_xnew(pa_idxset, 1);
s->hash_func = hash_func ? hash_func : pa_idxset_trivial_hash_func;
s->compare_func = compare_func ? compare_func : pa_idxset_trivial_compare_func;
s->hash_table_size = 1023;
s->hash_table = pa_xmalloc0(sizeof(struct idxset_entry*)*s->hash_table_size);
s->hash_table = pa_xmalloc0(sizeof(idxset_entry*)*s->hash_table_size);
s->array = NULL;
s->array_size = 0;
s->index = 0;
@ -90,11 +90,11 @@ struct pa_idxset* pa_idxset_new(unsigned (*hash_func) (const void *p), int (*com
return s;
}
void pa_idxset_free(struct pa_idxset *s, void (*free_func) (void *p, void *userdata), void *userdata) {
void pa_idxset_free(pa_idxset *s, void (*free_func) (void *p, void *userdata), void *userdata) {
assert(s);
while (s->iterate_list_head) {
struct idxset_entry *e = s->iterate_list_head;
idxset_entry *e = s->iterate_list_head;
s->iterate_list_head = s->iterate_list_head->iterate_next;
if (free_func)
@ -107,7 +107,7 @@ void pa_idxset_free(struct pa_idxset *s, void (*free_func) (void *p, void *userd
pa_xfree(s);
}
static struct idxset_entry* hash_scan(struct pa_idxset *s, struct idxset_entry* e, const void *p) {
static idxset_entry* hash_scan(pa_idxset *s, idxset_entry* e, const void *p) {
assert(p);
assert(s->compare_func);
@ -118,20 +118,20 @@ static struct idxset_entry* hash_scan(struct pa_idxset *s, struct idxset_entry*
return NULL;
}
static void extend_array(struct pa_idxset *s, uint32_t index) {
static void extend_array(pa_idxset *s, uint32_t idx) {
uint32_t i, j, l;
struct idxset_entry** n;
assert(index >= s->start_index);
idxset_entry** n;
assert(idx >= s->start_index);
if (index < s->start_index + s->array_size)
if (idx < s->start_index + s->array_size)
return;
for (i = 0; i < s->array_size; i++)
if (s->array[i])
break;
l = index - s->start_index - i + 100;
n = pa_xmalloc0(sizeof(struct hash_table_entry*)*l);
l = idx - s->start_index - i + 100;
n = pa_xnew0(idxset_entry*, l);
for (j = 0; j < s->array_size-i; j++)
n[j] = s->array[i+j];
@ -143,19 +143,19 @@ static void extend_array(struct pa_idxset *s, uint32_t index) {
s->start_index += i;
}
static struct idxset_entry** array_index(struct pa_idxset*s, uint32_t index) {
if (index >= s->start_index + s->array_size)
static idxset_entry** array_index(pa_idxset*s, uint32_t idx) {
if (idx >= s->start_index + s->array_size)
return NULL;
if (index < s->start_index)
if (idx < s->start_index)
return NULL;
return s->array + (index - s->start_index);
return s->array + (idx - s->start_index);
}
int pa_idxset_put(struct pa_idxset*s, void *p, uint32_t *index) {
int pa_idxset_put(pa_idxset*s, void *p, uint32_t *idx) {
unsigned h;
struct idxset_entry *e, **a;
idxset_entry *e, **a;
assert(s && p);
assert(s->hash_func);
@ -163,13 +163,13 @@ int pa_idxset_put(struct pa_idxset*s, void *p, uint32_t *index) {
assert(s->hash_table);
if ((e = hash_scan(s, s->hash_table[h], p))) {
if (index)
*index = e->index;
if (idx)
*idx = e->index;
return -1;
}
e = pa_xmalloc(sizeof(struct idxset_entry));
e = pa_xmalloc(sizeof(idxset_entry));
e->data = p;
e->index = s->index++;
e->hash_value = h;
@ -202,17 +202,17 @@ int pa_idxset_put(struct pa_idxset*s, void *p, uint32_t *index) {
s->n_entries++;
assert(s->n_entries >= 1);
if (index)
*index = e->index;
if (idx)
*idx = e->index;
return 0;
}
void* pa_idxset_get_by_index(struct pa_idxset*s, uint32_t index) {
struct idxset_entry **a;
void* pa_idxset_get_by_index(pa_idxset*s, uint32_t idx) {
idxset_entry **a;
assert(s);
if (!(a = array_index(s, index)))
if (!(a = array_index(s, idx)))
return NULL;
if (!*a)
@ -221,9 +221,9 @@ void* pa_idxset_get_by_index(struct pa_idxset*s, uint32_t index) {
return (*a)->data;
}
void* pa_idxset_get_by_data(struct pa_idxset*s, const void *p, uint32_t *index) {
void* pa_idxset_get_by_data(pa_idxset*s, const void *p, uint32_t *idx) {
unsigned h;
struct idxset_entry *e;
idxset_entry *e;
assert(s && p);
assert(s->hash_func);
@ -233,14 +233,14 @@ void* pa_idxset_get_by_data(struct pa_idxset*s, const void *p, uint32_t *index)
if (!(e = hash_scan(s, s->hash_table[h], p)))
return NULL;
if (index)
*index = e->index;
if (idx)
*idx = e->index;
return e->data;
}
static void remove_entry(struct pa_idxset *s, struct idxset_entry *e) {
struct idxset_entry **a;
static void remove_entry(pa_idxset *s, idxset_entry *e) {
idxset_entry **a;
assert(s && e);
/* Remove from array */
@ -274,13 +274,13 @@ static void remove_entry(struct pa_idxset *s, struct idxset_entry *e) {
s->n_entries--;
}
void* pa_idxset_remove_by_index(struct pa_idxset*s, uint32_t index) {
struct idxset_entry **a;
void* pa_idxset_remove_by_index(pa_idxset*s, uint32_t idx) {
idxset_entry **a;
void *data;
assert(s);
if (!(a = array_index(s, index)))
if (!(a = array_index(s, idx)))
return NULL;
data = (*a)->data;
@ -289,8 +289,8 @@ void* pa_idxset_remove_by_index(struct pa_idxset*s, uint32_t index) {
return data;
}
void* pa_idxset_remove_by_data(struct pa_idxset*s, const void *data, uint32_t *index) {
struct idxset_entry *e;
void* pa_idxset_remove_by_data(pa_idxset*s, const void *data, uint32_t *idx) {
idxset_entry *e;
unsigned h;
void *r;
@ -302,19 +302,19 @@ void* pa_idxset_remove_by_data(struct pa_idxset*s, const void *data, uint32_t *i
return NULL;
r = e->data;
if (index)
*index = e->index;
if (idx)
*idx = e->index;
remove_entry(s, e);
return r;
}
void* pa_idxset_rrobin(struct pa_idxset *s, uint32_t *index) {
struct idxset_entry **a, *e = NULL;
assert(s && index);
void* pa_idxset_rrobin(pa_idxset *s, uint32_t *idx) {
idxset_entry **a, *e = NULL;
assert(s && idx);
if ((a = array_index(s, *index)) && *a)
if ((a = array_index(s, *idx)) && *a)
e = (*a)->iterate_next;
if (!e)
@ -323,46 +323,46 @@ void* pa_idxset_rrobin(struct pa_idxset *s, uint32_t *index) {
if (!e)
return NULL;
*index = e->index;
*idx = e->index;
return e->data;
}
void* pa_idxset_first(struct pa_idxset *s, uint32_t *index) {
void* pa_idxset_first(pa_idxset *s, uint32_t *idx) {
assert(s);
if (!s->iterate_list_head)
return NULL;
if (index)
*index = s->iterate_list_head->index;
if (idx)
*idx = s->iterate_list_head->index;
return s->iterate_list_head->data;
}
void *pa_idxset_next(struct pa_idxset *s, uint32_t *index) {
struct idxset_entry **a, *e = NULL;
assert(s && index);
void *pa_idxset_next(pa_idxset *s, uint32_t *idx) {
idxset_entry **a, *e = NULL;
assert(s && idx);
if ((a = array_index(s, *index)) && *a)
if ((a = array_index(s, *idx)) && *a)
e = (*a)->iterate_next;
if (e) {
*index = e->index;
*idx = e->index;
return e->data;
} else {
*index = PA_IDXSET_INVALID;
*idx = PA_IDXSET_INVALID;
return NULL;
}
}
int pa_idxset_foreach(struct pa_idxset*s, int (*func)(void *p, uint32_t index, int *del, void*userdata), void *userdata) {
struct idxset_entry *e;
int pa_idxset_foreach(pa_idxset*s, int (*func)(void *p, uint32_t idx, int *del, void*userdata), void *userdata) {
idxset_entry *e;
assert(s && func);
e = s->iterate_list_head;
while (e) {
int del = 0, r;
struct idxset_entry *n = e->iterate_next;
idxset_entry *n = e->iterate_next;
r = func(e->data, e->index, &del, userdata);
@ -378,12 +378,12 @@ int pa_idxset_foreach(struct pa_idxset*s, int (*func)(void *p, uint32_t index, i
return 0;
}
unsigned pa_idxset_ncontents(struct pa_idxset*s) {
unsigned pa_idxset_size(pa_idxset*s) {
assert(s);
return s->n_entries;
}
int pa_idxset_isempty(struct pa_idxset *s) {
int pa_idxset_isempty(pa_idxset *s) {
assert(s);
return s->n_entries == 0;
}

View file

@ -41,53 +41,54 @@ int pa_idxset_trivial_compare_func(const void *a, const void *b);
unsigned pa_idxset_string_hash_func(const void *p);
int pa_idxset_string_compare_func(const void *a, const void *b);
struct pa_idxset;
typedef struct pa_idxset pa_idxset;
/* Instantiate a new idxset with the specified hash and comparison functions */
struct pa_idxset* pa_idxset_new(unsigned (*hash_func) (const void *p), int (*compare_func) (const void*a, const void*b));
pa_idxset* pa_idxset_new(unsigned (*hash_func) (const void *p), int (*compare_func) (const void*a, const void*b));
/* Free the idxset. When the idxset is not empty the specified function is called for every entry contained */
void pa_idxset_free(struct pa_idxset *s, void (*free_func) (void *p, void *userdata), void *userdata);
void pa_idxset_free(pa_idxset *s, void (*free_func) (void *p, void *userdata), void *userdata);
/* Store a new item in the idxset. The index of the item is returned in *index */
int pa_idxset_put(struct pa_idxset*s, void *p, uint32_t *index);
/* Store a new item in the idxset. The index of the item is returned in *idx */
int pa_idxset_put(pa_idxset*s, void *p, uint32_t *idx);
/* Get the entry by its index */
void* pa_idxset_get_by_index(struct pa_idxset*s, uint32_t index);
/* Get the entry by its idx */
void* pa_idxset_get_by_index(pa_idxset*s, uint32_t idx);
/* Get the entry by its data. The index is returned in *index */
void* pa_idxset_get_by_data(struct pa_idxset*s, const void *p, uint32_t *index);
/* Get the entry by its data. The idx is returned in *index */
void* pa_idxset_get_by_data(pa_idxset*s, const void *p, uint32_t *idx);
/* Similar to pa_idxset_get_by_index(), but removes the entry from the idxset. */
void* pa_idxset_remove_by_index(struct pa_idxset*s, uint32_t index);
void* pa_idxset_remove_by_index(pa_idxset*s, uint32_t idx);
/* Similar to pa_idxset_get_by_data(), but removes the entry from the idxset */
void* pa_idxset_remove_by_data(struct pa_idxset*s, const void *p, uint32_t *index);
void* pa_idxset_remove_by_data(pa_idxset*s, const void *p, uint32_t *idx);
/* This may be used to iterate through all entries. When called with
an invalid index value it returns the first entry, otherwise the
next following. The function is best called with *index =
next following. The function is best called with *idx =
PA_IDXSET_VALID first. It is safe to manipulate the idxset between
the calls. It is not guaranteed that all entries have already been
returned before the an entry is returned the second time.*/
void* pa_idxset_rrobin(struct pa_idxset *s, uint32_t *index);
void* pa_idxset_rrobin(pa_idxset *s, uint32_t *idx);
/* Return the oldest entry in the idxset. Fill in its index in *index. */
void* pa_idxset_first(struct pa_idxset *s, uint32_t *index);
/* Return the oldest entry in the idxset. Fill in its index in *idx. */
void* pa_idxset_first(pa_idxset *s, uint32_t *idx);
/* Return the entry following the entry indexed by *index. After the
/* Return the entry following the entry indexed by *idx. After the
* call *index contains the index of the returned
* object. pa_idxset_first() and pa_idxset_next() may be used to
* iterate through the set.*/
void *pa_idxset_next(struct pa_idxset *s, uint32_t *index);
void *pa_idxset_next(pa_idxset *s, uint32_t *idx);
/* Call a function for every item in the set. If the callback function
returns -1, the loop is terminated. If *del is set to non-zero that
specific item is removed. It is not safe to call any other
functions on the idxset while pa_idxset_foreach is executed. */
int pa_idxset_foreach(struct pa_idxset*s, int (*func)(void *p, uint32_t index, int *del, void*userdata), void *userdata);
int pa_idxset_foreach(pa_idxset*s, int (*func)(void *p, uint32_t idx, int *del, void*userdata), void *userdata);
unsigned pa_idxset_ncontents(struct pa_idxset*s);
int pa_idxset_isempty(struct pa_idxset *s);
unsigned pa_idxset_size(pa_idxset*s);
int pa_idxset_isempty(pa_idxset *s);
#endif

View file

@ -37,9 +37,9 @@
struct pa_iochannel {
int ifd, ofd;
struct pa_mainloop_api* mainloop;
pa_mainloop_api* mainloop;
void (*callback)(struct pa_iochannel*io, void *userdata);
pa_iochannel_callback_t callback;
void*userdata;
int readable;
@ -48,14 +48,14 @@ struct pa_iochannel {
int no_close;
struct pa_io_event* input_event, *output_event;
pa_io_event* input_event, *output_event;
};
static void enable_mainloop_sources(struct pa_iochannel *io) {
static void enable_mainloop_sources(pa_iochannel *io) {
assert(io);
if (io->input_event == io->output_event && io->input_event) {
enum pa_io_event_flags f = PA_IO_EVENT_NULL;
pa_io_event_flags f = PA_IO_EVENT_NULL;
assert(io->input_event);
if (!io->readable)
@ -72,10 +72,14 @@ static void enable_mainloop_sources(struct pa_iochannel *io) {
}
}
static void callback(struct pa_mainloop_api* m, struct pa_io_event *e, int fd, enum pa_io_event_flags f, void *userdata) {
struct pa_iochannel *io = userdata;
static void callback(pa_mainloop_api* m, pa_io_event *e, int fd, pa_io_event_flags f, void *userdata) {
pa_iochannel *io = userdata;
int changed = 0;
assert(m && e && fd >= 0 && userdata);
assert(m);
assert(e);
assert(fd >= 0);
assert(userdata);
if ((f & (PA_IO_EVENT_HANGUP|PA_IO_EVENT_ERROR)) && !io->hungup) {
io->hungup = 1;
@ -87,9 +91,7 @@ static void callback(struct pa_mainloop_api* m, struct pa_io_event *e, int fd, e
if (io->output_event == e)
io->output_event = NULL;
}
if (e == io->output_event) {
} else if (e == io->output_event) {
io->mainloop->io_free(io->output_event);
io->output_event = NULL;
}
@ -116,11 +118,13 @@ static void callback(struct pa_mainloop_api* m, struct pa_io_event *e, int fd, e
}
}
struct pa_iochannel* pa_iochannel_new(struct pa_mainloop_api*m, int ifd, int ofd) {
struct pa_iochannel *io;
assert(m && (ifd >= 0 || ofd >= 0));
pa_iochannel* pa_iochannel_new(pa_mainloop_api*m, int ifd, int ofd) {
pa_iochannel *io;
assert(m);
assert(ifd >= 0 || ofd >= 0);
io = pa_xmalloc(sizeof(struct pa_iochannel));
io = pa_xnew(pa_iochannel, 1);
io->ifd = ifd;
io->ofd = ofd;
io->mainloop = m;
@ -154,16 +158,18 @@ struct pa_iochannel* pa_iochannel_new(struct pa_mainloop_api*m, int ifd, int ofd
return io;
}
void pa_iochannel_free(struct pa_iochannel*io) {
void pa_iochannel_free(pa_iochannel*io) {
assert(io);
if (io->input_event)
io->mainloop->io_free(io->input_event);
if (io->output_event && (io->output_event != io->input_event))
io->mainloop->io_free(io->output_event);
if (!io->no_close) {
if (io->ifd >= 0)
close(io->ifd);
if (io->ofd >= 0 && io->ofd != io->ifd)
close(io->ofd);
@ -172,24 +178,31 @@ void pa_iochannel_free(struct pa_iochannel*io) {
pa_xfree(io);
}
int pa_iochannel_is_readable(struct pa_iochannel*io) {
int pa_iochannel_is_readable(pa_iochannel*io) {
assert(io);
return io->readable || io->hungup;
}
int pa_iochannel_is_writable(struct pa_iochannel*io) {
int pa_iochannel_is_writable(pa_iochannel*io) {
assert(io);
return io->writable && !io->hungup;
}
int pa_iochannel_is_hungup(struct pa_iochannel*io) {
int pa_iochannel_is_hungup(pa_iochannel*io) {
assert(io);
return io->hungup;
}
ssize_t pa_iochannel_write(struct pa_iochannel*io, const void*data, size_t l) {
ssize_t pa_iochannel_write(pa_iochannel*io, const void*data, size_t l) {
ssize_t r;
assert(io && data && l && io->ofd >= 0);
assert(io);
assert(data);
assert(l);
assert(io->ofd >= 0);
#ifdef OS_IS_WIN32
r = send(io->ofd, data, l, 0);
@ -211,9 +224,12 @@ ssize_t pa_iochannel_write(struct pa_iochannel*io, const void*data, size_t l) {
return r;
}
ssize_t pa_iochannel_read(struct pa_iochannel*io, void*data, size_t l) {
ssize_t pa_iochannel_read(pa_iochannel*io, void*data, size_t l) {
ssize_t r;
assert(io && data && io->ifd >= 0);
assert(io);
assert(data);
assert(io->ifd >= 0);
#ifdef OS_IS_WIN32
r = recv(io->ifd, data, l, 0);
@ -227,6 +243,7 @@ ssize_t pa_iochannel_read(struct pa_iochannel*io, void*data, size_t l) {
if (r < 0)
#endif
r = read(io->ifd, data, l);
if (r >= 0) {
io->readable = 0;
enable_mainloop_sources(io);
@ -235,34 +252,41 @@ ssize_t pa_iochannel_read(struct pa_iochannel*io, void*data, size_t l) {
return r;
}
void pa_iochannel_set_callback(struct pa_iochannel*io, void (*callback)(struct pa_iochannel*io, void *userdata), void *userdata) {
void pa_iochannel_set_callback(pa_iochannel*io, pa_iochannel_callback_t _callback, void *userdata) {
assert(io);
io->callback = callback;
io->callback = _callback;
io->userdata = userdata;
}
void pa_iochannel_set_noclose(struct pa_iochannel*io, int b) {
void pa_iochannel_set_noclose(pa_iochannel*io, int b) {
assert(io);
io->no_close = b;
}
void pa_iochannel_socket_peer_to_string(struct pa_iochannel*io, char*s, size_t l) {
assert(io && s && l);
void pa_iochannel_socket_peer_to_string(pa_iochannel*io, char*s, size_t l) {
assert(io);
assert(s);
assert(l);
pa_socket_peer_to_string(io->ifd, s, l);
}
int pa_iochannel_socket_set_rcvbuf(struct pa_iochannel *io, size_t l) {
int pa_iochannel_socket_set_rcvbuf(pa_iochannel *io, size_t l) {
assert(io);
return pa_socket_set_rcvbuf(io->ifd, l);
}
int pa_iochannel_socket_set_sndbuf(struct pa_iochannel *io, size_t l) {
int pa_iochannel_socket_set_sndbuf(pa_iochannel *io, size_t l) {
assert(io);
return pa_socket_set_sndbuf(io->ofd, l);
}
struct pa_mainloop_api* pa_iochannel_get_mainloop_api(struct pa_iochannel *io) {
pa_mainloop_api* pa_iochannel_get_mainloop_api(pa_iochannel *io) {
assert(io);
return io->mainloop;
}

View file

@ -35,37 +35,38 @@
* reached. Otherwise strange things may happen when an EOF is
* reached. */
struct pa_iochannel;
typedef struct pa_iochannel pa_iochannel;
/* Create a new IO channel for the specified file descriptors for
input resp. output. It is safe to pass the same file descriptor for
both parameters (in case of full-duplex channels). For a simplex
channel specify -1 for the other direction. */
struct pa_iochannel* pa_iochannel_new(struct pa_mainloop_api*m, int ifd, int ofd);
void pa_iochannel_free(struct pa_iochannel*io);
pa_iochannel* pa_iochannel_new(pa_mainloop_api*m, int ifd, int ofd);
void pa_iochannel_free(pa_iochannel*io);
ssize_t pa_iochannel_write(struct pa_iochannel*io, const void*data, size_t l);
ssize_t pa_iochannel_read(struct pa_iochannel*io, void*data, size_t l);
ssize_t pa_iochannel_write(pa_iochannel*io, const void*data, size_t l);
ssize_t pa_iochannel_read(pa_iochannel*io, void*data, size_t l);
int pa_iochannel_is_readable(struct pa_iochannel*io);
int pa_iochannel_is_writable(struct pa_iochannel*io);
int pa_iochannel_is_hungup(struct pa_iochannel*io);
int pa_iochannel_is_readable(pa_iochannel*io);
int pa_iochannel_is_writable(pa_iochannel*io);
int pa_iochannel_is_hungup(pa_iochannel*io);
/* Don't close the file descirptors when the io channel is freed. By
* default the file descriptors are closed. */
void pa_iochannel_set_noclose(struct pa_iochannel*io, int b);
void pa_iochannel_set_noclose(pa_iochannel*io, int b);
/* Set the callback function that is called whenever data becomes available for read or write */
void pa_iochannel_set_callback(struct pa_iochannel*io, void (*callback)(struct pa_iochannel*io, void *userdata), void *userdata);
typedef void (*pa_iochannel_callback_t)(pa_iochannel*io, void *userdata);
void pa_iochannel_set_callback(pa_iochannel*io, pa_iochannel_callback_t callback, void *userdata);
/* In case the file descriptor is a socket, return a pretty-printed string in *s which describes the peer connected */
void pa_iochannel_socket_peer_to_string(struct pa_iochannel*io, char*s, size_t l);
void pa_iochannel_socket_peer_to_string(pa_iochannel*io, char*s, size_t l);
/* Use setsockopt() to tune the recieve and send buffers of TCP sockets */
int pa_iochannel_socket_set_rcvbuf(struct pa_iochannel*io, size_t l);
int pa_iochannel_socket_set_sndbuf(struct pa_iochannel*io, size_t l);
int pa_iochannel_socket_set_rcvbuf(pa_iochannel*io, size_t l);
int pa_iochannel_socket_set_sndbuf(pa_iochannel*io, size_t l);
struct pa_mainloop_api* pa_iochannel_get_mainloop_api(struct pa_iochannel *io);
pa_mainloop_api* pa_iochannel_get_mainloop_api(pa_iochannel *io);
#endif

View file

@ -37,9 +37,9 @@
#define READ_SIZE (1024)
struct pa_ioline {
struct pa_iochannel *io;
struct pa_defer_event *defer_event;
struct pa_mainloop_api *mainloop;
pa_iochannel *io;
pa_defer_event *defer_event;
pa_mainloop_api *mainloop;
int ref;
int dead;
@ -49,20 +49,20 @@ struct pa_ioline {
char *rbuf;
size_t rbuf_length, rbuf_index, rbuf_valid_length;
void (*callback)(struct pa_ioline*io, const char *s, void *userdata);
void (*callback)(pa_ioline*io, const char *s, void *userdata);
void *userdata;
int defer_close;
};
static void io_callback(struct pa_iochannel*io, void *userdata);
static void defer_callback(struct pa_mainloop_api*m, struct pa_defer_event*e, void *userdata);
static void io_callback(pa_iochannel*io, void *userdata);
static void defer_callback(pa_mainloop_api*m, pa_defer_event*e, void *userdata);
struct pa_ioline* pa_ioline_new(struct pa_iochannel *io) {
struct pa_ioline *l;
pa_ioline* pa_ioline_new(pa_iochannel *io) {
pa_ioline *l;
assert(io);
l = pa_xmalloc(sizeof(struct pa_ioline));
l = pa_xmalloc(sizeof(pa_ioline));
l->io = io;
l->dead = 0;
@ -88,7 +88,7 @@ struct pa_ioline* pa_ioline_new(struct pa_iochannel *io) {
return l;
}
static void ioline_free(struct pa_ioline *l) {
static void ioline_free(pa_ioline *l) {
assert(l);
if (l->io)
@ -102,21 +102,21 @@ static void ioline_free(struct pa_ioline *l) {
pa_xfree(l);
}
void pa_ioline_unref(struct pa_ioline *l) {
void pa_ioline_unref(pa_ioline *l) {
assert(l && l->ref >= 1);
if ((--l->ref) <= 0)
ioline_free(l);
}
struct pa_ioline* pa_ioline_ref(struct pa_ioline *l) {
pa_ioline* pa_ioline_ref(pa_ioline *l) {
assert(l && l->ref >= 1);
l->ref++;
return l;
}
void pa_ioline_close(struct pa_ioline *l) {
void pa_ioline_close(pa_ioline *l) {
assert(l && l->ref >= 1);
l->dead = 1;
@ -131,7 +131,7 @@ void pa_ioline_close(struct pa_ioline *l) {
}
}
void pa_ioline_puts(struct pa_ioline *l, const char *c) {
void pa_ioline_puts(pa_ioline *l, const char *c) {
size_t len;
assert(l && c && l->ref >= 1 && !l->dead);
@ -174,13 +174,13 @@ void pa_ioline_puts(struct pa_ioline *l, const char *c) {
pa_ioline_unref(l);
}
void pa_ioline_set_callback(struct pa_ioline*l, void (*callback)(struct pa_ioline*io, const char *s, void *userdata), void *userdata) {
void pa_ioline_set_callback(pa_ioline*l, void (*callback)(pa_ioline*io, const char *s, void *userdata), void *userdata) {
assert(l && l->ref >= 1);
l->callback = callback;
l->userdata = userdata;
}
static void failure(struct pa_ioline *l) {
static void failure(pa_ioline *l) {
assert(l && l->ref >= 1 && !l->dead);
pa_ioline_close(l);
@ -191,7 +191,7 @@ static void failure(struct pa_ioline *l) {
}
}
static void scan_for_lines(struct pa_ioline *l, size_t skip) {
static void scan_for_lines(pa_ioline *l, size_t skip) {
assert(l && l->ref >= 1 && skip < l->rbuf_valid_length);
while (!l->dead && l->rbuf_valid_length > skip) {
@ -224,9 +224,9 @@ static void scan_for_lines(struct pa_ioline *l, size_t skip) {
l->rbuf_index = l->rbuf_valid_length = 0;
}
static int do_write(struct pa_ioline *l);
static int do_write(pa_ioline *l);
static int do_read(struct pa_ioline *l) {
static int do_read(pa_ioline *l) {
assert(l && l->ref >= 1);
while (!l->dead && pa_iochannel_is_readable(l->io)) {
@ -288,7 +288,7 @@ static int do_read(struct pa_ioline *l) {
}
/* Try to flush the buffer */
static int do_write(struct pa_ioline *l) {
static int do_write(pa_ioline *l) {
ssize_t r;
assert(l && l->ref >= 1);
@ -312,7 +312,7 @@ static int do_write(struct pa_ioline *l) {
}
/* Try to flush read/write data */
static void do_work(struct pa_ioline *l) {
static void do_work(pa_ioline *l) {
assert(l && l->ref >= 1);
pa_ioline_ref(l);
@ -331,21 +331,21 @@ static void do_work(struct pa_ioline *l) {
pa_ioline_unref(l);
}
static void io_callback(struct pa_iochannel*io, void *userdata) {
struct pa_ioline *l = userdata;
static void io_callback(pa_iochannel*io, void *userdata) {
pa_ioline *l = userdata;
assert(io && l && l->ref >= 1);
do_work(l);
}
static void defer_callback(struct pa_mainloop_api*m, struct pa_defer_event*e, void *userdata) {
struct pa_ioline *l = userdata;
static void defer_callback(pa_mainloop_api*m, pa_defer_event*e, void *userdata) {
pa_ioline *l = userdata;
assert(l && l->ref >= 1 && l->mainloop == m && l->defer_event == e);
do_work(l);
}
void pa_ioline_defer_close(struct pa_ioline *l) {
void pa_ioline_defer_close(pa_ioline *l) {
assert(l);
l->defer_close = 1;
@ -354,7 +354,7 @@ void pa_ioline_defer_close(struct pa_ioline *l) {
l->mainloop->defer_enable(l->defer_event, 1);
}
void pa_ioline_printf(struct pa_ioline *s, const char *format, ...) {
void pa_ioline_printf(pa_ioline *s, const char *format, ...) {
char *t;
va_list ap;

View file

@ -29,23 +29,23 @@
* callback function is called whenever a new line has been recieved
* from the client */
struct pa_ioline;
typedef struct pa_ioline pa_ioline;
struct pa_ioline* pa_ioline_new(struct pa_iochannel *io);
void pa_ioline_unref(struct pa_ioline *l);
struct pa_ioline* pa_ioline_ref(struct pa_ioline *l);
void pa_ioline_close(struct pa_ioline *l);
pa_ioline* pa_ioline_new(pa_iochannel *io);
void pa_ioline_unref(pa_ioline *l);
pa_ioline* pa_ioline_ref(pa_ioline *l);
void pa_ioline_close(pa_ioline *l);
/* Write a string to the channel */
void pa_ioline_puts(struct pa_ioline *s, const char *c);
void pa_ioline_puts(pa_ioline *s, const char *c);
/* Write a string to the channel */
void pa_ioline_printf(struct pa_ioline *s, const char *format, ...) PA_GCC_PRINTF_ATTR(2,3);
void pa_ioline_printf(pa_ioline *s, const char *format, ...) PA_GCC_PRINTF_ATTR(2,3);
/* Set the callback function that is called for every recieved line */
void pa_ioline_set_callback(struct pa_ioline*io, void (*callback)(struct pa_ioline*io, const char *s, void *userdata), void *userdata);
void pa_ioline_set_callback(pa_ioline*io, void (*callback)(pa_ioline*io, const char *s, void *userdata), void *userdata);
/* Make sure to close the ioline object as soon as the send buffer is emptied */
void pa_ioline_defer_close(struct pa_ioline *io);
void pa_ioline_defer_close(pa_ioline *io);
#endif

View file

@ -38,9 +38,9 @@
#define ENV_LOGLEVEL "POLYP_LOG"
static char *log_ident = NULL;
static enum pa_log_target log_target = PA_LOG_STDERR;
static void (*user_log_func)(enum pa_log_level l, const char *s) = NULL;
static enum pa_log_level maximal_level = PA_LOG_NOTICE;
static pa_log_target log_target = PA_LOG_STDERR;
static void (*user_log_func)(pa_log_level l, const char *s) = NULL;
static pa_log_level maximal_level = PA_LOG_NOTICE;
#ifdef HAVE_SYSLOG_H
static const int level_to_syslog[] = {
@ -59,18 +59,18 @@ void pa_log_set_ident(const char *p) {
log_ident = pa_xstrdup(p);
}
void pa_log_set_maximal_level(enum pa_log_level l) {
void pa_log_set_maximal_level(pa_log_level l) {
assert(l < PA_LOG_LEVEL_MAX);
maximal_level = l;
}
void pa_log_set_target(enum pa_log_target t, void (*func)(enum pa_log_level l, const char*s)) {
void pa_log_set_target(pa_log_target t, void (*func)(pa_log_level l, const char*s)) {
assert(t == PA_LOG_USER || !func);
log_target = t;
user_log_func = func;
}
void pa_log_levelv(enum pa_log_level level, const char *format, va_list ap) {
void pa_log_with_levelv(pa_log_level level, const char *format, va_list ap) {
const char *e;
assert(level < PA_LOG_LEVEL_MAX);
@ -107,44 +107,44 @@ void pa_log_levelv(enum pa_log_level level, const char *format, va_list ap) {
}
void pa_log_level(enum pa_log_level level, const char *format, ...) {
void pa_log_with_level(pa_log_level level, const char *format, ...) {
va_list ap;
va_start(ap, format);
pa_log_levelv(level, format, ap);
pa_log_with_levelv(level, format, ap);
va_end(ap);
}
void pa_log_debug(const char *format, ...) {
va_list ap;
va_start(ap, format);
pa_log_levelv(PA_LOG_DEBUG, format, ap);
pa_log_with_levelv(PA_LOG_DEBUG, format, ap);
va_end(ap);
}
void pa_log_info(const char *format, ...) {
va_list ap;
va_start(ap, format);
pa_log_levelv(PA_LOG_INFO, format, ap);
pa_log_with_levelv(PA_LOG_INFO, format, ap);
va_end(ap);
}
void pa_log_notice(const char *format, ...) {
va_list ap;
va_start(ap, format);
pa_log_levelv(PA_LOG_INFO, format, ap);
pa_log_with_levelv(PA_LOG_INFO, format, ap);
va_end(ap);
}
void pa_log_warn(const char *format, ...) {
va_list ap;
va_start(ap, format);
pa_log_levelv(PA_LOG_WARN, format, ap);
pa_log_with_levelv(PA_LOG_WARN, format, ap);
va_end(ap);
}
void pa_log_error(const char *format, ...) {
va_list ap;
va_start(ap, format);
pa_log_levelv(PA_LOG_ERROR, format, ap);
pa_log_with_levelv(PA_LOG_ERROR, format, ap);
va_end(ap);
}

View file

@ -23,35 +23,35 @@
***/
#include <stdarg.h>
#include "gcc-printf.h"
#include "gccmacro.h"
/* A simple logging subsystem */
/* Where to log to */
enum pa_log_target {
typedef enum pa_log_target {
PA_LOG_STDERR, /* default */
PA_LOG_SYSLOG,
PA_LOG_USER, /* to user specified function */
PA_LOG_NULL /* to /dev/null */
};
} pa_log_target;
enum pa_log_level {
typedef enum pa_log_level {
PA_LOG_ERROR = 0, /* Error messages */
PA_LOG_WARN = 1, /* Warning messages */
PA_LOG_NOTICE = 2, /* Notice messages */
PA_LOG_INFO = 3, /* Info messages */
PA_LOG_DEBUG = 4, /* debug message */
PA_LOG_LEVEL_MAX
};
} pa_log_level;
/* Set an identifcation for the current daemon. Used when logging to syslog. */
/* Set an identification for the current daemon. Used when logging to syslog. */
void pa_log_set_ident(const char *p);
/* Set another log target. If t is PA_LOG_USER you may specify a function that is called every log string */
void pa_log_set_target(enum pa_log_target t, void (*func)(enum pa_log_level, const char*s));
void pa_log_set_target(pa_log_target t, void (*func)(pa_log_level, const char*s));
/* Minimal log level */
void pa_log_set_maximal_level(enum pa_log_level l);
void pa_log_set_maximal_level(pa_log_level l);
/* Do a log line */
void pa_log_debug(const char *format, ...) PA_GCC_PRINTF_ATTR(1,2);
@ -60,9 +60,9 @@ void pa_log_notice(const char *format, ...) PA_GCC_PRINTF_ATTR(1,2);
void pa_log_warn(const char *format, ...) PA_GCC_PRINTF_ATTR(1,2);
void pa_log_error(const char *format, ...) PA_GCC_PRINTF_ATTR(1,2);
void pa_log_level(enum pa_log_level level, const char *format, ...) PA_GCC_PRINTF_ATTR(2,3);
void pa_log_with_level(pa_log_level level, const char *format, ...) PA_GCC_PRINTF_ATTR(2,3);
void pa_log_levelv(enum pa_log_level level, const char *format, va_list ap);
void pa_log_with_levelv(pa_log_level level, const char *format, va_list ap);
#define pa_log pa_log_error

View file

@ -75,7 +75,7 @@ int deny_severity = LOG_WARNING;
#ifdef OS_IS_WIN32
static void message_cb(struct pa_mainloop_api*a, struct pa_defer_event *e, void *userdata) {
static void message_cb(pa_mainloop_api*a, pa_defer_event *e, void *userdata) {
MSG msg;
while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
@ -90,7 +90,7 @@ static void message_cb(struct pa_mainloop_api*a, struct pa_defer_event *e, void
#endif
static void signal_callback(struct pa_mainloop_api*m, struct pa_signal_event *e, int sig, void *userdata) {
static void signal_callback(pa_mainloop_api*m, PA_GCC_UNUSED pa_signal_event *e, int sig, void *userdata) {
pa_log_info(__FILE__": Got signal %s.\n", pa_strsignal(sig));
switch (sig) {
@ -133,12 +133,12 @@ static void close_pipe(int p[2]) {
}
int main(int argc, char *argv[]) {
struct pa_core *c;
struct pa_strbuf *buf = NULL;
struct pa_daemon_conf *conf;
struct pa_mainloop *mainloop;
pa_core *c;
pa_strbuf *buf = NULL;
pa_daemon_conf *conf;
pa_mainloop *mainloop;
char *s;
char *s;
int r, retval = 1, d = 0;
int daemon_pipe[2] = { -1, -1 };
int suid_root;
@ -149,7 +149,7 @@ int main(int argc, char *argv[]) {
#endif
#ifdef OS_IS_WIN32
struct pa_defer_event *defer;
pa_defer_event *defer;
#endif
pa_limit_caps();
@ -213,7 +213,7 @@ int main(int argc, char *argv[]) {
goto finish;
case PA_CMD_DUMP_CONF: {
char *s = pa_daemon_conf_dump(conf);
s = pa_daemon_conf_dump(conf);
fputs(s, stdout);
pa_xfree(s);
retval = 0;
@ -405,7 +405,7 @@ int main(int argc, char *argv[]) {
if (conf->daemonize)
pa_loop_write(daemon_pipe[1], &retval, sizeof(retval));
#endif
} else if (!c->modules || pa_idxset_ncontents(c->modules) == 0) {
} else if (!c->modules || pa_idxset_size(c->modules) == 0) {
pa_log(__FILE__": daemon startup without any loaded modules, refusing to work.\n");
#ifdef HAVE_FORK
if (conf->daemonize)

View file

@ -28,13 +28,14 @@
#include "mainloop-api.h"
#include "xmalloc.h"
#include "gccmacro.h"
struct once_info {
void (*callback)(struct pa_mainloop_api*m, void *userdata);
void (*callback)(pa_mainloop_api*m, void *userdata);
void *userdata;
};
static void once_callback(struct pa_mainloop_api *m, struct pa_defer_event *e, void *userdata) {
static void once_callback(pa_mainloop_api *m, pa_defer_event *e, void *userdata) {
struct once_info *i = userdata;
assert(m && i && i->callback);
@ -44,18 +45,18 @@ static void once_callback(struct pa_mainloop_api *m, struct pa_defer_event *e, v
m->defer_free(e);
}
static void free_callback(struct pa_mainloop_api *m, struct pa_defer_event *e, void *userdata) {
static void free_callback(pa_mainloop_api *m, PA_GCC_UNUSED pa_defer_event *e, void *userdata) {
struct once_info *i = userdata;
assert(m && i);
pa_xfree(i);
}
void pa_mainloop_api_once(struct pa_mainloop_api* m, void (*callback)(struct pa_mainloop_api *m, void *userdata), void *userdata) {
void pa_mainloop_api_once(pa_mainloop_api* m, void (*callback)(pa_mainloop_api *m, void *userdata), void *userdata) {
struct once_info *i;
struct pa_defer_event *e;
pa_defer_event *e;
assert(m && callback);
i = pa_xmalloc(sizeof(struct once_info));
i = pa_xnew(struct once_info, 1);
i->callback = callback;
i->userdata = userdata;

View file

@ -45,73 +45,75 @@
PA_C_DECL_BEGIN
/** A bitmask for IO events */
enum pa_io_event_flags {
typedef enum pa_io_event_flags {
PA_IO_EVENT_NULL = 0, /**< No event */
PA_IO_EVENT_INPUT = 1, /**< Input event */
PA_IO_EVENT_OUTPUT = 2, /**< Output event */
PA_IO_EVENT_HANGUP = 4, /**< Hangup event */
PA_IO_EVENT_ERROR = 8 /**< Error event */
};
} pa_io_event_flags;
/** \struct pa_io_event
/** \pa_io_event
* An opaque IO event source object */
struct pa_io_event;
typedef struct pa_io_event pa_io_event;
/** \struct pa_defer_event
/** \pa_defer_event
* An opaque deferred event source object. Events of this type are triggered once in every main loop iteration */
struct pa_defer_event;
typedef struct pa_defer_event pa_defer_event;
/** \struct pa_time_event
/** \pa_time_event
* An opaque timer event source object */
struct pa_time_event;
typedef struct pa_time_event pa_time_event;
/** An abstract mainloop API vtable */
struct pa_mainloop_api {
typedef struct pa_mainloop_api pa_mainloop_api;
struct pa_mainloop_api {
/** A pointer to some private, arbitrary data of the main loop implementation */
void *userdata;
/** Create a new IO event source object */
struct pa_io_event* (*io_new)(struct pa_mainloop_api*a, int fd, enum pa_io_event_flags events, void (*callback) (struct pa_mainloop_api*a, struct pa_io_event* e, int fd, enum pa_io_event_flags events, void *userdata), void *userdata);
pa_io_event* (*io_new)(pa_mainloop_api*a, int fd, pa_io_event_flags events, void (*callback) (pa_mainloop_api*a, pa_io_event* e, int fd, pa_io_event_flags events, void *userdata), void *userdata);
/** Enable or disable IO events on this object */
void (*io_enable)(struct pa_io_event* e, enum pa_io_event_flags events);
void (*io_enable)(pa_io_event* e, pa_io_event_flags events);
/** Free a IO event source object */
void (*io_free)(struct pa_io_event* e);
void (*io_free)(pa_io_event* e);
/** Set a function that is called when the IO event source is destroyed. Use this to free the userdata argument if required */
void (*io_set_destroy)(struct pa_io_event *e, void (*callback) (struct pa_mainloop_api*a, struct pa_io_event *e, void *userdata));
void (*io_set_destroy)(pa_io_event *e, void (*callback) (pa_mainloop_api*a, pa_io_event *e, void *userdata));
/** Create a new timer event source object for the specified Unix time */
struct pa_time_event* (*time_new)(struct pa_mainloop_api*a, const struct timeval *tv, void (*callback) (struct pa_mainloop_api*a, struct pa_time_event* e, const struct timeval *tv, void *userdata), void *userdata);
pa_time_event* (*time_new)(pa_mainloop_api*a, const struct timeval *tv, void (*callback) (pa_mainloop_api*a, pa_time_event* e, const struct timeval *tv, void *userdata), void *userdata);
/** Restart a running or expired timer event source with a new Unix time */
void (*time_restart)(struct pa_time_event* e, const struct timeval *tv);
void (*time_restart)(pa_time_event* e, const struct timeval *tv);
/** Free a deferred timer event source object */
void (*time_free)(struct pa_time_event* e);
void (*time_free)(pa_time_event* e);
/** Set a function that is called when the timer event source is destroyed. Use this to free the userdata argument if required */
void (*time_set_destroy)(struct pa_time_event *e, void (*callback) (struct pa_mainloop_api*a, struct pa_time_event *e, void *userdata));
void (*time_set_destroy)(pa_time_event *e, void (*callback) (pa_mainloop_api*a, pa_time_event *e, void *userdata));
/** Create a new deferred event source object */
struct pa_defer_event* (*defer_new)(struct pa_mainloop_api*a, void (*callback) (struct pa_mainloop_api*a, struct pa_defer_event* e, void *userdata), void *userdata);
pa_defer_event* (*defer_new)(pa_mainloop_api*a, void (*callback) (pa_mainloop_api*a, pa_defer_event* e, void *userdata), void *userdata);
/** Enable or disable a deferred event source temporarily */
void (*defer_enable)(struct pa_defer_event* e, int b);
void (*defer_enable)(pa_defer_event* e, int b);
/** Free a deferred event source object */
void (*defer_free)(struct pa_defer_event* e);
void (*defer_free)(pa_defer_event* e);
/** Set a function that is called when the deferred event source is destroyed. Use this to free the userdata argument if required */
void (*defer_set_destroy)(struct pa_defer_event *e, void (*callback) (struct pa_mainloop_api*a, struct pa_defer_event *e, void *userdata));
void (*defer_set_destroy)(pa_defer_event *e, void (*callback) (pa_mainloop_api*a, pa_defer_event *e, void *userdata));
/** Exit the main loop and return the specfied retval*/
void (*quit)(struct pa_mainloop_api*a, int retval);
void (*quit)(pa_mainloop_api*a, int retval);
};
/** Run the specified callback function once from the main loop using an anonymous defer event. */
void pa_mainloop_api_once(struct pa_mainloop_api*m, void (*callback)(struct pa_mainloop_api*m, void *userdata), void *userdata);
void pa_mainloop_api_once(pa_mainloop_api*m, void (*callback)(pa_mainloop_api*m, void *userdata), void *userdata);
PA_C_DECL_END

View file

@ -40,6 +40,7 @@
#include "util.h"
#include "xmalloc.h"
#include "log.h"
#include "gccmacro.h"
struct pa_signal_event {
int sig;
@ -48,17 +49,17 @@ struct pa_signal_event {
#else
void (*saved_handler)(int sig);
#endif
void (*callback) (struct pa_mainloop_api*a, struct pa_signal_event *e, int signal, void *userdata);
void (*callback) (pa_mainloop_api*a, pa_signal_event *e, int sig, void *userdata);
void *userdata;
void (*destroy_callback) (struct pa_mainloop_api*a, struct pa_signal_event*e, void *userdata);
struct pa_signal_event *previous, *next;
void (*destroy_callback) (pa_mainloop_api*a, pa_signal_event*e, void *userdata);
pa_signal_event *previous, *next;
};
static struct pa_mainloop_api *api = NULL;
static pa_mainloop_api *api = NULL;
static int signal_pipe[2] = { -1, -1 };
static struct pa_io_event* io_event = NULL;
static struct pa_defer_event *defer_event = NULL;
static struct pa_signal_event *signals = NULL;
static pa_io_event* io_event = NULL;
static pa_defer_event *defer_event = NULL;
static pa_signal_event *signals = NULL;
#ifdef OS_IS_WIN32
static unsigned int waiting_signals = 0;
@ -78,8 +79,8 @@ static void signal_handler(int sig) {
#endif
}
static void dispatch(struct pa_mainloop_api*a, int sig) {
struct pa_signal_event*s;
static void dispatch(pa_mainloop_api*a, int sig) {
pa_signal_event*s;
for (s = signals; s; s = s->next)
if (s->sig == sig) {
@ -89,7 +90,7 @@ static void dispatch(struct pa_mainloop_api*a, int sig) {
}
}
static void defer(struct pa_mainloop_api*a, struct pa_defer_event*e, void *userdata) {
static void defer(pa_mainloop_api*a, PA_GCC_UNUSED pa_defer_event*e, PA_GCC_UNUSED void *userdata) {
ssize_t r;
int sig;
unsigned int sigs;
@ -118,7 +119,7 @@ static void defer(struct pa_mainloop_api*a, struct pa_defer_event*e, void *userd
}
}
static void callback(struct pa_mainloop_api*a, struct pa_io_event*e, int fd, enum pa_io_event_flags f, void *userdata) {
static void callback(pa_mainloop_api*a, pa_io_event*e, int fd, pa_io_event_flags f, PA_GCC_UNUSED void *userdata) {
ssize_t r;
int sig;
assert(a && e && f == PA_IO_EVENT_INPUT && e == io_event && fd == signal_pipe[0]);
@ -140,7 +141,7 @@ static void callback(struct pa_mainloop_api*a, struct pa_io_event*e, int fd, enu
dispatch(a, sig);
}
int pa_signal_init(struct pa_mainloop_api *a) {
int pa_signal_init(pa_mainloop_api *a) {
assert(!api && a && signal_pipe[0] == -1 && signal_pipe[1] == -1 && !io_event && !defer_event);
#ifdef OS_IS_WIN32
@ -196,22 +197,22 @@ void pa_signal_done(void) {
api = NULL;
}
struct pa_signal_event* pa_signal_new(int sig, void (*callback) (struct pa_mainloop_api *api, struct pa_signal_event*e, int sig, void *userdata), void *userdata) {
struct pa_signal_event *e = NULL;
pa_signal_event* pa_signal_new(int sig, void (*_callback) (pa_mainloop_api *api, pa_signal_event*e, int sig, void *userdata), void *userdata) {
pa_signal_event *e = NULL;
#ifdef HAVE_SIGACTION
struct sigaction sa;
#endif
assert(sig > 0 && callback);
assert(sig > 0 && _callback);
for (e = signals; e; e = e->next)
if (e->sig == sig)
goto fail;
e = pa_xmalloc(sizeof(struct pa_signal_event));
e = pa_xmalloc(sizeof(pa_signal_event));
e->sig = sig;
e->callback = callback;
e->callback = _callback;
e->userdata = userdata;
e->destroy_callback = NULL;
@ -238,7 +239,7 @@ fail:
return NULL;
}
void pa_signal_free(struct pa_signal_event *e) {
void pa_signal_free(pa_signal_event *e) {
assert(e);
if (e->next)
@ -260,7 +261,7 @@ void pa_signal_free(struct pa_signal_event *e) {
pa_xfree(e);
}
void pa_signal_set_destroy(struct pa_signal_event *e, void (*callback) (struct pa_mainloop_api *api, struct pa_signal_event*e, void *userdata)) {
void pa_signal_set_destroy(pa_signal_event *e, void (*_callback) (pa_mainloop_api *api, pa_signal_event*e, void *userdata)) {
assert(e);
e->destroy_callback = callback;
e->destroy_callback = _callback;
}

View file

@ -37,23 +37,23 @@ PA_C_DECL_BEGIN
*/
/** Initialize the UNIX signal subsystem and bind it to the specified main loop */
int pa_signal_init(struct pa_mainloop_api *api);
int pa_signal_init(pa_mainloop_api *api);
/** Cleanup the signal subsystem */
void pa_signal_done(void);
/** \struct pa_signal_event
/** \pa_signal_event
* An opaque UNIX signal event source object */
struct pa_signal_event;
typedef struct pa_signal_event pa_signal_event;
/** Create a new UNIX signal event source object */
struct pa_signal_event* pa_signal_new(int signal, void (*callback) (struct pa_mainloop_api *api, struct pa_signal_event*e, int signal, void *userdata), void *userdata);
pa_signal_event* pa_signal_new(int sig, void (*callback) (pa_mainloop_api *api, pa_signal_event*e, int sig, void *userdata), void *userdata);
/** Free a UNIX signal event source object */
void pa_signal_free(struct pa_signal_event *e);
void pa_signal_free(pa_signal_event *e);
/** Set a function that is called when the signal event source is destroyed. Use this to free the userdata argument if required */
void pa_signal_set_destroy(struct pa_signal_event *e, void (*callback) (struct pa_mainloop_api *api, struct pa_signal_event*e, void *userdata));
void pa_signal_set_destroy(pa_signal_event *e, void (*callback) (pa_mainloop_api *api, pa_signal_event*e, void *userdata));
PA_C_DECL_END

View file

@ -28,10 +28,14 @@
#include <sys/time.h>
#include <assert.h>
#include "util.h"
#include "gccmacro.h"
#ifdef GLIB_MAIN_LOOP
#include <glib.h>
#include "glib-mainloop.h"
static GMainLoop* glib_main_loop = NULL;
#if GLIB_MAJOR_VERSION >= 2
@ -45,21 +49,21 @@ static GMainLoop* glib_main_loop = NULL;
#include "mainloop.h"
#endif /* GLIB_MAIN_LOOP */
static struct pa_defer_event *de;
static pa_defer_event *de;
static void iocb(struct pa_mainloop_api*a, struct pa_io_event *e, int fd, enum pa_io_event_flags f, void *userdata) {
static void iocb(pa_mainloop_api*a, pa_io_event *e, int fd, pa_io_event_flags f, void *userdata) {
unsigned char c;
read(fd, &c, sizeof(c));
fprintf(stderr, "IO EVENT: %c\n", c < 32 ? '.' : c);
a->defer_enable(de, 1);
}
static void dcb(struct pa_mainloop_api*a, struct pa_defer_event *e, void *userdata) {
static void dcb(pa_mainloop_api*a, pa_defer_event *e, void *userdata) {
fprintf(stderr, "DEFER EVENT\n");
a->defer_enable(e, 0);
}
static void tcb(struct pa_mainloop_api*a, struct pa_time_event *e, const struct timeval *tv, void *userdata) {
static void tcb(pa_mainloop_api*a, pa_time_event *e, const struct timeval *tv, void *userdata) {
fprintf(stderr, "TIME EVENT\n");
#if defined(GLIB_MAIN_LOOP) && defined(GLIB20)
@ -71,14 +75,14 @@ static void tcb(struct pa_mainloop_api*a, struct pa_time_event *e, const struct
#endif
}
int main(int argc, char *argv[]) {
struct pa_mainloop_api *a;
struct pa_io_event *ioe;
struct pa_time_event *te;
int main(PA_GCC_UNUSED int argc, PA_GCC_UNUSED char *argv[]) {
pa_mainloop_api *a;
pa_io_event *ioe;
pa_time_event *te;
struct timeval tv;
#ifdef GLIB_MAIN_LOOP
struct pa_glib_mainloop *g;
pa_glib_mainloop *g;
#ifdef GLIB20
glib_main_loop = g_main_loop_new(NULL, FALSE);
@ -96,7 +100,7 @@ int main(int argc, char *argv[]) {
a = pa_glib_mainloop_get_api(g);
assert(a);
#else /* GLIB_MAIN_LOOP */
struct pa_mainloop *m;
pa_mainloop *m;
m = pa_mainloop_new();
assert(m);

View file

@ -47,37 +47,37 @@
#include "log.h"
struct pa_io_event {
struct pa_mainloop *mainloop;
pa_mainloop *mainloop;
int dead;
int fd;
enum pa_io_event_flags events;
void (*callback) (struct pa_mainloop_api*a, struct pa_io_event *e, int fd, enum pa_io_event_flags f, void *userdata);
pa_io_event_flags events;
void (*callback) (pa_mainloop_api*a, pa_io_event *e, int fd, pa_io_event_flags f, void *userdata);
struct pollfd *pollfd;
void *userdata;
void (*destroy_callback) (struct pa_mainloop_api*a, struct pa_io_event *e, void *userdata);
void (*destroy_callback) (pa_mainloop_api*a, pa_io_event *e, void *userdata);
};
struct pa_time_event {
struct pa_mainloop *mainloop;
pa_mainloop *mainloop;
int dead;
int enabled;
struct timeval timeval;
void (*callback)(struct pa_mainloop_api*a, struct pa_time_event *e, const struct timeval*tv, void *userdata);
void (*callback)(pa_mainloop_api*a, pa_time_event *e, const struct timeval*tv, void *userdata);
void *userdata;
void (*destroy_callback) (struct pa_mainloop_api*a, struct pa_time_event *e, void *userdata);
void (*destroy_callback) (pa_mainloop_api*a, pa_time_event *e, void *userdata);
};
struct pa_defer_event {
struct pa_mainloop *mainloop;
pa_mainloop *mainloop;
int dead;
int enabled;
void (*callback)(struct pa_mainloop_api*a, struct pa_defer_event*e, void *userdata);
void (*callback)(pa_mainloop_api*a, pa_defer_event*e, void *userdata);
void *userdata;
void (*destroy_callback) (struct pa_mainloop_api*a, struct pa_defer_event *e, void *userdata);
void (*destroy_callback) (pa_mainloop_api*a, pa_defer_event *e, void *userdata);
};
struct pa_mainloop {
struct pa_idxset *io_events, *time_events, *defer_events;
pa_idxset *io_events, *time_events, *defer_events;
int io_events_scan_dead, defer_events_scan_dead, time_events_scan_dead;
struct pollfd *pollfds;
@ -85,21 +85,21 @@ struct pa_mainloop {
int rebuild_pollfds;
int quit, running, retval;
struct pa_mainloop_api api;
pa_mainloop_api api;
int deferred_pending;
};
/* IO events */
static struct pa_io_event* mainloop_io_new(struct pa_mainloop_api*a, int fd, enum pa_io_event_flags events, void (*callback) (struct pa_mainloop_api*a, struct pa_io_event *e, int fd, enum pa_io_event_flags events, void *userdata), void *userdata) {
struct pa_mainloop *m;
struct pa_io_event *e;
static pa_io_event* mainloop_io_new(pa_mainloop_api*a, int fd, pa_io_event_flags events, void (*callback) (pa_mainloop_api*a, pa_io_event *e, int fd, pa_io_event_flags events, void *userdata), void *userdata) {
pa_mainloop *m;
pa_io_event *e;
assert(a && a->userdata && fd >= 0 && callback);
m = a->userdata;
assert(a == &m->api);
e = pa_xmalloc(sizeof(struct pa_io_event));
e = pa_xmalloc(sizeof(pa_io_event));
e->mainloop = m;
e->dead = 0;
@ -135,7 +135,7 @@ static struct pa_io_event* mainloop_io_new(struct pa_mainloop_api*a, int fd, enu
return e;
}
static void mainloop_io_enable(struct pa_io_event *e, enum pa_io_event_flags events) {
static void mainloop_io_enable(pa_io_event *e, pa_io_event_flags events) {
assert(e && e->mainloop);
e->events = events;
@ -146,26 +146,26 @@ static void mainloop_io_enable(struct pa_io_event *e, enum pa_io_event_flags eve
POLLERR | POLLHUP;
}
static void mainloop_io_free(struct pa_io_event *e) {
static void mainloop_io_free(pa_io_event *e) {
assert(e && e->mainloop);
e->dead = e->mainloop->io_events_scan_dead = e->mainloop->rebuild_pollfds = 1;
}
static void mainloop_io_set_destroy(struct pa_io_event *e, void (*callback)(struct pa_mainloop_api*a, struct pa_io_event *e, void *userdata)) {
static void mainloop_io_set_destroy(pa_io_event *e, void (*callback)(pa_mainloop_api*a, pa_io_event *e, void *userdata)) {
assert(e);
e->destroy_callback = callback;
}
/* Defer events */
static struct pa_defer_event* mainloop_defer_new(struct pa_mainloop_api*a, void (*callback) (struct pa_mainloop_api*a, struct pa_defer_event *e, void *userdata), void *userdata) {
struct pa_mainloop *m;
struct pa_defer_event *e;
static pa_defer_event* mainloop_defer_new(pa_mainloop_api*a, void (*callback) (pa_mainloop_api*a, pa_defer_event *e, void *userdata), void *userdata) {
pa_mainloop *m;
pa_defer_event *e;
assert(a && a->userdata && callback);
m = a->userdata;
assert(a == &m->api);
e = pa_xmalloc(sizeof(struct pa_defer_event));
e = pa_xmalloc(sizeof(pa_defer_event));
e->mainloop = m;
e->dead = 0;
@ -180,7 +180,7 @@ static struct pa_defer_event* mainloop_defer_new(struct pa_mainloop_api*a, void
return e;
}
static void mainloop_defer_enable(struct pa_defer_event *e, int b) {
static void mainloop_defer_enable(pa_defer_event *e, int b) {
assert(e);
if (e->enabled && !b) {
@ -192,7 +192,7 @@ static void mainloop_defer_enable(struct pa_defer_event *e, int b) {
e->enabled = b;
}
static void mainloop_defer_free(struct pa_defer_event *e) {
static void mainloop_defer_free(pa_defer_event *e) {
assert(e);
e->dead = e->mainloop->defer_events_scan_dead = 1;
@ -203,21 +203,21 @@ static void mainloop_defer_free(struct pa_defer_event *e) {
}
}
static void mainloop_defer_set_destroy(struct pa_defer_event *e, void (*callback)(struct pa_mainloop_api*a, struct pa_defer_event *e, void *userdata)) {
static void mainloop_defer_set_destroy(pa_defer_event *e, void (*callback)(pa_mainloop_api*a, pa_defer_event *e, void *userdata)) {
assert(e);
e->destroy_callback = callback;
}
/* Time events */
static struct pa_time_event* mainloop_time_new(struct pa_mainloop_api*a, const struct timeval *tv, void (*callback) (struct pa_mainloop_api*a, struct pa_time_event*e, const struct timeval *tv, void *userdata), void *userdata) {
struct pa_mainloop *m;
struct pa_time_event *e;
static pa_time_event* mainloop_time_new(pa_mainloop_api*a, const struct timeval *tv, void (*callback) (pa_mainloop_api*a, pa_time_event*e, const struct timeval *tv, void *userdata), void *userdata) {
pa_mainloop *m;
pa_time_event *e;
assert(a && a->userdata && callback);
m = a->userdata;
assert(a == &m->api);
e = pa_xmalloc(sizeof(struct pa_time_event));
e = pa_xmalloc(sizeof(pa_time_event));
e->mainloop = m;
e->dead = 0;
@ -234,7 +234,7 @@ static struct pa_time_event* mainloop_time_new(struct pa_mainloop_api*a, const s
return e;
}
static void mainloop_time_restart(struct pa_time_event *e, const struct timeval *tv) {
static void mainloop_time_restart(pa_time_event *e, const struct timeval *tv) {
assert(e);
if (tv) {
@ -244,21 +244,21 @@ static void mainloop_time_restart(struct pa_time_event *e, const struct timeval
e->enabled = 0;
}
static void mainloop_time_free(struct pa_time_event *e) {
static void mainloop_time_free(pa_time_event *e) {
assert(e);
e->dead = e->mainloop->time_events_scan_dead = 1;
}
static void mainloop_time_set_destroy(struct pa_time_event *e, void (*callback)(struct pa_mainloop_api*a, struct pa_time_event *e, void *userdata)) {
static void mainloop_time_set_destroy(pa_time_event *e, void (*callback)(pa_mainloop_api*a, pa_time_event *e, void *userdata)) {
assert(e);
e->destroy_callback = callback;
}
/* quit() */
static void mainloop_quit(struct pa_mainloop_api*a, int retval) {
struct pa_mainloop *m;
static void mainloop_quit(pa_mainloop_api*a, int retval) {
pa_mainloop *m;
assert(a && a->userdata);
m = a->userdata;
assert(a == &m->api);
@ -267,7 +267,7 @@ static void mainloop_quit(struct pa_mainloop_api*a, int retval) {
m->retval = retval;
}
static const struct pa_mainloop_api vtable = {
static const pa_mainloop_api vtable = {
.userdata = NULL,
.io_new= mainloop_io_new,
@ -288,10 +288,10 @@ static const struct pa_mainloop_api vtable = {
.quit = mainloop_quit,
};
struct pa_mainloop *pa_mainloop_new(void) {
struct pa_mainloop *m;
pa_mainloop *pa_mainloop_new(void) {
pa_mainloop *m;
m = pa_xmalloc(sizeof(struct pa_mainloop));
m = pa_xmalloc(sizeof(pa_mainloop));
m->io_events = pa_idxset_new(NULL, NULL);
m->defer_events = pa_idxset_new(NULL, NULL);
@ -314,8 +314,8 @@ struct pa_mainloop *pa_mainloop_new(void) {
return m;
}
static int io_foreach(void *p, uint32_t index, int *del, void*userdata) {
struct pa_io_event *e = p;
static int io_foreach(void *p, uint32_t PA_GCC_UNUSED idx, int *del, void*userdata) {
pa_io_event *e = p;
int *all = userdata;
assert(e && del && all);
@ -329,8 +329,8 @@ static int io_foreach(void *p, uint32_t index, int *del, void*userdata) {
return 0;
}
static int time_foreach(void *p, uint32_t index, int *del, void*userdata) {
struct pa_time_event *e = p;
static int time_foreach(void *p, uint32_t PA_GCC_UNUSED idx, int *del, void*userdata) {
pa_time_event *e = p;
int *all = userdata;
assert(e && del && all);
@ -344,8 +344,8 @@ static int time_foreach(void *p, uint32_t index, int *del, void*userdata) {
return 0;
}
static int defer_foreach(void *p, uint32_t index, int *del, void*userdata) {
struct pa_defer_event *e = p;
static int defer_foreach(void *p, PA_GCC_UNUSED uint32_t idx, int *del, void*userdata) {
pa_defer_event *e = p;
int *all = userdata;
assert(e && del && all);
@ -359,7 +359,7 @@ static int defer_foreach(void *p, uint32_t index, int *del, void*userdata) {
return 0;
}
void pa_mainloop_free(struct pa_mainloop* m) {
void pa_mainloop_free(pa_mainloop* m) {
int all = 1;
assert(m);
@ -375,7 +375,7 @@ void pa_mainloop_free(struct pa_mainloop* m) {
pa_xfree(m);
}
static void scan_dead(struct pa_mainloop *m) {
static void scan_dead(pa_mainloop *m) {
int all = 0;
assert(m);
@ -389,13 +389,13 @@ static void scan_dead(struct pa_mainloop *m) {
m->io_events_scan_dead = m->time_events_scan_dead = m->defer_events_scan_dead = 0;
}
static void rebuild_pollfds(struct pa_mainloop *m) {
struct pa_io_event*e;
static void rebuild_pollfds(pa_mainloop *m) {
pa_io_event*e;
struct pollfd *p;
uint32_t index = PA_IDXSET_INVALID;
uint32_t idx = PA_IDXSET_INVALID;
unsigned l;
l = pa_idxset_ncontents(m->io_events);
l = pa_idxset_size(m->io_events);
if (m->max_pollfds < l) {
m->pollfds = pa_xrealloc(m->pollfds, sizeof(struct pollfd)*l);
m->max_pollfds = l;
@ -403,7 +403,7 @@ static void rebuild_pollfds(struct pa_mainloop *m) {
m->n_pollfds = 0;
p = m->pollfds;
for (e = pa_idxset_first(m->io_events, &index); e; e = pa_idxset_next(m->io_events, &index)) {
for (e = pa_idxset_first(m->io_events, &idx); e; e = pa_idxset_next(m->io_events, &idx)) {
if (e->dead) {
e->pollfd = NULL;
continue;
@ -423,12 +423,12 @@ static void rebuild_pollfds(struct pa_mainloop *m) {
}
}
static int dispatch_pollfds(struct pa_mainloop *m) {
uint32_t index = PA_IDXSET_INVALID;
struct pa_io_event *e;
static int dispatch_pollfds(pa_mainloop *m) {
uint32_t idx = PA_IDXSET_INVALID;
pa_io_event *e;
int r = 0;
for (e = pa_idxset_first(m->io_events, &index); e && !m->quit; e = pa_idxset_next(m->io_events, &index)) {
for (e = pa_idxset_first(m->io_events, &idx); e && !m->quit; e = pa_idxset_next(m->io_events, &idx)) {
if (e->dead || !e->pollfd || !e->pollfd->revents)
continue;
@ -446,15 +446,15 @@ static int dispatch_pollfds(struct pa_mainloop *m) {
return r;
}
static int dispatch_defer(struct pa_mainloop *m) {
uint32_t index;
struct pa_defer_event *e;
static int dispatch_defer(pa_mainloop *m) {
uint32_t idx;
pa_defer_event *e;
int r = 0;
if (!m->deferred_pending)
return 0;
for (e = pa_idxset_first(m->defer_events, &index); e && !m->quit; e = pa_idxset_next(m->defer_events, &index)) {
for (e = pa_idxset_first(m->defer_events, &idx); e && !m->quit; e = pa_idxset_next(m->defer_events, &idx)) {
if (e->dead || !e->enabled)
continue;
@ -466,9 +466,9 @@ static int dispatch_defer(struct pa_mainloop *m) {
return r;
}
static int calc_next_timeout(struct pa_mainloop *m) {
uint32_t index;
struct pa_time_event *e;
static int calc_next_timeout(pa_mainloop *m) {
uint32_t idx;
pa_time_event *e;
struct timeval now;
int t = -1;
int got_time = 0;
@ -476,7 +476,7 @@ static int calc_next_timeout(struct pa_mainloop *m) {
if (pa_idxset_isempty(m->time_events))
return -1;
for (e = pa_idxset_first(m->time_events, &index); e; e = pa_idxset_next(m->time_events, &index)) {
for (e = pa_idxset_first(m->time_events, &idx); e; e = pa_idxset_next(m->time_events, &idx)) {
int tmp;
if (e->dead || !e->enabled)
@ -507,9 +507,9 @@ static int calc_next_timeout(struct pa_mainloop *m) {
return t;
}
static int dispatch_timeout(struct pa_mainloop *m) {
uint32_t index;
struct pa_time_event *e;
static int dispatch_timeout(pa_mainloop *m) {
uint32_t idx;
pa_time_event *e;
struct timeval now;
int got_time = 0;
int r = 0;
@ -518,7 +518,7 @@ static int dispatch_timeout(struct pa_mainloop *m) {
if (pa_idxset_isempty(m->time_events))
return 0;
for (e = pa_idxset_first(m->time_events, &index); e && !m->quit; e = pa_idxset_next(m->time_events, &index)) {
for (e = pa_idxset_first(m->time_events, &idx); e && !m->quit; e = pa_idxset_next(m->time_events, &idx)) {
if (e->dead || !e->enabled)
continue;
@ -542,7 +542,7 @@ static int dispatch_timeout(struct pa_mainloop *m) {
return r;
}
int pa_mainloop_iterate(struct pa_mainloop *m, int block, int *retval) {
int pa_mainloop_iterate(pa_mainloop *m, int block, int *retval) {
int r, t, dispatched = 0;
assert(m && !m->running);
@ -601,7 +601,7 @@ quit:
return -2;
}
int pa_mainloop_run(struct pa_mainloop *m, int *retval) {
int pa_mainloop_run(pa_mainloop *m, int *retval) {
int r;
while ((r = pa_mainloop_iterate(m, 1, retval)) >= 0);
@ -613,31 +613,32 @@ int pa_mainloop_run(struct pa_mainloop *m, int *retval) {
return 0;
}
void pa_mainloop_quit(struct pa_mainloop *m, int r) {
void pa_mainloop_quit(pa_mainloop *m, int r) {
assert(m);
m->quit = r;
}
struct pa_mainloop_api* pa_mainloop_get_api(struct pa_mainloop*m) {
pa_mainloop_api* pa_mainloop_get_api(pa_mainloop*m) {
assert(m);
return &m->api;
}
int pa_mainloop_deferred_pending(struct pa_mainloop *m) {
int pa_mainloop_deferred_pending(pa_mainloop *m) {
assert(m);
return m->deferred_pending > 0;
}
void pa_mainloop_dump(struct pa_mainloop *m) {
#if 0
void pa_mainloop_dump(pa_mainloop *m) {
assert(m);
pa_log(__FILE__": Dumping mainloop sources START\n");
{
uint32_t index = PA_IDXSET_INVALID;
struct pa_io_event *e;
for (e = pa_idxset_first(m->io_events, &index); e; e = pa_idxset_next(m->io_events, &index)) {
uint32_t idx = PA_IDXSET_INVALID;
pa_io_event *e;
for (e = pa_idxset_first(m->io_events, &idx); e; e = pa_idxset_next(m->io_events, &idx)) {
if (e->dead)
continue;
@ -645,9 +646,9 @@ void pa_mainloop_dump(struct pa_mainloop *m) {
}
}
{
uint32_t index = PA_IDXSET_INVALID;
struct pa_defer_event *e;
for (e = pa_idxset_first(m->defer_events, &index); e; e = pa_idxset_next(m->defer_events, &index)) {
uint32_t idx = PA_IDXSET_INVALID;
pa_defer_event *e;
for (e = pa_idxset_first(m->defer_events, &idx); e; e = pa_idxset_next(m->defer_events, &idx)) {
if (e->dead)
continue;
@ -655,9 +656,9 @@ void pa_mainloop_dump(struct pa_mainloop *m) {
}
}
{
uint32_t index = PA_IDXSET_INVALID;
struct pa_time_event *e;
for (e = pa_idxset_first(m->time_events, &index); e; e = pa_idxset_next(m->time_events, &index)) {
uint32_t idx = PA_IDXSET_INVALID;
pa_time_event *e;
for (e = pa_idxset_first(m->time_events, &idx); e; e = pa_idxset_next(m->time_events, &idx)) {
if (e->dead)
continue;
@ -668,3 +669,4 @@ void pa_mainloop_dump(struct pa_mainloop *m) {
pa_log(__FILE__": Dumping mainloop sources STOP\n");
}
#endif

View file

@ -35,32 +35,35 @@ PA_C_DECL_BEGIN
* defined in \ref mainloop-api.h. This implementation is thread safe
* as long as you access the main loop object from a single thread only.*/
/** \struct pa_mainloop
/** \pa_mainloop
* An opaque main loop object
*/
struct pa_mainloop;
typedef struct pa_mainloop pa_mainloop;
/** Allocate a new main loop object */
struct pa_mainloop *pa_mainloop_new(void);
pa_mainloop *pa_mainloop_new(void);
/** Free a main loop object */
void pa_mainloop_free(struct pa_mainloop* m);
void pa_mainloop_free(pa_mainloop* m);
/** Run a single iteration of the main loop. Returns a negative value
on error or exit request. If block is nonzero, block for events if
none are queued. Optionally return the return value as specified with
the main loop's quit() routine in the integer variable retval points
to. On success returns the number of source dispatched in this iteration. */
int pa_mainloop_iterate(struct pa_mainloop *m, int block, int *retval);
int pa_mainloop_iterate(pa_mainloop *m, int block, int *retval);
/** Run unlimited iterations of the main loop object until the main loop's quit() routine is called. */
int pa_mainloop_run(struct pa_mainloop *m, int *retval);
int pa_mainloop_run(pa_mainloop *m, int *retval);
/** Return the abstract main loop abstraction layer vtable for this main loop. This calls pa_mainloop_iterate() iteratively.*/
struct pa_mainloop_api* pa_mainloop_get_api(struct pa_mainloop*m);
pa_mainloop_api* pa_mainloop_get_api(pa_mainloop*m);
/** Return non-zero when there are any deferred events pending. \since 0.5 */
int pa_mainloop_deferred_pending(struct pa_mainloop *m);
int pa_mainloop_deferred_pending(pa_mainloop *m);
/** Shutdown the main loop */
void pa_mainloop_quit(pa_mainloop *m, int r);
PA_C_DECL_END

View file

@ -33,12 +33,13 @@
#include "util.h"
#include "mcalign.h"
#include "gccmacro.h"
/* A simple program for testing pa_mcalign */
int main(int argc, char *argv[]) {
struct pa_mcalign *a = pa_mcalign_new(11, NULL);
struct pa_memchunk c;
int main(PA_GCC_UNUSED int argc, PA_GCC_UNUSED char *argv[]) {
pa_mcalign *a = pa_mcalign_new(11, NULL);
pa_memchunk c;
pa_memchunk_reset(&c);
@ -76,7 +77,7 @@ int main(int argc, char *argv[]) {
}
for (;;) {
struct pa_memchunk t;
pa_memchunk t;
if (pa_mcalign_pop(a, &t) < 0)
break;

View file

@ -33,15 +33,15 @@
struct pa_mcalign {
size_t base;
struct pa_memchunk leftover, current;
struct pa_memblock_stat *memblock_stat;
pa_memchunk leftover, current;
pa_memblock_stat *memblock_stat;
};
struct pa_mcalign *pa_mcalign_new(size_t base, struct pa_memblock_stat *s) {
struct pa_mcalign *m;
pa_mcalign *pa_mcalign_new(size_t base, pa_memblock_stat *s) {
pa_mcalign *m;
assert(base);
m = pa_xmalloc(sizeof(struct pa_mcalign));
m = pa_xnew(pa_mcalign, 1);
m->base = base;
pa_memchunk_reset(&m->leftover);
pa_memchunk_reset(&m->current);
@ -50,7 +50,7 @@ struct pa_mcalign *pa_mcalign_new(size_t base, struct pa_memblock_stat *s) {
return m;
}
void pa_mcalign_free(struct pa_mcalign *m) {
void pa_mcalign_free(pa_mcalign *m) {
assert(m);
if (m->leftover.memblock)
@ -62,7 +62,7 @@ void pa_mcalign_free(struct pa_mcalign *m) {
pa_xfree(m);
}
void pa_mcalign_push(struct pa_mcalign *m, const struct pa_memchunk *c) {
void pa_mcalign_push(pa_mcalign *m, const pa_memchunk *c) {
assert(m && c && c->memblock && c->length);
/* Append to the leftover memory block */
@ -122,7 +122,7 @@ void pa_mcalign_push(struct pa_mcalign *m, const struct pa_memchunk *c) {
}
}
int pa_mcalign_pop(struct pa_mcalign *m, struct pa_memchunk *c) {
int pa_mcalign_pop(pa_mcalign *m, pa_memchunk *c) {
assert(m && c);
/* First test if there's a leftover memory block available */

View file

@ -36,10 +36,10 @@
* 0, the memchunk *c is valid and aligned to the granularity. Some
* pseudocode illustrating this:
*
* struct pa_mcalign *a = pa_mcalign_new(4, NULL);
* pa_mcalign *a = pa_mcalign_new(4, NULL);
*
* for (;;) {
* struct pa_memchunk input;
* pa_memchunk input;
*
* ... fill input ...
*
@ -47,7 +47,7 @@
* pa_memblock_unref(input.memblock);
*
* for (;;) {
* struct pa_memchunk output;
* pa_memchunk output;
*
* if (pa_mcalign_pop(m, &output) < 0)
* break;
@ -61,17 +61,17 @@
* pa_memchunk_free(a);
* */
struct pa_mcalign;
typedef struct pa_mcalign pa_mcalign;
struct pa_mcalign *pa_mcalign_new(size_t base, struct pa_memblock_stat *s);
void pa_mcalign_free(struct pa_mcalign *m);
pa_mcalign *pa_mcalign_new(size_t base, pa_memblock_stat *s);
void pa_mcalign_free(pa_mcalign *m);
/* Push a new memchunk into the aligner. The caller of this routine
* has to free the memchunk by himself. */
void pa_mcalign_push(struct pa_mcalign *m, const struct pa_memchunk *c);
void pa_mcalign_push(pa_mcalign *m, const pa_memchunk *c);
/* Pop a new memchunk from the aligner. Returns 0 when sucessful,
* nonzero otherwise. */
int pa_mcalign_pop(struct pa_mcalign *m, struct pa_memchunk *c);
int pa_mcalign_pop(pa_mcalign *m, pa_memchunk *c);
#endif

View file

@ -31,7 +31,7 @@
#include "memblock.h"
#include "xmalloc.h"
static void stat_add(struct pa_memblock*m, struct pa_memblock_stat *s) {
static void stat_add(pa_memblock*m, pa_memblock_stat *s) {
assert(m);
if (!s) {
@ -46,7 +46,7 @@ static void stat_add(struct pa_memblock*m, struct pa_memblock_stat *s) {
s->allocated_size += m->length;
}
static void stat_remove(struct pa_memblock *m) {
static void stat_remove(pa_memblock *m) {
assert(m);
if (!m->stat)
@ -59,8 +59,8 @@ static void stat_remove(struct pa_memblock *m) {
m->stat = NULL;
}
struct pa_memblock *pa_memblock_new(size_t length, struct pa_memblock_stat*s) {
struct pa_memblock *b = pa_xmalloc(sizeof(struct pa_memblock)+length);
pa_memblock *pa_memblock_new(size_t length, pa_memblock_stat*s) {
pa_memblock *b = pa_xmalloc(sizeof(pa_memblock)+length);
b->type = PA_MEMBLOCK_APPENDED;
b->ref = 1;
b->length = length;
@ -71,8 +71,8 @@ struct pa_memblock *pa_memblock_new(size_t length, struct pa_memblock_stat*s) {
return b;
}
struct pa_memblock *pa_memblock_new_dynamic(void *d, size_t length, struct pa_memblock_stat*s) {
struct pa_memblock *b = pa_xmalloc(sizeof(struct pa_memblock));
pa_memblock *pa_memblock_new_dynamic(void *d, size_t length, pa_memblock_stat*s) {
pa_memblock *b = pa_xmalloc(sizeof(pa_memblock));
b->type = PA_MEMBLOCK_DYNAMIC;
b->ref = 1;
b->length = length;
@ -83,8 +83,8 @@ struct pa_memblock *pa_memblock_new_dynamic(void *d, size_t length, struct pa_me
return b;
}
struct pa_memblock *pa_memblock_new_fixed(void *d, size_t length, int read_only, struct pa_memblock_stat*s) {
struct pa_memblock *b = pa_xmalloc(sizeof(struct pa_memblock));
pa_memblock *pa_memblock_new_fixed(void *d, size_t length, int read_only, pa_memblock_stat*s) {
pa_memblock *b = pa_xmalloc(sizeof(pa_memblock));
b->type = PA_MEMBLOCK_FIXED;
b->ref = 1;
b->length = length;
@ -95,10 +95,10 @@ struct pa_memblock *pa_memblock_new_fixed(void *d, size_t length, int read_only,
return b;
}
struct pa_memblock *pa_memblock_new_user(void *d, size_t length, void (*free_cb)(void *p), int read_only, struct pa_memblock_stat*s) {
struct pa_memblock *b;
pa_memblock *pa_memblock_new_user(void *d, size_t length, void (*free_cb)(void *p), int read_only, pa_memblock_stat*s) {
pa_memblock *b;
assert(d && length && free_cb);
b = pa_xmalloc(sizeof(struct pa_memblock));
b = pa_xmalloc(sizeof(pa_memblock));
b->type = PA_MEMBLOCK_USER;
b->ref = 1;
b->length = length;
@ -109,13 +109,13 @@ struct pa_memblock *pa_memblock_new_user(void *d, size_t length, void (*free_cb)
return b;
}
struct pa_memblock* pa_memblock_ref(struct pa_memblock*b) {
pa_memblock* pa_memblock_ref(pa_memblock*b) {
assert(b && b->ref >= 1);
b->ref++;
return b;
}
void pa_memblock_unref(struct pa_memblock*b) {
void pa_memblock_unref(pa_memblock*b) {
assert(b && b->ref >= 1);
if ((--(b->ref)) == 0) {
@ -131,7 +131,7 @@ void pa_memblock_unref(struct pa_memblock*b) {
}
}
void pa_memblock_unref_fixed(struct pa_memblock *b) {
void pa_memblock_unref_fixed(pa_memblock *b) {
assert(b && b->ref >= 1 && b->type == PA_MEMBLOCK_FIXED);
if (b->ref == 1)
@ -143,17 +143,17 @@ void pa_memblock_unref_fixed(struct pa_memblock *b) {
}
}
struct pa_memblock_stat* pa_memblock_stat_new(void) {
struct pa_memblock_stat *s;
pa_memblock_stat* pa_memblock_stat_new(void) {
pa_memblock_stat *s;
s = pa_xmalloc(sizeof(struct pa_memblock_stat));
s = pa_xmalloc(sizeof(pa_memblock_stat));
s->ref = 1;
s->total = s->total_size = s->allocated = s->allocated_size = 0;
return s;
}
void pa_memblock_stat_unref(struct pa_memblock_stat *s) {
void pa_memblock_stat_unref(pa_memblock_stat *s) {
assert(s && s->ref >= 1);
if (!(--(s->ref))) {
@ -162,7 +162,7 @@ void pa_memblock_stat_unref(struct pa_memblock_stat *s) {
}
}
struct pa_memblock_stat * pa_memblock_stat_ref(struct pa_memblock_stat *s) {
pa_memblock_stat * pa_memblock_stat_ref(pa_memblock_stat *s) {
assert(s);
s->ref++;
return s;

View file

@ -31,58 +31,57 @@
* memory blocks. */
/* The type of memory this block points to */
enum pa_memblock_type {
typedef enum {
PA_MEMBLOCK_FIXED, /* data is a pointer to fixed memory that needs not to be freed */
PA_MEMBLOCK_APPENDED, /* The most common kind: the data is appended to the memory block */
PA_MEMBLOCK_DYNAMIC, /* data is a pointer to some memory allocated with pa_xmalloc() */
PA_MEMBLOCK_USER /* User supplied memory, to be freed with free_cb */
};
} pa_memblock_type ;
/* A structure of keeping memory block statistics */
struct pa_memblock_stat;
struct pa_memblock {
enum pa_memblock_type type;
unsigned ref; /* the reference counter */
int read_only; /* boolean */
size_t length;
void *data;
void (*free_cb)(void *p); /* If type == PA_MEMBLOCK_USER this points to a function for freeing this memory block */
struct pa_memblock_stat *stat;
};
/* Allocate a new memory block of type PA_MEMBLOCK_APPENDED */
struct pa_memblock *pa_memblock_new(size_t length, struct pa_memblock_stat*s);
/* Allocate a new memory block of type PA_MEMBLOCK_DYNAMIC. The pointer data is to be maintained be the memory block */
struct pa_memblock *pa_memblock_new_dynamic(void *data, size_t length, struct pa_memblock_stat*s);
/* Allocate a new memory block of type PA_MEMBLOCK_FIXED */
struct pa_memblock *pa_memblock_new_fixed(void *data, size_t length, int read_only, struct pa_memblock_stat*s);
/* Allocate a new memory block of type PA_MEMBLOCK_USER */
struct pa_memblock *pa_memblock_new_user(void *data, size_t length, void (*free_cb)(void *p), int read_only, struct pa_memblock_stat*s);
void pa_memblock_unref(struct pa_memblock*b);
struct pa_memblock* pa_memblock_ref(struct pa_memblock*b);
/* This special unref function has to be called by the owner of the
memory of a static memory block when he wants to release all
references to the memory. This causes the memory to be copied and
converted into a PA_MEMBLOCK_DYNAMIC type memory block */
void pa_memblock_unref_fixed(struct pa_memblock*b);
/* Matinatins statistics about memory blocks */
struct pa_memblock_stat {
/* Maintains statistics about memory blocks */
typedef struct pa_memblock_stat {
int ref;
unsigned total;
unsigned total_size;
unsigned allocated;
unsigned allocated_size;
};
} pa_memblock_stat;
struct pa_memblock_stat* pa_memblock_stat_new(void);
void pa_memblock_stat_unref(struct pa_memblock_stat *s);
struct pa_memblock_stat * pa_memblock_stat_ref(struct pa_memblock_stat *s);
typedef struct pa_memblock {
pa_memblock_type type;
unsigned ref; /* the reference counter */
int read_only; /* boolean */
size_t length;
void *data;
void (*free_cb)(void *p); /* If type == PA_MEMBLOCK_USER this points to a function for freeing this memory block */
pa_memblock_stat *stat;
} pa_memblock;
/* Allocate a new memory block of type PA_MEMBLOCK_APPENDED */
pa_memblock *pa_memblock_new(size_t length, pa_memblock_stat*s);
/* Allocate a new memory block of type PA_MEMBLOCK_DYNAMIC. The pointer data is to be maintained be the memory block */
pa_memblock *pa_memblock_new_dynamic(void *data, size_t length, pa_memblock_stat*s);
/* Allocate a new memory block of type PA_MEMBLOCK_FIXED */
pa_memblock *pa_memblock_new_fixed(void *data, size_t length, int read_only, pa_memblock_stat*s);
/* Allocate a new memory block of type PA_MEMBLOCK_USER */
pa_memblock *pa_memblock_new_user(void *data, size_t length, void (*free_cb)(void *p), int read_only, pa_memblock_stat*s);
void pa_memblock_unref(pa_memblock*b);
pa_memblock* pa_memblock_ref(pa_memblock*b);
/* This special unref function has to be called by the owner of the
memory of a static memory block when he wants to release all
references to the memory. This causes the memory to be copied and
converted into a PA_MEMBLOCK_DYNAMIC type memory block */
void pa_memblock_unref_fixed(pa_memblock*b);
pa_memblock_stat* pa_memblock_stat_new(void);
void pa_memblock_stat_unref(pa_memblock_stat *s);
pa_memblock_stat * pa_memblock_stat_ref(pa_memblock_stat *s);
#endif

View file

@ -37,22 +37,22 @@
struct memblock_list {
struct memblock_list *next, *prev;
struct pa_memchunk chunk;
pa_memchunk chunk;
};
struct pa_memblockq {
struct memblock_list *blocks, *blocks_tail;
unsigned n_blocks;
size_t current_length, maxlength, tlength, base, prebuf, orig_prebuf, minreq;
struct pa_mcalign *mcalign;
struct pa_memblock_stat *memblock_stat;
pa_mcalign *mcalign;
pa_memblock_stat *memblock_stat;
};
struct pa_memblockq* pa_memblockq_new(size_t maxlength, size_t tlength, size_t base, size_t prebuf, size_t minreq, struct pa_memblock_stat *s) {
struct pa_memblockq* bq;
pa_memblockq* pa_memblockq_new(size_t maxlength, size_t tlength, size_t base, size_t prebuf, size_t minreq, pa_memblock_stat *s) {
pa_memblockq* bq;
assert(maxlength && base && maxlength);
bq = pa_xmalloc(sizeof(struct pa_memblockq));
bq = pa_xmalloc(sizeof(pa_memblockq));
bq->blocks = bq->blocks_tail = 0;
bq->n_blocks = 0;
@ -92,7 +92,7 @@ struct pa_memblockq* pa_memblockq_new(size_t maxlength, size_t tlength, size_t b
return bq;
}
void pa_memblockq_free(struct pa_memblockq* bq) {
void pa_memblockq_free(pa_memblockq* bq) {
assert(bq);
pa_memblockq_flush(bq);
@ -103,7 +103,7 @@ void pa_memblockq_free(struct pa_memblockq* bq) {
pa_xfree(bq);
}
void pa_memblockq_push(struct pa_memblockq* bq, const struct pa_memchunk *chunk, size_t delta) {
void pa_memblockq_push(pa_memblockq* bq, const pa_memchunk *chunk, size_t delta) {
struct memblock_list *q;
assert(bq && chunk && chunk->memblock && chunk->length && (chunk->length % bq->base) == 0);
@ -138,7 +138,7 @@ void pa_memblockq_push(struct pa_memblockq* bq, const struct pa_memchunk *chunk,
pa_memblockq_shorten(bq, bq->maxlength);
}
int pa_memblockq_peek(struct pa_memblockq* bq, struct pa_memchunk *chunk) {
int pa_memblockq_peek(pa_memblockq* bq, pa_memchunk *chunk) {
assert(bq && chunk);
if (!bq->blocks || bq->current_length < bq->prebuf)
@ -152,17 +152,17 @@ int pa_memblockq_peek(struct pa_memblockq* bq, struct pa_memchunk *chunk) {
return 0;
}
void pa_memblockq_drop(struct pa_memblockq *bq, const struct pa_memchunk *chunk, size_t length) {
void pa_memblockq_drop(pa_memblockq *bq, const pa_memchunk *chunk, size_t length) {
assert(bq && chunk && length);
if (!bq->blocks || memcmp(&bq->blocks->chunk, chunk, sizeof(struct pa_memchunk)))
if (!bq->blocks || memcmp(&bq->blocks->chunk, chunk, sizeof(pa_memchunk)))
return;
assert(length <= bq->blocks->chunk.length);
pa_memblockq_skip(bq, length);
}
static void remove_block(struct pa_memblockq *bq, struct memblock_list *q) {
static void remove_block(pa_memblockq *bq, struct memblock_list *q) {
assert(bq && q);
if (q->prev)
@ -185,7 +185,7 @@ static void remove_block(struct pa_memblockq *bq, struct memblock_list *q) {
bq->n_blocks--;
}
void pa_memblockq_skip(struct pa_memblockq *bq, size_t length) {
void pa_memblockq_skip(pa_memblockq *bq, size_t length) {
assert(bq && length && (length % bq->base) == 0);
while (length > 0) {
@ -206,7 +206,7 @@ void pa_memblockq_skip(struct pa_memblockq *bq, size_t length) {
}
}
void pa_memblockq_shorten(struct pa_memblockq *bq, size_t length) {
void pa_memblockq_shorten(pa_memblockq *bq, size_t length) {
size_t l;
assert(bq);
@ -223,29 +223,29 @@ void pa_memblockq_shorten(struct pa_memblockq *bq, size_t length) {
}
void pa_memblockq_empty(struct pa_memblockq *bq) {
void pa_memblockq_empty(pa_memblockq *bq) {
assert(bq);
pa_memblockq_shorten(bq, 0);
}
int pa_memblockq_is_readable(struct pa_memblockq *bq) {
int pa_memblockq_is_readable(pa_memblockq *bq) {
assert(bq);
return bq->current_length && (bq->current_length >= bq->prebuf);
}
int pa_memblockq_is_writable(struct pa_memblockq *bq, size_t length) {
int pa_memblockq_is_writable(pa_memblockq *bq, size_t length) {
assert(bq);
return bq->current_length + length <= bq->tlength;
}
uint32_t pa_memblockq_get_length(struct pa_memblockq *bq) {
uint32_t pa_memblockq_get_length(pa_memblockq *bq) {
assert(bq);
return bq->current_length;
}
uint32_t pa_memblockq_missing(struct pa_memblockq *bq) {
uint32_t pa_memblockq_missing(pa_memblockq *bq) {
size_t l;
assert(bq);
@ -258,8 +258,8 @@ uint32_t pa_memblockq_missing(struct pa_memblockq *bq) {
return (l >= bq->minreq) ? l : 0;
}
void pa_memblockq_push_align(struct pa_memblockq* bq, const struct pa_memchunk *chunk, size_t delta) {
struct pa_memchunk rchunk;
void pa_memblockq_push_align(pa_memblockq* bq, const pa_memchunk *chunk, size_t delta) {
pa_memchunk rchunk;
assert(bq && chunk && bq->base);
if (bq->base == 1) {
@ -281,22 +281,22 @@ void pa_memblockq_push_align(struct pa_memblockq* bq, const struct pa_memchunk *
}
}
uint32_t pa_memblockq_get_minreq(struct pa_memblockq *bq) {
uint32_t pa_memblockq_get_minreq(pa_memblockq *bq) {
assert(bq);
return bq->minreq;
}
void pa_memblockq_prebuf_disable(struct pa_memblockq *bq) {
void pa_memblockq_prebuf_disable(pa_memblockq *bq) {
assert(bq);
bq->prebuf = 0;
}
void pa_memblockq_prebuf_reenable(struct pa_memblockq *bq) {
void pa_memblockq_prebuf_reenable(pa_memblockq *bq) {
assert(bq);
bq->prebuf = bq->orig_prebuf;
}
void pa_memblockq_seek(struct pa_memblockq *bq, size_t length) {
void pa_memblockq_seek(pa_memblockq *bq, size_t length) {
assert(bq);
if (!length)
@ -322,7 +322,7 @@ void pa_memblockq_seek(struct pa_memblockq *bq, size_t length) {
}
}
void pa_memblockq_flush(struct pa_memblockq *bq) {
void pa_memblockq_flush(pa_memblockq *bq) {
struct memblock_list *l;
assert(bq);
@ -337,7 +337,7 @@ void pa_memblockq_flush(struct pa_memblockq *bq) {
bq->current_length = 0;
}
uint32_t pa_memblockq_get_tlength(struct pa_memblockq *bq) {
uint32_t pa_memblockq_get_tlength(pa_memblockq *bq) {
assert(bq);
return bq->tlength;
}

View file

@ -33,7 +33,7 @@
* type doesn't need to copy any data around, it just maintains
* references to reference counted memory blocks. */
struct pa_memblockq;
typedef struct pa_memblockq pa_memblockq;
/* Parameters:
- maxlength: maximum length of queue. If more data is pushed into the queue, data from the front is dropped
@ -42,63 +42,63 @@ struct pa_memblockq;
- prebuf: before passing the first byte out, make sure that enough bytes are in the queue
- minreq: pa_memblockq_missing() will only return values greater than this value
*/
struct pa_memblockq* pa_memblockq_new(size_t maxlength,
pa_memblockq* pa_memblockq_new(size_t maxlength,
size_t tlength,
size_t base,
size_t prebuf,
size_t minreq,
struct pa_memblock_stat *s);
void pa_memblockq_free(struct pa_memblockq*bq);
pa_memblock_stat *s);
void pa_memblockq_free(pa_memblockq*bq);
/* Push a new memory chunk into the queue. Optionally specify a value for future cancellation. */
void pa_memblockq_push(struct pa_memblockq* bq, const struct pa_memchunk *chunk, size_t delta);
void pa_memblockq_push(pa_memblockq* bq, const pa_memchunk *chunk, size_t delta);
/* Same as pa_memblockq_push(), however chunks are filtered through a mcalign object, and thus aligned to multiples of base */
void pa_memblockq_push_align(struct pa_memblockq* bq, const struct pa_memchunk *chunk, size_t delta);
void pa_memblockq_push_align(pa_memblockq* bq, const pa_memchunk *chunk, size_t delta);
/* Return a copy of the next memory chunk in the queue. It is not removed from the queue */
int pa_memblockq_peek(struct pa_memblockq* bq, struct pa_memchunk *chunk);
int pa_memblockq_peek(pa_memblockq* bq, pa_memchunk *chunk);
/* Drop the specified bytes from the queue, only valid aufter pa_memblockq_peek() */
void pa_memblockq_drop(struct pa_memblockq *bq, const struct pa_memchunk *chunk, size_t length);
void pa_memblockq_drop(pa_memblockq *bq, const pa_memchunk *chunk, size_t length);
/* Drop the specified bytes from the queue */
void pa_memblockq_skip(struct pa_memblockq *bq, size_t length);
void pa_memblockq_skip(pa_memblockq *bq, size_t length);
/* Shorten the pa_memblockq to the specified length by dropping data at the end of the queue */
void pa_memblockq_shorten(struct pa_memblockq *bq, size_t length);
void pa_memblockq_shorten(pa_memblockq *bq, size_t length);
/* Empty the pa_memblockq */
void pa_memblockq_empty(struct pa_memblockq *bq);
void pa_memblockq_empty(pa_memblockq *bq);
/* Test if the pa_memblockq is currently readable, that is, more data than base */
int pa_memblockq_is_readable(struct pa_memblockq *bq);
int pa_memblockq_is_readable(pa_memblockq *bq);
/* Test if the pa_memblockq is currently writable for the specified amount of bytes */
int pa_memblockq_is_writable(struct pa_memblockq *bq, size_t length);
int pa_memblockq_is_writable(pa_memblockq *bq, size_t length);
/* Return the length of the queue in bytes */
uint32_t pa_memblockq_get_length(struct pa_memblockq *bq);
uint32_t pa_memblockq_get_length(pa_memblockq *bq);
/* Return how many bytes are missing in queue to the specified fill amount */
uint32_t pa_memblockq_missing(struct pa_memblockq *bq);
uint32_t pa_memblockq_missing(pa_memblockq *bq);
/* Returns the minimal request value */
uint32_t pa_memblockq_get_minreq(struct pa_memblockq *bq);
uint32_t pa_memblockq_get_minreq(pa_memblockq *bq);
/* Force disabling of pre-buf even when the pre-buffer is not yet filled */
void pa_memblockq_prebuf_disable(struct pa_memblockq *bq);
void pa_memblockq_prebuf_disable(pa_memblockq *bq);
/* Reenable pre-buf to the initial level */
void pa_memblockq_prebuf_reenable(struct pa_memblockq *bq);
void pa_memblockq_prebuf_reenable(pa_memblockq *bq);
/* Manipulate the write pointer */
void pa_memblockq_seek(struct pa_memblockq *bq, size_t delta);
void pa_memblockq_seek(pa_memblockq *bq, size_t delta);
/* Flush the queue */
void pa_memblockq_flush(struct pa_memblockq *bq);
void pa_memblockq_flush(pa_memblockq *bq);
/* Get Target length */
uint32_t pa_memblockq_get_tlength(struct pa_memblockq *bq);
uint32_t pa_memblockq_get_tlength(pa_memblockq *bq);
#endif

View file

@ -31,8 +31,8 @@
#include "memchunk.h"
#include "xmalloc.h"
void pa_memchunk_make_writable(struct pa_memchunk *c, struct pa_memblock_stat *s, size_t min) {
struct pa_memblock *n;
void pa_memchunk_make_writable(pa_memchunk *c, pa_memblock_stat *s, size_t min) {
pa_memblock *n;
size_t l;
assert(c && c->memblock && c->memblock->ref >= 1);
@ -50,7 +50,7 @@ void pa_memchunk_make_writable(struct pa_memchunk *c, struct pa_memblock_stat *s
c->index = 0;
}
void pa_memchunk_reset(struct pa_memchunk *c) {
void pa_memchunk_reset(pa_memchunk *c) {
assert(c);
c->memblock = NULL;

View file

@ -24,22 +24,22 @@
#include "memblock.h"
/* A memchunk is a part of a memblock. In contrast to the memblock, a
/* A memchunk describes a part of a memblock. In contrast to the memblock, a
* memchunk is not allocated dynamically or reference counted, instead
* it is usually stored on the stack and copied around */
struct pa_memchunk {
struct pa_memblock *memblock;
typedef struct pa_memchunk {
pa_memblock *memblock;
size_t index, length;
};
} pa_memchunk;
/* Make a memchunk writable, i.e. make sure that the caller may have
* exclusive access to the memblock and it is not read_only. If needed
* the memblock in the structure is replaced by a copy. */
void pa_memchunk_make_writable(struct pa_memchunk *c, struct pa_memblock_stat *s, size_t min);
void pa_memchunk_make_writable(pa_memchunk *c, pa_memblock_stat *s, size_t min);
/* Invalidate a memchunk. This does not free the cotaining memblock,
* but sets all members to zero. */
void pa_memchunk_reset(struct pa_memchunk *c);
void pa_memchunk_reset(pa_memchunk *c);
#endif

View file

@ -38,13 +38,11 @@
#include "xmalloc.h"
#include "util.h"
struct pa_modargs;
struct entry {
char *key, *value;
};
static int add_key_value(struct pa_hashmap *map, char *key, char *value, const char* const valid_keys[]) {
static int add_key_value(pa_hashmap *map, char *key, char *value, const char* const valid_keys[]) {
struct entry *e;
assert(map && key && value);
@ -68,8 +66,8 @@ static int add_key_value(struct pa_hashmap *map, char *key, char *value, const c
return 0;
}
struct pa_modargs *pa_modargs_new(const char *args, const char* const* valid_keys) {
struct pa_hashmap *map = NULL;
pa_modargs *pa_modargs_new(const char *args, const char* const* valid_keys) {
pa_hashmap *map = NULL;
map = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
assert(map);
@ -154,18 +152,18 @@ struct pa_modargs *pa_modargs_new(const char *args, const char* const* valid_key
goto fail;
}
return (struct pa_modargs*) map;
return (pa_modargs*) map;
fail:
if (map)
pa_modargs_free((struct pa_modargs*) map);
pa_modargs_free((pa_modargs*) map);
return NULL;
}
static void free_func(void *p, void*userdata) {
static void free_func(void *p, PA_GCC_UNUSED void*userdata) {
struct entry *e = p;
assert(e);
pa_xfree(e->key);
@ -173,13 +171,13 @@ static void free_func(void *p, void*userdata) {
pa_xfree(e);
}
void pa_modargs_free(struct pa_modargs*ma) {
struct pa_hashmap *map = (struct pa_hashmap*) ma;
void pa_modargs_free(pa_modargs*ma) {
pa_hashmap *map = (pa_hashmap*) ma;
pa_hashmap_free(map, free_func, NULL);
}
const char *pa_modargs_get_value(struct pa_modargs *ma, const char *key, const char *def) {
struct pa_hashmap *map = (struct pa_hashmap*) ma;
const char *pa_modargs_get_value(pa_modargs *ma, const char *key, const char *def) {
pa_hashmap *map = (pa_hashmap*) ma;
struct entry*e;
if (!(e = pa_hashmap_get(map, key)))
@ -188,7 +186,7 @@ const char *pa_modargs_get_value(struct pa_modargs *ma, const char *key, const c
return e->value;
}
int pa_modargs_get_value_u32(struct pa_modargs *ma, const char *key, uint32_t *value) {
int pa_modargs_get_value_u32(pa_modargs *ma, const char *key, uint32_t *value) {
const char *v;
assert(ma && key && value);
@ -201,7 +199,7 @@ int pa_modargs_get_value_u32(struct pa_modargs *ma, const char *key, uint32_t *v
return 0;
}
int pa_modargs_get_value_s32(struct pa_modargs *ma, const char *key, int32_t *value) {
int pa_modargs_get_value_s32(pa_modargs *ma, const char *key, int32_t *value) {
const char *v;
assert(ma && key && value);
@ -214,7 +212,7 @@ int pa_modargs_get_value_s32(struct pa_modargs *ma, const char *key, int32_t *va
return 0;
}
int pa_modargs_get_value_boolean(struct pa_modargs *ma, const char *key, int *value) {
int pa_modargs_get_value_boolean(pa_modargs *ma, const char *key, int *value) {
const char *v;
int r;
assert(ma && key && value);
@ -232,10 +230,10 @@ int pa_modargs_get_value_boolean(struct pa_modargs *ma, const char *key, int *va
return 0;
}
int pa_modargs_get_sample_spec(struct pa_modargs *ma, struct pa_sample_spec *rss) {
int pa_modargs_get_sample_spec(pa_modargs *ma, pa_sample_spec *rss) {
const char *format;
uint32_t channels;
struct pa_sample_spec ss;
pa_sample_spec ss;
assert(ma && rss);
/* DEBUG_TRAP;*/

View file

@ -26,24 +26,24 @@
#include "sample.h"
#include "core.h"
struct pa_modargs;
typedef struct pa_modargs pa_modargs;
/* A generic parser for module arguments */
/* Parse the string args. The NULL-terminated array keys contains all valid arguments. */
struct pa_modargs *pa_modargs_new(const char *args, const char* const keys[]);
void pa_modargs_free(struct pa_modargs*ma);
pa_modargs *pa_modargs_new(const char *args, const char* const keys[]);
void pa_modargs_free(pa_modargs*ma);
/* Return the module argument for the specified name as a string. If
* the argument was not specified, return def instead.*/
const char *pa_modargs_get_value(struct pa_modargs *ma, const char *key, const char *def);
const char *pa_modargs_get_value(pa_modargs *ma, const char *key, const char *def);
/* Return a module argument as unsigned 32bit value in *value */
int pa_modargs_get_value_u32(struct pa_modargs *ma, const char *key, uint32_t *value);
int pa_modargs_get_value_s32(struct pa_modargs *ma, const char *key, int32_t *value);
int pa_modargs_get_value_boolean(struct pa_modargs *ma, const char *key, int *value);
int pa_modargs_get_value_u32(pa_modargs *ma, const char *key, uint32_t *value);
int pa_modargs_get_value_s32(pa_modargs *ma, const char *key, int32_t *value);
int pa_modargs_get_value_boolean(pa_modargs *ma, const char *key, int *value);
/* Return sample spec data from the three arguments "rate", "format" and "channels" */
int pa_modargs_get_sample_spec(struct pa_modargs *ma, struct pa_sample_spec *ss);
int pa_modargs_get_sample_spec(pa_modargs *ma, pa_sample_spec *ss);
#endif

View file

@ -36,12 +36,12 @@
#define PA_SYMBOL_USAGE "pa__get_usage"
#define PA_SYMBOL_VERSION "pa__get_version"
struct pa_modinfo *pa_modinfo_get_by_handle(lt_dlhandle dl) {
struct pa_modinfo *i;
pa_modinfo *pa_modinfo_get_by_handle(lt_dlhandle dl) {
pa_modinfo *i;
const char* (*func)(void);
assert(dl);
i = pa_xmalloc0(sizeof(struct pa_modinfo));
i = pa_xmalloc0(sizeof(pa_modinfo));
if ((func = (const char* (*)(void)) lt_dlsym(dl, PA_SYMBOL_AUTHOR)))
i->author = pa_xstrdup(func());
@ -58,9 +58,9 @@ struct pa_modinfo *pa_modinfo_get_by_handle(lt_dlhandle dl) {
return i;
}
struct pa_modinfo *pa_modinfo_get_by_name(const char *name) {
pa_modinfo *pa_modinfo_get_by_name(const char *name) {
lt_dlhandle dl;
struct pa_modinfo *i;
pa_modinfo *i;
assert(name);
if (!(dl = lt_dlopenext(name))) {
@ -74,7 +74,7 @@ struct pa_modinfo *pa_modinfo_get_by_name(const char *name) {
return i;
}
void pa_modinfo_free(struct pa_modinfo *i) {
void pa_modinfo_free(pa_modinfo *i) {
assert(i);
pa_xfree(i->author);
pa_xfree(i->description);

View file

@ -24,20 +24,20 @@
/* Some functions for reading module meta data from Polypaudio modules */
struct pa_modinfo {
typedef struct pa_modinfo {
char *author;
char *description;
char *usage;
char *version;
};
} pa_modinfo;
/* Read meta data from an libtool handle */
struct pa_modinfo *pa_modinfo_get_by_handle(lt_dlhandle dl);
pa_modinfo *pa_modinfo_get_by_handle(lt_dlhandle dl);
/* Read meta data from a module file */
struct pa_modinfo *pa_modinfo_get_by_name(const char *name);
pa_modinfo *pa_modinfo_get_by_name(const char *name);
/* Free meta data */
void pa_modinfo_free(struct pa_modinfo *i);
void pa_modinfo_free(pa_modinfo *i);
#endif

View file

@ -55,13 +55,13 @@ PA_MODULE_USAGE("sink_name=<name for the sink> device=<ALSA device> format=<samp
struct userdata {
snd_pcm_t *pcm_handle;
struct pa_sink *sink;
struct pa_io_event **io_events;
pa_sink *sink;
pa_io_event **io_events;
unsigned n_io_events;
size_t frame_size, fragment_size;
struct pa_memchunk memchunk, silence;
struct pa_module *module;
pa_memchunk memchunk, silence;
pa_module *module;
};
static const char* const valid_modargs[] = {
@ -80,8 +80,8 @@ static const char* const valid_modargs[] = {
static void update_usage(struct userdata *u) {
pa_module_set_used(u->module,
(u->sink ? pa_idxset_ncontents(u->sink->inputs) : 0) +
(u->sink ? pa_idxset_ncontents(u->sink->monitor_source->outputs) : 0));
(u->sink ? pa_idxset_size(u->sink->inputs) : 0) +
(u->sink ? pa_idxset_size(u->sink->monitor_source->outputs) : 0));
}
static void xrun_recovery(struct userdata *u) {
@ -99,7 +99,7 @@ static void do_write(struct userdata *u) {
update_usage(u);
for (;;) {
struct pa_memchunk *memchunk = NULL;
pa_memchunk *memchunk = NULL;
snd_pcm_sframes_t frames;
if (u->memchunk.memblock)
@ -142,7 +142,7 @@ static void do_write(struct userdata *u) {
}
}
static void io_callback(struct pa_mainloop_api*a, struct pa_io_event *e, int fd, enum pa_io_event_flags f, void *userdata) {
static void io_callback(pa_mainloop_api*a, pa_io_event *e, PA_GCC_UNUSED int fd, PA_GCC_UNUSED pa_io_event_flags f, void *userdata) {
struct userdata *u = userdata;
assert(u && a && e);
@ -152,7 +152,7 @@ static void io_callback(struct pa_mainloop_api*a, struct pa_io_event *e, int fd,
do_write(u);
}
static pa_usec_t sink_get_latency_cb(struct pa_sink *s) {
static pa_usec_t sink_get_latency_cb(pa_sink *s) {
pa_usec_t r = 0;
struct userdata *u = s->userdata;
snd_pcm_sframes_t frames;
@ -175,12 +175,12 @@ static pa_usec_t sink_get_latency_cb(struct pa_sink *s) {
return r;
}
int pa__init(struct pa_core *c, struct pa_module*m) {
struct pa_modargs *ma = NULL;
int pa__init(pa_core *c, pa_module*m) {
pa_modargs *ma = NULL;
int ret = -1;
struct userdata *u = NULL;
const char *dev;
struct pa_sample_spec ss;
pa_sample_spec ss;
uint32_t periods, fragsize;
snd_pcm_uframes_t period_size;
size_t frame_size;
@ -262,7 +262,7 @@ fail:
goto finish;
}
void pa__done(struct pa_core *c, struct pa_module*m) {
void pa__done(pa_core *c, pa_module*m) {
struct userdata *u;
assert(c && m);

View file

@ -55,13 +55,13 @@ PA_MODULE_USAGE("source_name=<name for the source> device=<ALSA device> format=<
struct userdata {
snd_pcm_t *pcm_handle;
struct pa_source *source;
struct pa_io_event **io_events;
pa_source *source;
pa_io_event **io_events;
unsigned n_io_events;
size_t frame_size, fragment_size;
struct pa_memchunk memchunk;
struct pa_module *module;
pa_memchunk memchunk;
pa_module *module;
};
static const char* const valid_modargs[] = {
@ -80,7 +80,7 @@ static const char* const valid_modargs[] = {
static void update_usage(struct userdata *u) {
pa_module_set_used(u->module,
(u->source ? pa_idxset_ncontents(u->source->outputs) : 0));
(u->source ? pa_idxset_size(u->source->outputs) : 0));
}
static void xrun_recovery(struct userdata *u) {
@ -98,7 +98,7 @@ static void do_read(struct userdata *u) {
update_usage(u);
for (;;) {
struct pa_memchunk post_memchunk;
pa_memchunk post_memchunk;
snd_pcm_sframes_t frames;
size_t l;
@ -142,7 +142,7 @@ static void do_read(struct userdata *u) {
}
}
static void io_callback(struct pa_mainloop_api*a, struct pa_io_event *e, int fd, enum pa_io_event_flags f, void *userdata) {
static void io_callback(pa_mainloop_api*a, pa_io_event *e, PA_GCC_UNUSED int fd, PA_GCC_UNUSED pa_io_event_flags f, void *userdata) {
struct userdata *u = userdata;
assert(u && a && e);
@ -152,7 +152,7 @@ static void io_callback(struct pa_mainloop_api*a, struct pa_io_event *e, int fd,
do_read(u);
}
static pa_usec_t source_get_latency_cb(struct pa_source *s) {
static pa_usec_t source_get_latency_cb(pa_source *s) {
struct userdata *u = s->userdata;
snd_pcm_sframes_t frames;
assert(s && u && u->source);
@ -166,12 +166,12 @@ static pa_usec_t source_get_latency_cb(struct pa_source *s) {
return pa_bytes_to_usec(frames * u->frame_size, &s->sample_spec);
}
int pa__init(struct pa_core *c, struct pa_module*m) {
struct pa_modargs *ma = NULL;
int pa__init(pa_core *c, pa_module*m) {
pa_modargs *ma = NULL;
int ret = -1;
struct userdata *u = NULL;
const char *dev;
struct pa_sample_spec ss;
pa_sample_spec ss;
unsigned periods, fragsize;
snd_pcm_uframes_t period_size;
size_t frame_size;
@ -250,7 +250,7 @@ fail:
goto finish;
}
void pa__done(struct pa_core *c, struct pa_module*m) {
void pa__done(pa_core *c, pa_module*m) {
struct userdata *u;
assert(c && m);

View file

@ -39,15 +39,15 @@ PA_MODULE_DESCRIPTION("Command line interface")
PA_MODULE_VERSION(PACKAGE_VERSION)
PA_MODULE_USAGE("No arguments")
static void eof_cb(struct pa_cli*c, void *userdata) {
struct pa_module *m = userdata;
static void eof_cb(pa_cli*c, void *userdata) {
pa_module *m = userdata;
assert(c && m);
pa_module_unload_request(m);
}
int pa__init(struct pa_core *c, struct pa_module*m) {
struct pa_iochannel *io;
int pa__init(pa_core *c, pa_module*m) {
pa_iochannel *io;
assert(c && m);
if (c->running_as_daemon) {
@ -77,7 +77,7 @@ int pa__init(struct pa_core *c, struct pa_module*m) {
return 0;
}
void pa__done(struct pa_core *c, struct pa_module*m) {
void pa__done(pa_core *c, pa_module*m) {
assert(c && m);
if (c->running_as_daemon == 0) {

View file

@ -62,20 +62,20 @@ static const char* const valid_modargs[] = {
struct output {
struct userdata *userdata;
struct pa_sink_input *sink_input;
pa_sink_input *sink_input;
size_t counter;
struct pa_memblockq *memblockq;
pa_memblockq *memblockq;
pa_usec_t total_latency;
PA_LLIST_FIELDS(struct output);
};
struct userdata {
struct pa_module *module;
struct pa_core *core;
struct pa_sink *sink;
pa_module *module;
pa_core *core;
pa_sink *sink;
unsigned n_outputs;
struct output *master;
struct pa_time_event *time_event;
pa_time_event *time_event;
uint32_t adjust_time;
PA_LLIST_HEAD(struct output, outputs);
@ -86,8 +86,8 @@ static void clear_up(struct userdata *u);
static void update_usage(struct userdata *u) {
pa_module_set_used(u->module,
(u->sink ? pa_idxset_ncontents(u->sink->inputs) : 0) +
(u->sink ? pa_idxset_ncontents(u->sink->monitor_source->outputs) : 0));
(u->sink ? pa_idxset_size(u->sink->inputs) : 0) +
(u->sink ? pa_idxset_size(u->sink->monitor_source->outputs) : 0));
}
@ -135,7 +135,7 @@ static void adjust_rates(struct userdata *u) {
}
static void request_memblock(struct userdata *u) {
struct pa_memchunk chunk;
pa_memchunk chunk;
struct output *o;
assert(u && u->sink);
@ -150,7 +150,7 @@ static void request_memblock(struct userdata *u) {
pa_memblock_unref(chunk.memblock);
}
static void time_callback(struct pa_mainloop_api*a, struct pa_time_event* e, const struct timeval *tv, void *userdata) {
static void time_callback(pa_mainloop_api*a, pa_time_event* e, PA_GCC_UNUSED const struct timeval *tv, void *userdata) {
struct userdata *u = userdata;
struct timeval n;
assert(u && a && u->time_event == e);
@ -162,7 +162,7 @@ static void time_callback(struct pa_mainloop_api*a, struct pa_time_event* e, con
u->sink->core->mainloop->time_restart(e, &n);
}
static int sink_input_peek_cb(struct pa_sink_input *i, struct pa_memchunk *chunk) {
static int sink_input_peek_cb(pa_sink_input *i, pa_memchunk *chunk) {
struct output *o = i->userdata;
assert(i && o && o->sink_input && chunk);
@ -175,7 +175,7 @@ static int sink_input_peek_cb(struct pa_sink_input *i, struct pa_memchunk *chunk
return pa_memblockq_peek(o->memblockq, chunk);
}
static void sink_input_drop_cb(struct pa_sink_input *i, const struct pa_memchunk *chunk, size_t length) {
static void sink_input_drop_cb(pa_sink_input *i, const pa_memchunk *chunk, size_t length) {
struct output *o = i->userdata;
assert(i && o && o->sink_input && chunk && length);
@ -183,28 +183,28 @@ static void sink_input_drop_cb(struct pa_sink_input *i, const struct pa_memchunk
o->counter += length;
}
static void sink_input_kill_cb(struct pa_sink_input *i) {
static void sink_input_kill_cb(pa_sink_input *i) {
struct output *o = i->userdata;
assert(i && o && o->sink_input);
pa_module_unload_request(o->userdata->module);
clear_up(o->userdata);
}
static pa_usec_t sink_input_get_latency_cb(struct pa_sink_input *i) {
static pa_usec_t sink_input_get_latency_cb(pa_sink_input *i) {
struct output *o = i->userdata;
assert(i && o && o->sink_input);
return pa_bytes_to_usec(pa_memblockq_get_length(o->memblockq), &i->sample_spec);
}
static pa_usec_t sink_get_latency_cb(struct pa_sink *s) {
static pa_usec_t sink_get_latency_cb(pa_sink *s) {
struct userdata *u = s->userdata;
assert(s && u && u->sink && u->master);
return pa_sink_input_get_latency(u->master->sink_input);
}
static struct output *output_new(struct userdata *u, struct pa_sink *sink, int resample_method) {
static struct output *output_new(struct userdata *u, pa_sink *sink, int resample_method) {
struct output *o = NULL;
char t[256];
assert(u && sink && u->sink);
@ -278,11 +278,11 @@ static void clear_up(struct userdata *u) {
}
}
int pa__init(struct pa_core *c, struct pa_module*m) {
int pa__init(pa_core *c, pa_module*m) {
struct userdata *u;
struct pa_modargs *ma = NULL;
pa_modargs *ma = NULL;
const char *master_name, *slaves, *rm;
struct pa_sink *master_sink;
pa_sink *master_sink;
char *n = NULL;
const char*split_state;
struct timeval tv;
@ -344,7 +344,7 @@ int pa__init(struct pa_core *c, struct pa_module*m) {
split_state = NULL;
while ((n = pa_split(slaves, ",", &split_state))) {
struct pa_sink *slave_sink;
pa_sink *slave_sink;
if (!(slave_sink = pa_namereg_get(c, n, PA_NAMEREG_SINK, 1))) {
pa_log(__FILE__": invalid slave sink '%s'\n", n);
@ -381,7 +381,7 @@ fail:
return -1;
}
void pa__done(struct pa_core *c, struct pa_module*m) {
void pa__done(pa_core *c, pa_module*m) {
struct userdata *u;
assert(c && m);

View file

@ -21,4 +21,9 @@ gen_symbol(pa__get_version)
int pa__init(struct pa_core *c, struct pa_module*m);
void pa__done(struct pa_core *c, struct pa_module*m);
const char* pa__get_author(void);
const char* pa__get_description(void);
const char* pa__get_usage(void);
const char* pa__get_version(void);
#endif

View file

@ -44,8 +44,8 @@ static const char* const valid_modargs[] = {
NULL,
};
int pa__init(struct pa_core *c, struct pa_module*m) {
struct pa_modargs *ma = NULL;
int pa__init(pa_core *c, pa_module*m) {
pa_modargs *ma = NULL;
int ret = -1, fd = -1;
char x = 1;
assert(c && m);
@ -73,7 +73,7 @@ finish:
return ret;
}
void pa__done(struct pa_core *c, struct pa_module*m) {
void pa__done(pa_core *c, pa_module*m) {
assert(c && m);
}

View file

@ -44,8 +44,8 @@ static const char* const valid_modargs[] = {
NULL,
};
int pa__init(struct pa_core *c, struct pa_module*m) {
struct pa_modargs *ma = NULL;
int pa__init(pa_core *c, pa_module*m) {
pa_modargs *ma = NULL;
int ret = -1;
uint32_t pid = 0;
assert(c && m);
@ -71,7 +71,7 @@ finish:
return ret;
}
void pa__done(struct pa_core *c, struct pa_module*m) {
void pa__done(pa_core *c, pa_module*m) {
assert(c && m);
}

View file

@ -55,16 +55,16 @@ PA_MODULE_USAGE("sink_name=<name for the sink> server=<address> cookie=<filename
#define PA_TYPEID_ESOUND_SINK PA_TYPEID_MAKE('E', 'S', 'D', 'S')
struct userdata {
struct pa_core *core;
pa_core *core;
struct pa_sink *sink;
struct pa_iochannel *io;
struct pa_socket_client *client;
pa_sink *sink;
pa_iochannel *io;
pa_socket_client *client;
struct pa_defer_event *defer_event;
pa_defer_event *defer_event;
struct pa_memchunk memchunk;
struct pa_module *module;
pa_memchunk memchunk;
pa_module *module;
void *write_data;
size_t write_length, write_index;
@ -141,7 +141,7 @@ static int do_write(struct userdata *u) {
u->write_index = u->write_length = 0;
}
} else if (u->state == STATE_RUNNING) {
pa_module_set_used(u->module, pa_idxset_ncontents(u->sink->inputs) + pa_idxset_ncontents(u->sink->monitor_source->outputs));
pa_module_set_used(u->module, pa_idxset_size(u->sink->inputs) + pa_idxset_size(u->sink->monitor_source->outputs));
if (!u->memchunk.length)
if (pa_sink_render(u->sink, 8192, &u->memchunk) < 0)
@ -269,7 +269,7 @@ static void do_work(struct userdata *u) {
cancel(u);
}
static void notify_cb(struct pa_sink*s) {
static void notify_cb(pa_sink*s) {
struct userdata *u = s->userdata;
assert(s && u);
@ -277,7 +277,7 @@ static void notify_cb(struct pa_sink*s) {
u->core->mainloop->defer_enable(u->defer_event, 1);
}
static pa_usec_t get_latency_cb(struct pa_sink *s) {
static pa_usec_t get_latency_cb(pa_sink *s) {
struct userdata *u = s->userdata;
assert(s && u);
@ -286,19 +286,19 @@ static pa_usec_t get_latency_cb(struct pa_sink *s) {
(u->memchunk.memblock ? pa_bytes_to_usec(u->memchunk.length, &s->sample_spec) : 0);
}
static void defer_callback(struct pa_mainloop_api *m, struct pa_defer_event*e, void *userdata) {
static void defer_callback(PA_GCC_UNUSED pa_mainloop_api *m, PA_GCC_UNUSED pa_defer_event*e, void *userdata) {
struct userdata *u = userdata;
assert(u);
do_work(u);
}
static void io_callback(struct pa_iochannel *io, void*userdata) {
static void io_callback(PA_GCC_UNUSED pa_iochannel *io, void*userdata) {
struct userdata *u = userdata;
assert(u);
do_work(u);
}
static void on_connection(struct pa_socket_client *c, struct pa_iochannel*io, void *userdata) {
static void on_connection(PA_GCC_UNUSED pa_socket_client *c, pa_iochannel*io, void *userdata) {
struct userdata *u = userdata;
pa_socket_client_unref(u->client);
@ -314,11 +314,11 @@ static void on_connection(struct pa_socket_client *c, struct pa_iochannel*io, vo
pa_iochannel_set_callback(u->io, io_callback, u);
}
int pa__init(struct pa_core *c, struct pa_module*m) {
int pa__init(pa_core *c, pa_module*m) {
struct userdata *u = NULL;
const char *p;
struct pa_sample_spec ss;
struct pa_modargs *ma = NULL;
pa_sample_spec ss;
pa_modargs *ma = NULL;
assert(c && m);
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
@ -402,7 +402,7 @@ fail:
return -1;
}
void pa__done(struct pa_core *c, struct pa_module*m) {
void pa__done(pa_core *c, pa_module*m) {
struct userdata *u;
assert(c && m);

View file

@ -52,16 +52,16 @@ static const char* const valid_modargs[] = {
struct userdata {
int lirc_fd;
struct pa_io_event *io;
pa_io_event *io;
struct lirc_config *config;
char *sink_name;
struct pa_module *module;
pa_module *module;
float mute_toggle_save;
};
static int lirc_in_use = 0;
static void io_callback(struct pa_mainloop_api *io, struct pa_io_event *e, int fd, enum pa_io_event_flags events, void*userdata) {
static void io_callback(pa_mainloop_api *io, PA_GCC_UNUSED pa_io_event *e, PA_GCC_UNUSED int fd, pa_io_event_flags events, void*userdata) {
struct userdata *u = userdata;
char *name = NULL, *code = NULL;
assert(io);
@ -104,7 +104,7 @@ static void io_callback(struct pa_mainloop_api *io, struct pa_io_event *e, int f
if (volchange == INVALID)
pa_log_warn(__FILE__": recieved unknown IR code '%s'\n", name);
else {
struct pa_sink *s;
pa_sink *s;
if (!(s = pa_namereg_get(u->module->core, u->sink_name, PA_NAMEREG_SINK, 1)))
pa_log(__FILE__": failed to get sink '%s'\n", u->sink_name);
@ -147,8 +147,8 @@ fail:
free(code);
}
int pa__init(struct pa_core *c, struct pa_module*m) {
struct pa_modargs *ma = NULL;
int pa__init(pa_core *c, pa_module*m) {
pa_modargs *ma = NULL;
struct userdata *u;
assert(c && m);
@ -197,7 +197,7 @@ fail:
return -1;
}
void pa__done(struct pa_core *c, struct pa_module*m) {
void pa__done(pa_core *c, pa_module*m) {
struct userdata *u;
assert(c);
assert(m);

View file

@ -68,7 +68,7 @@ struct rule {
struct userdata {
struct rule *rules;
struct pa_subscription *subscription;
pa_subscription *subscription;
};
static int load_rules(struct userdata *u, const char *filename) {
@ -154,16 +154,16 @@ finish:
return ret;
}
static void callback(struct pa_core *c, enum pa_subscription_event_type t, uint32_t index, void *userdata) {
static void callback(pa_core *c, pa_subscription_event_type t, uint32_t idx, void *userdata) {
struct userdata *u = userdata;
struct pa_sink_input *si;
pa_sink_input *si;
struct rule *r;
assert(c && u);
if (t != (PA_SUBSCRIPTION_EVENT_SINK_INPUT|PA_SUBSCRIPTION_EVENT_NEW))
return;
if (!(si = pa_idxset_get_by_index(c->sink_inputs, index)))
if (!(si = pa_idxset_get_by_index(c->sink_inputs, idx)))
return;
if (!si->name)
@ -177,8 +177,8 @@ static void callback(struct pa_core *c, enum pa_subscription_event_type t, uint3
}
}
int pa__init(struct pa_core *c, struct pa_module*m) {
struct pa_modargs *ma = NULL;
int pa__init(pa_core *c, pa_module*m) {
pa_modargs *ma = NULL;
struct userdata *u;
assert(c && m);
@ -208,7 +208,7 @@ fail:
return -1;
}
void pa__done(struct pa_core *c, struct pa_module*m) {
void pa__done(pa_core *c, pa_module*m) {
struct userdata* u;
struct rule *r, *n;
assert(c && m);

View file

@ -68,13 +68,13 @@ static const char* const valid_modargs[] = {
struct userdata {
int fd;
struct pa_io_event *io;
pa_io_event *io;
char *sink_name;
struct pa_module *module;
pa_module *module;
float mute_toggle_save;
};
static void io_callback(struct pa_mainloop_api *io, struct pa_io_event *e, int fd, enum pa_io_event_flags events, void*userdata) {
static void io_callback(pa_mainloop_api *io, PA_GCC_UNUSED pa_io_event *e, PA_GCC_UNUSED int fd, pa_io_event_flags events, void*userdata) {
struct userdata *u = userdata;
assert(io);
assert(u);
@ -85,26 +85,26 @@ static void io_callback(struct pa_mainloop_api *io, struct pa_io_event *e, int f
}
if (events & PA_IO_EVENT_INPUT) {
struct input_event e;
struct input_event ev;
if (pa_loop_read(u->fd, &e, sizeof(e)) <= 0) {
if (pa_loop_read(u->fd, &ev, sizeof(ev)) <= 0) {
pa_log(__FILE__": failed to read from event device: %s\n", strerror(errno));
goto fail;
}
if (e.type == EV_KEY && (e.value == 1 || e.value == 2)) {
if (ev.type == EV_KEY && (ev.value == 1 || ev.value == 2)) {
enum { INVALID, UP, DOWN, MUTE_TOGGLE } volchange = INVALID;
pa_log_debug(__FILE__": key code=%u, value=%u\n", e.code, e.value);
pa_log_debug(__FILE__": key code=%u, value=%u\n", ev.code, ev.value);
switch (e.code) {
switch (ev.code) {
case KEY_VOLUMEDOWN: volchange = DOWN; break;
case KEY_VOLUMEUP: volchange = UP; break;
case KEY_MUTE: volchange = MUTE_TOGGLE; break;
}
if (volchange != INVALID) {
struct pa_sink *s;
pa_sink *s;
if (!(s = pa_namereg_get(u->module->core, u->sink_name, PA_NAMEREG_SINK, 1)))
pa_log(__FILE__": failed to get sink '%s'\n", u->sink_name);
@ -143,8 +143,8 @@ fail:
#define test_bit(bit, array) (array[bit/8] & (1<<(bit%8)))
int pa__init(struct pa_core *c, struct pa_module*m) {
struct pa_modargs *ma = NULL;
int pa__init(pa_core *c, pa_module*m) {
pa_modargs *ma = NULL;
struct userdata *u;
int version;
struct _input_id input_id;
@ -217,7 +217,7 @@ fail:
return -1;
}
void pa__done(struct pa_core *c, struct pa_module*m) {
void pa__done(pa_core *c, pa_module*m) {
struct userdata *u;
assert(c);
assert(m);

View file

@ -45,9 +45,9 @@ static const char* const valid_modargs[] = {
NULL,
};
int pa__init(struct pa_core *c, struct pa_module*m) {
struct pa_iochannel *io;
struct pa_modargs *ma;
int pa__init(pa_core *c, pa_module*m) {
pa_iochannel *io;
pa_modargs *ma;
int fd, r = -1;
assert(c && m);
@ -77,7 +77,7 @@ finish:
return r;
}
void pa__done(struct pa_core *c, struct pa_module*m) {
void pa__done(pa_core *c, pa_module*m) {
assert(c && m);
pa_protocol_native_free(m->userdata);

View file

@ -52,10 +52,10 @@ PA_MODULE_USAGE("format=<sample format> channels=<number of channels> rate=<samp
#define PA_TYPEID_NULL PA_TYPEID_MAKE('N', 'U', 'L', 'L')
struct userdata {
struct pa_core *core;
struct pa_module *module;
struct pa_sink *sink;
struct pa_time_event *time_event;
pa_core *core;
pa_module *module;
pa_sink *sink;
pa_time_event *time_event;
size_t block_size;
};
@ -67,9 +67,9 @@ static const char* const valid_modargs[] = {
NULL
};
static void time_callback(struct pa_mainloop_api *m, struct pa_time_event*e, const struct timeval *tv, void *userdata) {
static void time_callback(pa_mainloop_api *m, pa_time_event*e, const struct timeval *tv, void *userdata) {
struct userdata *u = userdata;
struct pa_memchunk chunk;
pa_memchunk chunk;
struct timeval ntv = *tv;
size_t l;
@ -85,10 +85,10 @@ static void time_callback(struct pa_mainloop_api *m, struct pa_time_event*e, con
m->time_restart(e, &ntv);
}
int pa__init(struct pa_core *c, struct pa_module*m) {
int pa__init(pa_core *c, pa_module*m) {
struct userdata *u = NULL;
struct pa_sample_spec ss;
struct pa_modargs *ma = NULL;
pa_sample_spec ss;
pa_modargs *ma = NULL;
struct timeval tv;
assert(c && m);
@ -135,7 +135,7 @@ fail:
return -1;
}
void pa__done(struct pa_core *c, struct pa_module*m) {
void pa__done(pa_core *c, pa_module*m) {
struct userdata *u;
assert(c && m);

View file

@ -56,10 +56,10 @@ PA_MODULE_USAGE("sink_name=<name for the sink> source_name=<name for the source>
#define PA_TYPEID_OSS_MMAP PA_TYPEID_MAKE('O', 'S', 'S', 'M')
struct userdata {
struct pa_sink *sink;
struct pa_source *source;
struct pa_core *core;
struct pa_sample_spec sample_spec;
pa_sink *sink;
pa_source *source;
pa_core *core;
pa_sample_spec sample_spec;
size_t in_fragment_size, out_fragment_size, in_fragments, out_fragments, out_fill;
@ -68,11 +68,11 @@ struct userdata {
void *in_mmap, *out_mmap;
size_t in_mmap_length, out_mmap_length;
struct pa_io_event *io_event;
pa_io_event *io_event;
struct pa_memblock **in_memblocks, **out_memblocks;
pa_memblock **in_memblocks, **out_memblocks;
unsigned out_current, in_current;
struct pa_module *module;
pa_module *module;
};
static const char* const valid_modargs[] = {
@ -95,16 +95,16 @@ static const char* const valid_modargs[] = {
static void update_usage(struct userdata *u) {
pa_module_set_used(u->module,
(u->sink ? pa_idxset_ncontents(u->sink->inputs) : 0) +
(u->sink ? pa_idxset_ncontents(u->sink->monitor_source->outputs) : 0) +
(u->source ? pa_idxset_ncontents(u->source->outputs) : 0));
(u->sink ? pa_idxset_size(u->sink->inputs) : 0) +
(u->sink ? pa_idxset_size(u->sink->monitor_source->outputs) : 0) +
(u->source ? pa_idxset_size(u->source->outputs) : 0));
}
static void out_fill_memblocks(struct userdata *u, unsigned n) {
assert(u && u->out_memblocks);
while (n > 0) {
struct pa_memchunk chunk;
pa_memchunk chunk;
if (u->out_memblocks[u->out_current])
pa_memblock_unref_fixed(u->out_memblocks[u->out_current]);
@ -147,7 +147,7 @@ static void in_post_memblocks(struct userdata *u, unsigned n) {
assert(u && u->in_memblocks);
while (n > 0) {
struct pa_memchunk chunk;
pa_memchunk chunk;
if (!u->in_memblocks[u->in_current]) {
chunk.memblock = u->in_memblocks[u->in_current] = pa_memblock_new_fixed((uint8_t*) u->in_mmap+u->in_fragment_size*u->in_current, u->in_fragment_size, 1, u->core->memblock_stat);
@ -204,7 +204,7 @@ static void do_read(struct userdata *u) {
in_clear_memblocks(u, u->in_fragments/2);
}
static void io_callback(struct pa_mainloop_api *m, struct pa_io_event *e, int fd, enum pa_io_event_flags f, void *userdata) {
static void io_callback(pa_mainloop_api *m, pa_io_event *e, PA_GCC_UNUSED int fd, pa_io_event_flags f, void *userdata) {
struct userdata *u = userdata;
assert (u && u->core->mainloop == m && u->io_event == e);
@ -214,7 +214,7 @@ static void io_callback(struct pa_mainloop_api *m, struct pa_io_event *e, int fd
do_write(u);
}
static pa_usec_t sink_get_latency_cb(struct pa_sink *s) {
static pa_usec_t sink_get_latency_cb(pa_sink *s) {
struct userdata *u = s->userdata;
assert(s && u);
@ -222,7 +222,7 @@ static pa_usec_t sink_get_latency_cb(struct pa_sink *s) {
return pa_bytes_to_usec(u->out_fill, &s->sample_spec);
}
int pa__init(struct pa_core *c, struct pa_module*m) {
int pa__init(pa_core *c, pa_module*m) {
struct audio_buf_info info;
struct userdata *u = NULL;
const char *p;
@ -230,7 +230,7 @@ int pa__init(struct pa_core *c, struct pa_module*m) {
int mode, caps;
int enable_bits = 0, zero = 0;
int playback = 1, record = 1;
struct pa_modargs *ma = NULL;
pa_modargs *ma = NULL;
assert(c && m);
m->userdata = u = pa_xmalloc0(sizeof(struct userdata));
@ -310,7 +310,7 @@ int pa__init(struct pa_core *c, struct pa_module*m) {
pa_source_set_owner(u->source, m);
u->source->description = pa_sprintf_malloc("Open Sound System PCM/mmap() on '%s'", p);
u->in_memblocks = pa_xmalloc0(sizeof(struct pa_memblock *)*u->in_fragments);
u->in_memblocks = pa_xmalloc0(sizeof(pa_memblock *)*u->in_fragments);
enable_bits |= PCM_ENABLE_INPUT;
}
@ -378,7 +378,7 @@ fail:
return -1;
}
void pa__done(struct pa_core *c, struct pa_module*m) {
void pa__done(pa_core *c, pa_module*m) {
struct userdata *u;
assert(c && m);

View file

@ -55,18 +55,18 @@ PA_MODULE_USAGE("sink_name=<name for the sink> source_name=<name for the source>
#define PA_TYPEID_OSS PA_TYPEID_MAKE('O', 'S', 'S', '_')
struct userdata {
struct pa_sink *sink;
struct pa_source *source;
struct pa_iochannel *io;
struct pa_core *core;
pa_sink *sink;
pa_source *source;
pa_iochannel *io;
pa_core *core;
struct pa_memchunk memchunk, silence;
pa_memchunk memchunk, silence;
uint32_t in_fragment_size, out_fragment_size, sample_size;
int use_getospace, use_getispace;
int fd;
struct pa_module *module;
pa_module *module;
};
static const char* const valid_modargs[] = {
@ -89,13 +89,13 @@ static const char* const valid_modargs[] = {
static void update_usage(struct userdata *u) {
pa_module_set_used(u->module,
(u->sink ? pa_idxset_ncontents(u->sink->inputs) : 0) +
(u->sink ? pa_idxset_ncontents(u->sink->monitor_source->outputs) : 0) +
(u->source ? pa_idxset_ncontents(u->source->outputs) : 0));
(u->sink ? pa_idxset_size(u->sink->inputs) : 0) +
(u->sink ? pa_idxset_size(u->sink->monitor_source->outputs) : 0) +
(u->source ? pa_idxset_size(u->source->outputs) : 0));
}
static void do_write(struct userdata *u) {
struct pa_memchunk *memchunk;
pa_memchunk *memchunk;
ssize_t r;
size_t l;
int loop = 0;
@ -155,7 +155,7 @@ static void do_write(struct userdata *u) {
}
static void do_read(struct userdata *u) {
struct pa_memchunk memchunk;
pa_memchunk memchunk;
ssize_t r;
size_t l;
int loop = 0;
@ -202,14 +202,14 @@ static void do_read(struct userdata *u) {
} while (loop && l > 0);
}
static void io_callback(struct pa_iochannel *io, void*userdata) {
static void io_callback(PA_GCC_UNUSED pa_iochannel *io, void*userdata) {
struct userdata *u = userdata;
assert(u);
do_write(u);
do_read(u);
}
static pa_usec_t sink_get_latency_cb(struct pa_sink *s) {
static pa_usec_t sink_get_latency_cb(pa_sink *s) {
pa_usec_t r = 0;
int arg;
struct userdata *u = s->userdata;
@ -229,7 +229,7 @@ static pa_usec_t sink_get_latency_cb(struct pa_sink *s) {
return r;
}
static pa_usec_t source_get_latency_cb(struct pa_source *s) {
static pa_usec_t source_get_latency_cb(pa_source *s) {
struct userdata *u = s->userdata;
audio_buf_info info;
assert(s && u && u->source);
@ -248,7 +248,7 @@ static pa_usec_t source_get_latency_cb(struct pa_source *s) {
return pa_bytes_to_usec(info.bytes, &s->sample_spec);
}
int pa__init(struct pa_core *c, struct pa_module*m) {
int pa__init(pa_core *c, pa_module*m) {
struct audio_buf_info info;
struct userdata *u = NULL;
const char *p;
@ -256,8 +256,8 @@ int pa__init(struct pa_core *c, struct pa_module*m) {
int nfrags, frag_size, in_frag_size, out_frag_size;
int mode;
int record = 1, playback = 1;
struct pa_sample_spec ss;
struct pa_modargs *ma = NULL;
pa_sample_spec ss;
pa_modargs *ma = NULL;
assert(c && m);
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
@ -380,7 +380,7 @@ fail:
return -1;
}
void pa__done(struct pa_core *c, struct pa_module*m) {
void pa__done(pa_core *c, pa_module*m) {
struct userdata *u;
assert(c && m);

View file

@ -53,16 +53,16 @@ PA_MODULE_USAGE("sink_name=<name for the sink> file=<path of the FIFO> format=<s
#define PA_TYPEID_PIPE PA_TYPEID_MAKE('P', 'I', 'P', 'E')
struct userdata {
struct pa_core *core;
pa_core *core;
char *filename;
struct pa_sink *sink;
struct pa_iochannel *io;
struct pa_defer_event *defer_event;
pa_sink *sink;
pa_iochannel *io;
pa_defer_event *defer_event;
struct pa_memchunk memchunk;
struct pa_module *module;
pa_memchunk memchunk;
pa_module *module;
};
static const char* const valid_modargs[] = {
@ -83,7 +83,7 @@ static void do_write(struct userdata *u) {
if (!pa_iochannel_is_writable(u->io))
return;
pa_module_set_used(u->module, pa_idxset_ncontents(u->sink->inputs) + pa_idxset_ncontents(u->sink->monitor_source->outputs));
pa_module_set_used(u->module, pa_idxset_size(u->sink->inputs) + pa_idxset_size(u->sink->monitor_source->outputs));
if (!u->memchunk.length)
if (pa_sink_render(u->sink, PIPE_BUF, &u->memchunk) < 0)
@ -105,7 +105,7 @@ static void do_write(struct userdata *u) {
}
}
static void notify_cb(struct pa_sink*s) {
static void notify_cb(pa_sink*s) {
struct userdata *u = s->userdata;
assert(s && u);
@ -113,32 +113,32 @@ static void notify_cb(struct pa_sink*s) {
u->core->mainloop->defer_enable(u->defer_event, 1);
}
static pa_usec_t get_latency_cb(struct pa_sink *s) {
static pa_usec_t get_latency_cb(pa_sink *s) {
struct userdata *u = s->userdata;
assert(s && u);
return u->memchunk.memblock ? pa_bytes_to_usec(u->memchunk.length, &s->sample_spec) : 0;
}
static void defer_callback(struct pa_mainloop_api *m, struct pa_defer_event*e, void *userdata) {
static void defer_callback(PA_GCC_UNUSED pa_mainloop_api *m, PA_GCC_UNUSED pa_defer_event*e, void *userdata) {
struct userdata *u = userdata;
assert(u);
do_write(u);
}
static void io_callback(struct pa_iochannel *io, void*userdata) {
static void io_callback(PA_GCC_UNUSED pa_iochannel *io, void*userdata) {
struct userdata *u = userdata;
assert(u);
do_write(u);
}
int pa__init(struct pa_core *c, struct pa_module*m) {
int pa__init(pa_core *c, pa_module*m) {
struct userdata *u = NULL;
struct stat st;
const char *p;
int fd = -1;
struct pa_sample_spec ss;
struct pa_modargs *ma = NULL;
pa_sample_spec ss;
pa_modargs *ma = NULL;
assert(c && m);
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
@ -215,7 +215,7 @@ fail:
return -1;
}
void pa__done(struct pa_core *c, struct pa_module*m) {
void pa__done(pa_core *c, pa_module*m) {
struct userdata *u;
assert(c && m);

View file

@ -53,14 +53,14 @@ PA_MODULE_USAGE("source_name=<name for the source> file=<path of the FIFO> forma
#define PA_TYPEID_PIPE PA_TYPEID_MAKE('P', 'I', 'P', 'E')
struct userdata {
struct pa_core *core;
pa_core *core;
char *filename;
struct pa_source *source;
struct pa_iochannel *io;
struct pa_module *module;
struct pa_memchunk chunk;
pa_source *source;
pa_iochannel *io;
pa_module *module;
pa_memchunk chunk;
};
static const char* const valid_modargs[] = {
@ -74,13 +74,13 @@ static const char* const valid_modargs[] = {
static void do_read(struct userdata *u) {
ssize_t r;
struct pa_memchunk chunk;
pa_memchunk chunk;
assert(u);
if (!pa_iochannel_is_readable(u->io))
return;
pa_module_set_used(u->module, pa_idxset_ncontents(u->source->outputs));
pa_module_set_used(u->module, pa_idxset_size(u->source->outputs));
if (!u->chunk.memblock) {
u->chunk.memblock = pa_memblock_new(1024, u->core->memblock_stat);
@ -104,19 +104,19 @@ static void do_read(struct userdata *u) {
}
}
static void io_callback(struct pa_iochannel *io, void*userdata) {
static void io_callback(PA_GCC_UNUSED pa_iochannel *io, void*userdata) {
struct userdata *u = userdata;
assert(u);
do_read(u);
}
int pa__init(struct pa_core *c, struct pa_module*m) {
int pa__init(pa_core *c, pa_module*m) {
struct userdata *u = NULL;
struct stat st;
const char *p;
int fd = -1;
struct pa_sample_spec ss;
struct pa_modargs *ma = NULL;
pa_sample_spec ss;
pa_modargs *ma = NULL;
assert(c && m);
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
@ -189,7 +189,7 @@ fail:
return -1;
}
void pa__done(struct pa_core *c, struct pa_module*m) {
void pa__done(pa_core *c, pa_module*m) {
struct userdata *u;
assert(c && m);

View file

@ -166,8 +166,8 @@ static const char* const valid_modargs[] = {
NULL
};
static struct pa_socket_server *create_socket_server(struct pa_core *c, struct pa_modargs *ma) {
struct pa_socket_server *s;
static pa_socket_server *create_socket_server(pa_core *c, pa_modargs *ma) {
pa_socket_server *s;
#if defined(USE_TCP_SOCKETS) || defined(USE_TCP6_SOCKETS)
int loopback = 1;
uint32_t port = IPV4_PORT;
@ -183,7 +183,7 @@ static struct pa_socket_server *create_socket_server(struct pa_core *c, struct p
}
#ifdef USE_TCP6_SOCKETS
if (!(s = pa_socket_server_new_ipv6(c->mainloop, loopback ? (uint8_t*) &in6addr_loopback : (uint8_t*) &in6addr_any, port)))
if (!(s = pa_socket_server_new_ipv6(c->mainloop, loopback ? (const uint8_t*) &in6addr_loopback : (const uint8_t*) &in6addr_any, port)))
return NULL;
#else
if (!(s = pa_socket_server_new_ipv4(c->mainloop, loopback ? INADDR_LOOPBACK : INADDR_ANY, port, TCPWRAP_SERVICE)))
@ -220,9 +220,9 @@ static struct pa_socket_server *create_socket_server(struct pa_core *c, struct p
return s;
}
int pa__init(struct pa_core *c, struct pa_module*m) {
struct pa_socket_server *s;
struct pa_modargs *ma = NULL;
int pa__init(pa_core *c, pa_module*m) {
pa_socket_server *s;
pa_modargs *ma = NULL;
int ret = -1;
assert(c && m);
@ -248,7 +248,7 @@ finish:
return ret;
}
void pa__done(struct pa_core *c, struct pa_module*m) {
void pa__done(pa_core *c, pa_module*m) {
assert(c && m);
#if defined(USE_PROTOCOL_ESOUND)

View file

@ -43,10 +43,10 @@ PA_MODULE_VERSION(PACKAGE_VERSION)
#define PA_TYPEID_SINE PA_TYPEID_MAKE('S', 'I', 'N', 'E')
struct userdata {
struct pa_core *core;
struct pa_module *module;
struct pa_sink_input *sink_input;
struct pa_memblock *memblock;
pa_core *core;
pa_module *module;
pa_sink_input *sink_input;
pa_memblock *memblock;
size_t peek_index;
};
@ -56,7 +56,7 @@ static const char* const valid_modargs[] = {
NULL,
};
static int sink_input_peek(struct pa_sink_input *i, struct pa_memchunk *chunk) {
static int sink_input_peek(pa_sink_input *i, pa_memchunk *chunk) {
struct userdata *u;
assert(i && chunk && i->userdata);
u = i->userdata;
@ -67,7 +67,7 @@ static int sink_input_peek(struct pa_sink_input *i, struct pa_memchunk *chunk) {
return 0;
}
static void sink_input_drop(struct pa_sink_input *i, const struct pa_memchunk *chunk, size_t length) {
static void sink_input_drop(pa_sink_input *i, const pa_memchunk *chunk, size_t length) {
struct userdata *u;
assert(i && chunk && length && i->userdata);
u = i->userdata;
@ -80,7 +80,7 @@ static void sink_input_drop(struct pa_sink_input *i, const struct pa_memchunk *c
u->peek_index = 0;
}
static void sink_input_kill(struct pa_sink_input *i) {
static void sink_input_kill(pa_sink_input *i) {
struct userdata *u;
assert(i && i->userdata);
u = i->userdata;
@ -101,12 +101,12 @@ static void calc_sine(float *f, size_t l, float freq) {
f[i] = (float) sin((double) i/l*M_PI*2*freq)/2;
}
int pa__init(struct pa_core *c, struct pa_module*m) {
struct pa_modargs *ma = NULL;
int pa__init(pa_core *c, pa_module*m) {
pa_modargs *ma = NULL;
struct userdata *u;
struct pa_sink *sink;
pa_sink *sink;
const char *sink_name;
struct pa_sample_spec ss;
pa_sample_spec ss;
uint32_t frequency;
char t[256];
@ -164,7 +164,7 @@ fail:
return -1;
}
void pa__done(struct pa_core *c, struct pa_module*m) {
void pa__done(pa_core *c, pa_module*m) {
struct userdata *u = m->userdata;
assert(c && m);

View file

@ -58,18 +58,18 @@ PA_MODULE_USAGE("sink_name=<name for the sink> source_name=<name for the source>
#define PA_TYPEID_SOLARIS PA_TYPEID_MAKE('S', 'L', 'R', 'S')
struct userdata {
struct pa_sink *sink;
struct pa_source *source;
struct pa_iochannel *io;
struct pa_core *core;
pa_sink *sink;
pa_source *source;
pa_iochannel *io;
pa_core *core;
struct pa_memchunk memchunk, silence;
pa_memchunk memchunk, silence;
uint32_t sample_size;
unsigned int written_bytes, read_bytes;
int fd;
struct pa_module *module;
pa_module *module;
};
static const char* const valid_modargs[] = {
@ -93,13 +93,13 @@ static const char* const valid_modargs[] = {
static void update_usage(struct userdata *u) {
pa_module_set_used(u->module,
(u->sink ? pa_idxset_ncontents(u->sink->inputs) : 0) +
(u->sink ? pa_idxset_ncontents(u->sink->monitor_source->outputs) : 0) +
(u->source ? pa_idxset_ncontents(u->source->outputs) : 0));
(u->sink ? pa_idxset_size(u->sink->inputs) : 0) +
(u->sink ? pa_idxset_size(u->sink->monitor_source->outputs) : 0) +
(u->source ? pa_idxset_size(u->source->outputs) : 0));
}
static void do_write(struct userdata *u) {
struct pa_memchunk *memchunk;
pa_memchunk *memchunk;
ssize_t r;
assert(u);
@ -140,7 +140,7 @@ static void do_write(struct userdata *u) {
}
static void do_read(struct userdata *u) {
struct pa_memchunk memchunk;
pa_memchunk memchunk;
int err, l;
ssize_t r;
assert(u);
@ -172,14 +172,14 @@ static void do_read(struct userdata *u) {
u->read_bytes += r;
}
static void io_callback(struct pa_iochannel *io, void*userdata) {
static void io_callback(pa_iochannel *io, void*userdata) {
struct userdata *u = userdata;
assert(u);
do_write(u);
do_read(u);
}
static pa_usec_t sink_get_latency_cb(struct pa_sink *s) {
static pa_usec_t sink_get_latency_cb(pa_sink *s) {
pa_usec_t r = 0;
audio_info_t info;
int err;
@ -198,7 +198,7 @@ static pa_usec_t sink_get_latency_cb(struct pa_sink *s) {
return r;
}
static pa_usec_t source_get_latency_cb(struct pa_source *s) {
static pa_usec_t source_get_latency_cb(pa_source *s) {
pa_usec_t r = 0;
struct userdata *u = s->userdata;
audio_info_t info;
@ -214,7 +214,7 @@ static pa_usec_t source_get_latency_cb(struct pa_source *s) {
return r;
}
static int pa_solaris_auto_format(int fd, int mode, struct pa_sample_spec *ss) {
static int pa_solaris_auto_format(int fd, int mode, pa_sample_spec *ss) {
audio_info_t info;
AUDIO_INITINFO(&info);
@ -298,15 +298,15 @@ static int pa_solaris_set_buffer(int fd, int buffer_size) {
return 0;
}
int pa__init(struct pa_core *c, struct pa_module*m) {
int pa__init(pa_core *c, pa_module*m) {
struct userdata *u = NULL;
const char *p;
int fd = -1;
int buffer_size;
int mode;
int record = 1, playback = 1;
struct pa_sample_spec ss;
struct pa_modargs *ma = NULL;
pa_sample_spec ss;
pa_modargs *ma = NULL;
assert(c && m);
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
@ -409,7 +409,7 @@ fail:
return -1;
}
void pa__done(struct pa_core *c, struct pa_module*m) {
void pa__done(pa_core *c, pa_module*m) {
struct userdata *u;
assert(c && m);

View file

@ -90,37 +90,37 @@ static const char* const valid_modargs[] = {
NULL,
};
static void command_stream_killed(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
static void command_stream_killed(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
#ifdef TUNNEL_SINK
static void command_request(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
static void command_request(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
#endif
static const struct pa_pdispatch_command command_table[PA_COMMAND_MAX] = {
static const pa_pdispatch_callback command_table[PA_COMMAND_MAX] = {
#ifdef TUNNEL_SINK
[PA_COMMAND_REQUEST] = { command_request },
[PA_COMMAND_REQUEST] = command_request,
#endif
[PA_COMMAND_PLAYBACK_STREAM_KILLED] = { command_stream_killed },
[PA_COMMAND_RECORD_STREAM_KILLED] = { command_stream_killed },
[PA_COMMAND_PLAYBACK_STREAM_KILLED] = command_stream_killed,
[PA_COMMAND_RECORD_STREAM_KILLED] = command_stream_killed
};
struct userdata {
struct pa_socket_client *client;
struct pa_pstream *pstream;
struct pa_pdispatch *pdispatch;
pa_socket_client *client;
pa_pstream *pstream;
pa_pdispatch *pdispatch;
char *server_name;
#ifdef TUNNEL_SINK
char *sink_name;
struct pa_sink *sink;
pa_sink *sink;
uint32_t requested_bytes;
#else
char *source_name;
struct pa_source *source;
pa_source *source;
#endif
struct pa_module *module;
struct pa_core *core;
pa_module *module;
pa_core *core;
uint8_t auth_cookie[PA_NATIVE_COOKIE_LENGTH];
@ -130,7 +130,7 @@ struct userdata {
pa_usec_t host_latency;
struct pa_time_event *time_event;
pa_time_event *time_event;
int auth_cookie_in_property;
};
@ -180,7 +180,7 @@ static void die(struct userdata *u) {
pa_module_unload_request(u->module);
}
static void command_stream_killed(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
static void command_stream_killed(pa_pdispatch *pd, PA_GCC_UNUSED uint32_t command, PA_GCC_UNUSED uint32_t tag, pa_tagstruct *t, void *userdata) {
struct userdata *u = userdata;
assert(pd && t && u && u->pdispatch == pd);
@ -190,7 +190,7 @@ static void command_stream_killed(struct pa_pdispatch *pd, uint32_t command, uin
#ifdef TUNNEL_SINK
static void send_prebuf_request(struct userdata *u) {
struct pa_tagstruct *t;
pa_tagstruct *t;
t = pa_tagstruct_new(NULL, 0);
pa_tagstruct_putu32(t, PA_COMMAND_PREBUF_PLAYBACK_STREAM);
@ -206,7 +206,7 @@ static void send_bytes(struct userdata *u) {
return;
while (u->requested_bytes > 0) {
struct pa_memchunk chunk;
pa_memchunk chunk;
if (pa_sink_render(u->sink, u->requested_bytes, &chunk) < 0) {
@ -226,7 +226,7 @@ static void send_bytes(struct userdata *u) {
}
}
static void command_request(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
static void command_request(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED uint32_t tag, pa_tagstruct *t, void *userdata) {
struct userdata *u = userdata;
uint32_t bytes, channel;
assert(pd && command == PA_COMMAND_REQUEST && t && u && u->pdispatch == pd);
@ -251,7 +251,7 @@ static void command_request(struct pa_pdispatch *pd, uint32_t command, uint32_t
#endif
static void stream_get_latency_callback(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
static void stream_get_latency_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED uint32_t tag, pa_tagstruct *t, void *userdata) {
struct userdata *u = userdata;
pa_usec_t buffer_usec, sink_usec, source_usec, transport_usec;
int playing;
@ -309,7 +309,7 @@ static void stream_get_latency_callback(struct pa_pdispatch *pd, uint32_t comman
}
static void request_latency(struct userdata *u) {
struct pa_tagstruct *t;
pa_tagstruct *t;
struct timeval now;
uint32_t tag;
assert(u);
@ -331,7 +331,7 @@ static void request_latency(struct userdata *u) {
pa_pdispatch_register_reply(u->pdispatch, tag, DEFAULT_TIMEOUT, stream_get_latency_callback, u);
}
static void create_stream_callback(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
static void create_stream_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED uint32_t tag, pa_tagstruct *t, void *userdata) {
struct userdata *u = userdata;
assert(pd && u && u->pdispatch == pd);
@ -361,9 +361,9 @@ static void create_stream_callback(struct pa_pdispatch *pd, uint32_t command, ui
#endif
}
static void setup_complete_callback(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
static void setup_complete_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
struct userdata *u = userdata;
struct pa_tagstruct *reply;
pa_tagstruct *reply;
char name[256], un[128], hn[128];
assert(pd && u && u->pdispatch == pd);
@ -424,7 +424,7 @@ static void setup_complete_callback(struct pa_pdispatch *pd, uint32_t command, u
pa_pdispatch_register_reply(u->pdispatch, tag, DEFAULT_TIMEOUT, create_stream_callback, u);
}
static void pstream_die_callback(struct pa_pstream *p, void *userdata) {
static void pstream_die_callback(pa_pstream *p, void *userdata) {
struct userdata *u = userdata;
assert(p && u);
@ -433,7 +433,7 @@ static void pstream_die_callback(struct pa_pstream *p, void *userdata) {
}
static void pstream_packet_callback(struct pa_pstream *p, struct pa_packet *packet, void *userdata) {
static void pstream_packet_callback(pa_pstream *p, pa_packet *packet, void *userdata) {
struct userdata *u = userdata;
assert(p && packet && u);
@ -444,7 +444,7 @@ static void pstream_packet_callback(struct pa_pstream *p, struct pa_packet *pack
}
#ifndef TUNNEL_SINK
static void pstream_memblock_callback(struct pa_pstream *p, uint32_t channel, uint32_t delta, const struct pa_memchunk *chunk, void *userdata) {
static void pstream_memblock_callback(pa_pstream *p, uint32_t channel, uint32_t delta, const pa_memchunk *chunk, void *userdata) {
struct userdata *u = userdata;
assert(p && chunk && u);
@ -458,9 +458,9 @@ static void pstream_memblock_callback(struct pa_pstream *p, uint32_t channel, ui
}
#endif
static void on_connection(struct pa_socket_client *sc, struct pa_iochannel *io, void *userdata) {
static void on_connection(pa_socket_client *sc, pa_iochannel *io, void *userdata) {
struct userdata *u = userdata;
struct pa_tagstruct *t;
pa_tagstruct *t;
uint32_t tag;
assert(sc && u && u->client == sc);
@ -492,7 +492,7 @@ static void on_connection(struct pa_socket_client *sc, struct pa_iochannel *io,
}
#ifdef TUNNEL_SINK
static void sink_notify(struct pa_sink*sink) {
static void sink_notify(pa_sink*sink) {
struct userdata *u;
assert(sink && sink->userdata);
u = sink->userdata;
@ -500,7 +500,7 @@ static void sink_notify(struct pa_sink*sink) {
send_bytes(u);
}
static pa_usec_t sink_get_latency(struct pa_sink *sink) {
static pa_usec_t sink_get_latency(pa_sink *sink) {
struct userdata *u;
uint32_t l;
pa_usec_t usec = 0;
@ -519,7 +519,7 @@ static pa_usec_t sink_get_latency(struct pa_sink *sink) {
return usec;
}
#else
static pa_usec_t source_get_latency(struct pa_source *source) {
static pa_usec_t source_get_latency(pa_source *source) {
struct userdata *u;
assert(source && source->userdata);
u = source->userdata;
@ -528,7 +528,7 @@ static pa_usec_t source_get_latency(struct pa_source *source) {
}
#endif
static void timeout_callback(struct pa_mainloop_api *m, struct pa_time_event*e, const struct timeval *tv, void *userdata) {
static void timeout_callback(pa_mainloop_api *m, pa_time_event*e, PA_GCC_UNUSED const struct timeval *tv, void *userdata) {
struct userdata *u = userdata;
struct timeval ntv;
assert(m && e && u);
@ -566,10 +566,10 @@ static int load_key(struct userdata *u, const char*fn) {
return 0;
}
int pa__init(struct pa_core *c, struct pa_module*m) {
struct pa_modargs *ma = NULL;
int pa__init(pa_core *c, pa_module*m) {
pa_modargs *ma = NULL;
struct userdata *u = NULL;
struct pa_sample_spec ss;
pa_sample_spec ss;
struct timeval ntv;
assert(c && m);
@ -665,7 +665,7 @@ fail:
return -1;
}
void pa__done(struct pa_core *c, struct pa_module*m) {
void pa__done(pa_core *c, pa_module*m) {
struct userdata* u;
assert(c && m);

View file

@ -49,11 +49,11 @@ PA_MODULE_USAGE("sink_name=<name for the sink> source_name=<name for the source>
#define DEFAULT_SOURCE_NAME "wave_input"
struct userdata {
struct pa_sink *sink;
struct pa_source *source;
struct pa_core *core;
struct pa_time_event *event;
struct pa_defer_event *defer;
pa_sink *sink;
pa_source *source;
pa_core *core;
pa_time_event *event;
pa_defer_event *defer;
pa_usec_t poll_timeout;
uint32_t fragments, fragment_size;
@ -65,11 +65,11 @@ struct userdata {
int cur_ohdr, cur_ihdr;
unsigned int oremain;
WAVEHDR *ohdrs, *ihdrs;
struct pa_memchunk silence;
pa_memchunk silence;
HWAVEOUT hwo;
HWAVEIN hwi;
struct pa_module *module;
pa_module *module;
CRITICAL_SECTION crit;
};
@ -89,15 +89,15 @@ static const char* const valid_modargs[] = {
static void update_usage(struct userdata *u) {
pa_module_set_used(u->module,
(u->sink ? pa_idxset_ncontents(u->sink->inputs) : 0) +
(u->sink ? pa_idxset_ncontents(u->sink->monitor_source->outputs) : 0) +
(u->source ? pa_idxset_ncontents(u->source->outputs) : 0));
(u->sink ? pa_idxset_size(u->sink->inputs) : 0) +
(u->sink ? pa_idxset_size(u->sink->monitor_source->outputs) : 0) +
(u->source ? pa_idxset_size(u->source->outputs) : 0));
}
static void do_write(struct userdata *u)
{
uint32_t free_frags, remain;
struct pa_memchunk memchunk, *cur_chunk;
pa_memchunk memchunk, *cur_chunk;
WAVEHDR *hdr;
MMRESULT res;
@ -178,7 +178,7 @@ static void do_write(struct userdata *u)
static void do_read(struct userdata *u)
{
uint32_t free_frags;
struct pa_memchunk memchunk;
pa_memchunk memchunk;
WAVEHDR *hdr;
MMRESULT res;
@ -227,7 +227,7 @@ static void do_read(struct userdata *u)
}
}
static void poll_cb(struct pa_mainloop_api*a, struct pa_time_event *e, const struct timeval *tv, void *userdata) {
static void poll_cb(pa_mainloop_api*a, pa_time_event *e, const struct timeval *tv, void *userdata) {
struct userdata *u = userdata;
struct timeval ntv;
@ -244,7 +244,7 @@ static void poll_cb(struct pa_mainloop_api*a, struct pa_time_event *e, const str
a->time_restart(e, &ntv);
}
static void defer_cb(struct pa_mainloop_api*a, struct pa_defer_event *e, void *userdata) {
static void defer_cb(pa_mainloop_api*a, pa_defer_event *e, void *userdata) {
struct userdata *u = userdata;
assert(u);
@ -283,7 +283,7 @@ static void CALLBACK chunk_ready_cb(HWAVEIN hwi, UINT msg, DWORD_PTR inst, DWORD
LeaveCriticalSection(&u->crit);
}
static pa_usec_t sink_get_latency_cb(struct pa_sink *s) {
static pa_usec_t sink_get_latency_cb(pa_sink *s) {
struct userdata *u = s->userdata;
uint32_t free_frags;
MMTIME mmt;
@ -305,7 +305,7 @@ static pa_usec_t sink_get_latency_cb(struct pa_sink *s) {
}
}
static pa_usec_t source_get_latency_cb(struct pa_source *s) {
static pa_usec_t source_get_latency_cb(pa_source *s) {
pa_usec_t r = 0;
struct userdata *u = s->userdata;
uint32_t free_frags;
@ -324,21 +324,21 @@ static pa_usec_t source_get_latency_cb(struct pa_source *s) {
return r;
}
static void notify_sink_cb(struct pa_sink *s) {
static void notify_sink_cb(pa_sink *s) {
struct userdata *u = s->userdata;
assert(u);
u->core->mainloop->defer_enable(u->defer, 1);
}
static void notify_source_cb(struct pa_source *s) {
static void notify_source_cb(pa_source *s) {
struct userdata *u = s->userdata;
assert(u);
u->core->mainloop->defer_enable(u->defer, 1);
}
static int ss_to_waveformat(struct pa_sample_spec *ss, LPWAVEFORMATEX wf) {
static int ss_to_waveformat(pa_sample_spec *ss, LPWAVEFORMATEX wf) {
wf->wFormatTag = WAVE_FORMAT_PCM;
if (ss->channels > 2) {
@ -378,15 +378,15 @@ static int ss_to_waveformat(struct pa_sample_spec *ss, LPWAVEFORMATEX wf) {
return 0;
}
int pa__init(struct pa_core *c, struct pa_module*m) {
int pa__init(pa_core *c, pa_module*m) {
struct userdata *u = NULL;
HWAVEOUT hwo = INVALID_HANDLE_VALUE;
HWAVEIN hwi = INVALID_HANDLE_VALUE;
WAVEFORMATEX wf;
int nfrags, frag_size;
int record = 1, playback = 1;
struct pa_sample_spec ss;
struct pa_modargs *ma = NULL;
pa_sample_spec ss;
pa_modargs *ma = NULL;
unsigned int i;
struct timeval tv;
@ -534,7 +534,7 @@ fail:
return -1;
}
void pa__done(struct pa_core *c, struct pa_module*m) {
void pa__done(pa_core *c, pa_module*m) {
struct userdata *u;
unsigned int i;

View file

@ -47,14 +47,14 @@ PA_MODULE_VERSION(PACKAGE_VERSION)
PA_MODULE_USAGE("sink=<sink to connect to> sample=<sample name> display=<X11 display>")
struct userdata {
struct pa_core *core;
pa_core *core;
int xkb_event_base;
char *sink_name;
char *scache_item;
Display *display;
struct pa_x11_wrapper *x11_wrapper;
struct pa_x11_client *x11_client;
pa_x11_wrapper *x11_wrapper;
pa_x11_client *x11_client;
};
static const char* const valid_modargs[] = {
@ -65,7 +65,7 @@ static const char* const valid_modargs[] = {
};
static int ring_bell(struct userdata *u, int percent) {
struct pa_sink *s;
pa_sink *s;
assert(u);
if (!(s = pa_namereg_get(u->core, u->sink_name, PA_NAMEREG_SINK, 1))) {
@ -77,7 +77,7 @@ static int ring_bell(struct userdata *u, int percent) {
return 0;
}
static int x11_event_callback(struct pa_x11_wrapper *w, XEvent *e, void *userdata) {
static int x11_event_callback(pa_x11_wrapper *w, XEvent *e, void *userdata) {
XkbBellNotifyEvent *bne;
struct userdata *u = userdata;
assert(w && e && u && u->x11_wrapper == w);
@ -95,9 +95,9 @@ static int x11_event_callback(struct pa_x11_wrapper *w, XEvent *e, void *userdat
return 1;
}
int pa__init(struct pa_core *c, struct pa_module*m) {
int pa__init(pa_core *c, pa_module*m) {
struct userdata *u = NULL;
struct pa_modargs *ma = NULL;
pa_modargs *ma = NULL;
int major, minor;
unsigned int auto_ctrls, auto_values;
assert(c && m);
@ -154,7 +154,7 @@ fail:
return -1;
}
void pa__done(struct pa_core *c, struct pa_module*m) {
void pa__done(pa_core *c, pa_module*m) {
struct userdata *u = m->userdata;
assert(c && m && u);

View file

@ -63,8 +63,8 @@ static const char* const valid_modargs[] = {
};
struct userdata {
struct pa_core *core;
struct pa_x11_wrapper *x11_wrapper;
pa_core *core;
pa_x11_wrapper *x11_wrapper;
Display *display;
char *id;
uint8_t auth_cookie[PA_NATIVE_COOKIE_LENGTH];
@ -97,14 +97,14 @@ static int load_key(struct userdata *u, const char*fn) {
return 0;
}
int pa__init(struct pa_core *c, struct pa_module*m) {
int pa__init(pa_core *c, pa_module*m) {
struct userdata *u;
struct pa_modargs *ma = NULL;
pa_modargs *ma = NULL;
char hn[256], un[128];
char hx[PA_NATIVE_COOKIE_LENGTH*2+1];
const char *t;
char *s;
struct pa_strlist *l;
pa_strlist *l;
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
pa_log(__FILE__": failed to parse module arguments\n");
@ -156,7 +156,7 @@ fail:
return -1;
}
void pa__done(struct pa_core *c, struct pa_module*m) {
void pa__done(pa_core *c, pa_module*m) {
struct userdata*u;
assert(c && m);

View file

@ -64,23 +64,23 @@ struct service {
struct {
int valid;
enum pa_namereg_type type;
pa_namereg_type type;
uint32_t index;
} loaded;
struct {
int valid;
enum pa_namereg_type type;
pa_namereg_type type;
uint32_t index;
} autoload;
};
struct userdata {
struct pa_core *core;
struct pa_howl_wrapper *howl_wrapper;
struct pa_hashmap *services;
struct pa_dynarray *sink_dynarray, *source_dynarray, *autoload_dynarray;
struct pa_subscription *subscription;
pa_core *core;
pa_howl_wrapper *howl_wrapper;
pa_hashmap *services;
pa_dynarray *sink_dynarray, *source_dynarray, *autoload_dynarray;
pa_subscription *subscription;
uint16_t port;
sw_discovery_oid server_oid;
@ -90,17 +90,17 @@ static sw_result publish_reply(sw_discovery discovery, sw_discovery_publish_stat
return SW_OKAY;
}
static void get_service_data(struct userdata *u, struct service *s, struct pa_sample_spec *ret_ss, char **ret_description, pa_typeid_t *ret_typeid) {
static void get_service_data(struct userdata *u, struct service *s, pa_sample_spec *ret_ss, char **ret_description, pa_typeid_t *ret_typeid) {
assert(u && s && s->loaded.valid && ret_ss && ret_description && ret_typeid);
if (s->loaded.type == PA_NAMEREG_SINK) {
struct pa_sink *sink = pa_idxset_get_by_index(u->core->sinks, s->loaded.index);
pa_sink *sink = pa_idxset_get_by_index(u->core->sinks, s->loaded.index);
assert(sink);
*ret_ss = sink->sample_spec;
*ret_description = sink->description;
*ret_typeid = sink->typeid;
} else if (s->loaded.type == PA_NAMEREG_SOURCE) {
struct pa_source *source = pa_idxset_get_by_index(u->core->sources, s->loaded.index);
pa_source *source = pa_idxset_get_by_index(u->core->sources, s->loaded.index);
assert(source);
*ret_ss = source->sample_spec;
*ret_description = source->description;
@ -109,7 +109,7 @@ static void get_service_data(struct userdata *u, struct service *s, struct pa_sa
assert(0);
}
static void txt_record_server_data(struct pa_core *c, sw_text_record t) {
static void txt_record_server_data(pa_core *c, sw_text_record t) {
char s[256];
assert(c);
@ -152,7 +152,7 @@ static int publish_service(struct userdata *u, struct service *s) {
if (s->loaded.valid) {
char z[64], *description;
pa_typeid_t typeid;
struct pa_sample_spec ss;
pa_sample_spec ss;
get_service_data(u, s, &ss, &description, &typeid);
@ -223,7 +223,7 @@ struct service *get_service(struct userdata *u, const char *name) {
return s;
}
static int publish_sink(struct userdata *u, struct pa_sink *s) {
static int publish_sink(struct userdata *u, pa_sink *s) {
struct service *svc;
assert(u && s);
@ -240,7 +240,7 @@ static int publish_sink(struct userdata *u, struct pa_sink *s) {
return publish_service(u, svc);
}
static int publish_source(struct userdata *u, struct pa_source *s) {
static int publish_source(struct userdata *u, pa_source *s) {
struct service *svc;
assert(u && s);
@ -257,7 +257,7 @@ static int publish_source(struct userdata *u, struct pa_source *s) {
return publish_service(u, svc);
}
static int publish_autoload(struct userdata *u, struct pa_autoload_entry *s) {
static int publish_autoload(struct userdata *u, pa_autoload_entry *s) {
struct service *svc;
assert(u && s);
@ -322,14 +322,14 @@ static int remove_autoload(struct userdata *u, uint32_t index) {
return publish_service(u, svc);
}
static void subscribe_callback(struct pa_core *c, enum pa_subscription_event_type t, uint32_t index, void *userdata) {
static void subscribe_callback(pa_core *c, pa_subscription_event_type t, uint32_t index, void *userdata) {
struct userdata *u = userdata;
assert(u && c);
switch (t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK)
case PA_SUBSCRIPTION_EVENT_SINK: {
if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_NEW) {
struct pa_sink *sink;
pa_sink *sink;
if ((sink = pa_idxset_get_by_index(c->sinks, index))) {
if (publish_sink(u, sink) < 0)
@ -345,7 +345,7 @@ static void subscribe_callback(struct pa_core *c, enum pa_subscription_event_typ
case PA_SUBSCRIPTION_EVENT_SOURCE:
if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_NEW) {
struct pa_source *source;
pa_source *source;
if ((source = pa_idxset_get_by_index(c->sources, index))) {
if (publish_source(u, source) < 0)
@ -360,7 +360,7 @@ static void subscribe_callback(struct pa_core *c, enum pa_subscription_event_typ
case PA_SUBSCRIPTION_EVENT_AUTOLOAD:
if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_NEW) {
struct pa_autoload_entry *autoload;
pa_autoload_entry *autoload;
if ((autoload = pa_idxset_get_by_index(c->autoload_idxset, index))) {
if (publish_autoload(u, autoload) < 0)
@ -383,13 +383,13 @@ fail:
}
}
int pa__init(struct pa_core *c, struct pa_module*m) {
int pa__init(pa_core *c, pa_module*m) {
struct userdata *u;
uint32_t index, port = PA_NATIVE_DEFAULT_PORT;
struct pa_sink *sink;
struct pa_source *source;
struct pa_autoload_entry *autoload;
struct pa_modargs *ma = NULL;
pa_sink *sink;
pa_source *source;
pa_autoload_entry *autoload;
pa_modargs *ma = NULL;
char t[256], hn[256];
int free_txt = 0;
sw_text_record txt;
@ -478,7 +478,7 @@ static void service_free(void *p, void *userdata) {
pa_xfree(s);
}
void pa__done(struct pa_core *c, struct pa_module*m) {
void pa__done(pa_core *c, pa_module*m) {
struct userdata*u;
assert(c && m);

View file

@ -34,14 +34,15 @@
#include "xmalloc.h"
#include "subscribe.h"
#include "log.h"
#include "util.h"
#define PA_SYMBOL_INIT "pa__init"
#define PA_SYMBOL_DONE "pa__done"
#define UNLOAD_POLL_TIME 2
static void timeout_callback(struct pa_mainloop_api *m, struct pa_time_event*e, const struct timeval *tv, void *userdata) {
struct pa_core *c = userdata;
static void timeout_callback(pa_mainloop_api *m, pa_time_event*e, PA_GCC_UNUSED const struct timeval *tv, void *userdata) {
pa_core *c = userdata;
struct timeval ntv;
assert(c && c->mainloop == m && c->module_auto_unload_event == e);
@ -52,8 +53,8 @@ static void timeout_callback(struct pa_mainloop_api *m, struct pa_time_event*e,
m->time_restart(e, &ntv);
}
struct pa_module* pa_module_load(struct pa_core *c, const char *name, const char *argument) {
struct pa_module *m = NULL;
pa_module* pa_module_load(pa_core *c, const char *name, const char *argument) {
pa_module *m = NULL;
int r;
assert(c && name);
@ -61,7 +62,7 @@ struct pa_module* pa_module_load(struct pa_core *c, const char *name, const char
if (c->disallow_module_loading)
goto fail;
m = pa_xmalloc(sizeof(struct pa_module));
m = pa_xmalloc(sizeof(pa_module));
m->name = pa_xstrdup(name);
m->argument = pa_xstrdup(argument);
@ -71,12 +72,12 @@ struct pa_module* pa_module_load(struct pa_core *c, const char *name, const char
goto fail;
}
if (!(m->init = (int (*)(struct pa_core *c, struct pa_module*m)) lt_dlsym(m->dl, PA_SYMBOL_INIT))) {
if (!(m->init = (int (*)(pa_core *_c, pa_module*_m)) lt_dlsym(m->dl, PA_SYMBOL_INIT))) {
pa_log(__FILE__": Failed to load module \"%s\": symbol \""PA_SYMBOL_INIT"\" not found.\n", name);
goto fail;
}
if (!(m->done = (void (*)(struct pa_core *c, struct pa_module*m)) lt_dlsym(m->dl, PA_SYMBOL_DONE))) {
if (!(m->done = (void (*)(pa_core *_c, pa_module*_m)) lt_dlsym(m->dl, PA_SYMBOL_DONE))) {
pa_log(__FILE__": Failed to load module \"%s\": symbol \""PA_SYMBOL_DONE"\" not found.\n", name);
goto fail;
}
@ -129,7 +130,7 @@ fail:
return NULL;
}
static void pa_module_free(struct pa_module *m) {
static void pa_module_free(pa_module *m) {
assert(m && m->done && m->core);
if (m->core->disallow_module_loading)
@ -150,7 +151,7 @@ static void pa_module_free(struct pa_module *m) {
pa_xfree(m);
}
void pa_module_unload(struct pa_core *c, struct pa_module *m) {
void pa_module_unload(pa_core *c, pa_module *m) {
assert(c && m);
assert(c->modules);
@ -160,24 +161,24 @@ void pa_module_unload(struct pa_core *c, struct pa_module *m) {
pa_module_free(m);
}
void pa_module_unload_by_index(struct pa_core *c, uint32_t index) {
struct pa_module *m;
assert(c && index != PA_IDXSET_INVALID);
void pa_module_unload_by_index(pa_core *c, uint32_t idx) {
pa_module *m;
assert(c && idx != PA_IDXSET_INVALID);
assert(c->modules);
if (!(m = pa_idxset_remove_by_index(c->modules, index)))
if (!(m = pa_idxset_remove_by_index(c->modules, idx)))
return;
pa_module_free(m);
}
static void free_callback(void *p, void *userdata) {
struct pa_module *m = p;
static void free_callback(void *p, PA_GCC_UNUSED void *userdata) {
pa_module *m = p;
assert(m);
pa_module_free(m);
}
void pa_module_unload_all(struct pa_core *c) {
void pa_module_unload_all(pa_core *c) {
assert(c);
if (!c->modules)
@ -197,8 +198,8 @@ void pa_module_unload_all(struct pa_core *c) {
}
}
static int unused_callback(void *p, uint32_t index, int *del, void *userdata) {
struct pa_module *m = p;
static int unused_callback(void *p, PA_GCC_UNUSED uint32_t idx, int *del, void *userdata) {
pa_module *m = p;
time_t *now = userdata;
assert(p && del && now);
@ -210,7 +211,7 @@ static int unused_callback(void *p, uint32_t index, int *del, void *userdata) {
return 0;
}
void pa_module_unload_unused(struct pa_core *c) {
void pa_module_unload_unused(pa_core *c) {
time_t now;
assert(c);
@ -221,8 +222,8 @@ void pa_module_unload_unused(struct pa_core *c) {
pa_idxset_foreach(c->modules, unused_callback, &now);
}
static int unload_callback(void *p, uint32_t index, int *del, void *userdata) {
struct pa_module *m = p;
static int unload_callback(void *p, PA_GCC_UNUSED uint32_t idx, int *del, PA_GCC_UNUSED void *userdata) {
pa_module *m = p;
assert(m);
if (m->unload_requested) {
@ -233,8 +234,8 @@ static int unload_callback(void *p, uint32_t index, int *del, void *userdata) {
return 0;
}
static void defer_cb(struct pa_mainloop_api*api, struct pa_defer_event *e, void *userdata) {
struct pa_core *core = userdata;
static void defer_cb(pa_mainloop_api*api, pa_defer_event *e, void *userdata) {
pa_core *core = userdata;
api->defer_enable(e, 0);
if (!core->modules)
@ -244,7 +245,7 @@ static void defer_cb(struct pa_mainloop_api*api, struct pa_defer_event *e, void
}
void pa_module_unload_request(struct pa_module *m) {
void pa_module_unload_request(pa_module *m) {
assert(m);
m->unload_requested = 1;
@ -255,7 +256,7 @@ void pa_module_unload_request(struct pa_module *m) {
m->core->mainloop->defer_enable(m->core->module_defer_unload_event, 1);
}
void pa_module_set_used(struct pa_module*m, int used) {
void pa_module_set_used(pa_module*m, int used) {
assert(m);
if (m->n_used != used)
@ -267,7 +268,7 @@ void pa_module_set_used(struct pa_module*m, int used) {
m->n_used = used;
}
struct pa_modinfo *pa_module_get_info(struct pa_module *m) {
pa_modinfo *pa_module_get_info(pa_module *m) {
assert(m);
return pa_modinfo_get_by_handle(m->dl);

View file

@ -28,15 +28,17 @@
#include "core.h"
#include "modinfo.h"
typedef struct pa_module pa_module;
struct pa_module {
struct pa_core *core;
pa_core *core;
char *name, *argument;
uint32_t index;
lt_dlhandle dl;
int (*init)(struct pa_core *c, struct pa_module*m);
void (*done)(struct pa_core *c, struct pa_module*m);
int (*init)(pa_core *c, pa_module*m);
void (*done)(pa_core *c, pa_module*m);
void *userdata;
@ -47,22 +49,22 @@ struct pa_module {
int unload_requested;
};
struct pa_module* pa_module_load(struct pa_core *c, const char *name, const char*argument);
/* void pa_module_unload(struct pa_core *c, struct pa_module *m); */
/* void pa_module_unload_by_index(struct pa_core *c, uint32_t index); */
pa_module* pa_module_load(pa_core *c, const char *name, const char*argument);
void pa_module_unload(pa_core *c, pa_module *m);
void pa_module_unload_by_index(pa_core *c, uint32_t idx);
void pa_module_unload_all(struct pa_core *c);
void pa_module_unload_unused(struct pa_core *c);
void pa_module_unload_all(pa_core *c);
void pa_module_unload_unused(pa_core *c);
void pa_module_unload_request(struct pa_module *m);
void pa_module_unload_request(pa_module *m);
void pa_module_set_used(struct pa_module*m, int used);
void pa_module_set_used(pa_module*m, int used);
#define PA_MODULE_AUTHOR(s) const char * pa__get_author(void) { return s; }
#define PA_MODULE_DESCRIPTION(s) const char * pa__get_description(void) { return s; }
#define PA_MODULE_USAGE(s) const char * pa__get_usage(void) { return s; }
#define PA_MODULE_VERSION(s) const char * pa__get_version(void) { return s; }
struct pa_modinfo *pa_module_get_info(struct pa_module *m);
pa_modinfo *pa_module_get_info(pa_module *m);
#endif

View file

@ -38,20 +38,20 @@
#include "util.h"
struct namereg_entry {
enum pa_namereg_type type;
pa_namereg_type type;
char *name;
void *data;
};
void pa_namereg_free(struct pa_core *c) {
void pa_namereg_free(pa_core *c) {
assert(c);
if (!c->namereg)
return;
assert(pa_hashmap_ncontents(c->namereg) == 0);
assert(pa_hashmap_size(c->namereg) == 0);
pa_hashmap_free(c->namereg, NULL, NULL);
}
const char *pa_namereg_register(struct pa_core *c, const char *name, enum pa_namereg_type type, void *data, int fail) {
const char *pa_namereg_register(pa_core *c, const char *name, pa_namereg_type type, void *data, int fail) {
struct namereg_entry *e;
char *n = NULL;
int r;
@ -99,7 +99,7 @@ const char *pa_namereg_register(struct pa_core *c, const char *name, enum pa_nam
}
void pa_namereg_unregister(struct pa_core *c, const char *name) {
void pa_namereg_unregister(pa_core *c, const char *name) {
struct namereg_entry *e;
assert(c && name);
@ -110,9 +110,9 @@ void pa_namereg_unregister(struct pa_core *c, const char *name) {
pa_xfree(e);
}
void* pa_namereg_get(struct pa_core *c, const char *name, enum pa_namereg_type type, int autoload) {
void* pa_namereg_get(pa_core *c, const char *name, pa_namereg_type type, int autoload) {
struct namereg_entry *e;
uint32_t index;
uint32_t idx;
assert(c);
if (!name) {
@ -129,7 +129,7 @@ void* pa_namereg_get(struct pa_core *c, const char *name, enum pa_namereg_type t
if (e->type == e->type)
return e->data;
if (pa_atou(name, &index) < 0) {
if (pa_atou(name, &idx) < 0) {
if (autoload) {
pa_autoload_request(c, name, type);
@ -143,16 +143,16 @@ void* pa_namereg_get(struct pa_core *c, const char *name, enum pa_namereg_type t
}
if (type == PA_NAMEREG_SINK)
return pa_idxset_get_by_index(c->sinks, index);
return pa_idxset_get_by_index(c->sinks, idx);
else if (type == PA_NAMEREG_SOURCE)
return pa_idxset_get_by_index(c->sources, index);
return pa_idxset_get_by_index(c->sources, idx);
else if (type == PA_NAMEREG_SAMPLE && c->scache)
return pa_idxset_get_by_index(c->scache, index);
return pa_idxset_get_by_index(c->scache, idx);
return NULL;
}
void pa_namereg_set_default(struct pa_core*c, const char *name, enum pa_namereg_type type) {
void pa_namereg_set_default(pa_core*c, const char *name, pa_namereg_type type) {
char **s;
assert(c && (type == PA_NAMEREG_SINK || type == PA_NAMEREG_SOURCE));
@ -170,8 +170,8 @@ void pa_namereg_set_default(struct pa_core*c, const char *name, enum pa_namereg_
pa_subscription_post(c, PA_SUBSCRIPTION_EVENT_SERVER|PA_SUBSCRIPTION_EVENT_CHANGE, PA_INVALID_INDEX);
}
const char *pa_namereg_get_default_sink_name(struct pa_core *c) {
struct pa_sink *s;
const char *pa_namereg_get_default_sink_name(pa_core *c) {
pa_sink *s;
assert(c);
if (c->default_sink_name)
@ -186,16 +186,16 @@ const char *pa_namereg_get_default_sink_name(struct pa_core *c) {
return NULL;
}
const char *pa_namereg_get_default_source_name(struct pa_core *c) {
struct pa_source *s;
uint32_t index;
const char *pa_namereg_get_default_source_name(pa_core *c) {
pa_source *s;
uint32_t idx;
assert(c);
if (c->default_source_name)
return c->default_source_name;
for (s = pa_idxset_first(c->sources, &index); s; s = pa_idxset_next(c->sources, &index))
for (s = pa_idxset_first(c->sources, &idx); s; s = pa_idxset_next(c->sources, &idx))
if (!s->monitor_of) {
pa_namereg_set_default(c, s->name, PA_NAMEREG_SOURCE);
break;

View file

@ -24,20 +24,20 @@
#include "core.h"
enum pa_namereg_type {
typedef enum pa_namereg_type {
PA_NAMEREG_SINK,
PA_NAMEREG_SOURCE,
PA_NAMEREG_SAMPLE
};
} pa_namereg_type ;
void pa_namereg_free(struct pa_core *c);
void pa_namereg_free(pa_core *c);
const char *pa_namereg_register(struct pa_core *c, const char *name, enum pa_namereg_type type, void *data, int fail);
void pa_namereg_unregister(struct pa_core *c, const char *name);
void* pa_namereg_get(struct pa_core *c, const char *name, enum pa_namereg_type type, int autoload);
void pa_namereg_set_default(struct pa_core*c, const char *name, enum pa_namereg_type type);
const char *pa_namereg_register(pa_core *c, const char *name, pa_namereg_type type, void *data, int fail);
void pa_namereg_unregister(pa_core *c, const char *name);
void* pa_namereg_get(pa_core *c, const char *name, pa_namereg_type type, int autoload);
void pa_namereg_set_default(pa_core*c, const char *name, pa_namereg_type type);
const char *pa_namereg_get_default_sink_name(struct pa_core *c);
const char *pa_namereg_get_default_source_name(struct pa_core *c);
const char *pa_namereg_get_default_sink_name(pa_core *c);
const char *pa_namereg_get_default_source_name(pa_core *c);
#endif

Some files were not shown because too many files have changed in this diff Show more