summaryrefslogtreecommitdiffstats
path: root/polyp
diff options
context:
space:
mode:
Diffstat (limited to 'polyp')
-rw-r--r--polyp/Makefile.am6
-rw-r--r--polyp/alsa-util.c10
-rw-r--r--polyp/alsa-util.h6
-rw-r--r--polyp/authkey-prop.c8
-rw-r--r--polyp/authkey-prop.h8
-rw-r--r--polyp/autoload.c54
-rw-r--r--polyp/autoload.h22
-rw-r--r--polyp/cli-command.c196
-rw-r--r--polyp/cli-command.h6
-rw-r--r--polyp/cli-text.c102
-rw-r--r--polyp/cli-text.h20
-rw-r--r--polyp/cli.c32
-rw-r--r--polyp/cli.h8
-rw-r--r--polyp/client-conf-x11.c2
-rw-r--r--polyp/client-conf-x11.h2
-rw-r--r--polyp/client-conf.c16
-rw-r--r--polyp/client-conf.h14
-rw-r--r--polyp/client.c12
-rw-r--r--polyp/client.h16
-rw-r--r--polyp/cmdline.c4
-rw-r--r--polyp/cmdline.h2
-rw-r--r--polyp/conf-parser.c12
-rw-r--r--polyp/conf-parser.h6
-rw-r--r--polyp/core.c18
-rw-r--r--polyp/core.h36
-rw-r--r--polyp/cpulimit-test.c7
-rw-r--r--polyp/cpulimit.c21
-rw-r--r--polyp/cpulimit.h2
-rw-r--r--polyp/daemon-conf.c38
-rw-r--r--polyp/daemon-conf.h30
-rw-r--r--polyp/dumpmodules.c12
-rw-r--r--polyp/dumpmodules.h2
-rw-r--r--polyp/dynarray.c16
-rw-r--r--polyp/dynarray.h14
-rw-r--r--polyp/gccmacro.h (renamed from polyp/gcc-printf.h)28
-rw-r--r--polyp/glib-mainloop.c126
-rw-r--r--polyp/glib-mainloop.h12
-rw-r--r--polyp/glib12-mainloop.c123
-rw-r--r--polyp/hashmap.c22
-rw-r--r--polyp/hashmap.h16
-rw-r--r--polyp/howl-wrap.c28
-rw-r--r--polyp/howl-wrap.h10
-rw-r--r--polyp/idxset.c124
-rw-r--r--polyp/idxset.h41
-rw-r--r--polyp/iochannel.c88
-rw-r--r--polyp/iochannel.h29
-rw-r--r--polyp/ioline.c54
-rw-r--r--polyp/ioline.h18
-rw-r--r--polyp/log.c26
-rw-r--r--polyp/log.h20
-rw-r--r--polyp/main.c20
-rw-r--r--polyp/mainloop-api.c13
-rw-r--r--polyp/mainloop-api.h48
-rw-r--r--polyp/mainloop-signal.c41
-rw-r--r--polyp/mainloop-signal.h12
-rw-r--r--polyp/mainloop-test.c24
-rw-r--r--polyp/mainloop.c168
-rw-r--r--polyp/mainloop.h19
-rw-r--r--polyp/mcalign-test.c9
-rw-r--r--polyp/mcalign.c16
-rw-r--r--polyp/mcalign.h16
-rw-r--r--polyp/memblock.c38
-rw-r--r--polyp/memblock.h49
-rw-r--r--polyp/memblockq.c54
-rw-r--r--polyp/memblockq.h42
-rw-r--r--polyp/memchunk.c6
-rw-r--r--polyp/memchunk.h12
-rw-r--r--polyp/modargs.c32
-rw-r--r--polyp/modargs.h16
-rw-r--r--polyp/modinfo.c12
-rw-r--r--polyp/modinfo.h10
-rw-r--r--polyp/module-alsa-sink.c26
-rw-r--r--polyp/module-alsa-source.c24
-rw-r--r--polyp/module-cli.c10
-rw-r--r--polyp/module-combine.c42
-rw-r--r--polyp/module-defs.h.m45
-rw-r--r--polyp/module-esound-compat-spawnfd.c6
-rw-r--r--polyp/module-esound-compat-spawnpid.c6
-rw-r--r--polyp/module-esound-sink.c34
-rw-r--r--polyp/module-lirc.c14
-rw-r--r--polyp/module-match.c14
-rw-r--r--polyp/module-mmkbd-evdev.c24
-rw-r--r--polyp/module-native-protocol-fd.c8
-rw-r--r--polyp/module-null-sink.c20
-rw-r--r--polyp/module-oss-mmap.c36
-rw-r--r--polyp/module-oss.c36
-rw-r--r--polyp/module-pipe-sink.c30
-rw-r--r--polyp/module-pipe-source.c24
-rw-r--r--polyp/module-protocol-stub.c14
-rw-r--r--polyp/module-sine.c24
-rw-r--r--polyp/module-solaris.c38
-rw-r--r--polyp/module-tunnel.c72
-rw-r--r--polyp/module-waveout.c46
-rw-r--r--polyp/module-x11-bell.c16
-rw-r--r--polyp/module-x11-publish.c12
-rw-r--r--polyp/module-zeroconf-publish.c50
-rw-r--r--polyp/module.c53
-rw-r--r--polyp/module.h24
-rw-r--r--polyp/namereg.c36
-rw-r--r--polyp/namereg.h18
-rw-r--r--polyp/oss-util.c2
-rw-r--r--polyp/oss-util.h2
-rw-r--r--polyp/pabrowse.c12
-rw-r--r--polyp/pacat-simple.c7
-rw-r--r--polyp/pacat.c36
-rw-r--r--polyp/packet.c16
-rw-r--r--polyp/packet.h12
-rw-r--r--polyp/pacmd.c2
-rw-r--r--polyp/pactl.c44
-rw-r--r--polyp/paplay.c33
-rw-r--r--polyp/parec-simple.c9
-rw-r--r--polyp/parseaddr.c4
-rw-r--r--polyp/parseaddr.h12
-rw-r--r--polyp/pax11publish.c22
-rw-r--r--polyp/pdispatch.c52
-rw-r--r--polyp/pdispatch.h23
-rw-r--r--polyp/play-memchunk.c23
-rw-r--r--polyp/play-memchunk.h2
-rw-r--r--polyp/polyplib-browser.c38
-rw-r--r--polyp/polyplib-browser.h16
-rw-r--r--polyp/polyplib-context.c166
-rw-r--r--polyp/polyplib-context.h38
-rw-r--r--polyp/polyplib-def.h40
-rw-r--r--polyp/polyplib-internal.h94
-rw-r--r--polyp/polyplib-introspect.c373
-rw-r--r--polyp/polyplib-introspect.h124
-rw-r--r--polyp/polyplib-operation.c22
-rw-r--r--polyp/polyplib-operation.h12
-rw-r--r--polyp/polyplib-scache.c24
-rw-r--r--polyp/polyplib-scache.h8
-rw-r--r--polyp/polyplib-simple.c130
-rw-r--r--polyp/polyplib-simple.h24
-rw-r--r--polyp/polyplib-stream.c160
-rw-r--r--polyp/polyplib-stream.h58
-rw-r--r--polyp/polyplib-subscribe.c17
-rw-r--r--polyp/polyplib-subscribe.h4
-rw-r--r--polyp/props.c36
-rw-r--r--polyp/props.h14
-rw-r--r--polyp/protocol-cli.c30
-rw-r--r--polyp/protocol-cli.h6
-rw-r--r--polyp/protocol-esound.c193
-rw-r--r--polyp/protocol-esound.h6
-rw-r--r--polyp/protocol-http.c38
-rw-r--r--polyp/protocol-http.h6
-rw-r--r--polyp/protocol-native.c640
-rw-r--r--polyp/protocol-native.h8
-rw-r--r--polyp/protocol-simple.c68
-rw-r--r--polyp/protocol-simple.h6
-rw-r--r--polyp/pstream-util.c12
-rw-r--r--polyp/pstream-util.h6
-rw-r--r--polyp/pstream.c86
-rw-r--r--polyp/pstream.h24
-rw-r--r--polyp/queue.c14
-rw-r--r--polyp/queue.h12
-rw-r--r--polyp/resampler.c52
-rw-r--r--polyp/resampler.h22
-rw-r--r--polyp/sample-util.c12
-rw-r--r--polyp/sample-util.h16
-rw-r--r--polyp/sample.c16
-rw-r--r--polyp/sample.h26
-rw-r--r--polyp/scache.c83
-rw-r--r--polyp/scache.h32
-rw-r--r--polyp/sconv-s16be.c3
-rw-r--r--polyp/sconv-s16le.c1
-rw-r--r--polyp/sconv.c8
-rw-r--r--polyp/sconv.h4
-rw-r--r--polyp/sink-input.c38
-rw-r--r--polyp/sink-input.h56
-rw-r--r--polyp/sink.c55
-rw-r--r--polyp/sink.h49
-rw-r--r--polyp/socket-client.c74
-rw-r--r--polyp/socket-client.h20
-rw-r--r--polyp/socket-server.c42
-rw-r--r--polyp/socket-server.h18
-rw-r--r--polyp/sound-file-stream.c16
-rw-r--r--polyp/sound-file-stream.h2
-rw-r--r--polyp/sound-file.c4
-rw-r--r--polyp/sound-file.h2
-rw-r--r--polyp/source-output.c32
-rw-r--r--polyp/source-output.h44
-rw-r--r--polyp/source.c30
-rw-r--r--polyp/source.h39
-rw-r--r--polyp/strbuf.c18
-rw-r--r--polyp/strbuf.h18
-rw-r--r--polyp/strlist-test.c5
-rw-r--r--polyp/strlist.c34
-rw-r--r--polyp/strlist.h14
-rw-r--r--polyp/subscribe.c49
-rw-r--r--polyp/subscribe.h14
-rw-r--r--polyp/tagstruct.c52
-rw-r--r--polyp/tagstruct.h56
-rw-r--r--polyp/tokenizer.c17
-rw-r--r--polyp/tokenizer.h8
-rw-r--r--polyp/util.c8
-rw-r--r--polyp/util.h2
-rw-r--r--polyp/voltest.c3
-rw-r--r--polyp/x11wrap.c90
-rw-r--r--polyp/x11wrap.h16
-rw-r--r--polyp/xmalloc.c4
-rw-r--r--polyp/xmalloc.h20
200 files changed, 3574 insertions, 3460 deletions
diff --git a/polyp/Makefile.am b/polyp/Makefile.am
index 22e8da3d..8712782f 100644
--- a/polyp/Makefile.am
+++ b/polyp/Makefile.am
@@ -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)
diff --git a/polyp/alsa-util.c b/polyp/alsa-util.c
index 2894c9e8..73f3be7d 100644
--- a/polyp/alsa-util.c
+++ b/polyp/alsa-util.c
@@ -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++)
diff --git a/polyp/alsa-util.h b/polyp/alsa-util.h
index adec143f..787519f7 100644
--- a/polyp/alsa-util.h
+++ b/polyp/alsa-util.h
@@ -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
diff --git a/polyp/authkey-prop.c b/polyp/authkey-prop.c
index 2adfc41f..8657f5a5 100644
--- a/polyp/authkey-prop.c
+++ b/polyp/authkey-prop.c
@@ -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);
diff --git a/polyp/authkey-prop.h b/polyp/authkey-prop.h
index 1b1948c7..29b40bb2 100644
--- a/polyp/authkey-prop.h
+++ b/polyp/authkey-prop.h
@@ -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
diff --git a/polyp/autoload.c b/polyp/autoload.c
index 96fa750a..7e05c168 100644
--- a/polyp/autoload.c
+++ b/polyp/autoload.c
@@ -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;
diff --git a/polyp/autoload.h b/polyp/autoload.h
index 23475684..622a854e 100644
--- a/polyp/autoload.h
+++ b/polyp/autoload.h
@@ -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
diff --git a/polyp/cli-command.c b/polyp/cli-command.c
index 12447879..63241a81 100644
--- a/polyp/cli-command.c
+++ b/polyp/cli-command.c
@@ -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);
diff --git a/polyp/cli-command.h b/polyp/cli-command.h
index 7af9d014..78b8d5c6 100644
--- a/polyp/cli-command.h
+++ b/polyp/cli-command.h
@@ -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
diff --git a/polyp/cli-text.c b/polyp/cli-text.c
index d4c46dc0..a19bfc97 100644
--- a/polyp/cli-text.c
+++ b/polyp/cli-text.c
@@ -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();
diff --git a/polyp/cli-text.h b/polyp/cli-text.h
index d19dd48c..7a1a0361 100644
--- a/polyp/cli-text.h
+++ b/polyp/cli-text.h
@@ -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_full_status_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(pa_core *c);
#endif
diff --git a/polyp/cli.c b/polyp/cli.c
index 16323cba..7b1022c1 100644
--- a/polyp/cli.c
+++ b/polyp/cli.c
@@ -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;
diff --git a/polyp/cli.h b/polyp/cli.h
index 44ed706c..03f31c22 100644
--- a/polyp/cli.h
+++ b/polyp/cli.h
@@ -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
diff --git a/polyp/client-conf-x11.c b/polyp/client-conf-x11.c
index 383aa64e..4fd75744 100644
--- a/polyp/client-conf-x11.c
+++ b/polyp/client-conf-x11.c
@@ -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];
diff --git a/polyp/client-conf-x11.h b/polyp/client-conf-x11.h
index e65e8202..64459224 100644
--- a/polyp/client-conf-x11.h
+++ b/polyp/client-conf-x11.h
@@ -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
diff --git a/polyp/client-conf.c b/polyp/client-conf.c
index 04c3d2ef..bcd4275d 100644
--- a/polyp/client-conf.c
+++ b/polyp/client-conf.c
@@ -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;
diff --git a/polyp/client-conf.h b/polyp/client-conf.h
index b4625039..7ca2f233 100644
--- a/polyp/client-conf.h
+++ b/polyp/client-conf.h
@@ -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
diff --git a/polyp/client.c b/polyp/client.c
index 8c7f4800..1938a4e0 100644
--- a/polyp/client.c
+++ b/polyp/client.c
@@ -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);
diff --git a/polyp/client.h b/polyp/client.h
index 2a3a09e0..198dbbf6 100644
--- a/polyp/client.h
+++ b/polyp/client.h
@@ -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
diff --git a/polyp/cmdline.c b/polyp/cmdline.c
index 0951725a..5635707f 100644
--- a/polyp/cmdline.c
+++ b/polyp/cmdline.c
@@ -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);
diff --git a/polyp/cmdline.h b/polyp/cmdline.h
index ca100d1d..e2eaf0d2 100644
--- a/polyp/cmdline.h
+++ b/polyp/cmdline.h
@@ -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. */
diff --git a/polyp/conf-parser.c b/polyp/conf-parser.c
index 8d2f2f68..507f2bf1 100644
--- a/polyp/conf-parser.c
+++ b/polyp/conf-parser.c
@@ -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);
diff --git a/polyp/conf-parser.h b/polyp/conf-parser.h
index 9add0be0..2dca3bce 100644
--- a/polyp/conf-parser.h
+++ b/polyp/conf-parser.h
@@ -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);
diff --git a/polyp/core.c b/polyp/core.c
index 60439243..678e8212 100644
--- a/polyp/core.c
+++ b/polyp/core.c
@@ -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;
}
diff --git a/polyp/core.h b/polyp/core.h
index 8ef66570..704246a9 100644
--- a/polyp/core.h
+++ b/polyp/core.h
@@ -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
diff --git a/polyp/cpulimit-test.c b/polyp/cpulimit-test.c
index de5e20ad..598b2dd2 100644
--- a/polyp/cpulimit-test.c
+++ b/polyp/cpulimit-test.c
@@ -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);
diff --git a/polyp/cpulimit.c b/polyp/cpulimit.c
index 53920f50..a834b094 100644
--- a/polyp/cpulimit.c
+++ b/polyp/cpulimit.c
@@ -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;
}
diff --git a/polyp/cpulimit.h b/polyp/cpulimit.h
index a171da9b..8ca4f8d9 100644
--- a/polyp/cpulimit.h
+++ b/polyp/cpulimit.h
@@ -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
diff --git a/polyp/daemon-conf.c b/polyp/daemon-conf.c
index 780581b2..4ad78bab 100644
--- a/polyp/daemon-conf.c
+++ b/polyp/daemon-conf.c
@@ -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);
diff --git a/polyp/daemon-conf.h b/polyp/daemon-conf.h
index 30137e8b..4eb61365 100644
--- a/polyp/daemon-conf.h
+++ b/polyp/daemon-conf.h
@@ -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
diff --git a/polyp/dumpmodules.c b/polyp/dumpmodules.c
index 5aaa108d..6864b965 100644
--- a/polyp/dumpmodules.c
+++ b/polyp/dumpmodules.c
@@ -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++)
diff --git a/polyp/dumpmodules.h b/polyp/dumpmodules.h
index fadc571f..968d2de9 100644
--- a/polyp/dumpmodules.h
+++ b/polyp/dumpmodules.h
@@ -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
diff --git a/polyp/dynarray.c b/polyp/dynarray.c
index 0e406ea1..435fd768 100644
--- a/polyp/dynarray.c
+++ b/polyp/dynarray.c
@@ -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;
}
diff --git a/polyp/dynarray.h b/polyp/dynarray.h
index 6733e958..9b1601ba 100644
--- a/polyp/dynarray.h
+++ b/polyp/dynarray.h
@@ -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
diff --git a/polyp/gcc-printf.h b/polyp/gccmacro.h
index 70679df9..9e212f2e 100644
--- a/polyp/gcc-printf.h
+++ b/polyp/gccmacro.h
@@ -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
diff --git a/polyp/glib-mainloop.c b/polyp/glib-mainloop.c
index 0f96a594..6552da15 100644
--- a/polyp/glib-mainloop.c
+++ b/polyp/glib-mainloop.c
@@ -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)
diff --git a/polyp/glib-mainloop.h b/polyp/glib-mainloop.h
index d830561f..d3e98597 100644
--- a/polyp/glib-mainloop.h
+++ b/polyp/glib-mainloop.h
@@ -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
diff --git a/polyp/glib12-mainloop.c b/polyp/glib12-mainloop.c
index c328471c..e322ac07 100644
--- a/polyp/glib12-mainloop.c
+++ b/polyp/glib12-mainloop.c
@@ -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)
diff --git a/polyp/hashmap.c b/polyp/hashmap.c
index 3b1265c9..a37decb8 100644
--- a/polyp/hashmap.c
+++ b/polyp/hashmap.c
@@ -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)
diff --git a/polyp/hashmap.h b/polyp/hashmap.h
index d55834c1..14f82705 100644
--- a/polyp/hashmap.h
+++ b/polyp/hashmap.h
@@ -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
diff --git a/polyp/howl-wrap.c b/polyp/howl-wrap.c
index af050930..77d096ac 100644
--- a/polyp/howl-wrap.c
+++ b/polyp/howl-wrap.c
@@ -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;
diff --git a/polyp/howl-wrap.h b/polyp/howl-wrap.h
index feb54556..a670b082 100644
--- a/polyp/howl-wrap.h
+++ b/polyp/howl-wrap.h
@@ -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
diff --git a/polyp/idxset.c b/polyp/idxset.c
index dcc38423..409d1fab 100644
--- a/polyp/idxset.c
+++ b/polyp/idxset.c
@@ -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;
}
diff --git a/polyp/idxset.h b/polyp/idxset.h
index 4c89eea1..17ae16cb 100644
--- a/polyp/idxset.h
+++ b/polyp/idxset.h
@@ -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
diff --git a/polyp/iochannel.c b/polyp/iochannel.c
index 1a0dbf91..e6271319 100644
--- a/polyp/iochannel.c
+++ b/polyp/iochannel.c
@@ -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;
}
diff --git a/polyp/iochannel.h b/polyp/iochannel.h
index 2a1ba370..e2b8bccf 100644
--- a/polyp/iochannel.h
+++ b/polyp/iochannel.h
@@ -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
diff --git a/polyp/ioline.c b/polyp/ioline.c
index 72df6b87..5b669f5c 100644
--- a/polyp/ioline.c
+++ b/polyp/ioline.c
@@ -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;
diff --git a/polyp/ioline.h b/polyp/ioline.h
index 6e9c76d0..84ccb47a 100644
--- a/polyp/ioline.h
+++ b/polyp/ioline.h
@@ -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
diff --git a/polyp/log.c b/polyp/log.c
index 2bbf2e86..c41fbbae 100644
--- a/polyp/log.c
+++ b/polyp/log.c
@@ -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);
}
diff --git a/polyp/log.h b/polyp/log.h
index fe2dad59..7c6a8e61 100644
--- a/polyp/log.h
+++ b/polyp/log.h
@@ -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
diff --git a/polyp/main.c b/polyp/main.c
index e481fce1..1c3b566d 100644
--- a/polyp/main.c
+++ b/polyp/main.c
@@ -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)
diff --git a/polyp/mainloop-api.c b/polyp/mainloop-api.c
index 7b80e4fe..3229ec20 100644
--- a/polyp/mainloop-api.c
+++ b/polyp/mainloop-api.c
@@ -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;
diff --git a/polyp/mainloop-api.h b/polyp/mainloop-api.h
index 3fb221fa..1604e740 100644
--- a/polyp/mainloop-api.h
+++ b/polyp/mainloop-api.h
@@ -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
diff --git a/polyp/mainloop-signal.c b/polyp/mainloop-signal.c
index 432498a8..f225e60b 100644
--- a/polyp/mainloop-signal.c
+++ b/polyp/mainloop-signal.c
@@ -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;
}
diff --git a/polyp/mainloop-signal.h b/polyp/mainloop-signal.h
index 9ba92141..6ce31370 100644
--- a/polyp/mainloop-signal.h
+++ b/polyp/mainloop-signal.h
@@ -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
diff --git a/polyp/mainloop-test.c b/polyp/mainloop-test.c
index dd8f8137..097ce1c7 100644
--- a/polyp/mainloop-test.c
+++ b/polyp/mainloop-test.c
@@ -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);
diff --git a/polyp/mainloop.c b/polyp/mainloop.c
index ada74afc..599a90f8 100644
--- a/polyp/mainloop.c
+++ b/polyp/mainloop.c
@@ -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
diff --git a/polyp/mainloop.h b/polyp/mainloop.h
index 06a6ccaa..06764907 100644
--- a/polyp/mainloop.h
+++ b/polyp/mainloop.h
@@ -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
diff --git a/polyp/mcalign-test.c b/polyp/mcalign-test.c
index 2ace6e59..c151d8f2 100644
--- a/polyp/mcalign-test.c
+++ b/polyp/mcalign-test.c
@@ -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;
diff --git a/polyp/mcalign.c b/polyp/mcalign.c
index 0b7f0db0..4d765625 100644
--- a/polyp/mcalign.c
+++ b/polyp/mcalign.c
@@ -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 */
diff --git a/polyp/mcalign.h b/polyp/mcalign.h
index 925f438a..5de75bc7 100644
--- a/polyp/mcalign.h
+++ b/polyp/mcalign.h
@@ -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
diff --git a/polyp/memblock.c b/polyp/memblock.c
index c070bee6..8da53525 100644
--- a/polyp/memblock.c
+++ b/polyp/memblock.c
@@ -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;
diff --git a/polyp/memblock.h b/polyp/memblock.h
index 8555954c..cbf5d684 100644
--- a/polyp/memblock.h
+++ b/polyp/memblock.h
@@ -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;
+/* 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 {
- enum pa_memblock_type type;
+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 */
- struct pa_memblock_stat *stat;
-};
+ pa_memblock_stat *stat;
+} pa_memblock;
/* Allocate a new memory block of type PA_MEMBLOCK_APPENDED */
-struct pa_memblock *pa_memblock_new(size_t length, struct pa_memblock_stat*s);
+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 */
-struct pa_memblock *pa_memblock_new_dynamic(void *data, size_t length, struct pa_memblock_stat*s);
+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 */
-struct pa_memblock *pa_memblock_new_fixed(void *data, size_t length, int read_only, struct pa_memblock_stat*s);
+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 */
-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);
+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(struct pa_memblock*b);
-struct pa_memblock* pa_memblock_ref(struct pa_memblock*b);
+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(struct pa_memblock*b);
+void pa_memblock_unref_fixed(pa_memblock*b);
-/* Matinatins statistics about memory blocks */
-struct pa_memblock_stat {
- int ref;
- unsigned total;
- unsigned total_size;
- unsigned allocated;
- unsigned allocated_size;
-};
-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);
+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
diff --git a/polyp/memblockq.c b/polyp/memblockq.c
index 3f2e4db1..ba6b76ea 100644
--- a/polyp/memblockq.c
+++ b/polyp/memblockq.c
@@ -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;
}
diff --git a/polyp/memblockq.h b/polyp/memblockq.h
index 2c762bf4..1695daba 100644
--- a/polyp/memblockq.h
+++ b/polyp/memblockq.h
@@ -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
diff --git a/polyp/memchunk.c b/polyp/memchunk.c
index d1c923f3..bfd74f9e 100644
--- a/polyp/memchunk.c
+++ b/polyp/memchunk.c
@@ -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;
diff --git a/polyp/memchunk.h b/polyp/memchunk.h
index a004c2e8..4eefc8c1 100644
--- a/polyp/memchunk.h
+++ b/polyp/memchunk.h
@@ -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
diff --git a/polyp/modargs.c b/polyp/modargs.c
index 9437d839..07062946 100644
--- a/polyp/modargs.c
+++ b/polyp/modargs.c
@@ -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;*/
diff --git a/polyp/modargs.h b/polyp/modargs.h
index 07db6ae5..56605379 100644
--- a/polyp/modargs.h
+++ b/polyp/modargs.h
@@ -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
diff --git a/polyp/modinfo.c b/polyp/modinfo.c
index a96bb17e..53440612 100644
--- a/polyp/modinfo.c
+++ b/polyp/modinfo.c
@@ -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);
diff --git a/polyp/modinfo.h b/polyp/modinfo.h
index 9da9dc4e..53176147 100644
--- a/polyp/modinfo.h
+++ b/polyp/modinfo.h
@@ -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
diff --git a/polyp/module-alsa-sink.c b/polyp/module-alsa-sink.c
index dde5d8b6..14070d63 100644
--- a/polyp/module-alsa-sink.c
+++ b/polyp/module-alsa-sink.c
@@ -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);
diff --git a/polyp/module-alsa-source.c b/polyp/module-alsa-source.c
index 5b4076f8..4ad8dd84 100644
--- a/polyp/module-alsa-source.c
+++ b/polyp/module-alsa-source.c
@@ -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);
diff --git a/polyp/module-cli.c b/polyp/module-cli.c
index 7d278f90..db0e895c 100644
--- a/polyp/module-cli.c
+++ b/polyp/module-cli.c
@@ -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) {
diff --git a/polyp/module-combine.c b/polyp/module-combine.c
index 7283c554..cee0a5dc 100644
--- a/polyp/module-combine.c
+++ b/polyp/module-combine.c
@@ -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);
diff --git a/polyp/module-defs.h.m4 b/polyp/module-defs.h.m4
index 2b9cdf9e..2eff25a7 100644
--- a/polyp/module-defs.h.m4
+++ b/polyp/module-defs.h.m4
@@ -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
diff --git a/polyp/module-esound-compat-spawnfd.c b/polyp/module-esound-compat-spawnfd.c
index de2cf4e6..5051e4d0 100644
--- a/polyp/module-esound-compat-spawnfd.c
+++ b/polyp/module-esound-compat-spawnfd.c
@@ -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);
}
diff --git a/polyp/module-esound-compat-spawnpid.c b/polyp/module-esound-compat-spawnpid.c
index 6f945728..aa8b0f82 100644
--- a/polyp/module-esound-compat-spawnpid.c
+++ b/polyp/module-esound-compat-spawnpid.c
@@ -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);
}
diff --git a/polyp/module-esound-sink.c b/polyp/module-esound-sink.c
index 19106506..ac211a31 100644
--- a/polyp/module-esound-sink.c
+++ b/polyp/module-esound-sink.c
@@ -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);
diff --git a/polyp/module-lirc.c b/polyp/module-lirc.c
index 4cfc09de..eb71c47f 100644
--- a/polyp/module-lirc.c
+++ b/polyp/module-lirc.c
@@ -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);
diff --git a/polyp/module-match.c b/polyp/module-match.c
index 3599a830..e48d55ca 100644
--- a/polyp/module-match.c
+++ b/polyp/module-match.c
@@ -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);
diff --git a/polyp/module-mmkbd-evdev.c b/polyp/module-mmkbd-evdev.c
index 5368af50..5eb55e35 100644
--- a/polyp/module-mmkbd-evdev.c
+++ b/polyp/module-mmkbd-evdev.c
@@ -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);
diff --git a/polyp/module-native-protocol-fd.c b/polyp/module-native-protocol-fd.c
index 11f6e572..7f09ff91 100644
--- a/polyp/module-native-protocol-fd.c
+++ b/polyp/module-native-protocol-fd.c
@@ -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);
diff --git a/polyp/module-null-sink.c b/polyp/module-null-sink.c
index 6c7a44f2..b26ea50b 100644
--- a/polyp/module-null-sink.c
+++ b/polyp/module-null-sink.c
@@ -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);
diff --git a/polyp/module-oss-mmap.c b/polyp/module-oss-mmap.c
index 3c5c0ad8..ac510f96 100644
--- a/polyp/module-oss-mmap.c
+++ b/polyp/module-oss-mmap.c
@@ -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);
diff --git a/polyp/module-oss.c b/polyp/module-oss.c
index 02acc6f4..7c331893 100644
--- a/polyp/module-oss.c
+++ b/polyp/module-oss.c
@@ -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);
diff --git a/polyp/module-pipe-sink.c b/polyp/module-pipe-sink.c
index b6d8dc2e..537cb86b 100644
--- a/polyp/module-pipe-sink.c
+++ b/polyp/module-pipe-sink.c
@@ -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);
diff --git a/polyp/module-pipe-source.c b/polyp/module-pipe-source.c
index 5a397162..31653627 100644
--- a/polyp/module-pipe-source.c
+++ b/polyp/module-pipe-source.c
@@ -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);
diff --git a/polyp/module-protocol-stub.c b/polyp/module-protocol-stub.c
index 141eadd3..3cf3d9d4 100644
--- a/polyp/module-protocol-stub.c
+++ b/polyp/module-protocol-stub.c
@@ -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)
diff --git a/polyp/module-sine.c b/polyp/module-sine.c
index d8f7e4ef..c531386a 100644
--- a/polyp/module-sine.c
+++ b/polyp/module-sine.c
@@ -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);
diff --git a/polyp/module-solaris.c b/polyp/module-solaris.c
index 3eb66462..c8ad7cf1 100644
--- a/polyp/module-solaris.c
+++ b/polyp/module-solaris.c
@@ -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);
diff --git a/polyp/module-tunnel.c b/polyp/module-tunnel.c
index c6a35ca6..e0eab6c2 100644
--- a/polyp/module-tunnel.c
+++ b/polyp/module-tunnel.c
@@ -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);
diff --git a/polyp/module-waveout.c b/polyp/module-waveout.c
index 4e01bc75..4d6d8c7b 100644
--- a/polyp/module-waveout.c
+++ b/polyp/module-waveout.c
@@ -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;
diff --git a/polyp/module-x11-bell.c b/polyp/module-x11-bell.c
index 084f5d4b..9b08c166 100644
--- a/polyp/module-x11-bell.c
+++ b/polyp/module-x11-bell.c
@@ -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);
diff --git a/polyp/module-x11-publish.c b/polyp/module-x11-publish.c
index a47a7606..0116914f 100644
--- a/polyp/module-x11-publish.c
+++ b/polyp/module-x11-publish.c
@@ -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);
diff --git a/polyp/module-zeroconf-publish.c b/polyp/module-zeroconf-publish.c
index a7e2073e..7e0a2764 100644
--- a/polyp/module-zeroconf-publish.c
+++ b/polyp/module-zeroconf-publish.c
@@ -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);
diff --git a/polyp/module.c b/polyp/module.c
index 0a3d569b..499ea299 100644
--- a/polyp/module.c
+++ b/polyp/module.c
@@ -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);
diff --git a/polyp/module.h b/polyp/module.h
index f5daff95..6f137c15 100644
--- a/polyp/module.h
+++ b/polyp/module.h
@@ -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
diff --git a/polyp/namereg.c b/polyp/namereg.c
index 04601442..7c53a05d 100644
--- a/polyp/namereg.c
+++ b/polyp/namereg.c
@@ -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;
diff --git a/polyp/namereg.h b/polyp/namereg.h
index 99032be8..04f1737b 100644
--- a/polyp/namereg.h
+++ b/polyp/namereg.h
@@ -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
diff --git a/polyp/oss-util.c b/polyp/oss-util.c
index 799bc40a..20a2965a 100644
--- a/polyp/oss-util.c
+++ b/polyp/oss-util.c
@@ -90,7 +90,7 @@ fail:
return fd;
}
-int pa_oss_auto_format(int fd, struct pa_sample_spec *ss) {
+int pa_oss_auto_format(int fd, pa_sample_spec *ss) {
int format, channels, speed, reqformat;
static const int format_trans[PA_SAMPLE_MAX] = {
[PA_SAMPLE_U8] = AFMT_U8,
diff --git a/polyp/oss-util.h b/polyp/oss-util.h
index c1c69632..3ee51cc5 100644
--- a/polyp/oss-util.h
+++ b/polyp/oss-util.h
@@ -25,7 +25,7 @@
#include "sample.h"
int pa_oss_open(const char *device, int *mode, int* pcaps);
-int pa_oss_auto_format(int fd, struct pa_sample_spec *ss);
+int pa_oss_auto_format(int fd, pa_sample_spec *ss);
int pa_oss_set_fragments(int fd, int frags, int frag_size);
diff --git a/polyp/pabrowse.c b/polyp/pabrowse.c
index ccea0cd4..634c308a 100644
--- a/polyp/pabrowse.c
+++ b/polyp/pabrowse.c
@@ -32,12 +32,12 @@
#include <polyp/polyplib-browser.h>
#include <polyp/typeid.h>
-static void exit_signal_callback(struct pa_mainloop_api*m, struct pa_signal_event *e, int sig, void *userdata) {
+static void exit_signal_callback(pa_mainloop_api*m, pa_signal_event *e, int sig, void *userdata) {
fprintf(stderr, "Got signal, exiting\n");
m->quit(m, 0);
}
-static void dump_server(const struct pa_browse_info *i) {
+static void dump_server(const pa_browse_info *i) {
char t[16];
if (i->cookie)
@@ -55,7 +55,7 @@ static void dump_server(const struct pa_browse_info *i) {
i->cookie ? t : "n/a");
}
-static void dump_device(const struct pa_browse_info *i) {
+static void dump_device(const pa_browse_info *i) {
char t[16], ss[PA_SAMPLE_SPEC_SNPRINT_MAX];
if (i->sample_spec)
@@ -75,7 +75,7 @@ static void dump_device(const struct pa_browse_info *i) {
}
-static void browser_callback(struct pa_browser *b, enum pa_browse_opcode c, const struct pa_browse_info *i, void *userdata) {
+static void browser_callback(pa_browser *b, pa_browse_opcode c, const pa_browse_info *i, void *userdata) {
assert(b && i);
switch (c) {
@@ -108,8 +108,8 @@ static void browser_callback(struct pa_browser *b, enum pa_browse_opcode c, cons
int main(int argc, char *argv[]) {
- struct pa_mainloop *mainloop = NULL;
- struct pa_browser *browser = NULL;
+ pa_mainloop *mainloop = NULL;
+ pa_browser *browser = NULL;
int ret = 1, r;
if (!(mainloop = pa_mainloop_new()))
diff --git a/polyp/pacat-simple.c b/polyp/pacat-simple.c
index 09cf4d1a..373cdd57 100644
--- a/polyp/pacat-simple.c
+++ b/polyp/pacat-simple.c
@@ -30,19 +30,20 @@
#include <polyp/polyplib-simple.h>
#include <polyp/polyplib-error.h>
+#include "gccmacro.h"
#define BUFSIZE 1024
-int main(int argc, char*argv[]) {
+int main(PA_GCC_UNUSED int argc, char*argv[]) {
/* The Sample format to use */
- static const struct pa_sample_spec ss = {
+ static const pa_sample_spec ss = {
.format = PA_SAMPLE_S16LE,
.rate = 44100,
.channels = 2
};
- struct pa_simple *s = NULL;
+ pa_simple *s = NULL;
int ret = 1;
int error;
diff --git a/polyp/pacat.c b/polyp/pacat.c
index 1bba2ee4..6842d61a 100644
--- a/polyp/pacat.c
+++ b/polyp/pacat.c
@@ -44,21 +44,21 @@
static enum { RECORD, PLAYBACK } mode = PLAYBACK;
-static struct pa_context *context = NULL;
-static struct pa_stream *stream = NULL;
-static struct pa_mainloop_api *mainloop_api = NULL;
+static pa_context *context = NULL;
+static pa_stream *stream = NULL;
+static pa_mainloop_api *mainloop_api = NULL;
static void *buffer = NULL;
static size_t buffer_length = 0, buffer_index = 0;
-static struct pa_io_event* stdio_event = NULL;
+static pa_io_event* stdio_event = NULL;
static char *stream_name = NULL, *client_name = NULL, *device = NULL;
static int verbose = 0;
static pa_volume_t volume = PA_VOLUME_NORM;
-static struct pa_sample_spec sample_spec = {
+static pa_sample_spec sample_spec = {
.format = PA_SAMPLE_S16LE,
.rate = 44100,
.channels = 2
@@ -94,7 +94,7 @@ static void do_stream_write(size_t length) {
}
/* This is called whenever new data may be written to the stream */
-static void stream_write_callback(struct pa_stream *s, size_t length, void *userdata) {
+static void stream_write_callback(pa_stream *s, size_t length, void *userdata) {
assert(s && length);
if (stdio_event)
@@ -107,7 +107,7 @@ static void stream_write_callback(struct pa_stream *s, size_t length, void *user
}
/* This is called whenever new data may is available */
-static void stream_read_callback(struct pa_stream *s, const void*data, size_t length, void *userdata) {
+static void stream_read_callback(pa_stream *s, const void*data, size_t length, void *userdata) {
assert(s && data && length);
if (stdio_event)
@@ -125,7 +125,7 @@ static void stream_read_callback(struct pa_stream *s, const void*data, size_t le
}
/* This routine is called whenever the stream state changes */
-static void stream_state_callback(struct pa_stream *s, void *userdata) {
+static void stream_state_callback(pa_stream *s, void *userdata) {
assert(s);
switch (pa_stream_get_state(s)) {
@@ -146,7 +146,7 @@ static void stream_state_callback(struct pa_stream *s, void *userdata) {
}
/* This is called whenever the context status changes */
-static void context_state_callback(struct pa_context *c, void *userdata) {
+static void context_state_callback(pa_context *c, void *userdata) {
assert(c);
switch (pa_context_get_state(c)) {
@@ -188,13 +188,13 @@ static void context_state_callback(struct pa_context *c, void *userdata) {
}
/* Connection draining complete */
-static void context_drain_complete(struct pa_context*c, void *userdata) {
+static void context_drain_complete(pa_context*c, void *userdata) {
pa_context_disconnect(c);
}
/* Stream draining complete */
-static void stream_drain_complete(struct pa_stream*s, int success, void *userdata) {
- struct pa_operation *o;
+static void stream_drain_complete(pa_stream*s, int success, void *userdata) {
+ pa_operation *o;
if (!success) {
fprintf(stderr, "Failed to drain stream: %s\n", pa_strerror(pa_context_errno(context)));
@@ -219,7 +219,7 @@ static void stream_drain_complete(struct pa_stream*s, int success, void *userdat
}
/* New data on STDIN **/
-static void stdin_callback(struct pa_mainloop_api*a, struct pa_io_event *e, int fd, enum pa_io_event_flags f, void *userdata) {
+static void stdin_callback(pa_mainloop_api*a, pa_io_event *e, int fd, pa_io_event_flags f, void *userdata) {
size_t l, w = 0;
ssize_t r;
assert(a == mainloop_api && e && stdio_event == e);
@@ -257,7 +257,7 @@ static void stdin_callback(struct pa_mainloop_api*a, struct pa_io_event *e, int
}
/* Some data may be written to STDOUT */
-static void stdout_callback(struct pa_mainloop_api*a, struct pa_io_event *e, int fd, enum pa_io_event_flags f, void *userdata) {
+static void stdout_callback(pa_mainloop_api*a, pa_io_event *e, int fd, pa_io_event_flags f, void *userdata) {
ssize_t r;
assert(a == mainloop_api && e && stdio_event == e);
@@ -288,7 +288,7 @@ static void stdout_callback(struct pa_mainloop_api*a, struct pa_io_event *e, int
}
/* UNIX signal to quit recieved */
-static void exit_signal_callback(struct pa_mainloop_api*m, struct pa_signal_event *e, int sig, void *userdata) {
+static void exit_signal_callback(pa_mainloop_api*m, pa_signal_event *e, int sig, void *userdata) {
if (verbose)
fprintf(stderr, "Got signal, exiting.\n");
quit(0);
@@ -296,7 +296,7 @@ static void exit_signal_callback(struct pa_mainloop_api*m, struct pa_signal_even
}
/* Show the current latency */
-static void stream_get_latency_callback(struct pa_stream *s, const struct pa_latency_info *i, void *userdata) {
+static void stream_get_latency_callback(pa_stream *s, const pa_latency_info *i, void *userdata) {
pa_usec_t total;
int negative = 0;
assert(s);
@@ -315,7 +315,7 @@ static void stream_get_latency_callback(struct pa_stream *s, const struct pa_lat
}
/* Someone requested that the latency is shown */
-static void sigusr1_signal_callback(struct pa_mainloop_api*m, struct pa_signal_event *e, int sig, void *userdata) {
+static void sigusr1_signal_callback(pa_mainloop_api*m, pa_signal_event *e, int sig, void *userdata) {
fprintf(stderr, "Got SIGUSR1, requesting latency.\n");
pa_operation_unref(pa_stream_get_latency_info(stream, stream_get_latency_callback, NULL));
}
@@ -352,7 +352,7 @@ enum {
};
int main(int argc, char *argv[]) {
- struct pa_mainloop* m = NULL;
+ pa_mainloop* m = NULL;
int ret = 1, r, c;
char *bn, *server = NULL;
diff --git a/polyp/packet.c b/polyp/packet.c
index 84ac6d62..b3a2e074 100644
--- a/polyp/packet.c
+++ b/polyp/packet.c
@@ -29,10 +29,10 @@
#include "packet.h"
#include "xmalloc.h"
-struct pa_packet* pa_packet_new(size_t length) {
- struct pa_packet *p;
+pa_packet* pa_packet_new(size_t length) {
+ pa_packet *p;
assert(length);
- p = pa_xmalloc(sizeof(struct pa_packet)+length);
+ p = pa_xmalloc(sizeof(pa_packet)+length);
p->ref = 1;
p->length = length;
p->data = (uint8_t*) (p+1);
@@ -40,10 +40,10 @@ struct pa_packet* pa_packet_new(size_t length) {
return p;
}
-struct pa_packet* pa_packet_new_dynamic(uint8_t* data, size_t length) {
- struct pa_packet *p;
+pa_packet* pa_packet_new_dynamic(uint8_t* data, size_t length) {
+ pa_packet *p;
assert(data && length);
- p = pa_xmalloc(sizeof(struct pa_packet));
+ p = pa_xmalloc(sizeof(pa_packet));
p->ref = 1;
p->length = length;
p->data = data;
@@ -51,13 +51,13 @@ struct pa_packet* pa_packet_new_dynamic(uint8_t* data, size_t length) {
return p;
}
-struct pa_packet* pa_packet_ref(struct pa_packet *p) {
+pa_packet* pa_packet_ref(pa_packet *p) {
assert(p && p->ref >= 1);
p->ref++;
return p;
}
-void pa_packet_unref(struct pa_packet *p) {
+void pa_packet_unref(pa_packet *p) {
assert(p && p->ref >= 1);
p->ref--;
diff --git a/polyp/packet.h b/polyp/packet.h
index 5e4e92f7..0ac47485 100644
--- a/polyp/packet.h
+++ b/polyp/packet.h
@@ -25,17 +25,17 @@
#include <sys/types.h>
#include <inttypes.h>
-struct pa_packet {
+typedef struct pa_packet {
enum { PA_PACKET_APPENDED, PA_PACKET_DYNAMIC } type;
unsigned ref;
size_t length;
uint8_t *data;
-};
+} pa_packet;
-struct pa_packet* pa_packet_new(size_t length);
-struct pa_packet* pa_packet_new_dynamic(uint8_t* data, size_t length);
+pa_packet* pa_packet_new(size_t length);
+pa_packet* pa_packet_new_dynamic(uint8_t* data, size_t length);
-struct pa_packet* pa_packet_ref(struct pa_packet *p);
-void pa_packet_unref(struct pa_packet *p);
+pa_packet* pa_packet_ref(pa_packet *p);
+void pa_packet_unref(pa_packet *p);
#endif
diff --git a/polyp/pacmd.c b/polyp/pacmd.c
index d69c14d7..e6c0da6a 100644
--- a/polyp/pacmd.c
+++ b/polyp/pacmd.c
@@ -36,7 +36,7 @@
#include "log.h"
#include "pid.h"
-int main() {
+int main(PA_GCC_UNUSED int main, PA_GCC_UNUSED char*argv[]) {
pid_t pid ;
int fd = -1;
int ret = 1, i;
diff --git a/polyp/pactl.c b/polyp/pactl.c
index 725b5460..6943a11f 100644
--- a/polyp/pactl.c
+++ b/polyp/pactl.c
@@ -47,14 +47,14 @@
#define BUFSIZE 1024
-static struct pa_context *context = NULL;
-static struct pa_mainloop_api *mainloop_api = NULL;
+static pa_context *context = NULL;
+static pa_mainloop_api *mainloop_api = NULL;
static char *device = NULL, *sample_name = NULL;
static SNDFILE *sndfile = NULL;
-static struct pa_stream *sample_stream = NULL;
-static struct pa_sample_spec sample_spec;
+static pa_stream *sample_stream = NULL;
+static pa_sample_spec sample_spec;
static size_t sample_length = 0;
static int actions = 1;
@@ -77,12 +77,12 @@ static void quit(int ret) {
}
-static void context_drain_complete(struct pa_context *c, void *userdata) {
+static void context_drain_complete(pa_context *c, void *userdata) {
pa_context_disconnect(c);
}
static void drain(void) {
- struct pa_operation *o;
+ pa_operation *o;
if (!(o = pa_context_drain(context, context_drain_complete, NULL)))
pa_context_disconnect(context);
else
@@ -97,7 +97,7 @@ static void complete_action(void) {
drain();
}
-static void stat_callback(struct pa_context *c, const struct pa_stat_info *i, void *userdata) {
+static void stat_callback(pa_context *c, const pa_stat_info *i, void *userdata) {
char s[128];
if (!i) {
fprintf(stderr, "Failed to get statistics: %s\n", pa_strerror(pa_context_errno(c)));
@@ -117,7 +117,7 @@ static void stat_callback(struct pa_context *c, const struct pa_stat_info *i, vo
complete_action();
}
-static void get_server_info_callback(struct pa_context *c, const struct pa_server_info *i, void *useerdata) {
+static void get_server_info_callback(pa_context *c, const pa_server_info *i, void *useerdata) {
char s[PA_SAMPLE_SPEC_SNPRINT_MAX];
if (!i) {
@@ -148,7 +148,7 @@ static void get_server_info_callback(struct pa_context *c, const struct pa_serve
complete_action();
}
-static void get_sink_info_callback(struct pa_context *c, const struct pa_sink_info *i, int is_last, void *userdata) {
+static void get_sink_info_callback(pa_context *c, const pa_sink_info *i, int is_last, void *userdata) {
char s[PA_SAMPLE_SPEC_SNPRINT_MAX], tid[5];
if (is_last < 0) {
@@ -191,7 +191,7 @@ static void get_sink_info_callback(struct pa_context *c, const struct pa_sink_in
}
-static void get_source_info_callback(struct pa_context *c, const struct pa_source_info *i, int is_last, void *userdata) {
+static void get_source_info_callback(pa_context *c, const pa_source_info *i, int is_last, void *userdata) {
char s[PA_SAMPLE_SPEC_SNPRINT_MAX], t[32], tid[5];
if (is_last < 0) {
@@ -234,7 +234,7 @@ static void get_source_info_callback(struct pa_context *c, const struct pa_sourc
}
-static void get_module_info_callback(struct pa_context *c, const struct pa_module_info *i, int is_last, void *userdata) {
+static void get_module_info_callback(pa_context *c, const pa_module_info *i, int is_last, void *userdata) {
char t[32];
if (is_last < 0) {
@@ -268,7 +268,7 @@ static void get_module_info_callback(struct pa_context *c, const struct pa_modul
i->auto_unload ? "yes" : "no");
}
-static void get_client_info_callback(struct pa_context *c, const struct pa_client_info *i, int is_last, void *userdata) {
+static void get_client_info_callback(pa_context *c, const pa_client_info *i, int is_last, void *userdata) {
char t[32], tid[5];
if (is_last < 0) {
@@ -300,7 +300,7 @@ static void get_client_info_callback(struct pa_context *c, const struct pa_clien
i->owner_module != PA_INVALID_INDEX ? t : "n/a");
}
-static void get_sink_input_info_callback(struct pa_context *c, const struct pa_sink_input_info *i, int is_last, void *userdata) {
+static void get_sink_input_info_callback(pa_context *c, const pa_sink_input_info *i, int is_last, void *userdata) {
char t[32], k[32], s[PA_SAMPLE_SPEC_SNPRINT_MAX], tid[5];
if (is_last < 0) {
@@ -349,7 +349,7 @@ static void get_sink_input_info_callback(struct pa_context *c, const struct pa_s
}
-static void get_source_output_info_callback(struct pa_context *c, const struct pa_source_output_info *i, int is_last, void *userdata) {
+static void get_source_output_info_callback(pa_context *c, const pa_source_output_info *i, int is_last, void *userdata) {
char t[32], k[32], s[PA_SAMPLE_SPEC_SNPRINT_MAX], tid[5];
if (is_last < 0) {
@@ -395,7 +395,7 @@ static void get_source_output_info_callback(struct pa_context *c, const struct p
i->resample_method ? i->resample_method : "n/a");
}
-static void get_sample_info_callback(struct pa_context *c, const struct pa_sample_info *i, int is_last, void *userdata) {
+static void get_sample_info_callback(pa_context *c, const pa_sample_info *i, int is_last, void *userdata) {
char t[32], s[PA_SAMPLE_SPEC_SNPRINT_MAX];
if (is_last < 0) {
@@ -436,7 +436,7 @@ static void get_sample_info_callback(struct pa_context *c, const struct pa_sampl
i->filename ? i->filename : "n/a");
}
-static void get_autoload_info_callback(struct pa_context *c, const struct pa_autoload_info *i, int is_last, void *userdata) {
+static void get_autoload_info_callback(pa_context *c, const pa_autoload_info *i, int is_last, void *userdata) {
if (is_last < 0) {
fprintf(stderr, "Failed to get autoload information: %s\n", pa_strerror(pa_context_errno(c)));
quit(1);
@@ -466,7 +466,7 @@ static void get_autoload_info_callback(struct pa_context *c, const struct pa_aut
i->argument);
}
-static void simple_callback(struct pa_context *c, int success, void *userdata) {
+static void simple_callback(pa_context *c, int success, void *userdata) {
if (!success) {
fprintf(stderr, "Failure: %s\n", pa_strerror(pa_context_errno(c)));
quit(1);
@@ -476,7 +476,7 @@ static void simple_callback(struct pa_context *c, int success, void *userdata) {
complete_action();
}
-static void stream_state_callback(struct pa_stream *s, void *userdata) {
+static void stream_state_callback(pa_stream *s, void *userdata) {
assert(s);
switch (pa_stream_get_state(s)) {
@@ -495,7 +495,7 @@ static void stream_state_callback(struct pa_stream *s, void *userdata) {
}
}
-static void stream_write_callback(struct pa_stream *s, size_t length, void *userdata) {
+static void stream_write_callback(pa_stream *s, size_t length, void *userdata) {
sf_count_t l;
float *d;
assert(s && length && sndfile);
@@ -522,7 +522,7 @@ static void stream_write_callback(struct pa_stream *s, size_t length, void *user
}
}
-static void context_state_callback(struct pa_context *c, void *userdata) {
+static void context_state_callback(pa_context *c, void *userdata) {
assert(c);
switch (pa_context_get_state(c)) {
case PA_CONTEXT_CONNECTING:
@@ -587,7 +587,7 @@ static void context_state_callback(struct pa_context *c, void *userdata) {
}
}
-static void exit_signal_callback(struct pa_mainloop_api *m, struct pa_signal_event *e, int sig, void *userdata) {
+static void exit_signal_callback(pa_mainloop_api *m, pa_signal_event *e, int sig, void *userdata) {
fprintf(stderr, "Got SIGINT, exiting.\n");
quit(0);
}
@@ -610,7 +610,7 @@ static void help(const char *argv0) {
enum { ARG_VERSION = 256 };
int main(int argc, char *argv[]) {
- struct pa_mainloop* m = NULL;
+ pa_mainloop* m = NULL;
char tmp[PATH_MAX];
int ret = 1, r, c;
char *server = NULL, *client_name = NULL, *bn;
diff --git a/polyp/paplay.c b/polyp/paplay.c
index 4ace1973..d9aa71a6 100644
--- a/polyp/paplay.c
+++ b/polyp/paplay.c
@@ -44,9 +44,9 @@
#error Invalid Polypaudio API version
#endif
-static struct pa_context *context = NULL;
-static struct pa_stream *stream = NULL;
-static struct pa_mainloop_api *mainloop_api = NULL;
+static pa_context *context = NULL;
+static pa_stream *stream = NULL;
+static pa_mainloop_api *mainloop_api = NULL;
static char *stream_name = NULL, *client_name = NULL, *device = NULL;
@@ -55,9 +55,9 @@ static pa_volume_t volume = PA_VOLUME_NORM;
static SNDFILE* sndfile = NULL;
-static struct pa_sample_spec sample_spec = { 0, 0, 0 };
+static pa_sample_spec sample_spec = { 0, 0, 0 };
-static sf_count_t (*readf_function)(SNDFILE *sndfile, void *ptr, sf_count_t frames);
+static sf_count_t (*readf_function)(SNDFILE *_sndfile, void *ptr, sf_count_t frames);
/* A shortcut for terminating the application */
static void quit(int ret) {
@@ -66,13 +66,13 @@ static void quit(int ret) {
}
/* Connection draining complete */
-static void context_drain_complete(struct pa_context*c, void *userdata) {
+static void context_drain_complete(pa_context*c, void *userdata) {
pa_context_disconnect(c);
}
/* Stream draining complete */
-static void stream_drain_complete(struct pa_stream*s, int success, void *userdata) {
- struct pa_operation *o;
+static void stream_drain_complete(pa_stream*s, int success, void *userdata) {
+ pa_operation *o;
if (!success) {
fprintf(stderr, "Failed to drain stream: %s\n", pa_strerror(pa_context_errno(context)));
@@ -97,7 +97,7 @@ static void stream_drain_complete(struct pa_stream*s, int success, void *userdat
}
/* This is called whenever new data may be written to the stream */
-static void stream_write_callback(struct pa_stream *s, size_t length, void *userdata) {
+static void stream_write_callback(pa_stream *s, size_t length, void *userdata) {
size_t k;
sf_count_t f, n;
void *data;
@@ -125,7 +125,7 @@ static void stream_write_callback(struct pa_stream *s, size_t length, void *user
}
/* This routine is called whenever the stream state changes */
-static void stream_state_callback(struct pa_stream *s, void *userdata) {
+static void stream_state_callback(pa_stream *s, void *userdata) {
assert(s);
switch (pa_stream_get_state(s)) {
@@ -146,7 +146,7 @@ static void stream_state_callback(struct pa_stream *s, void *userdata) {
}
/* This is called whenever the context status changes */
-static void context_state_callback(struct pa_context *c, void *userdata) {
+static void context_state_callback(pa_context *c, void *userdata) {
assert(c);
switch (pa_context_get_state(c)) {
@@ -183,7 +183,7 @@ static void context_state_callback(struct pa_context *c, void *userdata) {
}
/* UNIX signal to quit recieved */
-static void exit_signal_callback(struct pa_mainloop_api*m, struct pa_signal_event *e, int sig, void *userdata) {
+static void exit_signal_callback(pa_mainloop_api*m, pa_signal_event *e, int sig, void *userdata) {
if (verbose)
fprintf(stderr, "Got SIGINT, exiting.\n");
quit(0);
@@ -211,9 +211,10 @@ enum {
};
int main(int argc, char *argv[]) {
- struct pa_mainloop* m = NULL;
+ pa_mainloop* m = NULL;
int ret = 1, r, c;
- char *bn, *server = NULL, *filename;
+ char *bn, *server = NULL;
+ const char *filename;
SF_INFO sfinfo;
static const struct option long_options[] = {
@@ -312,12 +313,12 @@ int main(int argc, char *argv[]) {
case SF_FORMAT_ULAW:
case SF_FORMAT_ALAW:
sample_spec.format = PA_SAMPLE_S16NE;
- readf_function = (sf_count_t (*)(SNDFILE *sndfile, void *ptr, sf_count_t frames)) sf_readf_short;
+ readf_function = (sf_count_t (*)(SNDFILE *_sndfile, void *ptr, sf_count_t frames)) sf_readf_short;
break;
case SF_FORMAT_FLOAT:
default:
sample_spec.format = PA_SAMPLE_FLOAT32NE;
- readf_function = (sf_count_t (*)(SNDFILE *sndfile, void *ptr, sf_count_t frames)) sf_readf_float;
+ readf_function = (sf_count_t (*)(SNDFILE *_sndfile, void *ptr, sf_count_t frames)) sf_readf_float;
break;
}
diff --git a/polyp/parec-simple.c b/polyp/parec-simple.c
index 130627d7..5f5abe11 100644
--- a/polyp/parec-simple.c
+++ b/polyp/parec-simple.c
@@ -30,6 +30,7 @@
#include <polyp/polyplib-simple.h>
#include <polyp/polyplib-error.h>
+#include "gccmacro.h"
#define BUFSIZE 1024
@@ -47,21 +48,21 @@ static ssize_t loop_write(int fd, const void*data, size_t size) {
break;
ret += r;
- data = (uint8_t*) data + r;
+ data = (const uint8_t*) data + r;
size -= r;
}
return ret;
}
-int main(int argc, char*argv[]) {
+int main(PA_GCC_UNUSED int argc, char*argv[]) {
/* The sample type to use */
- static const struct pa_sample_spec ss = {
+ static const pa_sample_spec ss = {
.format = PA_SAMPLE_S16LE,
.rate = 44100,
.channels = 2
};
- struct pa_simple *s = NULL;
+ pa_simple *s = NULL;
int ret = 1;
int error;
diff --git a/polyp/parseaddr.c b/polyp/parseaddr.c
index 05ed508b..5e4c689c 100644
--- a/polyp/parseaddr.c
+++ b/polyp/parseaddr.c
@@ -63,10 +63,10 @@ static char *parse_host(const char *s, uint16_t *ret_port) {
}
}
-int pa_parse_address(const char *name, struct pa_parsed_address *ret_p) {
+int pa_parse_address(const char *name, pa_parsed_address *ret_p) {
const char *p;
assert(name && ret_p);
- memset(ret_p, 0, sizeof(struct pa_parsed_address));
+ memset(ret_p, 0, sizeof(pa_parsed_address));
ret_p->type = PA_PARSED_ADDRESS_TCP_AUTO;
if (*name == '{') {
diff --git a/polyp/parseaddr.h b/polyp/parseaddr.h
index 5ddc0351..f0efd766 100644
--- a/polyp/parseaddr.h
+++ b/polyp/parseaddr.h
@@ -24,19 +24,19 @@
#include <inttypes.h>
-enum pa_parsed_address_type {
+typedef enum pa_parsed_address_type {
PA_PARSED_ADDRESS_UNIX,
PA_PARSED_ADDRESS_TCP4,
PA_PARSED_ADDRESS_TCP6,
PA_PARSED_ADDRESS_TCP_AUTO
-};
+} pa_parsed_address_type;
-struct pa_parsed_address {
- enum pa_parsed_address_type type;
+typedef struct pa_parsed_address {
+ pa_parsed_address_type type;
char *path_or_host;
uint16_t port;
-};
+} pa_parsed_address;
-int pa_parse_address(const char *a, struct pa_parsed_address *ret_p);
+int pa_parse_address(const char *a, pa_parsed_address *ret_p);
#endif
diff --git a/polyp/pax11publish.c b/polyp/pax11publish.c
index a1cb006a..42947836 100644
--- a/polyp/pax11publish.c
+++ b/polyp/pax11publish.c
@@ -135,17 +135,17 @@ int main(int argc, char *argv[]) {
}
case EXPORT: {
- struct pa_client_conf *c = pa_client_conf_new();
+ pa_client_conf *conf = pa_client_conf_new();
uint8_t cookie[PA_NATIVE_COOKIE_LENGTH];
char hx[PA_NATIVE_COOKIE_LENGTH*2+1];
- assert(c);
+ assert(conf);
- if (pa_client_conf_load(c, NULL) < 0) {
+ if (pa_client_conf_load(conf, NULL) < 0) {
fprintf(stderr, "Failed to load client configuration file.\n");
goto finish;
}
- if (pa_client_conf_env(c) < 0) {
+ if (pa_client_conf_env(conf) < 0) {
fprintf(stderr, "Failed to read environment configuration data.\n");
goto finish;
}
@@ -158,8 +158,8 @@ int main(int argc, char *argv[]) {
if (server)
pa_x11_set_prop(d, "POLYP_SERVER", server);
- else if (c->default_server)
- pa_x11_set_prop(d, "POLYP_SERVER", c->default_server);
+ else if (conf->default_server)
+ pa_x11_set_prop(d, "POLYP_SERVER", conf->default_server);
else {
char hn[256];
if (!pa_get_fqdn(hn, sizeof(hn))) {
@@ -172,15 +172,15 @@ int main(int argc, char *argv[]) {
if (sink)
pa_x11_set_prop(d, "POLYP_SINK", sink);
- else if (c->default_sink)
- pa_x11_set_prop(d, "POLYP_SINK", c->default_sink);
+ else if (conf->default_sink)
+ pa_x11_set_prop(d, "POLYP_SINK", conf->default_sink);
if (source)
pa_x11_set_prop(d, "POLYP_SOURCE", source);
- if (c->default_source)
- pa_x11_set_prop(d, "POLYP_SOURCE", c->default_source);
+ if (conf->default_source)
+ pa_x11_set_prop(d, "POLYP_SOURCE", conf->default_source);
- pa_client_conf_free(c);
+ pa_client_conf_free(conf);
if (pa_authkey_load_auto(cookie_file, cookie, sizeof(cookie)) < 0) {
fprintf(stderr, "Failed to load cookie data\n");
diff --git a/polyp/pdispatch.c b/polyp/pdispatch.c
index 60dd911c..5a50a0d5 100644
--- a/polyp/pdispatch.c
+++ b/polyp/pdispatch.c
@@ -91,21 +91,21 @@ static const char *command_names[PA_COMMAND_MAX] = {
#endif
struct reply_info {
- struct pa_pdispatch *pdispatch;
+ pa_pdispatch *pdispatch;
PA_LLIST_FIELDS(struct reply_info);
- void (*callback)(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
+ pa_pdispatch_callback callback;
void *userdata;
uint32_t tag;
- struct pa_time_event *time_event;
+ pa_time_event *time_event;
};
struct pa_pdispatch {
int ref;
- struct pa_mainloop_api *mainloop;
- const struct pa_pdispatch_command *command_table;
+ pa_mainloop_api *mainloop;
+ const pa_pdispatch_callback *callback_table;
unsigned n_commands;
PA_LLIST_HEAD(struct reply_info, replies);
- void (*drain_callback)(struct pa_pdispatch *pd, void *userdata);
+ pa_pdispatch_drain_callback drain_callback;
void *drain_userdata;
};
@@ -120,25 +120,25 @@ static void reply_info_free(struct reply_info *r) {
pa_xfree(r);
}
-struct pa_pdispatch* pa_pdispatch_new(struct pa_mainloop_api *mainloop, const struct pa_pdispatch_command*table, unsigned entries) {
- struct pa_pdispatch *pd;
+pa_pdispatch* pa_pdispatch_new(pa_mainloop_api *mainloop, const pa_pdispatch_callback*table, unsigned entries) {
+ pa_pdispatch *pd;
assert(mainloop);
assert((entries && table) || (!entries && !table));
- pd = pa_xmalloc(sizeof(struct pa_pdispatch));
+ pd = pa_xmalloc(sizeof(pa_pdispatch));
pd->ref = 1;
pd->mainloop = mainloop;
- pd->command_table = table;
+ pd->callback_table = table;
pd->n_commands = entries;
- PA_LLIST_HEAD_INIT(struct pa_reply_info, pd->replies);
+ PA_LLIST_HEAD_INIT(pa_reply_info, pd->replies);
pd->drain_callback = NULL;
pd->drain_userdata = NULL;
return pd;
}
-void pdispatch_free(struct pa_pdispatch *pd) {
+static void pdispatch_free(pa_pdispatch *pd) {
assert(pd);
while (pd->replies)
@@ -147,8 +147,8 @@ void pdispatch_free(struct pa_pdispatch *pd) {
pa_xfree(pd);
}
-static void run_action(struct pa_pdispatch *pd, struct reply_info *r, uint32_t command, struct pa_tagstruct *ts) {
- void (*callback)(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
+static void run_action(pa_pdispatch *pd, struct reply_info *r, uint32_t command, pa_tagstruct *ts) {
+ pa_pdispatch_callback callback;
void *userdata;
uint32_t tag;
assert(r);
@@ -169,9 +169,9 @@ static void run_action(struct pa_pdispatch *pd, struct reply_info *r, uint32_t c
pa_pdispatch_unref(pd);
}
-int pa_pdispatch_run(struct pa_pdispatch *pd, struct pa_packet*packet, void *userdata) {
+int pa_pdispatch_run(pa_pdispatch *pd, pa_packet*packet, void *userdata) {
uint32_t tag, command;
- struct pa_tagstruct *ts = NULL;
+ pa_tagstruct *ts = NULL;
int ret = -1;
assert(pd && packet && packet->data);
@@ -208,10 +208,10 @@ int pa_pdispatch_run(struct pa_pdispatch *pd, struct pa_packet*packet, void *use
if (r)
run_action(pd, r, command, ts);
- } else if (pd->command_table && (command < pd->n_commands) && pd->command_table[command].proc) {
- const struct pa_pdispatch_command *c = pd->command_table+command;
+ } else if (pd->callback_table && (command < pd->n_commands) && pd->callback_table[command]) {
+ const pa_pdispatch_callback *c = pd->callback_table+command;
- c->proc(pd, command, tag, ts, userdata);
+ (*c)(pd, command, tag, ts, userdata);
} else {
pa_log(__FILE__": Recieved unsupported command %u\n", command);
goto finish;
@@ -228,14 +228,14 @@ finish:
return ret;
}
-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 reply_info*r = userdata;
assert(r && r->time_event == e && r->pdispatch && r->pdispatch->mainloop == m && r->callback);
run_action(r->pdispatch, r, PA_COMMAND_TIMEOUT, NULL);
}
-void pa_pdispatch_register_reply(struct pa_pdispatch *pd, uint32_t tag, int timeout, void (*cb)(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata), void *userdata) {
+void pa_pdispatch_register_reply(pa_pdispatch *pd, uint32_t tag, int timeout, pa_pdispatch_callback cb, void *userdata) {
struct reply_info *r;
struct timeval tv;
assert(pd && pd->ref >= 1 && cb);
@@ -255,13 +255,13 @@ void pa_pdispatch_register_reply(struct pa_pdispatch *pd, uint32_t tag, int time
PA_LLIST_PREPEND(struct reply_info, pd->replies, r);
}
-int pa_pdispatch_is_pending(struct pa_pdispatch *pd) {
+int pa_pdispatch_is_pending(pa_pdispatch *pd) {
assert(pd);
return !!pd->replies;
}
-void pa_pdispatch_set_drain_callback(struct pa_pdispatch *pd, void (*cb)(struct pa_pdispatch *pd, void *userdata), void *userdata) {
+void pa_pdispatch_set_drain_callback(pa_pdispatch *pd, void (*cb)(pa_pdispatch *pd, void *userdata), void *userdata) {
assert(pd);
assert(!cb || pa_pdispatch_is_pending(pd));
@@ -269,7 +269,7 @@ void pa_pdispatch_set_drain_callback(struct pa_pdispatch *pd, void (*cb)(struct
pd->drain_userdata = userdata;
}
-void pa_pdispatch_unregister_reply(struct pa_pdispatch *pd, void *userdata) {
+void pa_pdispatch_unregister_reply(pa_pdispatch *pd, void *userdata) {
struct reply_info *r, *n;
assert(pd);
@@ -281,14 +281,14 @@ void pa_pdispatch_unregister_reply(struct pa_pdispatch *pd, void *userdata) {
}
}
-void pa_pdispatch_unref(struct pa_pdispatch *pd) {
+void pa_pdispatch_unref(pa_pdispatch *pd) {
assert(pd && pd->ref >= 1);
if (!(--(pd->ref)))
pdispatch_free(pd);
}
-struct pa_pdispatch* pa_pdispatch_ref(struct pa_pdispatch *pd) {
+pa_pdispatch* pa_pdispatch_ref(pa_pdispatch *pd) {
assert(pd && pd->ref >= 1);
pd->ref++;
return pd;
diff --git a/polyp/pdispatch.h b/polyp/pdispatch.h
index 571d0fb4..40f5d4c4 100644
--- a/polyp/pdispatch.h
+++ b/polyp/pdispatch.h
@@ -27,25 +27,24 @@
#include "packet.h"
#include "mainloop-api.h"
-struct pa_pdispatch;
+typedef struct pa_pdispatch pa_pdispatch;
-struct pa_pdispatch_command {
- void (*proc)(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
-};
+typedef void (*pa_pdispatch_callback)(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
-struct pa_pdispatch* pa_pdispatch_new(struct pa_mainloop_api *m, const struct pa_pdispatch_command*table, unsigned entries);
-void pa_pdispatch_unref(struct pa_pdispatch *pd);
-struct pa_pdispatch* pa_pdispatch_ref(struct pa_pdispatch *pd);
+pa_pdispatch* pa_pdispatch_new(pa_mainloop_api *m, const pa_pdispatch_callback*table, unsigned entries);
+void pa_pdispatch_unref(pa_pdispatch *pd);
+pa_pdispatch* pa_pdispatch_ref(pa_pdispatch *pd);
-int pa_pdispatch_run(struct pa_pdispatch *pd, struct pa_packet*p, void *userdata);
+int pa_pdispatch_run(pa_pdispatch *pd, pa_packet*p, void *userdata);
-void pa_pdispatch_register_reply(struct pa_pdispatch *pd, uint32_t tag, int timeout, void (*cb)(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata), void *userdata);
+void pa_pdispatch_register_reply(pa_pdispatch *pd, uint32_t tag, int timeout, pa_pdispatch_callback callback, void *userdata);
-int pa_pdispatch_is_pending(struct pa_pdispatch *pd);
+int pa_pdispatch_is_pending(pa_pdispatch *pd);
-void pa_pdispatch_set_drain_callback(struct pa_pdispatch *pd, void (*cb)(struct pa_pdispatch *pd, void *userdata), void *userdata);
+typedef void (*pa_pdispatch_drain_callback)(pa_pdispatch *pd, void *userdata);
+void pa_pdispatch_set_drain_callback(pa_pdispatch *pd, pa_pdispatch_drain_callback callback, void *userdata);
/* Remove all reply slots with the give userdata parameter */
-void pa_pdispatch_unregister_reply(struct pa_pdispatch *pd, void *userdata);
+void pa_pdispatch_unregister_reply(pa_pdispatch *pd, void *userdata);
#endif
diff --git a/polyp/play-memchunk.c b/polyp/play-memchunk.c
index c7a85454..c3db1462 100644
--- a/polyp/play-memchunk.c
+++ b/polyp/play-memchunk.c
@@ -31,11 +31,12 @@
#include "play-memchunk.h"
#include "sink-input.h"
#include "xmalloc.h"
+#include "gccmacro.h"
#define PA_TYPEID_MEMCHUNK PA_TYPEID_MAKE('M', 'C', 'N', 'K')
-static void sink_input_kill(struct pa_sink_input *i) {
- struct pa_memchunk *c;
+static void sink_input_kill(pa_sink_input *i) {
+ pa_memchunk *c;
assert(i && i->userdata);
c = i->userdata;
@@ -47,8 +48,8 @@ static void sink_input_kill(struct pa_sink_input *i) {
}
-static int sink_input_peek(struct pa_sink_input *i, struct pa_memchunk *chunk) {
- struct pa_memchunk *c;
+static int sink_input_peek(pa_sink_input *i, pa_memchunk *chunk) {
+ pa_memchunk *c;
assert(i && chunk && i->userdata);
c = i->userdata;
@@ -62,12 +63,12 @@ static int sink_input_peek(struct pa_sink_input *i, struct pa_memchunk *chunk) {
return 0;
}
-static void si_kill(struct pa_mainloop_api *m, void *i) {
+static void si_kill(PA_GCC_UNUSED pa_mainloop_api *m, void *i) {
sink_input_kill(i);
}
-static void sink_input_drop(struct pa_sink_input *i, const struct pa_memchunk*chunk, size_t length) {
- struct pa_memchunk *c;
+static void sink_input_drop(pa_sink_input *i, const pa_memchunk*chunk, size_t length) {
+ pa_memchunk *c;
assert(i && length && i->userdata);
c = i->userdata;
@@ -81,9 +82,9 @@ static void sink_input_drop(struct pa_sink_input *i, const struct pa_memchunk*ch
pa_mainloop_api_once(i->sink->core->mainloop, si_kill, i);
}
-int pa_play_memchunk(struct pa_sink *sink, const char *name, const struct pa_sample_spec *ss, const struct pa_memchunk *chunk, pa_volume_t volume) {
- struct pa_sink_input *si;
- struct pa_memchunk *nchunk;
+int pa_play_memchunk(pa_sink *sink, const char *name, const pa_sample_spec *ss, const pa_memchunk *chunk, pa_volume_t volume) {
+ pa_sink_input *si;
+ pa_memchunk *nchunk;
assert(sink && chunk);
@@ -98,7 +99,7 @@ int pa_play_memchunk(struct pa_sink *sink, const char *name, const struct pa_sam
si->drop = sink_input_drop;
si->kill = sink_input_kill;
- si->userdata = nchunk = pa_xmalloc(sizeof(struct pa_memchunk));
+ si->userdata = nchunk = pa_xmalloc(sizeof(pa_memchunk));
*nchunk = *chunk;
pa_memblock_ref(chunk->memblock);
diff --git a/polyp/play-memchunk.h b/polyp/play-memchunk.h
index c69165a2..247cc870 100644
--- a/polyp/play-memchunk.h
+++ b/polyp/play-memchunk.h
@@ -25,6 +25,6 @@
#include "sink.h"
#include "memchunk.h"
-int pa_play_memchunk(struct pa_sink *sink, const char *name, const struct pa_sample_spec *ss, const struct pa_memchunk *chunk, pa_volume_t volume);
+int pa_play_memchunk(pa_sink *sink, const char *name, const pa_sample_spec *ss, const pa_memchunk *chunk, pa_volume_t volume);
#endif
diff --git a/polyp/polyplib-browser.c b/polyp/polyplib-browser.c
index 2e75a42d..6fee84a4 100644
--- a/polyp/polyplib-browser.c
+++ b/polyp/polyplib-browser.c
@@ -31,20 +31,20 @@
#define SERVICE_NAME_SOURCE "_polypaudio-source._tcp."
#define SERVICE_NAME_SERVER "_polypaudio-server._tcp."
-struct pa_browser {
+pa_browser {
int ref;
- struct pa_mainloop_api *mainloop;
+ pa_mainloop_api *mainloop;
- void (*callback)(struct pa_browser *z, enum pa_browse_opcode c, const struct pa_browse_info *i, void *userdata);
+ void (*callback)(pa_browser *z, pa_browse_opcode c, const pa_browse_info *i, void *userdata);
void *callback_userdata;
sw_discovery discovery;
- struct pa_io_event *io_event;
+ pa_io_event *io_event;
};
-static void io_callback(struct pa_mainloop_api*a, struct pa_io_event*e, int fd, enum pa_io_event_flags events, void *userdata) {
- struct pa_browser *b = userdata;
+static void io_callback(pa_mainloop_api*a, pa_io_event*e, int fd, pa_io_event_flags events, void *userdata) {
+ pa_browser *b = userdata;
assert(a && b && b->mainloop == a);
if (events != PA_IO_EVENT_INPUT || sw_discovery_read_socket(b->discovery) != SW_OKAY) {
@@ -68,14 +68,14 @@ static sw_result resolve_reply(
sw_ulong text_record_len,
sw_opaque extra) {
- struct pa_browser *b = extra;
- struct pa_browse_info i;
+ pa_browser *b = extra;
+ pa_browse_info i;
char ip[256], a[256];
- enum pa_browse_opcode opcode;
+ pa_browse_opcode opcode;
int device_found = 0;
uint32_t cookie;
pa_typeid_t typeid;
- struct pa_sample_spec ss;
+ pa_sample_spec ss;
int ss_valid = 0;
sw_text_record_iterator iterator;
int free_iterator = 0;
@@ -221,7 +221,7 @@ static sw_result browse_reply(
sw_const_string domain,
sw_opaque extra) {
- struct pa_browser *b = extra;
+ pa_browser *b = extra;
assert(b);
switch (status) {
@@ -236,7 +236,7 @@ static sw_result browse_reply(
case SW_DISCOVERY_BROWSE_REMOVE_SERVICE:
if (b->callback) {
- struct pa_browse_info i;
+ pa_browse_info i;
memset(&i, 0, sizeof(i));
i.name = name;
b->callback(b, PA_BROWSE_REMOVE, &i, b->callback_userdata);
@@ -250,11 +250,11 @@ static sw_result browse_reply(
return SW_OKAY;
}
-struct pa_browser *pa_browser_new(struct pa_mainloop_api *mainloop) {
- struct pa_browser *b;
+pa_browser *pa_browser_new(pa_mainloop_api *mainloop) {
+ pa_browser *b;
sw_discovery_oid oid;
- b = pa_xmalloc(sizeof(struct pa_browser));
+ b = pa_xmalloc(sizeof(pa_browser));
b->mainloop = mainloop;
b->ref = 1;
b->callback = NULL;
@@ -281,7 +281,7 @@ struct pa_browser *pa_browser_new(struct pa_mainloop_api *mainloop) {
return b;
}
-static void browser_free(struct pa_browser *b) {
+static void browser_free(pa_browser *b) {
assert(b && b->mainloop);
if (b->io_event)
@@ -291,20 +291,20 @@ static void browser_free(struct pa_browser *b) {
pa_xfree(b);
}
-struct pa_browser *pa_browser_ref(struct pa_browser *b) {
+pa_browser *pa_browser_ref(pa_browser *b) {
assert(b && b->ref >= 1);
b->ref++;
return b;
}
-void pa_browser_unref(struct pa_browser *b) {
+void pa_browser_unref(pa_browser *b) {
assert(b && b->ref >= 1);
if ((-- (b->ref)) <= 0)
browser_free(b);
}
-void pa_browser_set_callback(struct pa_browser *b, void (*cb)(struct pa_browser *z, enum pa_browse_opcode c, const struct pa_browse_info *i, void* userdata), void *userdata) {
+void pa_browser_set_callback(pa_browser *b, void (*cb)(pa_browser *z, pa_browse_opcode c, const pa_browse_info *i, void* userdata), void *userdata) {
assert(b);
b->callback = cb;
diff --git a/polyp/polyplib-browser.h b/polyp/polyplib-browser.h
index c13eff22..853304d7 100644
--- a/polyp/polyplib-browser.h
+++ b/polyp/polyplib-browser.h
@@ -29,20 +29,20 @@
PA_C_DECL_BEGIN
-struct pa_browser;
+pa_browser;
-enum pa_browse_opcode {
+pa_browse_opcode {
PA_BROWSE_NEW_SERVER,
PA_BROWSE_NEW_SINK,
PA_BROWSE_NEW_SOURCE,
PA_BROWSE_REMOVE
};
-struct pa_browser *pa_browser_new(struct pa_mainloop_api *mainloop);
-struct pa_browser *pa_browser_ref(struct pa_browser *z);
-void pa_browser_unref(struct pa_browser *z);
+pa_browser *pa_browser_new(pa_mainloop_api *mainloop);
+pa_browser *pa_browser_ref(pa_browser *z);
+void pa_browser_unref(pa_browser *z);
-struct pa_browse_info {
+pa_browse_info {
/* Unique service name */
const char *name; /* always available */
@@ -55,10 +55,10 @@ struct pa_browse_info {
const char *device; /* always available when this information is of a sink/source */
const char *description; /* optional */
const pa_typeid_t *typeid; /* optional */
- const struct pa_sample_spec *sample_spec; /* optional */
+ const pa_sample_spec *sample_spec; /* optional */
};
-void pa_browser_set_callback(struct pa_browser *z, void (*cb)(struct pa_browser *z, enum pa_browse_opcode c, const struct pa_browse_info *i, void *userdata), void *userdata);
+void pa_browser_set_callback(pa_browser *z, void (*cb)(pa_browser *z, pa_browse_opcode c, const pa_browse_info *i, void *userdata), void *userdata);
PA_C_DECL_END
diff --git a/polyp/polyplib-context.c b/polyp/polyplib-context.c
index f97d9b82..0cf32490 100644
--- a/polyp/polyplib-context.c
+++ b/polyp/polyplib-context.c
@@ -49,6 +49,7 @@
#include "polyplib-internal.h"
#include "polyplib-context.h"
+#include "polyplib-version.h"
#include "native-common.h"
#include "pdispatch.h"
#include "pstream.h"
@@ -67,14 +68,14 @@
#define AUTOSPAWN_LOCK "autospawn.lock"
-static const struct pa_pdispatch_command command_table[PA_COMMAND_MAX] = {
- [PA_COMMAND_REQUEST] = { pa_command_request },
- [PA_COMMAND_PLAYBACK_STREAM_KILLED] = { pa_command_stream_killed },
- [PA_COMMAND_RECORD_STREAM_KILLED] = { pa_command_stream_killed },
- [PA_COMMAND_SUBSCRIBE_EVENT] = { pa_command_subscribe_event },
+static const pa_pdispatch_callback command_table[PA_COMMAND_MAX] = {
+ [PA_COMMAND_REQUEST] = pa_command_request,
+ [PA_COMMAND_PLAYBACK_STREAM_KILLED] = pa_command_stream_killed,
+ [PA_COMMAND_RECORD_STREAM_KILLED] = pa_command_stream_killed,
+ [PA_COMMAND_SUBSCRIBE_EVENT] = pa_command_subscribe_event
};
-static void unlock_autospawn_lock_file(struct pa_context *c) {
+static void unlock_autospawn_lock_file(pa_context *c) {
assert(c);
if (c->autospawn_lock_fd >= 0) {
@@ -86,11 +87,11 @@ static void unlock_autospawn_lock_file(struct pa_context *c) {
}
}
-struct pa_context *pa_context_new(struct pa_mainloop_api *mainloop, const char *name) {
- struct pa_context *c;
+pa_context *pa_context_new(pa_mainloop_api *mainloop, const char *name) {
+ pa_context *c;
assert(mainloop && name);
- c = pa_xmalloc(sizeof(struct pa_context));
+ c = pa_xmalloc(sizeof(pa_context));
c->ref = 1;
c->name = pa_xstrdup(name);
c->mainloop = mainloop;
@@ -101,8 +102,8 @@ struct pa_context *pa_context_new(struct pa_mainloop_api *mainloop, const char *
c->record_streams = pa_dynarray_new();
assert(c->playback_streams && c->record_streams);
- PA_LLIST_HEAD_INIT(struct pa_stream, c->streams);
- PA_LLIST_HEAD_INIT(struct pa_operation, c->operations);
+ PA_LLIST_HEAD_INIT(pa_stream, c->streams);
+ PA_LLIST_HEAD_INIT(pa_operation, c->operations);
c->error = PA_ERROR_OK;
c->state = PA_CONTEXT_UNCONNECTED;
@@ -136,7 +137,7 @@ struct pa_context *pa_context_new(struct pa_mainloop_api *mainloop, const char *
return c;
}
-static void context_free(struct pa_context *c) {
+static void context_free(pa_context *c) {
assert(c);
unlock_autospawn_lock_file(c);
@@ -173,20 +174,20 @@ static void context_free(struct pa_context *c) {
pa_xfree(c);
}
-struct pa_context* pa_context_ref(struct pa_context *c) {
+pa_context* pa_context_ref(pa_context *c) {
assert(c && c->ref >= 1);
c->ref++;
return c;
}
-void pa_context_unref(struct pa_context *c) {
+void pa_context_unref(pa_context *c) {
assert(c && c->ref >= 1);
if ((--(c->ref)) == 0)
context_free(c);
}
-void pa_context_set_state(struct pa_context *c, enum pa_context_state st) {
+void pa_context_set_state(pa_context *c, pa_context_state st) {
assert(c);
if (c->state == st)
@@ -195,11 +196,11 @@ void pa_context_set_state(struct pa_context *c, enum pa_context_state st) {
pa_context_ref(c);
if (st == PA_CONTEXT_FAILED || st == PA_CONTEXT_TERMINATED) {
- struct pa_stream *s;
+ pa_stream *s;
s = c->streams ? pa_stream_ref(c->streams) : NULL;
while (s) {
- struct pa_stream *n = s->next ? pa_stream_ref(s->next) : NULL;
+ pa_stream *n = s->next ? pa_stream_ref(s->next) : NULL;
pa_stream_set_state(s, st == PA_CONTEXT_FAILED ? PA_STREAM_FAILED : PA_STREAM_TERMINATED);
pa_stream_unref(s);
s = n;
@@ -227,20 +228,20 @@ void pa_context_set_state(struct pa_context *c, enum pa_context_state st) {
pa_context_unref(c);
}
-void pa_context_fail(struct pa_context *c, int error) {
+void pa_context_fail(pa_context *c, int error) {
assert(c);
c->error = error;
pa_context_set_state(c, PA_CONTEXT_FAILED);
}
-static void pstream_die_callback(struct pa_pstream *p, void *userdata) {
- struct pa_context *c = userdata;
+static void pstream_die_callback(pa_pstream *p, void *userdata) {
+ pa_context *c = userdata;
assert(p && c);
pa_context_fail(c, PA_ERROR_CONNECTIONTERMINATED);
}
-static void pstream_packet_callback(struct pa_pstream *p, struct pa_packet *packet, void *userdata) {
- struct pa_context *c = userdata;
+static void pstream_packet_callback(pa_pstream *p, pa_packet *packet, void *userdata) {
+ pa_context *c = userdata;
assert(p && packet && c);
pa_context_ref(c);
@@ -253,9 +254,9 @@ static void pstream_packet_callback(struct pa_pstream *p, struct pa_packet *pack
pa_context_unref(c);
}
-static void pstream_memblock_callback(struct pa_pstream *p, uint32_t channel, uint32_t delta, const struct pa_memchunk *chunk, void *userdata) {
- struct pa_context *c = userdata;
- struct pa_stream *s;
+static void pstream_memblock_callback(pa_pstream *p, uint32_t channel, PA_GCC_UNUSED uint32_t delta, const pa_memchunk *chunk, void *userdata) {
+ pa_context *c = userdata;
+ pa_stream *s;
assert(p && chunk && c && chunk->memblock && chunk->memblock->data);
pa_context_ref(c);
@@ -264,7 +265,7 @@ static void pstream_memblock_callback(struct pa_pstream *p, uint32_t channel, ui
pa_mcalign_push(s->mcalign, chunk);
for (;;) {
- struct pa_memchunk t;
+ pa_memchunk t;
if (pa_mcalign_pop(s->mcalign, &t) < 0)
break;
@@ -281,7 +282,7 @@ static void pstream_memblock_callback(struct pa_pstream *p, uint32_t channel, ui
pa_context_unref(c);
}
-int pa_context_handle_error(struct pa_context *c, uint32_t command, struct pa_tagstruct *t) {
+int pa_context_handle_error(pa_context *c, uint32_t command, pa_tagstruct *t) {
assert(c);
if (command == PA_COMMAND_ERROR) {
@@ -302,8 +303,8 @@ int pa_context_handle_error(struct pa_context *c, uint32_t command, struct pa_ta
return 0;
}
-static void setup_complete_callback(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
- struct pa_context *c = userdata;
+static void setup_complete_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
+ pa_context *c = userdata;
assert(pd && c && (c->state == PA_CONTEXT_AUTHORIZING || c->state == PA_CONTEXT_SETTING_NAME));
pa_context_ref(c);
@@ -319,13 +320,12 @@ static void setup_complete_callback(struct pa_pdispatch *pd, uint32_t command, u
switch(c->state) {
case PA_CONTEXT_AUTHORIZING: {
- struct pa_tagstruct *t;
- t = pa_tagstruct_new(NULL, 0);
- assert(t);
- pa_tagstruct_putu32(t, PA_COMMAND_SET_CLIENT_NAME);
- pa_tagstruct_putu32(t, tag = c->ctag++);
- pa_tagstruct_puts(t, c->name);
- pa_pstream_send_tagstruct(c->pstream, t);
+ pa_tagstruct *reply;
+ reply = pa_tagstruct_new(NULL, 0);
+ pa_tagstruct_putu32(reply, PA_COMMAND_SET_CLIENT_NAME);
+ pa_tagstruct_putu32(reply, tag = c->ctag++);
+ pa_tagstruct_puts(reply, c->name);
+ pa_pstream_send_tagstruct(c->pstream, reply);
pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, setup_complete_callback, c);
pa_context_set_state(c, PA_CONTEXT_SETTING_NAME);
@@ -344,8 +344,8 @@ finish:
pa_context_unref(c);
}
-static void setup_context(struct pa_context *c, struct pa_iochannel *io) {
- struct pa_tagstruct *t;
+static void setup_context(pa_context *c, pa_iochannel *io) {
+ pa_tagstruct *t;
uint32_t tag;
assert(c && io);
@@ -383,15 +383,15 @@ finish:
pa_context_unref(c);
}
-static void on_connection(struct pa_socket_client *client, struct pa_iochannel*io, void *userdata);
+static void on_connection(pa_socket_client *client, pa_iochannel*io, void *userdata);
#ifndef OS_IS_WIN32
-static int context_connect_spawn(struct pa_context *c) {
+static int context_connect_spawn(pa_context *c) {
pid_t pid;
int status, r;
int fds[2] = { -1, -1} ;
- struct pa_iochannel *io;
+ pa_iochannel *io;
pa_context_ref(c);
@@ -423,7 +423,7 @@ static int context_connect_spawn(struct pa_context *c) {
char t[128];
const char *state = NULL;
#define MAX_ARGS 64
- char *argv[MAX_ARGS+1];
+ const char * argv[MAX_ARGS+1];
int n;
/* Not required, since fds[0] has CLOEXEC enabled anyway */
@@ -453,7 +453,7 @@ static int context_connect_spawn(struct pa_context *c) {
argv[n++] = NULL;
- execv(argv[0], argv);
+ execv(argv[0], (char * const *) argv);
_exit(1);
#undef MAX_ARGS
}
@@ -502,7 +502,7 @@ fail:
#endif /* OS_IS_WIN32 */
-static int try_next_connection(struct pa_context *c) {
+static int try_next_connection(pa_context *c) {
char *u = NULL;
int r = -1;
assert(c && !c->client);
@@ -549,8 +549,8 @@ finish:
return r;
}
-static void on_connection(struct pa_socket_client *client, struct pa_iochannel*io, void *userdata) {
- struct pa_context *c = userdata;
+static void on_connection(pa_socket_client *client, pa_iochannel*io, void *userdata) {
+ pa_context *c = userdata;
assert(client && c && c->state == PA_CONTEXT_CONNECTING);
pa_context_ref(c);
@@ -576,7 +576,7 @@ finish:
pa_context_unref(c);
}
-int pa_context_connect(struct pa_context *c, const char *server, int spawn, const struct pa_spawn_api *api) {
+int pa_context_connect(pa_context *c, const char *server, int spawn, const pa_spawn_api *api) {
int r = -1;
assert(c && c->ref >= 1 && c->state == PA_CONTEXT_UNCONNECTED);
@@ -639,28 +639,28 @@ finish:
return r;
}
-void pa_context_disconnect(struct pa_context *c) {
+void pa_context_disconnect(pa_context *c) {
assert(c);
pa_context_set_state(c, PA_CONTEXT_TERMINATED);
}
-enum pa_context_state pa_context_get_state(struct pa_context *c) {
+pa_context_state pa_context_get_state(pa_context *c) {
assert(c && c->ref >= 1);
return c->state;
}
-int pa_context_errno(struct pa_context *c) {
+int pa_context_errno(pa_context *c) {
assert(c && c->ref >= 1);
return c->error;
}
-void pa_context_set_state_callback(struct pa_context *c, void (*cb)(struct pa_context *c, void *userdata), void *userdata) {
+void pa_context_set_state_callback(pa_context *c, void (*cb)(pa_context *c, void *userdata), void *userdata) {
assert(c && c->ref >= 1);
c->state_callback = cb;
c->state_userdata = userdata;
}
-int pa_context_is_pending(struct pa_context *c) {
+int pa_context_is_pending(pa_context *c) {
assert(c && c->ref >= 1);
/* pa_log("pstream: %i\n", pa_pstream_is_pending(c->pstream)); */
@@ -671,17 +671,17 @@ int pa_context_is_pending(struct pa_context *c) {
c->client;
}
-static void set_dispatch_callbacks(struct pa_operation *o);
+static void set_dispatch_callbacks(pa_operation *o);
-static void pdispatch_drain_callback(struct pa_pdispatch*pd, void *userdata) {
+static void pdispatch_drain_callback(PA_GCC_UNUSED pa_pdispatch*pd, void *userdata) {
set_dispatch_callbacks(userdata);
}
-static void pstream_drain_callback(struct pa_pstream *s, void *userdata) {
+static void pstream_drain_callback(PA_GCC_UNUSED pa_pstream *s, void *userdata) {
set_dispatch_callbacks(userdata);
}
-static void set_dispatch_callbacks(struct pa_operation *o) {
+static void set_dispatch_callbacks(pa_operation *o) {
int done = 1;
assert(o && o->context && o->context->ref >= 1 && o->ref >= 1 && o->context->state == PA_CONTEXT_READY);
@@ -702,8 +702,8 @@ static void set_dispatch_callbacks(struct pa_operation *o) {
pa_operation_ref(o);
else {
if (o->callback) {
- void (*cb)(struct pa_context *c, void *userdata);
- cb = (void (*)(struct pa_context*, void*)) o->callback;
+ void (*cb)(pa_context *c, void *userdata);
+ cb = (void (*)(pa_context*, void*)) o->callback;
cb(o->context, o->userdata);
}
@@ -713,8 +713,8 @@ static void set_dispatch_callbacks(struct pa_operation *o) {
pa_operation_unref(o);
}
-struct pa_operation* pa_context_drain(struct pa_context *c, void (*cb) (struct pa_context*c, void *userdata), void *userdata) {
- struct pa_operation *o;
+pa_operation* pa_context_drain(pa_context *c, void (*cb) (pa_context*c, void *userdata), void *userdata) {
+ pa_operation *o;
assert(c && c->ref >= 1);
if (c->state != PA_CONTEXT_READY)
@@ -725,7 +725,7 @@ struct pa_operation* pa_context_drain(struct pa_context *c, void (*cb) (struct p
o = pa_operation_new(c, NULL);
assert(o);
- o->callback = cb;
+ o->callback = (pa_operation_callback) cb;
o->userdata = userdata;
set_dispatch_callbacks(pa_operation_ref(o));
@@ -733,8 +733,8 @@ struct pa_operation* pa_context_drain(struct pa_context *c, void (*cb) (struct p
return o;
}
-void pa_context_exit_daemon(struct pa_context *c) {
- struct pa_tagstruct *t;
+void pa_context_exit_daemon(pa_context *c) {
+ pa_tagstruct *t;
assert(c && c->ref >= 1);
t = pa_tagstruct_new(NULL, 0);
@@ -744,8 +744,8 @@ void pa_context_exit_daemon(struct pa_context *c) {
pa_pstream_send_tagstruct(c->pstream, t);
}
-void pa_context_simple_ack_callback(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
- struct pa_operation *o = userdata;
+void pa_context_simple_ack_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED uint32_t tag, pa_tagstruct *t, void *userdata) {
+ pa_operation *o = userdata;
int success = 1;
assert(pd && o && o->context && o->ref >= 1);
@@ -760,7 +760,7 @@ void pa_context_simple_ack_callback(struct pa_pdispatch *pd, uint32_t command, u
}
if (o->callback) {
- void (*cb)(struct pa_context *c, int success, void *userdata) = o->callback;
+ void (*cb)(pa_context *c, int _success, void *_userdata) = (void (*)(pa_context *c, int _success, void *_userdata)) o->callback;
cb(o->context, success, o->userdata);
}
@@ -769,9 +769,9 @@ finish:
pa_operation_unref(o);
}
-struct pa_operation* pa_context_send_simple_command(struct pa_context *c, uint32_t command, void (*internal_callback)(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata), void (*cb)(), void *userdata) {
- struct pa_tagstruct *t;
- struct pa_operation *o;
+pa_operation* pa_context_send_simple_command(pa_context *c, uint32_t command, void (*internal_callback)(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata), void (*cb)(void), void *userdata) {
+ pa_tagstruct *t;
+ pa_operation *o;
uint32_t tag;
assert(c && cb);
@@ -788,14 +788,14 @@ struct pa_operation* pa_context_send_simple_command(struct pa_context *c, uint32
return pa_operation_ref(o);
}
-struct pa_operation* pa_context_set_default_sink(struct pa_context *c, const char *name, void(*cb)(struct pa_context*c, int success, void *userdata), void *userdata) {
- struct pa_tagstruct *t;
- struct pa_operation *o;
+pa_operation* pa_context_set_default_sink(pa_context *c, const char *name, void(*cb)(pa_context*c, int success, void *userdata), void *userdata) {
+ pa_tagstruct *t;
+ pa_operation *o;
uint32_t tag;
assert(c && cb);
o = pa_operation_new(c, NULL);
- o->callback = cb;
+ o->callback = (pa_operation_callback) cb;
o->userdata = userdata;
t = pa_tagstruct_new(NULL, 0);
@@ -808,14 +808,14 @@ struct pa_operation* pa_context_set_default_sink(struct pa_context *c, const cha
return pa_operation_ref(o);
}
-struct pa_operation* pa_context_set_default_source(struct pa_context *c, const char *name, void(*cb)(struct pa_context*c, int success, void *userdata), void *userdata) {
- struct pa_tagstruct *t;
- struct pa_operation *o;
+pa_operation* pa_context_set_default_source(pa_context *c, const char *name, void(*cb)(pa_context*c, int success, void *userdata), void *userdata) {
+ pa_tagstruct *t;
+ pa_operation *o;
uint32_t tag;
assert(c && cb);
o = pa_operation_new(c, NULL);
- o->callback = cb;
+ o->callback = (pa_operation_callback) cb;
o->userdata = userdata;
t = pa_tagstruct_new(NULL, 0);
@@ -828,19 +828,19 @@ struct pa_operation* pa_context_set_default_source(struct pa_context *c, const c
return pa_operation_ref(o);
}
-int pa_context_is_local(struct pa_context *c) {
+int pa_context_is_local(pa_context *c) {
assert(c);
return c->local;
}
-struct pa_operation* pa_context_set_name(struct pa_context *c, const char *name, void(*cb)(struct pa_context*c, int success, void *userdata), void *userdata) {
- struct pa_tagstruct *t;
- struct pa_operation *o;
+pa_operation* pa_context_set_name(pa_context *c, const char *name, void(*cb)(pa_context*c, int success, void *userdata), void *userdata) {
+ pa_tagstruct *t;
+ pa_operation *o;
uint32_t tag;
assert(c && name && cb);
o = pa_operation_new(c, NULL);
- o->callback = cb;
+ o->callback = (pa_operation_callback) cb;
o->userdata = userdata;
t = pa_tagstruct_new(NULL, 0);
@@ -857,7 +857,7 @@ const char* pa_get_library_version(void) {
return PACKAGE_VERSION;
}
-const char* pa_context_get_server(struct pa_context *c) {
+const char* pa_context_get_server(pa_context *c) {
if (!c->server)
return NULL;
diff --git a/polyp/polyplib-context.h b/polyp/polyplib-context.h
index 0283312a..80c1b601 100644
--- a/polyp/polyplib-context.h
+++ b/polyp/polyplib-context.h
@@ -49,31 +49,33 @@
PA_C_DECL_BEGIN
-/** \struct pa_context
+/** \pa_context
* An opaque connection context to a daemon */
-struct pa_context;
+typedef struct pa_context pa_context;
/** Instantiate a new connection context with an abstract mainloop API
* and an application name */
-struct pa_context *pa_context_new(struct pa_mainloop_api *mainloop, const char *name);
+pa_context *pa_context_new(pa_mainloop_api *mainloop, const char *name);
/** Decrease the reference counter of the context by one */
-void pa_context_unref(struct pa_context *c);
+void pa_context_unref(pa_context *c);
/** Increase the reference counter of the context by one */
-struct pa_context* pa_context_ref(struct pa_context *c);
+pa_context* pa_context_ref(pa_context *c);
+
+typedef void (*pa_context_state_callback)(pa_context *c, void *userdata);
/** Set a callback function that is called whenever the context status changes */
-void pa_context_set_state_callback(struct pa_context *c, void (*cb)(struct pa_context *c, void *userdata), void *userdata);
+void pa_context_set_state_callback(pa_context *c, pa_context_state_callback callback, void *userdata);
/** Return the error number of the last failed operation */
-int pa_context_errno(struct pa_context *c);
+int pa_context_errno(pa_context *c);
/** Return non-zero if some data is pending to be written to the connection */
-int pa_context_is_pending(struct pa_context *c);
+int pa_context_is_pending(pa_context *c);
/** Return the current context status */
-enum pa_context_state pa_context_get_state(struct pa_context *c);
+pa_context_state pa_context_get_state(pa_context *c);
/** Connect the context to the specified server. If server is NULL,
connect to the default server. This routine may but will not always
@@ -82,33 +84,33 @@ be notified when the connection is established. If spawn is non-zero
and no specific server is specified or accessible a new daemon is
spawned. If api is non-NULL, the functions specified in the structure
are used when forking a new child process. */
-int pa_context_connect(struct pa_context *c, const char *server, int spawn, const struct pa_spawn_api *api);
+int pa_context_connect(pa_context *c, const char *server, int spawn, const pa_spawn_api *api);
/** Terminate the context connection immediately */
-void pa_context_disconnect(struct pa_context *c);
+void pa_context_disconnect(pa_context *c);
/** Drain the context. If there is nothing to drain, the function returns NULL */
-struct pa_operation* pa_context_drain(struct pa_context *c, void (*cb) (struct pa_context*c, void *userdata), void *userdata);
+pa_operation* pa_context_drain(pa_context *c, void (*cb) (pa_context*c, void *userdata), void *userdata);
/** Tell the daemon to exit. No operation object is returned as the
* connection is terminated when the daemon quits, thus this operation
* would never complete. */
-void pa_context_exit_daemon(struct pa_context *c);
+void pa_context_exit_daemon(pa_context *c);
/** Set the name of the default sink. \since 0.4 */
-struct pa_operation* pa_context_set_default_sink(struct pa_context *c, const char *name, void(*cb)(struct pa_context*c, int success, void *userdata), void *userdata);
+pa_operation* pa_context_set_default_sink(pa_context *c, const char *name, void(*cb)(pa_context*c, int success, void *userdata), void *userdata);
/** Set the name of the default source. \since 0.4 */
-struct pa_operation* pa_context_set_default_source(struct pa_context *c, const char *name, void(*cb)(struct pa_context*c, int success, void *userdata), void *userdata);
+pa_operation* pa_context_set_default_source(pa_context *c, const char *name, void(*cb)(pa_context*c, int success, void *userdata), void *userdata);
/** Returns 1 when the connection is to a local daemon. Returns negative when no connection has been made yet. \since 0.5 */
-int pa_context_is_local(struct pa_context *c);
+int pa_context_is_local(pa_context *c);
/** Set a different application name for context on the server. \since 0.5 */
-struct pa_operation* pa_context_set_name(struct pa_context *c, const char *name, void(*cb)(struct pa_context*c, int success, void *userdata), void *userdata);
+pa_operation* pa_context_set_name(pa_context *c, const char *name, void(*cb)(pa_context*c, int success, void *userdata), void *userdata);
/** Return the server name this context is connected to. \since 0.7 */
-const char* pa_context_get_server(struct pa_context *c);
+const char* pa_context_get_server(pa_context *c);
PA_C_DECL_END
diff --git a/polyp/polyplib-def.h b/polyp/polyplib-def.h
index 9adb68fc..499282c4 100644
--- a/polyp/polyplib-def.h
+++ b/polyp/polyplib-def.h
@@ -35,7 +35,7 @@
PA_C_DECL_BEGIN
/** The state of a connection context */
-enum pa_context_state {
+typedef enum pa_context_state {
PA_CONTEXT_UNCONNECTED, /**< The context hasn't been connected yet */
PA_CONTEXT_CONNECTING, /**< A connection is being established */
PA_CONTEXT_AUTHORIZING, /**< The client is authorizing itself to the daemon */
@@ -43,37 +43,37 @@ enum pa_context_state {
PA_CONTEXT_READY, /**< The connection is established, the context is ready to execute operations */
PA_CONTEXT_FAILED, /**< The connection failed or was disconnected */
PA_CONTEXT_TERMINATED /**< The connection was terminated cleanly */
-};
+} pa_context_state;
/** The state of a stream */
-enum pa_stream_state {
+typedef enum pa_stream_state {
PA_STREAM_DISCONNECTED, /**< The stream is not yet connected to any sink or source */
PA_STREAM_CREATING, /**< The stream is being created */
PA_STREAM_READY, /**< The stream is established, you may pass audio data to it now */
PA_STREAM_FAILED, /**< An error occured that made the stream invalid */
PA_STREAM_TERMINATED /**< The stream has been terminated cleanly */
-};
+} pa_stream_state;
/** The state of an operation */
-enum pa_operation_state {
+typedef enum pa_operation_state {
PA_OPERATION_RUNNING, /**< The operation is still running */
PA_OPERATION_DONE, /**< The operation has been completed */
PA_OPERATION_CANCELED /**< The operation has been canceled */
-};
+} pa_operation_state;
/** An invalid index */
#define PA_INVALID_INDEX ((uint32_t) -1)
/** The direction of a pa_stream object */
-enum pa_stream_direction {
+typedef enum pa_stream_direction {
PA_STREAM_NODIRECTION, /**< Invalid direction */
PA_STREAM_PLAYBACK, /**< Playback stream */
PA_STREAM_RECORD, /**< Record stream */
PA_STREAM_UPLOAD /**< Sample upload stream */
-};
+} pa_stream_direction;
/** Some special flags for stream connections. \since 0.6 */
-enum pa_stream_flags {
+typedef enum pa_stream_flags {
PA_STREAM_START_CORKED = 1, /**< Create the stream corked, requiring an explicit pa_stream_cork() call to uncork it. */
PA_STREAM_INTERPOLATE_LATENCY = 2 /**< Interpolate the latency for
* this stream. When enabled,
@@ -90,16 +90,16 @@ enum pa_stream_flags {
* information. This is
* especially useful on long latency
* network connections. */
-};
+} pa_stream_flags;
/** Playback and record buffer metrics */
-struct pa_buffer_attr{
+typedef struct pa_buffer_attr {
uint32_t maxlength; /**< Maximum length of the buffer */
uint32_t tlength; /**< Playback only: target length of the buffer. The server tries to assure that at least tlength bytes are always available in the buffer */
uint32_t prebuf; /**< Playback only: pre-buffering. The server does not start with playback before at least prebug bytes are available in the buffer */
uint32_t minreq; /**< Playback only: minimum request. The server does not request less than minreq bytes from the client, instead waints until the buffer is free enough to request more bytes at once */
uint32_t fragsize; /**< Recording only: fragment size. The server sends data in blocks of fragsize bytes size. Large values deminish interactivity with other operations on the connection context but decrease control overhead. */
-};
+} pa_buffer_attr;
/** Error values as used by pa_context_errno(). Use pa_strerror() to convert these values to human readable strings */
enum {
@@ -122,7 +122,7 @@ enum {
};
/** Subscription event mask, as used by pa_context_subscribe() */
-enum pa_subscription_mask {
+typedef enum pa_subscription_mask {
PA_SUBSCRIPTION_MASK_NULL = 0, /**< No events */
PA_SUBSCRIPTION_MASK_SINK = 1, /**< Sink events */
PA_SUBSCRIPTION_MASK_SOURCE = 2, /**< Source events */
@@ -133,10 +133,10 @@ enum pa_subscription_mask {
PA_SUBSCRIPTION_MASK_SAMPLE_CACHE = 64, /**< Sample cache events */
PA_SUBSCRIPTION_MASK_SERVER = 128, /**< Other global server changes. \since 0.4 */
PA_SUBSCRIPTION_MASK_AUTOLOAD = 256 /**< Autoload table events. \since 0.5 */
-};
+} pa_subscription_mask;
/** Subscription event types, as used by pa_context_subscribe() */
-enum pa_subscription_event_type {
+typedef enum pa_subscription_event_type {
PA_SUBSCRIPTION_EVENT_SINK = 0, /**< Event type: Sink */
PA_SUBSCRIPTION_EVENT_SOURCE = 1, /**< Event type: Source */
PA_SUBSCRIPTION_EVENT_SINK_INPUT = 2, /**< Event type: Sink input */
@@ -152,7 +152,7 @@ enum pa_subscription_event_type {
PA_SUBSCRIPTION_EVENT_CHANGE = 16, /**< A property of the object was modified */
PA_SUBSCRIPTION_EVENT_REMOVE = 32, /**< An object was removed */
PA_SUBSCRIPTION_EVENT_TYPE_MASK = 16+32 /**< A mask to extract the event operation from an event value */
-};
+} pa_subscription_event_type;
/** Return one if an event type t matches an event mask bitfield */
#define pa_subscription_match_flags(m, t) (!!((m) & (1 << ((t) & PA_SUBSCRIPTION_EVENT_FACILITY_MASK))))
@@ -170,7 +170,7 @@ enum pa_subscription_event_type {
* source_usec+buffer_usec+transport_usec-sink_usec. (Take care of
* sign issues!) When connected to a monitor source sink_usec contains
* the latency of the owning sink.*/
-struct pa_latency_info {
+typedef struct pa_latency_info {
pa_usec_t buffer_usec; /**< Time in usecs the current buffer takes to play. For both playback and record streams. */
pa_usec_t sink_usec; /**< Time in usecs a sample takes to be played on the sink. For playback streams and record streams connected to a monitor source. */
pa_usec_t source_usec; /**< Time in usecs a sample takes from being recorded to being delivered to the application. Only for record streams. \since 0.5*/
@@ -187,7 +187,7 @@ struct pa_latency_info {
* 0.5 */
struct timeval timestamp; /**< The time when this latency info was current */
uint64_t counter; /**< The byte counter current when the latency info was requested. \since 0.6 */
-};
+} pa_latency_info;
/** A structure for the spawn api. This may be used to integrate auto
* spawned daemons into your application. For more information see
@@ -196,7 +196,7 @@ struct pa_latency_info {
* block or ignore SIGCHLD signals, since this cannot be done in a
* thread compatible way. You might have to do this in
* prefork/postfork. \since 0.4 */
-struct pa_spawn_api {
+typedef struct pa_spawn_api {
void (*prefork)(void); /**< Is called just before the fork in the parent process. May be NULL. */
void (*postfork)(void); /**< Is called immediately after the fork in the parent process. May be NULL.*/
void (*atfork)(void); /**< Is called immediately after the
@@ -206,7 +206,7 @@ struct pa_spawn_api {
* unconditionally, since a UNIX socket
* (created using socketpair()) is
* passed to the new process. */
-};
+} pa_spawn_api;
PA_C_DECL_END
diff --git a/polyp/polyplib-internal.h b/polyp/polyplib-internal.h
index 8677c813..09f9473a 100644
--- a/polyp/polyplib-internal.h
+++ b/polyp/polyplib-internal.h
@@ -43,109 +43,111 @@ struct pa_context {
int ref;
char *name;
- struct pa_mainloop_api* mainloop;
+ pa_mainloop_api* mainloop;
- struct pa_socket_client *client;
- struct pa_pstream *pstream;
- struct pa_pdispatch *pdispatch;
+ pa_socket_client *client;
+ pa_pstream *pstream;
+ pa_pdispatch *pdispatch;
- struct pa_dynarray *record_streams, *playback_streams;
- PA_LLIST_HEAD(struct pa_stream, streams);
- PA_LLIST_HEAD(struct pa_operation, operations);
+ pa_dynarray *record_streams, *playback_streams;
+ PA_LLIST_HEAD(pa_stream, streams);
+ PA_LLIST_HEAD(pa_operation, operations);
uint32_t ctag;
uint32_t error;
- enum pa_context_state state;
+ pa_context_state state;
- void (*state_callback)(struct pa_context*c, void *userdata);
+ void (*state_callback)(pa_context*c, void *userdata);
void *state_userdata;
- void (*subscribe_callback)(struct pa_context *c, enum pa_subscription_event_type t, uint32_t index, void *userdata);
+ void (*subscribe_callback)(pa_context *c, pa_subscription_event_type t, uint32_t idx, void *userdata);
void *subscribe_userdata;
- struct pa_memblock_stat *memblock_stat;
+ pa_memblock_stat *memblock_stat;
int local;
int do_autospawn;
int autospawn_lock_fd;
- struct pa_spawn_api spawn_api;
+ pa_spawn_api spawn_api;
- struct pa_strlist *server_list;
+ pa_strlist *server_list;
char *server;
- struct pa_client_conf *conf;
+ pa_client_conf *conf;
};
struct pa_stream {
int ref;
- struct pa_context *context;
- struct pa_mainloop_api *mainloop;
- PA_LLIST_FIELDS(struct pa_stream);
+ pa_context *context;
+ pa_mainloop_api *mainloop;
+ PA_LLIST_FIELDS(pa_stream);
char *name;
- struct pa_buffer_attr buffer_attr;
- struct pa_sample_spec sample_spec;
+ pa_buffer_attr buffer_attr;
+ pa_sample_spec sample_spec;
uint32_t channel;
int channel_valid;
uint32_t device_index;
- enum pa_stream_direction direction;
+ pa_stream_direction direction;
uint32_t requested_bytes;
uint64_t counter;
pa_usec_t previous_time;
pa_usec_t previous_ipol_time;
- enum pa_stream_state state;
- struct pa_mcalign *mcalign;
+ pa_stream_state state;
+ pa_mcalign *mcalign;
int interpolate;
int corked;
uint32_t ipol_usec;
struct timeval ipol_timestamp;
- struct pa_time_event *ipol_event;
+ pa_time_event *ipol_event;
int ipol_requested;
- void (*state_callback)(struct pa_stream*c, void *userdata);
+ void (*state_callback)(pa_stream*c, void *userdata);
void *state_userdata;
- void (*read_callback)(struct pa_stream *p, const void*data, size_t length, void *userdata);
+ void (*read_callback)(pa_stream *p, const void*data, size_t length, void *userdata);
void *read_userdata;
- void (*write_callback)(struct pa_stream *p, size_t length, void *userdata);
+ void (*write_callback)(pa_stream *p, size_t length, void *userdata);
void *write_userdata;
};
+typedef void (*pa_operation_callback)(void);
+
struct pa_operation {
int ref;
- struct pa_context *context;
- struct pa_stream *stream;
- PA_LLIST_FIELDS(struct pa_operation);
+ pa_context *context;
+ pa_stream *stream;
+ PA_LLIST_FIELDS(pa_operation);
- enum pa_operation_state state;
+ pa_operation_state state;
void *userdata;
- void (*callback)();
+ pa_operation_callback callback;
};
-void pa_command_request(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
-void pa_command_stream_killed(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
-void pa_command_subscribe_event(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
+void pa_command_request(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
+void pa_command_stream_killed(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
+void pa_command_subscribe_event(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
-struct pa_operation *pa_operation_new(struct pa_context *c, struct pa_stream *s);
-void pa_operation_done(struct pa_operation *o);
+pa_operation *pa_operation_new(pa_context *c, pa_stream *s);
+void pa_operation_done(pa_operation *o);
-void pa_create_stream_callback(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
-void pa_stream_disconnect_callback(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
-void pa_context_simple_ack_callback(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
-void pa_stream_simple_ack_callback(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
+void pa_create_stream_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
+void pa_stream_disconnect_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
+void pa_context_simple_ack_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
+void pa_stream_simple_ack_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
-void pa_context_fail(struct pa_context *c, int error);
-void pa_context_set_state(struct pa_context *c, enum pa_context_state st);
-int pa_context_handle_error(struct pa_context *c, uint32_t command, struct pa_tagstruct *t);
-struct pa_operation* pa_context_send_simple_command(struct pa_context *c, uint32_t command, void (*internal_callback)(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata), void (*cb)(), void *userdata);
+void pa_context_fail(pa_context *c, int error);
+void pa_context_set_state(pa_context *c, pa_context_state st);
+int pa_context_handle_error(pa_context *c, uint32_t command, pa_tagstruct *t);
+pa_operation* pa_context_send_simple_command(pa_context *c, uint32_t command, void (*internal_callback)(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata), void (*cb)(void), void *userdata);
-void pa_stream_set_state(struct pa_stream *s, enum pa_stream_state st);
+void pa_stream_set_state(pa_stream *s, pa_stream_state st);
-void pa_stream_trash_ipol(struct pa_stream *s);
+void pa_stream_trash_ipol(pa_stream *s);
#endif
diff --git a/polyp/polyplib-introspect.c b/polyp/polyplib-introspect.c
index 5d6d64ab..91105969 100644
--- a/polyp/polyplib-introspect.c
+++ b/polyp/polyplib-introspect.c
@@ -29,12 +29,13 @@
#include "polyplib-context.h"
#include "polyplib-internal.h"
#include "pstream-util.h"
+#include "gccmacro.h"
/*** Statistics ***/
-static void context_stat_callback(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
- struct pa_operation *o = userdata;
- struct pa_stat_info i, *p = &i;
+static void context_stat_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED uint32_t tag, pa_tagstruct *t, void *userdata) {
+ pa_operation *o = userdata;
+ pa_stat_info i, *p = &i;
assert(pd && o && o->context && o->ref >= 1);
if (command != PA_COMMAND_REPLY) {
@@ -53,7 +54,7 @@ static void context_stat_callback(struct pa_pdispatch *pd, uint32_t command, uin
}
if (o->callback) {
- void (*cb)(struct pa_context *s, const struct pa_stat_info*i, void *userdata) = o->callback;
+ void (*cb)(pa_context *s, const pa_stat_info*_i, void *_userdata) = (void (*)(pa_context *s, const pa_stat_info*_i, void *_userdata)) o->callback;
cb(o->context, p, o->userdata);
}
@@ -62,15 +63,15 @@ finish:
pa_operation_unref(o);
}
-struct pa_operation* pa_context_stat(struct pa_context *c, void (*cb)(struct pa_context *c, const struct pa_stat_info*i, void *userdata), void *userdata) {
- return pa_context_send_simple_command(c, PA_COMMAND_STAT, context_stat_callback, cb, userdata);
+pa_operation* pa_context_stat(pa_context *c, void (*cb)(pa_context *c, const pa_stat_info*i, void *userdata), void *userdata) {
+ return pa_context_send_simple_command(c, PA_COMMAND_STAT, context_stat_callback, (pa_operation_callback) cb, userdata);
}
/*** Server Info ***/
-static void context_get_server_info_callback(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
- struct pa_operation *o = userdata;
- struct pa_server_info i, *p = &i;
+static void context_get_server_info_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED uint32_t tag, pa_tagstruct *t, void *userdata) {
+ pa_operation *o = userdata;
+ pa_server_info i, *p = &i;
assert(pd && o && o->context && o->ref >= 1);
if (command != PA_COMMAND_REPLY) {
@@ -93,7 +94,7 @@ static void context_get_server_info_callback(struct pa_pdispatch *pd, uint32_t c
}
if (o->callback) {
- void (*cb)(struct pa_context *s, const struct pa_server_info*i, void *userdata) = o->callback;
+ void (*cb)(pa_context *s, const pa_server_info*_i, void *_userdata) = (void (*)(pa_context *s, const pa_server_info*_i, void *_userdata)) o->callback;
cb(o->context, p, o->userdata);
}
@@ -102,14 +103,14 @@ finish:
pa_operation_unref(o);
}
-struct pa_operation* pa_context_get_server_info(struct pa_context *c, void (*cb)(struct pa_context *c, const struct pa_server_info*i, void *userdata), void *userdata) {
- return pa_context_send_simple_command(c, PA_COMMAND_GET_SERVER_INFO, context_get_server_info_callback, cb, userdata);
+pa_operation* pa_context_get_server_info(pa_context *c, void (*cb)(pa_context *c, const pa_server_info*i, void *userdata), void *userdata) {
+ return pa_context_send_simple_command(c, PA_COMMAND_GET_SERVER_INFO, context_get_server_info_callback, (pa_operation_callback) cb, userdata);
}
/*** Sink Info ***/
-static void context_get_sink_info_callback(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
- struct pa_operation *o = userdata;
+static void context_get_sink_info_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED uint32_t tag, pa_tagstruct *t, void *userdata) {
+ pa_operation *o = userdata;
int eof = 1;
assert(pd && o && o->context && o->ref >= 1);
@@ -121,7 +122,7 @@ static void context_get_sink_info_callback(struct pa_pdispatch *pd, uint32_t com
} else {
while (!pa_tagstruct_eof(t)) {
- struct pa_sink_info i;
+ pa_sink_info i;
if (pa_tagstruct_getu32(t, &i.index) < 0 ||
pa_tagstruct_gets(t, &i.name) < 0 ||
@@ -139,14 +140,14 @@ static void context_get_sink_info_callback(struct pa_pdispatch *pd, uint32_t com
}
if (o->callback) {
- void (*cb)(struct pa_context *s, const struct pa_sink_info*i, int eof, void *userdata) = o->callback;
+ void (*cb)(pa_context *s, const pa_sink_info*_i, int _eof, void *_userdata) = (void (*)(pa_context *s, const pa_sink_info*_i, int _eof, void *_userdata)) o->callback;
cb(o->context, &i, 0, o->userdata);
}
}
}
if (o->callback) {
- void (*cb)(struct pa_context *s, const struct pa_sink_info*i, int eof, void *userdata) = o->callback;
+ void (*cb)(pa_context *s, const pa_sink_info*_i, int _eof, void *_userdata) = (void (*)(pa_context *s, const pa_sink_info*_i, int _eof, void *_userdata)) o->callback;
cb(o->context, NULL, eof, o->userdata);
}
@@ -155,24 +156,24 @@ finish:
pa_operation_unref(o);
}
-struct pa_operation* pa_context_get_sink_info_list(struct pa_context *c, void (*cb)(struct pa_context *c, const struct pa_sink_info *i, int is_last, void *userdata), void *userdata) {
- return pa_context_send_simple_command(c, PA_COMMAND_GET_SINK_INFO_LIST, context_get_sink_info_callback, cb, userdata);
+pa_operation* pa_context_get_sink_info_list(pa_context *c, void (*cb)(pa_context *c, const pa_sink_info *i, int is_last, void *userdata), void *userdata) {
+ return pa_context_send_simple_command(c, PA_COMMAND_GET_SINK_INFO_LIST, context_get_sink_info_callback, (pa_operation_callback) cb, userdata);
}
-struct pa_operation* pa_context_get_sink_info_by_index(struct pa_context *c, uint32_t index, void (*cb)(struct pa_context *c, const struct pa_sink_info *i, int is_last, void *userdata), void *userdata) {
- struct pa_tagstruct *t;
- struct pa_operation *o;
+pa_operation* pa_context_get_sink_info_by_index(pa_context *c, uint32_t idx, void (*cb)(pa_context *c, const pa_sink_info *i, int is_last, void *userdata), void *userdata) {
+ pa_tagstruct *t;
+ pa_operation *o;
uint32_t tag;
assert(c && cb);
o = pa_operation_new(c, NULL);
- o->callback = cb;
+ o->callback = (pa_operation_callback) cb;
o->userdata = userdata;
t = pa_tagstruct_new(NULL, 0);
pa_tagstruct_putu32(t, PA_COMMAND_GET_SINK_INFO);
pa_tagstruct_putu32(t, tag = c->ctag++);
- pa_tagstruct_putu32(t, index);
+ pa_tagstruct_putu32(t, idx);
pa_tagstruct_puts(t, NULL);
pa_pstream_send_tagstruct(c->pstream, t);
pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, context_get_sink_info_callback, o);
@@ -180,14 +181,14 @@ struct pa_operation* pa_context_get_sink_info_by_index(struct pa_context *c, uin
return pa_operation_ref(o);
}
-struct pa_operation* pa_context_get_sink_info_by_name(struct pa_context *c, const char *name, void (*cb)(struct pa_context *c, const struct pa_sink_info *i, int is_last, void *userdata), void *userdata) {
- struct pa_tagstruct *t;
- struct pa_operation *o;
+pa_operation* pa_context_get_sink_info_by_name(pa_context *c, const char *name, void (*cb)(pa_context *c, const pa_sink_info *i, int is_last, void *userdata), void *userdata) {
+ pa_tagstruct *t;
+ pa_operation *o;
uint32_t tag;
assert(c && cb);
o = pa_operation_new(c, NULL);
- o->callback = cb;
+ o->callback = (pa_operation_callback) cb;
o->userdata = userdata;
t = pa_tagstruct_new(NULL, 0);
@@ -203,8 +204,8 @@ struct pa_operation* pa_context_get_sink_info_by_name(struct pa_context *c, cons
/*** Source info ***/
-static void context_get_source_info_callback(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
- struct pa_operation *o = userdata;
+static void context_get_source_info_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED uint32_t tag, pa_tagstruct *t, void *userdata) {
+ pa_operation *o = userdata;
int eof = 1;
assert(pd && o && o->context && o->ref >= 1);
@@ -216,7 +217,7 @@ static void context_get_source_info_callback(struct pa_pdispatch *pd, uint32_t c
} else {
while (!pa_tagstruct_eof(t)) {
- struct pa_source_info i;
+ pa_source_info i;
if (pa_tagstruct_getu32(t, &i.index) < 0 ||
pa_tagstruct_gets(t, &i.name) < 0 ||
@@ -233,14 +234,14 @@ static void context_get_source_info_callback(struct pa_pdispatch *pd, uint32_t c
}
if (o->callback) {
- void (*cb)(struct pa_context *s, const struct pa_source_info*i, int eof, void *userdata) = o->callback;
+ void (*cb)(pa_context *s, const pa_source_info*_i, int _eof, void *_userdata) = (void (*)(pa_context *s, const pa_source_info*_i, int _eof, void *_userdata)) o->callback;
cb(o->context, &i, 0, o->userdata);
}
}
}
if (o->callback) {
- void (*cb)(struct pa_context *s, const struct pa_source_info*i, int eof, void *userdata) = o->callback;
+ void (*cb)(pa_context *s, const pa_source_info*_i, int _eof, void *_userdata) = (void (*)(pa_context *s, const pa_source_info*_i, int _eof, void *_userdata)) o->callback;
cb(o->context, NULL, eof, o->userdata);
}
@@ -249,24 +250,24 @@ finish:
pa_operation_unref(o);
}
-struct pa_operation* pa_context_get_source_info_list(struct pa_context *c, void (*cb)(struct pa_context *c, const struct pa_source_info *i, int is_last, void *userdata), void *userdata) {
- return pa_context_send_simple_command(c, PA_COMMAND_GET_SOURCE_INFO_LIST, context_get_source_info_callback, cb, userdata);
+pa_operation* pa_context_get_source_info_list(pa_context *c, void (*cb)(pa_context *c, const pa_source_info *i, int is_last, void *userdata), void *userdata) {
+ return pa_context_send_simple_command(c, PA_COMMAND_GET_SOURCE_INFO_LIST, context_get_source_info_callback, (pa_operation_callback) cb, userdata);
}
-struct pa_operation* pa_context_get_source_info_by_index(struct pa_context *c, uint32_t index, void (*cb)(struct pa_context *c, const struct pa_source_info *i, int is_last, void *userdata), void *userdata) {
- struct pa_tagstruct *t;
- struct pa_operation *o;
+pa_operation* pa_context_get_source_info_by_index(pa_context *c, uint32_t idx, void (*cb)(pa_context *c, const pa_source_info *i, int is_last, void *userdata), void *userdata) {
+ pa_tagstruct *t;
+ pa_operation *o;
uint32_t tag;
assert(c && cb);
o = pa_operation_new(c, NULL);
- o->callback = cb;
+ o->callback = (pa_operation_callback) cb;
o->userdata = userdata;
t = pa_tagstruct_new(NULL, 0);
pa_tagstruct_putu32(t, PA_COMMAND_GET_SOURCE_INFO);
pa_tagstruct_putu32(t, tag = c->ctag++);
- pa_tagstruct_putu32(t, index);
+ pa_tagstruct_putu32(t, idx);
pa_tagstruct_puts(t, NULL);
pa_pstream_send_tagstruct(c->pstream, t);
pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, context_get_source_info_callback, o);
@@ -274,14 +275,14 @@ struct pa_operation* pa_context_get_source_info_by_index(struct pa_context *c, u
return pa_operation_ref(o);
}
-struct pa_operation* pa_context_get_source_info_by_name(struct pa_context *c, const char *name, void (*cb)(struct pa_context *c, const struct pa_source_info *i, int is_last, void *userdata), void *userdata) {
- struct pa_tagstruct *t;
- struct pa_operation *o;
+pa_operation* pa_context_get_source_info_by_name(pa_context *c, const char *name, void (*cb)(pa_context *c, const pa_source_info *i, int is_last, void *userdata), void *userdata) {
+ pa_tagstruct *t;
+ pa_operation *o;
uint32_t tag;
assert(c && cb);
o = pa_operation_new(c, NULL);
- o->callback = cb;
+ o->callback = (pa_operation_callback) cb;
o->userdata = userdata;
t = pa_tagstruct_new(NULL, 0);
@@ -297,8 +298,8 @@ struct pa_operation* pa_context_get_source_info_by_name(struct pa_context *c, co
/*** Client info ***/
-static void context_get_client_info_callback(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
- struct pa_operation *o = userdata;
+static void context_get_client_info_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED uint32_t tag, pa_tagstruct *t, void *userdata) {
+ pa_operation *o = userdata;
int eof = 1;
assert(pd && o && o->context && o->ref >= 1);
@@ -310,7 +311,7 @@ static void context_get_client_info_callback(struct pa_pdispatch *pd, uint32_t c
} else {
while (!pa_tagstruct_eof(t)) {
- struct pa_client_info i;
+ pa_client_info i;
if (pa_tagstruct_getu32(t, &i.index) < 0 ||
pa_tagstruct_gets(t, &i.name) < 0 ||
@@ -321,14 +322,14 @@ static void context_get_client_info_callback(struct pa_pdispatch *pd, uint32_t c
}
if (o->callback) {
- void (*cb)(struct pa_context *s, const struct pa_client_info*i, int eof, void *userdata) = o->callback;
+ void (*cb)(pa_context *s, const pa_client_info*_i, int _eof, void *_userdata) = (void (*)(pa_context *s, const pa_client_info*_i, int _eof, void *_userdata)) o->callback;
cb(o->context, &i, 0, o->userdata);
}
}
}
if (o->callback) {
- void (*cb)(struct pa_context *s, const struct pa_client_info*i, int eof, void *userdata) = o->callback;
+ void (*cb)(pa_context *s, const pa_client_info*_i, int _eof, void *_userdata) = (void (*)(pa_context *s, const pa_client_info*_i, int _eof, void *_userdata)) o->callback;
cb(o->context, NULL, eof, o->userdata);
}
@@ -337,34 +338,34 @@ finish:
pa_operation_unref(o);
}
-struct pa_operation* pa_context_get_client_info(struct pa_context *c, uint32_t index, void (*cb)(struct pa_context *c, const struct pa_client_info*i, int is_last, void *userdata), void *userdata) {
- struct pa_tagstruct *t;
- struct pa_operation *o;
+pa_operation* pa_context_get_client_info(pa_context *c, uint32_t idx, void (*cb)(pa_context *c, const pa_client_info*i, int is_last, void *userdata), void *userdata) {
+ pa_tagstruct *t;
+ pa_operation *o;
uint32_t tag;
assert(c && cb);
o = pa_operation_new(c, NULL);
- o->callback = cb;
+ o->callback = (pa_operation_callback) cb;
o->userdata = userdata;
t = pa_tagstruct_new(NULL, 0);
pa_tagstruct_putu32(t, PA_COMMAND_GET_CLIENT_INFO);
pa_tagstruct_putu32(t, tag = c->ctag++);
- pa_tagstruct_putu32(t, index);
+ pa_tagstruct_putu32(t, idx);
pa_pstream_send_tagstruct(c->pstream, t);
pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, context_get_client_info_callback, o);
return pa_operation_ref(o);
}
-struct pa_operation* pa_context_get_client_info_list(struct pa_context *c, void (*cb)(struct pa_context *c, const struct pa_client_info*i, int is_last, void *userdata), void *userdata) {
- return pa_context_send_simple_command(c, PA_COMMAND_GET_CLIENT_INFO_LIST, context_get_client_info_callback, cb, userdata);
+pa_operation* pa_context_get_client_info_list(pa_context *c, void (*cb)(pa_context *c, const pa_client_info*i, int is_last, void *userdata), void *userdata) {
+ return pa_context_send_simple_command(c, PA_COMMAND_GET_CLIENT_INFO_LIST, context_get_client_info_callback, (pa_operation_callback) cb, userdata);
}
/*** Module info ***/
-static void context_get_module_info_callback(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
- struct pa_operation *o = userdata;
+static void context_get_module_info_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED uint32_t tag, pa_tagstruct *t, void *userdata) {
+ pa_operation *o = userdata;
int eof = 1;
assert(pd && o && o->context && o->ref >= 1);
@@ -376,7 +377,7 @@ static void context_get_module_info_callback(struct pa_pdispatch *pd, uint32_t c
} else {
while (!pa_tagstruct_eof(t)) {
- struct pa_module_info i;
+ pa_module_info i;
if (pa_tagstruct_getu32(t, &i.index) < 0 ||
pa_tagstruct_gets(t, &i.name) < 0 ||
@@ -388,14 +389,14 @@ static void context_get_module_info_callback(struct pa_pdispatch *pd, uint32_t c
}
if (o->callback) {
- void (*cb)(struct pa_context *s, const struct pa_module_info*i, int eof, void *userdata) = o->callback;
+ void (*cb)(pa_context *s, const pa_module_info*_i, int _eof, void *_userdata) = (void (*)(pa_context *s, const pa_module_info*_i, int _eof, void *_userdata)) o->callback;
cb(o->context, &i, 0, o->userdata);
}
}
}
if (o->callback) {
- void (*cb)(struct pa_context *s, const struct pa_module_info*i, int eof, void *userdata) = o->callback;
+ void (*cb)(pa_context *s, const pa_module_info*_i, int _eof, void *_userdata) = (void (*)(pa_context *s, const pa_module_info*_i, int _eof, void *_userdata)) o->callback;
cb(o->context, NULL, eof, o->userdata);
}
@@ -404,34 +405,34 @@ finish:
pa_operation_unref(o);
}
-struct pa_operation* pa_context_get_module_info(struct pa_context *c, uint32_t index, void (*cb)(struct pa_context *c, const struct pa_module_info*i, int is_last, void *userdata), void *userdata) {
- struct pa_tagstruct *t;
- struct pa_operation *o;
+pa_operation* pa_context_get_module_info(pa_context *c, uint32_t idx, void (*cb)(pa_context *c, const pa_module_info*i, int is_last, void *userdata), void *userdata) {
+ pa_tagstruct *t;
+ pa_operation *o;
uint32_t tag;
assert(c && cb);
o = pa_operation_new(c, NULL);
- o->callback = cb;
+ o->callback = (pa_operation_callback) cb;
o->userdata = userdata;
t = pa_tagstruct_new(NULL, 0);
pa_tagstruct_putu32(t, PA_COMMAND_GET_MODULE_INFO);
pa_tagstruct_putu32(t, tag = c->ctag++);
- pa_tagstruct_putu32(t, index);
+ pa_tagstruct_putu32(t, idx);
pa_pstream_send_tagstruct(c->pstream, t);
pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, context_get_module_info_callback, o);
return pa_operation_ref(o);
}
-struct pa_operation* pa_context_get_module_info_list(struct pa_context *c, void (*cb)(struct pa_context *c, const struct pa_module_info*i, int is_last, void *userdata), void *userdata) {
- return pa_context_send_simple_command(c, PA_COMMAND_GET_MODULE_INFO_LIST, context_get_module_info_callback, cb, userdata);
+pa_operation* pa_context_get_module_info_list(pa_context *c, void (*cb)(pa_context *c, const pa_module_info*i, int is_last, void *userdata), void *userdata) {
+ return pa_context_send_simple_command(c, PA_COMMAND_GET_MODULE_INFO_LIST, context_get_module_info_callback, (pa_operation_callback) cb, userdata);
}
/*** Sink input info ***/
-static void context_get_sink_input_info_callback(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
- struct pa_operation *o = userdata;
+static void context_get_sink_input_info_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED uint32_t tag, pa_tagstruct *t, void *userdata) {
+ pa_operation *o = userdata;
int eof = 1;
assert(pd && o && o->context && o->ref >= 1);
@@ -443,7 +444,7 @@ static void context_get_sink_input_info_callback(struct pa_pdispatch *pd, uint32
} else {
while (!pa_tagstruct_eof(t)) {
- struct pa_sink_input_info i;
+ pa_sink_input_info i;
if (pa_tagstruct_getu32(t, &i.index) < 0 ||
pa_tagstruct_gets(t, &i.name) < 0 ||
@@ -462,14 +463,14 @@ static void context_get_sink_input_info_callback(struct pa_pdispatch *pd, uint32
}
if (o->callback) {
- void (*cb)(struct pa_context *s, const struct pa_sink_input_info*i, int eof, void *userdata) = o->callback;
+ void (*cb)(pa_context *s, const pa_sink_input_info*_i, int _eof, void *_userdata) = (void (*)(pa_context *s, const pa_sink_input_info*_i, int _eof, void *_userdata)) o->callback;
cb(o->context, &i, 0, o->userdata);
}
}
}
if (o->callback) {
- void (*cb)(struct pa_context *s, const struct pa_sink_input_info*i, int eof, void *userdata) = o->callback;
+ void (*cb)(pa_context *s, const pa_sink_input_info*_i, int _eof, void *_userdata) = (void (*)(pa_context *s, const pa_sink_input_info*_i, int _eof, void *_userdata)) o->callback;
cb(o->context, NULL, eof, o->userdata);
}
@@ -478,34 +479,34 @@ finish:
pa_operation_unref(o);
}
-struct pa_operation* pa_context_get_sink_input_info(struct pa_context *c, uint32_t index, void (*cb)(struct pa_context *c, const struct pa_sink_input_info*i, int is_last, void *userdata), void *userdata) {
- struct pa_tagstruct *t;
- struct pa_operation *o;
+pa_operation* pa_context_get_sink_input_info(pa_context *c, uint32_t idx, void (*cb)(pa_context *c, const pa_sink_input_info*i, int is_last, void *userdata), void *userdata) {
+ pa_tagstruct *t;
+ pa_operation *o;
uint32_t tag;
assert(c && cb);
o = pa_operation_new(c, NULL);
- o->callback = cb;
+ o->callback = (pa_operation_callback) cb;
o->userdata = userdata;
t = pa_tagstruct_new(NULL, 0);
pa_tagstruct_putu32(t, PA_COMMAND_GET_SINK_INPUT_INFO);
pa_tagstruct_putu32(t, tag = c->ctag++);
- pa_tagstruct_putu32(t, index);
+ pa_tagstruct_putu32(t, idx);
pa_pstream_send_tagstruct(c->pstream, t);
pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, context_get_sink_input_info_callback, o);
return pa_operation_ref(o);
}
-struct pa_operation* pa_context_get_sink_input_info_list(struct pa_context *c, void (*cb)(struct pa_context *c, const struct pa_sink_input_info*i, int is_last, void *userdata), void *userdata) {
- return pa_context_send_simple_command(c, PA_COMMAND_GET_SINK_INPUT_INFO_LIST, context_get_sink_input_info_callback, cb, userdata);
+pa_operation* pa_context_get_sink_input_info_list(pa_context *c, void (*cb)(pa_context *c, const pa_sink_input_info*i, int is_last, void *userdata), void *userdata) {
+ return pa_context_send_simple_command(c, PA_COMMAND_GET_SINK_INPUT_INFO_LIST, context_get_sink_input_info_callback, (pa_operation_callback) cb, userdata);
}
/*** Source output info ***/
-static void context_get_source_output_info_callback(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
- struct pa_operation *o = userdata;
+static void context_get_source_output_info_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED uint32_t tag, pa_tagstruct *t, void *userdata) {
+ pa_operation *o = userdata;
int eof = 1;
assert(pd && o && o->context && o->ref >= 1);
@@ -517,7 +518,7 @@ static void context_get_source_output_info_callback(struct pa_pdispatch *pd, uin
} else {
while (!pa_tagstruct_eof(t)) {
- struct pa_source_output_info i;
+ pa_source_output_info i;
if (pa_tagstruct_getu32(t, &i.index) < 0 ||
pa_tagstruct_gets(t, &i.name) < 0 ||
@@ -535,14 +536,14 @@ static void context_get_source_output_info_callback(struct pa_pdispatch *pd, uin
}
if (o->callback) {
- void (*cb)(struct pa_context *s, const struct pa_source_output_info*i, int eof, void *userdata) = o->callback;
+ void (*cb)(pa_context *s, const pa_source_output_info*_i, int _eof, void *_userdata) = (void (*)(pa_context *s, const pa_source_output_info*_i, int _eof, void *_userdata)) o->callback;
cb(o->context, &i, 0, o->userdata);
}
}
}
if (o->callback) {
- void (*cb)(struct pa_context *s, const struct pa_source_output_info*i, int eof, void *userdata) = o->callback;
+ void (*cb)(pa_context *s, const pa_source_output_info*_i, int _eof, void *_userdata) = (void (*)(pa_context *s, const pa_source_output_info*_i, int _eof, void *_userdata))o->callback;
cb(o->context, NULL, eof, o->userdata);
}
@@ -551,46 +552,46 @@ finish:
pa_operation_unref(o);
}
-struct pa_operation* pa_context_get_source_output_info(struct pa_context *c, uint32_t index, void (*cb)(struct pa_context *c, const struct pa_source_output_info*i, int is_last, void *userdata), void *userdata) {
- struct pa_tagstruct *t;
- struct pa_operation *o;
+pa_operation* pa_context_get_source_output_info(pa_context *c, uint32_t idx, void (*cb)(pa_context *c, const pa_source_output_info*i, int is_last, void *userdata), void *userdata) {
+ pa_tagstruct *t;
+ pa_operation *o;
uint32_t tag;
assert(c && cb);
o = pa_operation_new(c, NULL);
- o->callback = cb;
+ o->callback = (pa_operation_callback) cb;
o->userdata = userdata;
t = pa_tagstruct_new(NULL, 0);
pa_tagstruct_putu32(t, PA_COMMAND_GET_SOURCE_OUTPUT_INFO);
pa_tagstruct_putu32(t, tag = c->ctag++);
- pa_tagstruct_putu32(t, index);
+ pa_tagstruct_putu32(t, idx);
pa_pstream_send_tagstruct(c->pstream, t);
pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, context_get_source_output_info_callback, o);
return pa_operation_ref(o);
}
-struct pa_operation* pa_context_get_source_output_info_list(struct pa_context *c, void (*cb)(struct pa_context *c, const struct pa_source_output_info*i, int is_last, void *userdata), void *userdata) {
- return pa_context_send_simple_command(c, PA_COMMAND_GET_SOURCE_OUTPUT_INFO_LIST, context_get_source_output_info_callback, cb, userdata);
+pa_operation* pa_context_get_source_output_info_list(pa_context *c, void (*cb)(pa_context *c, const pa_source_output_info*i, int is_last, void *userdata), void *userdata) {
+ return pa_context_send_simple_command(c, PA_COMMAND_GET_SOURCE_OUTPUT_INFO_LIST, context_get_source_output_info_callback, (pa_operation_callback) cb, userdata);
}
/*** Volume manipulation ***/
-struct pa_operation* pa_context_set_sink_volume_by_index(struct pa_context *c, uint32_t index, pa_volume_t volume, void (*cb)(struct pa_context *c, int success, void *userdata), void *userdata) {
- struct pa_operation *o;
- struct pa_tagstruct *t;
+pa_operation* pa_context_set_sink_volume_by_index(pa_context *c, uint32_t idx, pa_volume_t volume, void (*cb)(pa_context *c, int success, void *userdata), void *userdata) {
+ pa_operation *o;
+ pa_tagstruct *t;
uint32_t tag;
- assert(c && index != PA_INVALID_INDEX);
+ assert(c && idx != PA_INVALID_INDEX);
o = pa_operation_new(c, NULL);
- o->callback = cb;
+ o->callback = (pa_operation_callback) cb;
o->userdata = userdata;
t = pa_tagstruct_new(NULL, 0);
pa_tagstruct_putu32(t, PA_COMMAND_SET_SINK_VOLUME);
pa_tagstruct_putu32(t, tag = c->ctag++);
- pa_tagstruct_putu32(t, index);
+ pa_tagstruct_putu32(t, idx);
pa_tagstruct_puts(t, NULL);
pa_tagstruct_putu32(t, volume);
pa_pstream_send_tagstruct(c->pstream, t);
@@ -599,14 +600,14 @@ struct pa_operation* pa_context_set_sink_volume_by_index(struct pa_context *c, u
return pa_operation_ref(o);
}
-struct pa_operation* pa_context_set_sink_volume_by_name(struct pa_context *c, const char *name, pa_volume_t volume, void (*cb)(struct pa_context *c, int success, void *userdata), void *userdata) {
- struct pa_operation *o;
- struct pa_tagstruct *t;
+pa_operation* pa_context_set_sink_volume_by_name(pa_context *c, const char *name, pa_volume_t volume, void (*cb)(pa_context *c, int success, void *userdata), void *userdata) {
+ pa_operation *o;
+ pa_tagstruct *t;
uint32_t tag;
assert(c && name);
o = pa_operation_new(c, NULL);
- o->callback = cb;
+ o->callback = (pa_operation_callback) cb;
o->userdata = userdata;
t = pa_tagstruct_new(NULL, 0);
@@ -621,20 +622,20 @@ struct pa_operation* pa_context_set_sink_volume_by_name(struct pa_context *c, co
return pa_operation_ref(o);
}
-struct pa_operation* pa_context_set_sink_input_volume(struct pa_context *c, uint32_t index, pa_volume_t volume, void (*cb)(struct pa_context *c, int success, void *userdata), void *userdata) {
- struct pa_operation *o;
- struct pa_tagstruct *t;
+pa_operation* pa_context_set_sink_input_volume(pa_context *c, uint32_t idx, pa_volume_t volume, void (*cb)(pa_context *c, int success, void *userdata), void *userdata) {
+ pa_operation *o;
+ pa_tagstruct *t;
uint32_t tag;
- assert(c && index != PA_INVALID_INDEX);
+ assert(c && idx != PA_INVALID_INDEX);
o = pa_operation_new(c, NULL);
- o->callback = cb;
+ o->callback = (pa_operation_callback) cb;
o->userdata = userdata;
t = pa_tagstruct_new(NULL, 0);
pa_tagstruct_putu32(t, PA_COMMAND_SET_SINK_INPUT_VOLUME);
pa_tagstruct_putu32(t, tag = c->ctag++);
- pa_tagstruct_putu32(t, index);
+ pa_tagstruct_putu32(t, idx);
pa_tagstruct_putu32(t, volume);
pa_pstream_send_tagstruct(c->pstream, t);
pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, o);
@@ -644,8 +645,8 @@ struct pa_operation* pa_context_set_sink_input_volume(struct pa_context *c, uint
/** Sample Cache **/
-static void context_get_sample_info_callback(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
- struct pa_operation *o = userdata;
+static void context_get_sample_info_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED uint32_t tag, pa_tagstruct *t, void *userdata) {
+ pa_operation *o = userdata;
int eof = 1;
assert(pd && o && o->context && o->ref >= 1);
@@ -657,7 +658,7 @@ static void context_get_sample_info_callback(struct pa_pdispatch *pd, uint32_t c
} else {
while (!pa_tagstruct_eof(t)) {
- struct pa_sample_info i;
+ pa_sample_info i;
if (pa_tagstruct_getu32(t, &i.index) < 0 ||
pa_tagstruct_gets(t, &i.name) < 0 ||
@@ -673,14 +674,14 @@ static void context_get_sample_info_callback(struct pa_pdispatch *pd, uint32_t c
}
if (o->callback) {
- void (*cb)(struct pa_context *s, const struct pa_sample_info*i, int eof, void *userdata) = o->callback;
+ void (*cb)(pa_context *s, const pa_sample_info*_i, int _eof, void *_userdata) = (void (*)(pa_context *s, const pa_sample_info*_i, int _eof, void *_userdata)) o->callback;
cb(o->context, &i, 0, o->userdata);
}
}
}
if (o->callback) {
- void (*cb)(struct pa_context *s, const struct pa_sample_info*i, int eof, void *userdata) = o->callback;
+ void (*cb)(pa_context *s, const pa_sample_info*_i, int _eof, void *_userdata) = (void (*)(pa_context *s, const pa_sample_info*_i, int _eof, void *_userdata)) o->callback;
cb(o->context, NULL, eof, o->userdata);
}
@@ -689,14 +690,14 @@ finish:
pa_operation_unref(o);
}
-struct pa_operation* pa_context_get_sample_info_by_name(struct pa_context *c, const char *name, void (*cb)(struct pa_context *c, const struct pa_sample_info *i, int is_last, void *userdata), void *userdata) {
- struct pa_tagstruct *t;
- struct pa_operation *o;
+pa_operation* pa_context_get_sample_info_by_name(pa_context *c, const char *name, void (*cb)(pa_context *c, const pa_sample_info *i, int is_last, void *userdata), void *userdata) {
+ pa_tagstruct *t;
+ pa_operation *o;
uint32_t tag;
assert(c && cb && name);
o = pa_operation_new(c, NULL);
- o->callback = cb;
+ o->callback = (pa_operation_callback) cb;
o->userdata = userdata;
t = pa_tagstruct_new(NULL, 0);
@@ -710,20 +711,20 @@ struct pa_operation* pa_context_get_sample_info_by_name(struct pa_context *c, co
return pa_operation_ref(o);
}
-struct pa_operation* pa_context_get_sample_info_by_index(struct pa_context *c, uint32_t index, void (*cb)(struct pa_context *c, const struct pa_sample_info *i, int is_last, void *userdata), void *userdata) {
- struct pa_tagstruct *t;
- struct pa_operation *o;
+pa_operation* pa_context_get_sample_info_by_index(pa_context *c, uint32_t idx, void (*cb)(pa_context *c, const pa_sample_info *i, int is_last, void *userdata), void *userdata) {
+ pa_tagstruct *t;
+ pa_operation *o;
uint32_t tag;
assert(c && cb);
o = pa_operation_new(c, NULL);
- o->callback = cb;
+ o->callback = (pa_operation_callback) cb;
o->userdata = userdata;
t = pa_tagstruct_new(NULL, 0);
pa_tagstruct_putu32(t, PA_COMMAND_GET_SAMPLE_INFO);
pa_tagstruct_putu32(t, tag = c->ctag++);
- pa_tagstruct_putu32(t, index);
+ pa_tagstruct_putu32(t, idx);
pa_tagstruct_puts(t, NULL);
pa_pstream_send_tagstruct(c->pstream, t);
pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, context_get_sample_info_callback, o);
@@ -731,60 +732,60 @@ struct pa_operation* pa_context_get_sample_info_by_index(struct pa_context *c, u
return pa_operation_ref(o);
}
-struct pa_operation* pa_context_get_sample_info_list(struct pa_context *c, void (*cb)(struct pa_context *c, const struct pa_sample_info *i, int is_last, void *userdata), void *userdata) {
- return pa_context_send_simple_command(c, PA_COMMAND_GET_SAMPLE_INFO_LIST, context_get_sample_info_callback, cb, userdata);
+pa_operation* pa_context_get_sample_info_list(pa_context *c, void (*cb)(pa_context *c, const pa_sample_info *i, int is_last, void *userdata), void *userdata) {
+ return pa_context_send_simple_command(c, PA_COMMAND_GET_SAMPLE_INFO_LIST, context_get_sample_info_callback, (pa_operation_callback) cb, userdata);
}
-static struct pa_operation* command_kill(struct pa_context *c, uint32_t command, uint32_t index, void (*cb)(struct pa_context *c, int success, void *userdata), void *userdata) {
- struct pa_operation *o;
- struct pa_tagstruct *t;
+static pa_operation* command_kill(pa_context *c, uint32_t command, uint32_t idx, void (*cb)(pa_context *c, int success, void *userdata), void *userdata) {
+ pa_operation *o;
+ pa_tagstruct *t;
uint32_t tag;
- assert(c && index != PA_INVALID_INDEX);
+ assert(c && idx != PA_INVALID_INDEX);
o = pa_operation_new(c, NULL);
- o->callback = cb;
+ o->callback = (pa_operation_callback) cb;
o->userdata = userdata;
t = pa_tagstruct_new(NULL, 0);
pa_tagstruct_putu32(t, command);
pa_tagstruct_putu32(t, tag = c->ctag++);
- pa_tagstruct_putu32(t, index);
+ pa_tagstruct_putu32(t, idx);
pa_pstream_send_tagstruct(c->pstream, t);
pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, o);
return pa_operation_ref(o);
}
-struct pa_operation* pa_context_kill_client(struct pa_context *c, uint32_t index, void (*cb)(struct pa_context *c, int success, void *userdata), void *userdata) {
- return command_kill(c, PA_COMMAND_KILL_CLIENT, index, cb, userdata);
+pa_operation* pa_context_kill_client(pa_context *c, uint32_t idx, void (*cb)(pa_context *c, int success, void *userdata), void *userdata) {
+ return command_kill(c, PA_COMMAND_KILL_CLIENT, idx, cb, userdata);
}
-struct pa_operation* pa_context_kill_sink_input(struct pa_context *c, uint32_t index, void (*cb)(struct pa_context *c, int success, void *userdata), void *userdata) {
- return command_kill(c, PA_COMMAND_KILL_SINK_INPUT, index, cb, userdata);
+pa_operation* pa_context_kill_sink_input(pa_context *c, uint32_t idx, void (*cb)(pa_context *c, int success, void *userdata), void *userdata) {
+ return command_kill(c, PA_COMMAND_KILL_SINK_INPUT, idx, cb, userdata);
}
-struct pa_operation* pa_context_kill_source_output(struct pa_context *c, uint32_t index, void (*cb)(struct pa_context *c, int success, void *userdata), void *userdata) {
- return command_kill(c, PA_COMMAND_KILL_SOURCE_OUTPUT, index, cb, userdata);
+pa_operation* pa_context_kill_source_output(pa_context *c, uint32_t idx, void (*cb)(pa_context *c, int success, void *userdata), void *userdata) {
+ return command_kill(c, PA_COMMAND_KILL_SOURCE_OUTPUT, idx, cb, userdata);
}
-static void load_module_callback(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
- struct pa_operation *o = userdata;
- uint32_t index = -1;
+static void load_module_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED uint32_t tag, pa_tagstruct *t, void *userdata) {
+ pa_operation *o = userdata;
+ uint32_t idx = -1;
assert(pd && o && o->context && o->ref >= 1);
if (command != PA_COMMAND_REPLY) {
if (pa_context_handle_error(o->context, command, t) < 0)
goto finish;
- } else if (pa_tagstruct_getu32(t, &index) < 0 ||
+ } else if (pa_tagstruct_getu32(t, &idx) < 0 ||
!pa_tagstruct_eof(t)) {
pa_context_fail(o->context, PA_ERROR_PROTOCOL);
goto finish;
}
if (o->callback) {
- void (*cb)(struct pa_context *c, uint32_t index, void *userdata) = o->callback;
- cb(o->context, index, o->userdata);
+ void (*cb)(pa_context *c, uint32_t _idx, void *_userdata) = (void (*)(pa_context *c, uint32_t _idx, void *_userdata)) o->callback;
+ cb(o->context, idx, o->userdata);
}
finish:
@@ -792,14 +793,14 @@ finish:
pa_operation_unref(o);
}
-struct pa_operation* pa_context_load_module(struct pa_context *c, const char*name, const char *argument, void (*cb)(struct pa_context *c, uint32_t index, void *userdata), void *userdata) {
- struct pa_operation *o;
- struct pa_tagstruct *t;
+pa_operation* pa_context_load_module(pa_context *c, const char*name, const char *argument, void (*cb)(pa_context *c, uint32_t idx, void *userdata), void *userdata) {
+ pa_operation *o;
+ pa_tagstruct *t;
uint32_t tag;
assert(c && name && argument);
o = pa_operation_new(c, NULL);
- o->callback = cb;
+ o->callback = (pa_operation_callback) cb;
o->userdata = userdata;
t = pa_tagstruct_new(NULL, 0);
@@ -813,14 +814,14 @@ struct pa_operation* pa_context_load_module(struct pa_context *c, const char*nam
return pa_operation_ref(o);
}
-struct pa_operation* pa_context_unload_module(struct pa_context *c, uint32_t index, void (*cb)(struct pa_context *c, int success, void *userdata), void *userdata) {
- return command_kill(c, PA_COMMAND_UNLOAD_MODULE, index, cb, userdata);
+pa_operation* pa_context_unload_module(pa_context *c, uint32_t idx, void (*cb)(pa_context *c, int success, void *userdata), void *userdata) {
+ return command_kill(c, PA_COMMAND_UNLOAD_MODULE, idx, cb, userdata);
}
/*** Autoload stuff ***/
-static void context_get_autoload_info_callback(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
- struct pa_operation *o = userdata;
+static void context_get_autoload_info_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED uint32_t tag, pa_tagstruct *t, void *userdata) {
+ pa_operation *o = userdata;
int eof = 1;
assert(pd && o && o->context && o->ref >= 1);
@@ -832,7 +833,7 @@ static void context_get_autoload_info_callback(struct pa_pdispatch *pd, uint32_t
} else {
while (!pa_tagstruct_eof(t)) {
- struct pa_autoload_info i;
+ pa_autoload_info i;
if (pa_tagstruct_getu32(t, &i.index) < 0 ||
pa_tagstruct_gets(t, &i.name) < 0 ||
@@ -844,14 +845,14 @@ static void context_get_autoload_info_callback(struct pa_pdispatch *pd, uint32_t
}
if (o->callback) {
- void (*cb)(struct pa_context *s, const struct pa_autoload_info*i, int eof, void *userdata) = o->callback;
+ void (*cb)(pa_context *s, const pa_autoload_info*_i, int _eof, void *_userdata) = (void (*)(pa_context *s, const pa_autoload_info*_i, int _eof, void *_userdata)) o->callback;
cb(o->context, &i, 0, o->userdata);
}
}
}
if (o->callback) {
- void (*cb)(struct pa_context *s, const struct pa_autoload_info*i, int eof, void *userdata) = o->callback;
+ void (*cb)(pa_context *s, const pa_autoload_info*_i, int _eof, void *_userdata) = (void (*)(pa_context *s, const pa_autoload_info*_i, int _eof, void *_userdata)) o->callback;
cb(o->context, NULL, eof, o->userdata);
}
@@ -860,14 +861,14 @@ finish:
pa_operation_unref(o);
}
-struct pa_operation* pa_context_get_autoload_info_by_name(struct pa_context *c, const char *name, enum pa_autoload_type type, void (*cb)(struct pa_context *c, const struct pa_autoload_info *i, int is_last, void *userdata), void *userdata) {
- struct pa_tagstruct *t;
- struct pa_operation *o;
+pa_operation* pa_context_get_autoload_info_by_name(pa_context *c, const char *name, pa_autoload_type type, void (*cb)(pa_context *c, const pa_autoload_info *i, int is_last, void *userdata), void *userdata) {
+ pa_tagstruct *t;
+ pa_operation *o;
uint32_t tag;
assert(c && cb && name);
o = pa_operation_new(c, NULL);
- o->callback = cb;
+ o->callback = (pa_operation_callback) cb;
o->userdata = userdata;
t = pa_tagstruct_new(NULL, 0);
@@ -881,49 +882,49 @@ struct pa_operation* pa_context_get_autoload_info_by_name(struct pa_context *c,
return pa_operation_ref(o);
}
-struct pa_operation* pa_context_get_autoload_info_by_index(struct pa_context *c, uint32_t index, void (*cb)(struct pa_context *c, const struct pa_autoload_info *i, int is_last, void *userdata), void *userdata) {
- struct pa_tagstruct *t;
- struct pa_operation *o;
+pa_operation* pa_context_get_autoload_info_by_index(pa_context *c, uint32_t idx, void (*cb)(pa_context *c, const pa_autoload_info *i, int is_last, void *userdata), void *userdata) {
+ pa_tagstruct *t;
+ pa_operation *o;
uint32_t tag;
- assert(c && cb && index != PA_INVALID_INDEX);
+ assert(c && cb && idx != PA_INVALID_INDEX);
o = pa_operation_new(c, NULL);
- o->callback = cb;
+ o->callback = (pa_operation_callback) cb;
o->userdata = userdata;
t = pa_tagstruct_new(NULL, 0);
pa_tagstruct_putu32(t, PA_COMMAND_GET_AUTOLOAD_INFO);
pa_tagstruct_putu32(t, tag = c->ctag++);
- pa_tagstruct_putu32(t, index);
+ pa_tagstruct_putu32(t, idx);
pa_pstream_send_tagstruct(c->pstream, t);
pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, context_get_autoload_info_callback, o);
return pa_operation_ref(o);
}
-struct pa_operation* pa_context_get_autoload_info_list(struct pa_context *c, void (*cb)(struct pa_context *c, const struct pa_autoload_info *i, int is_last, void *userdata), void *userdata) {
- return pa_context_send_simple_command(c, PA_COMMAND_GET_AUTOLOAD_INFO_LIST, context_get_autoload_info_callback, cb, userdata);
+pa_operation* pa_context_get_autoload_info_list(pa_context *c, void (*cb)(pa_context *c, const pa_autoload_info *i, int is_last, void *userdata), void *userdata) {
+ return pa_context_send_simple_command(c, PA_COMMAND_GET_AUTOLOAD_INFO_LIST, context_get_autoload_info_callback, (pa_operation_callback) cb, userdata);
}
-static void context_add_autoload_callback(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
- struct pa_operation *o = userdata;
- uint32_t index;
+static void context_add_autoload_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED uint32_t tag, pa_tagstruct *t, void *userdata) {
+ pa_operation *o = userdata;
+ uint32_t idx;
assert(pd && o && o->context && o->ref >= 1);
if (command != PA_COMMAND_REPLY) {
if (pa_context_handle_error(o->context, command, t) < 0)
goto finish;
- index = PA_INVALID_INDEX;
- } else if (pa_tagstruct_getu32(t, &index) ||
+ idx = PA_INVALID_INDEX;
+ } else if (pa_tagstruct_getu32(t, &idx) ||
!pa_tagstruct_eof(t)) {
pa_context_fail(o->context, PA_ERROR_PROTOCOL);
goto finish;
}
if (o->callback) {
- void (*cb)(struct pa_context *s, uint32_t index, void *userdata) = o->callback;
- cb(o->context, index, o->userdata);
+ void (*cb)(pa_context *s, uint32_t _idx, void *_userdata) = (void (*)(pa_context *s, uint32_t _idx, void *_userdata)) o->callback;
+ cb(o->context, idx, o->userdata);
}
@@ -933,14 +934,14 @@ finish:
}
-struct pa_operation* pa_context_add_autoload(struct pa_context *c, const char *name, enum pa_autoload_type type, const char *module, const char*argument, void (*cb)(struct pa_context *c, int success, void *userdata), void* userdata) {
- struct pa_operation *o;
- struct pa_tagstruct *t;
+pa_operation* pa_context_add_autoload(pa_context *c, const char *name, pa_autoload_type type, const char *module, const char*argument, void (*cb)(pa_context *c, int success, void *userdata), void* userdata) {
+ pa_operation *o;
+ pa_tagstruct *t;
uint32_t tag;
assert(c && name && module && argument);
o = pa_operation_new(c, NULL);
- o->callback = cb;
+ o->callback = (pa_operation_callback) cb;
o->userdata = userdata;
t = pa_tagstruct_new(NULL, 0);
@@ -956,14 +957,14 @@ struct pa_operation* pa_context_add_autoload(struct pa_context *c, const char *n
return pa_operation_ref(o);
}
-struct pa_operation* pa_context_remove_autoload_by_name(struct pa_context *c, const char *name, enum pa_autoload_type type, void (*cb)(struct pa_context *c, int success, void *userdata), void* userdata) {
- struct pa_operation *o;
- struct pa_tagstruct *t;
+pa_operation* pa_context_remove_autoload_by_name(pa_context *c, const char *name, pa_autoload_type type, void (*cb)(pa_context *c, int success, void *userdata), void* userdata) {
+ pa_operation *o;
+ pa_tagstruct *t;
uint32_t tag;
assert(c && name);
o = pa_operation_new(c, NULL);
- o->callback = cb;
+ o->callback = (pa_operation_callback) cb;
o->userdata = userdata;
t = pa_tagstruct_new(NULL, 0);
@@ -977,20 +978,20 @@ struct pa_operation* pa_context_remove_autoload_by_name(struct pa_context *c, co
return pa_operation_ref(o);
}
-struct pa_operation* pa_context_remove_autoload_by_index(struct pa_context *c, uint32_t index, void (*cb)(struct pa_context *c, int success, void *userdata), void* userdata) {
- struct pa_operation *o;
- struct pa_tagstruct *t;
+pa_operation* pa_context_remove_autoload_by_index(pa_context *c, uint32_t idx, void (*cb)(pa_context *c, int success, void *userdata), void* userdata) {
+ pa_operation *o;
+ pa_tagstruct *t;
uint32_t tag;
- assert(c && index != PA_INVALID_INDEX);
+ assert(c && idx != PA_INVALID_INDEX);
o = pa_operation_new(c, NULL);
- o->callback = cb;
+ o->callback = (pa_operation_callback) cb;
o->userdata = userdata;
t = pa_tagstruct_new(NULL, 0);
pa_tagstruct_putu32(t, PA_COMMAND_REMOVE_AUTOLOAD);
pa_tagstruct_putu32(t, tag = c->ctag++);
- pa_tagstruct_putu32(t, index);
+ pa_tagstruct_putu32(t, idx);
pa_pstream_send_tagstruct(c->pstream, t);
pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, o);
diff --git a/polyp/polyplib-introspect.h b/polyp/polyplib-introspect.h
index 83cdba16..2848e22f 100644
--- a/polyp/polyplib-introspect.h
+++ b/polyp/polyplib-introspect.h
@@ -48,224 +48,224 @@
PA_C_DECL_BEGIN
/** Stores information about sinks */
-struct pa_sink_info {
+typedef struct pa_sink_info {
const char *name; /**< Name of the sink */
uint32_t index; /**< Index of the sink */
const char *description; /**< Description of this sink */
- struct pa_sample_spec sample_spec; /**< Sample spec of this sink */
+ pa_sample_spec sample_spec; /**< Sample spec of this sink */
uint32_t owner_module; /**< Index of the owning module of this sink, or PA_INVALID_INDEX */
pa_volume_t volume; /**< Volume of the sink */
uint32_t monitor_source; /**< Index of the monitor source connected to this sink */
const char *monitor_source_name; /**< The name of the monitor source */
pa_usec_t latency; /**< Length of filled playback buffer of this sink */
pa_typeid_t _typeid; /**< Implementation type. \since 0.8 */
-};
+} pa_sink_info;
/** Get information about a sink by its name */
-struct pa_operation* pa_context_get_sink_info_by_name(struct pa_context *c, const char *name, void (*cb)(struct pa_context *c, const struct pa_sink_info *i, int is_last, void *userdata), void *userdata);
+pa_operation* pa_context_get_sink_info_by_name(pa_context *c, const char *name, void (*cb)(pa_context *c, const pa_sink_info *i, int is_last, void *userdata), void *userdata);
/** Get information about a sink by its index */
-struct pa_operation* pa_context_get_sink_info_by_index(struct pa_context *c, uint32_t id, void (*cb)(struct pa_context *c, const struct pa_sink_info *i, int is_last, void *userdata), void *userdata);
+pa_operation* pa_context_get_sink_info_by_index(pa_context *c, uint32_t id, void (*cb)(pa_context *c, const pa_sink_info *i, int is_last, void *userdata), void *userdata);
/** Get the complete sink list */
-struct pa_operation* pa_context_get_sink_info_list(struct pa_context *c, void (*cb)(struct pa_context *c, const struct pa_sink_info *i, int is_last, void *userdata), void *userdata);
+pa_operation* pa_context_get_sink_info_list(pa_context *c, void (*cb)(pa_context *c, const pa_sink_info *i, int is_last, void *userdata), void *userdata);
/** Stores information about sources */
-struct pa_source_info {
+typedef struct pa_source_info {
const char *name ; /**< Name of the source */
uint32_t index; /**< Index of the source */
const char *description; /**< Description of this source */
- struct pa_sample_spec sample_spec; /**< Sample spec of this source */
+ pa_sample_spec sample_spec; /**< Sample spec of this source */
uint32_t owner_module; /**< Owning module index, or PA_INVALID_INDEX */
uint32_t monitor_of_sink; /**< If this is a monitor source the index of the owning sink, otherwise PA_INVALID_INDEX */
const char *monitor_of_sink_name; /**< Name of the owning sink, or PA_INVALID_INDEX */
pa_usec_t latency; /**< Length of filled record buffer of this source. \since 0.5 */
pa_typeid_t _typeid; /**< Implementation type. \since 0.8 */
-};
+} pa_source_info;
/** Get information about a source by its name */
-struct pa_operation* pa_context_get_source_info_by_name(struct pa_context *c, const char *name, void (*cb)(struct pa_context *c, const struct pa_source_info *i, int is_last, void *userdata), void *userdata);
+pa_operation* pa_context_get_source_info_by_name(pa_context *c, const char *name, void (*cb)(pa_context *c, const pa_source_info *i, int is_last, void *userdata), void *userdata);
/** Get information about a source by its index */
-struct pa_operation* pa_context_get_source_info_by_index(struct pa_context *c, uint32_t id, void (*cb)(struct pa_context *c, const struct pa_source_info *i, int is_last, void *userdata), void *userdata);
+pa_operation* pa_context_get_source_info_by_index(pa_context *c, uint32_t id, void (*cb)(pa_context *c, const pa_source_info *i, int is_last, void *userdata), void *userdata);
/** Get the complete source list */
-struct pa_operation* pa_context_get_source_info_list(struct pa_context *c, void (*cb)(struct pa_context *c, const struct pa_source_info *i, int is_last, void *userdata), void *userdata);
+pa_operation* pa_context_get_source_info_list(pa_context *c, void (*cb)(pa_context *c, const pa_source_info *i, int is_last, void *userdata), void *userdata);
/** Server information */
-struct pa_server_info {
+typedef struct pa_server_info {
const char *user_name; /**< User name of the daemon process */
const char *host_name; /**< Host name the daemon is running on */
const char *server_version; /**< Version string of the daemon */
const char *server_name; /**< Server package name (usually "polypaudio") */
- struct pa_sample_spec sample_spec; /**< Default sample specification */
+ pa_sample_spec sample_spec; /**< Default sample specification */
const char *default_sink_name; /**< Name of default sink. \since 0.4 */
const char *default_source_name; /**< Name of default sink. \since 0.4*/
uint32_t cookie; /**< A random cookie for identifying this instance of polypaudio. \since 0.8 */
-};
+} pa_server_info;
/** Get some information about the server */
-struct pa_operation* pa_context_get_server_info(struct pa_context *c, void (*cb)(struct pa_context *c, const struct pa_server_info*i, void *userdata), void *userdata);
+pa_operation* pa_context_get_server_info(pa_context *c, void (*cb)(pa_context *c, const pa_server_info*i, void *userdata), void *userdata);
/** Stores information about modules */
-struct pa_module_info {
+typedef struct pa_module_info {
uint32_t index; /**< Index of the module */
const char*name, /**< Name of the module */
*argument; /**< Argument string of the module */
uint32_t n_used; /**< Usage counter or PA_INVALID_INDEX */
int auto_unload; /**< Non-zero if this is an autoloaded module */
-};
+} pa_module_info;
/** Get some information about a module by its index */
-struct pa_operation* pa_context_get_module_info(struct pa_context *c, uint32_t index, void (*cb)(struct pa_context *c, const struct pa_module_info*i, int is_last, void *userdata), void *userdata);
+pa_operation* pa_context_get_module_info(pa_context *c, uint32_t idx, void (*cb)(pa_context *c, const pa_module_info*i, int is_last, void *userdata), void *userdata);
/** Get the complete list of currently loaded modules */
-struct pa_operation* pa_context_get_module_info_list(struct pa_context *c, void (*cb)(struct pa_context *c, const struct pa_module_info*i, int is_last, void *userdata), void *userdata);
+pa_operation* pa_context_get_module_info_list(pa_context *c, void (*cb)(pa_context *c, const pa_module_info*i, int is_last, void *userdata), void *userdata);
/** Stores information about clients */
-struct pa_client_info {
+typedef struct pa_client_info {
uint32_t index; /**< Index of this client */
const char *name; /**< Name of this client */
uint32_t owner_module; /**< Index of the owning module, or PA_INVALID_INDEX */
pa_typeid_t _typeid; /**< Implementation type. \since 0.8 */
-};
+} pa_client_info;
/** Get information about a client by its index */
-struct pa_operation* pa_context_get_client_info(struct pa_context *c, uint32_t index, void (*cb)(struct pa_context *c, const struct pa_client_info*i, int is_last, void *userdata), void *userdata);
+pa_operation* pa_context_get_client_info(pa_context *c, uint32_t idx, void (*cb)(pa_context *c, const pa_client_info*i, int is_last, void *userdata), void *userdata);
/** Get the complete client list */
-struct pa_operation* pa_context_get_client_info_list(struct pa_context *c, void (*cb)(struct pa_context *c, const struct pa_client_info*i, int is_last, void *userdata), void *userdata);
+pa_operation* pa_context_get_client_info_list(pa_context *c, void (*cb)(pa_context *c, const pa_client_info*i, int is_last, void *userdata), void *userdata);
/** Stores information about sink inputs */
-struct pa_sink_input_info {
+typedef struct pa_sink_input_info {
uint32_t index; /**< Index of the sink input */
const char *name; /**< Name of the sink input */
uint32_t owner_module; /**< Index of the module this sink input belongs to, or PA_INVALID_INDEX when it does not belong to any module */
uint32_t client; /**< Index of the client this sink input belongs to, or PA_INVALID_INDEX when it does not belong to any client */
uint32_t sink; /**< Index of the connected sink */
- struct pa_sample_spec sample_spec; /**< The sample specification of the sink input */
+ pa_sample_spec sample_spec; /**< The sample specification of the sink input */
pa_volume_t volume; /**< The volume of this sink input */
pa_usec_t buffer_usec; /**< Latency due to buffering in sink input, see pa_latency_info for details */
pa_usec_t sink_usec; /**< Latency of the sink device, see pa_latency_info for details */
const char *resample_method; /**< Thre resampling method used by this sink input. \since 0.7 */
pa_typeid_t _typeid; /**< Implementation type. \since 0.8 */
-};
+} pa_sink_input_info;
/** Get some information about a sink input by its index */
-struct pa_operation* pa_context_get_sink_input_info(struct pa_context *c, uint32_t index, void (*cb)(struct pa_context *c, const struct pa_sink_input_info*i, int is_last, void *userdata), void *userdata);
+pa_operation* pa_context_get_sink_input_info(pa_context *c, uint32_t idx, void (*cb)(pa_context *c, const pa_sink_input_info*i, int is_last, void *userdata), void *userdata);
/** Get the complete sink input list */
-struct pa_operation* pa_context_get_sink_input_info_list(struct pa_context *c, void (*cb)(struct pa_context *c, const struct pa_sink_input_info*i, int is_last, void *userdata), void *userdata);
+pa_operation* pa_context_get_sink_input_info_list(pa_context *c, void (*cb)(pa_context *c, const pa_sink_input_info*i, int is_last, void *userdata), void *userdata);
/** Stores information about source outputs */
-struct pa_source_output_info {
+typedef struct pa_source_output_info {
uint32_t index; /**< Index of the sink input */
const char *name; /**< Name of the sink input */
uint32_t owner_module; /**< Index of the module this sink input belongs to, or PA_INVALID_INDEX when it does not belong to any module */
uint32_t client; /**< Index of the client this sink input belongs to, or PA_INVALID_INDEX when it does not belong to any client */
uint32_t source; /**< Index of the connected source */
- struct pa_sample_spec sample_spec; /**< The sample specification of the source output */
+ pa_sample_spec sample_spec; /**< The sample specification of the source output */
pa_usec_t buffer_usec; /**< Latency due to buffering in the source output, see pa_latency_info for details. \since 0.5 */
pa_usec_t source_usec; /**< Latency of the source device, see pa_latency_info for details. \since 0.5 */
const char *resample_method; /**< Thre resampling method used by this source output. \since 0.7 */
pa_typeid_t _typeid; /**< Implementation type. \since 0.8 */
-};
+} pa_source_output_info;
/** Get information about a source output by its index */
-struct pa_operation* pa_context_get_source_output_info(struct pa_context *c, uint32_t index, void (*cb)(struct pa_context *c, const struct pa_source_output_info*i, int is_last, void *userdata), void *userdata);
+pa_operation* pa_context_get_source_output_info(pa_context *c, uint32_t idx, void (*cb)(pa_context *c, const pa_source_output_info*i, int is_last, void *userdata), void *userdata);
/** Get the complete list of source outputs */
-struct pa_operation* pa_context_get_source_output_info_list(struct pa_context *c, void (*cb)(struct pa_context *c, const struct pa_source_output_info*i, int is_last, void *userdata), void *userdata);
+pa_operation* pa_context_get_source_output_info_list(pa_context *c, void (*cb)(pa_context *c, const pa_source_output_info*i, int is_last, void *userdata), void *userdata);
/** Set the volume of a sink device specified by its index */
-struct pa_operation* pa_context_set_sink_volume_by_index(struct pa_context *c, uint32_t index, pa_volume_t volume, void (*cb)(struct pa_context *c, int success, void *userdata), void *userdata);
+pa_operation* pa_context_set_sink_volume_by_index(pa_context *c, uint32_t idx, pa_volume_t volume, void (*cb)(pa_context *c, int success, void *userdata), void *userdata);
/** Set the volume of a sink device specified by its name */
-struct pa_operation* pa_context_set_sink_volume_by_name(struct pa_context *c, const char *name, pa_volume_t volume, void (*cb)(struct pa_context *c, int success, void *userdata), void *userdata);
+pa_operation* pa_context_set_sink_volume_by_name(pa_context *c, const char *name, pa_volume_t volume, void (*cb)(pa_context *c, int success, void *userdata), void *userdata);
/** Set the volume of a sink input stream */
-struct pa_operation* pa_context_set_sink_input_volume(struct pa_context *c, uint32_t index, pa_volume_t volume, void (*cb)(struct pa_context *c, int success, void *userdata), void *userdata);
+pa_operation* pa_context_set_sink_input_volume(pa_context *c, uint32_t idx, pa_volume_t volume, void (*cb)(pa_context *c, int success, void *userdata), void *userdata);
/** Memory block statistics */
-struct pa_stat_info {
+typedef struct pa_stat_info {
uint32_t memblock_total; /**< Currently allocated memory blocks */
uint32_t memblock_total_size; /**< Currentl total size of allocated memory blocks */
uint32_t memblock_allocated; /**< Allocated memory blocks during the whole lifetime of the daemon */
uint32_t memblock_allocated_size; /**< Total size of all memory blocks allocated during the whole lifetime of the daemon */
uint32_t scache_size; /**< Total size of all sample cache entries. \since 0.4 */
-};
+} pa_stat_info;
/** Get daemon memory block statistics */
-struct pa_operation* pa_context_stat(struct pa_context *c, void (*cb)(struct pa_context *c, const struct pa_stat_info *i, void *userdata), void *userdata);
+pa_operation* pa_context_stat(pa_context *c, void (*cb)(pa_context *c, const pa_stat_info *i, void *userdata), void *userdata);
/** Stores information about sample cache entries */
-struct pa_sample_info {
+typedef struct pa_sample_info {
uint32_t index; /**< Index of this entry */
const char *name; /**< Name of this entry */
pa_volume_t volume; /**< Default volume of this entry */
- struct pa_sample_spec sample_spec; /**< Sample specification of the sampel */
+ pa_sample_spec sample_spec; /**< Sample specification of the sampel */
pa_usec_t duration; /**< Duration of this entry */
uint32_t bytes; /**< Length of this sample in bytes. \since 0.4 */
int lazy; /**< Non-zero when this is a lazy cache entry. \since 0.5 */
const char *filename; /**< In case this is a lazy cache entry, the filename for the sound file to be loaded on demand. \since 0.5 */
-};
+} pa_sample_info;
/** Get information about a sample by its name */
-struct pa_operation* pa_context_get_sample_info_by_name(struct pa_context *c, const char *name, void (*cb)(struct pa_context *c, const struct pa_sample_info *i, int is_last, void *userdata), void *userdata);
+pa_operation* pa_context_get_sample_info_by_name(pa_context *c, const char *name, void (*cb)(pa_context *c, const pa_sample_info *i, int is_last, void *userdata), void *userdata);
/** Get information about a sample by its index */
-struct pa_operation* pa_context_get_sample_info_by_index(struct pa_context *c, uint32_t index, void (*cb)(struct pa_context *c, const struct pa_sample_info *i, int is_last, void *userdata), void *userdata);
+pa_operation* pa_context_get_sample_info_by_index(pa_context *c, uint32_t idx, void (*cb)(pa_context *c, const pa_sample_info *i, int is_last, void *userdata), void *userdata);
/** Get the complete list of samples stored in the daemon. */
-struct pa_operation* pa_context_get_sample_info_list(struct pa_context *c, void (*cb)(struct pa_context *c, const struct pa_sample_info *i, int is_last, void *userdata), void *userdata);
+pa_operation* pa_context_get_sample_info_list(pa_context *c, void (*cb)(pa_context *c, const pa_sample_info *i, int is_last, void *userdata), void *userdata);
/** Kill a client. \since 0.5 */
-struct pa_operation* pa_context_kill_client(struct pa_context *c, uint32_t index, void (*cb)(struct pa_context *c, int success, void *userdata), void *userdata);
+pa_operation* pa_context_kill_client(pa_context *c, uint32_t idx, void (*cb)(pa_context *c, int success, void *userdata), void *userdata);
/** Kill a sink input. \since 0.5 */
-struct pa_operation* pa_context_kill_sink_input(struct pa_context *c, uint32_t index, void (*cb)(struct pa_context *c, int success, void *userdata), void *userdata);
+pa_operation* pa_context_kill_sink_input(pa_context *c, uint32_t idx, void (*cb)(pa_context *c, int success, void *userdata), void *userdata);
/** Kill a source output. \since 0.5 */
-struct pa_operation* pa_context_kill_source_output(struct pa_context *c, uint32_t index, void (*cb)(struct pa_context *c, int success, void *userdata), void *userdata);
+pa_operation* pa_context_kill_source_output(pa_context *c, uint32_t idx, void (*cb)(pa_context *c, int success, void *userdata), void *userdata);
/** Load a module. \since 0.5 */
-struct pa_operation* pa_context_load_module(struct pa_context *c, const char*name, const char *argument, void (*cb)(struct pa_context *c, uint32_t index, void *userdata), void *userdata);
+pa_operation* pa_context_load_module(pa_context *c, const char*name, const char *argument, void (*cb)(pa_context *c, uint32_t idx, void *userdata), void *userdata);
/** Unload a module. \since 0.5 */
-struct pa_operation* pa_context_unload_module(struct pa_context *c, uint32_t index, void (*cb)(struct pa_context *c, int success, void *userdata), void *userdata);
+pa_operation* pa_context_unload_module(pa_context *c, uint32_t idx, void (*cb)(pa_context *c, int success, void *userdata), void *userdata);
/** Type of an autoload entry. \since 0.5 */
-enum pa_autoload_type {
+typedef enum pa_autoload_type {
PA_AUTOLOAD_SINK = 0,
PA_AUTOLOAD_SOURCE = 1
-};
+} pa_autoload_type;
/** Stores information about autoload entries. \since 0.5 */
-struct pa_autoload_info {
+typedef struct pa_autoload_info {
uint32_t index; /**< Index of this autoload entry */
const char *name; /**< Name of the sink or source */
- enum pa_autoload_type type; /**< Type of the autoload entry */
+ pa_autoload_type type; /**< Type of the autoload entry */
const char *module; /**< Module name to load */
const char *argument; /**< Argument string for module */
-};
+} pa_autoload_info;
/** Get info about a specific autoload entry. \since 0.6 */
-struct pa_operation* pa_context_get_autoload_info_by_name(struct pa_context *c, const char *name, enum pa_autoload_type type, void (*cb)(struct pa_context *c, const struct pa_autoload_info *i, int is_last, void *userdata), void *userdata);
+pa_operation* pa_context_get_autoload_info_by_name(pa_context *c, const char *name, pa_autoload_type type, void (*cb)(pa_context *c, const pa_autoload_info *i, int is_last, void *userdata), void *userdata);
/** Get info about a specific autoload entry. \since 0.6 */
-struct pa_operation* pa_context_get_autoload_info_by_index(struct pa_context *c, uint32_t index, void (*cb)(struct pa_context *c, const struct pa_autoload_info *i, int is_last, void *userdata), void *userdata);
+pa_operation* pa_context_get_autoload_info_by_index(pa_context *c, uint32_t idx, void (*cb)(pa_context *c, const pa_autoload_info *i, int is_last, void *userdata), void *userdata);
/** Get the complete list of autoload entries. \since 0.5 */
-struct pa_operation* pa_context_get_autoload_info_list(struct pa_context *c, void (*cb)(struct pa_context *c, const struct pa_autoload_info *i, int is_last, void *userdata), void *userdata);
+pa_operation* pa_context_get_autoload_info_list(pa_context *c, void (*cb)(pa_context *c, const pa_autoload_info *i, int is_last, void *userdata), void *userdata);
/** Add a new autoload entry. \since 0.5 */
-struct pa_operation* pa_context_add_autoload(struct pa_context *c, const char *name, enum pa_autoload_type type, const char *module, const char*argument, void (*cb)(struct pa_context *c, int index, void *userdata), void* userdata);
+pa_operation* pa_context_add_autoload(pa_context *c, const char *name, pa_autoload_type type, const char *module, const char*argument, void (*cb)(pa_context *c, int idx, void *userdata), void* userdata);
/** Remove an autoload entry. \since 0.6 */
-struct pa_operation* pa_context_remove_autoload_by_name(struct pa_context *c, const char *name, enum pa_autoload_type type, void (*cb)(struct pa_context *c, int success, void *userdata), void* userdata);
+pa_operation* pa_context_remove_autoload_by_name(pa_context *c, const char *name, pa_autoload_type type, void (*cb)(pa_context *c, int success, void *userdata), void* userdata);
/** Remove an autoload entry. \since 0.6 */
-struct pa_operation* pa_context_remove_autoload_by_index(struct pa_context *c, uint32_t index, void (*cb)(struct pa_context *c, int success, void *userdata), void* userdata);
+pa_operation* pa_context_remove_autoload_by_index(pa_context *c, uint32_t idx, void (*cb)(pa_context *c, int success, void *userdata), void* userdata);
PA_C_DECL_END
diff --git a/polyp/polyplib-operation.c b/polyp/polyplib-operation.c
index 77fe70fa..3bee8cc7 100644
--- a/polyp/polyplib-operation.c
+++ b/polyp/polyplib-operation.c
@@ -29,11 +29,11 @@
#include "polyplib-internal.h"
#include "polyplib-operation.h"
-struct pa_operation *pa_operation_new(struct pa_context *c, struct pa_stream *s) {
- struct pa_operation *o;
+pa_operation *pa_operation_new(pa_context *c, pa_stream *s) {
+ pa_operation *o;
assert(c);
- o = pa_xmalloc(sizeof(struct pa_operation));
+ o = pa_xmalloc(sizeof(pa_operation));
o->ref = 1;
o->context = pa_context_ref(c);
o->stream = s ? pa_stream_ref(s) : NULL;
@@ -42,17 +42,17 @@ struct pa_operation *pa_operation_new(struct pa_context *c, struct pa_stream *s)
o->userdata = NULL;
o->callback = NULL;
- PA_LLIST_PREPEND(struct pa_operation, o->context->operations, o);
+ PA_LLIST_PREPEND(pa_operation, o->context->operations, o);
return pa_operation_ref(o);
}
-struct pa_operation *pa_operation_ref(struct pa_operation *o) {
+pa_operation *pa_operation_ref(pa_operation *o) {
assert(o && o->ref >= 1);
o->ref++;
return o;
}
-void pa_operation_unref(struct pa_operation *o) {
+void pa_operation_unref(pa_operation *o) {
assert(o && o->ref >= 1);
if ((--(o->ref)) == 0) {
@@ -62,7 +62,7 @@ void pa_operation_unref(struct pa_operation *o) {
}
}
-static void operation_set_state(struct pa_operation *o, enum pa_operation_state st) {
+static void operation_set_state(pa_operation *o, pa_operation_state st) {
assert(o && o->ref >= 1);
if (st == o->state)
@@ -74,7 +74,7 @@ static void operation_set_state(struct pa_operation *o, enum pa_operation_state
o->state = st;
if ((o->state == PA_OPERATION_DONE) || (o->state == PA_OPERATION_CANCELED)) {
- PA_LLIST_REMOVE(struct pa_operation, o->context->operations, o);
+ PA_LLIST_REMOVE(pa_operation, o->context->operations, o);
pa_context_unref(o->context);
if (o->stream)
pa_stream_unref(o->stream);
@@ -87,17 +87,17 @@ static void operation_set_state(struct pa_operation *o, enum pa_operation_state
}
}
-void pa_operation_cancel(struct pa_operation *o) {
+void pa_operation_cancel(pa_operation *o) {
assert(o && o->ref >= 1);
operation_set_state(o, PA_OPERATION_CANCELED);
}
-void pa_operation_done(struct pa_operation *o) {
+void pa_operation_done(pa_operation *o) {
assert(o && o->ref >= 1);
operation_set_state(o, PA_OPERATION_DONE);
}
-enum pa_operation_state pa_operation_get_state(struct pa_operation *o) {
+pa_operation_state pa_operation_get_state(pa_operation *o) {
assert(o && o->ref >= 1);
return o->state;
}
diff --git a/polyp/polyplib-operation.h b/polyp/polyplib-operation.h
index 5c3af49c..63dcbc9f 100644
--- a/polyp/polyplib-operation.h
+++ b/polyp/polyplib-operation.h
@@ -30,21 +30,21 @@
PA_C_DECL_BEGIN
-/** \struct pa_operation
+/** \pa_operation
* An asynchronous operation object */
-struct pa_operation;
+typedef struct pa_operation pa_operation;
/** Increase the reference count by one */
-struct pa_operation *pa_operation_ref(struct pa_operation *o);
+pa_operation *pa_operation_ref(pa_operation *o);
/** Decrease the reference count by one */
-void pa_operation_unref(struct pa_operation *o);
+void pa_operation_unref(pa_operation *o);
/** Cancel the operation. Beware! This will not necessarily cancel the execution of the operation on the server side. */
-void pa_operation_cancel(struct pa_operation *o);
+void pa_operation_cancel(pa_operation *o);
/** Return the current status of the operation */
-enum pa_operation_state pa_operation_get_state(struct pa_operation *o);
+pa_operation_state pa_operation_get_state(pa_operation *o);
PA_C_DECL_END
diff --git a/polyp/polyplib-scache.c b/polyp/polyplib-scache.c
index bce5d18a..01c64828 100644
--- a/polyp/polyplib-scache.c
+++ b/polyp/polyplib-scache.c
@@ -32,8 +32,8 @@
#include "polyplib-internal.h"
#include "pstream-util.h"
-void pa_stream_connect_upload(struct pa_stream *s, size_t length) {
- struct pa_tagstruct *t;
+void pa_stream_connect_upload(pa_stream *s, size_t length) {
+ pa_tagstruct *t;
uint32_t tag;
assert(s && length);
@@ -55,8 +55,8 @@ void pa_stream_connect_upload(struct pa_stream *s, size_t length) {
pa_stream_unref(s);
}
-void pa_stream_finish_upload(struct pa_stream *s) {
- struct pa_tagstruct *t;
+void pa_stream_finish_upload(pa_stream *s) {
+ pa_tagstruct *t;
uint32_t tag;
assert(s);
@@ -77,14 +77,14 @@ void pa_stream_finish_upload(struct pa_stream *s) {
pa_stream_unref(s);
}
-struct pa_operation * pa_context_play_sample(struct pa_context *c, const char *name, const char *dev, uint32_t volume, void (*cb)(struct pa_context *c, int success, void *userdata), void *userdata) {
- struct pa_operation *o;
- struct pa_tagstruct *t;
+pa_operation * pa_context_play_sample(pa_context *c, const char *name, const char *dev, uint32_t volume, void (*cb)(pa_context *c, int success, void *userdata), void *userdata) {
+ pa_operation *o;
+ pa_tagstruct *t;
uint32_t tag;
assert(c && name && *name && (!dev || *dev));
o = pa_operation_new(c, NULL);
- o->callback = cb;
+ o->callback = (pa_operation_callback) cb;
o->userdata = userdata;
if (!dev)
@@ -104,14 +104,14 @@ struct pa_operation * pa_context_play_sample(struct pa_context *c, const char *n
return pa_operation_ref(o);
}
-struct pa_operation* pa_context_remove_sample(struct pa_context *c, const char *name, void (*cb)(struct pa_context *c, int success, void *userdata), void *userdata) {
- struct pa_operation *o;
- struct pa_tagstruct *t;
+pa_operation* pa_context_remove_sample(pa_context *c, const char *name, void (*cb)(pa_context *c, int success, void *userdata), void *userdata) {
+ pa_operation *o;
+ pa_tagstruct *t;
uint32_t tag;
assert(c && name);
o = pa_operation_new(c, NULL);
- o->callback = cb;
+ o->callback = (pa_operation_callback) cb;
o->userdata = userdata;
t = pa_tagstruct_new(NULL, 0);
diff --git a/polyp/polyplib-scache.h b/polyp/polyplib-scache.h
index 8ec375ea..89d27597 100644
--- a/polyp/polyplib-scache.h
+++ b/polyp/polyplib-scache.h
@@ -34,16 +34,16 @@
PA_C_DECL_BEGIN
/** Make this stream a sample upload stream */
-void pa_stream_connect_upload(struct pa_stream *s, size_t length);
+void pa_stream_connect_upload(pa_stream *s, size_t length);
/** Finish the sample upload, the stream name will become the sample name. You cancel a sample upload by issuing pa_stream_disconnect() */
-void pa_stream_finish_upload(struct pa_stream *s);
+void pa_stream_finish_upload(pa_stream *s);
/** Play a sample from the sample cache to the specified device. If the latter is NULL use the default sink. Returns an operation object */
-struct pa_operation* pa_context_play_sample(struct pa_context *c, const char *name, const char *dev, uint32_t volume, void (*cb)(struct pa_context *c, int success, void *userdata), void *userdata);
+pa_operation* pa_context_play_sample(pa_context *c, const char *name, const char *dev, uint32_t volume, void (*cb)(pa_context *c, int success, void *userdata), void *userdata);
/** Remove a sample from the sample cache. Returns an operation object which may be used to cancel the operation while it is running */
-struct pa_operation* pa_context_remove_sample(struct pa_context *c, const char *name, void (*cb)(struct pa_context *c, int success, void *userdata), void *userdata);
+pa_operation* pa_context_remove_sample(pa_context *c, const char *name, void (*cb)(pa_context *c, int success, void *userdata), void *userdata);
PA_C_DECL_END
diff --git a/polyp/polyplib-simple.c b/polyp/polyplib-simple.c
index a73aacfa..b1357128 100644
--- a/polyp/polyplib-simple.c
+++ b/polyp/polyplib-simple.c
@@ -36,10 +36,10 @@
#include "log.h"
struct pa_simple {
- struct pa_mainloop *mainloop;
- struct pa_context *context;
- struct pa_stream *stream;
- enum pa_stream_direction direction;
+ pa_mainloop *mainloop;
+ pa_context *context;
+ pa_stream *stream;
+ pa_stream_direction direction;
int dead;
@@ -48,11 +48,11 @@ struct pa_simple {
pa_usec_t latency;
};
-static void read_callback(struct pa_stream *s, const void*data, size_t length, void *userdata);
+static void read_callback(pa_stream *s, const void*data, size_t length, void *userdata);
-static int check_error(struct pa_simple *p, int *perror) {
- enum pa_context_state cst;
- enum pa_stream_state sst;
+static int check_error(pa_simple *p, int *rerror) {
+ pa_context_state cst;
+ pa_stream_state sst;
assert(p);
if ((cst = pa_context_get_state(p->context)) == PA_CONTEXT_FAILED)
@@ -70,18 +70,18 @@ static int check_error(struct pa_simple *p, int *perror) {
return 0;
fail:
- if (perror)
- *perror = pa_context_errno(p->context);
+ if (rerror)
+ *rerror = pa_context_errno(p->context);
p->dead = 1;
return -1;
}
-static int iterate(struct pa_simple *p, int block, int *perror) {
+static int iterate(pa_simple *p, int block, int *rerror) {
assert(p && p->context && p->mainloop);
- if (check_error(p, perror) < 0)
+ if (check_error(p, rerror) < 0)
return -1;
if (!block && !pa_context_is_pending(p->context))
@@ -89,12 +89,12 @@ static int iterate(struct pa_simple *p, int block, int *perror) {
do {
if (pa_mainloop_iterate(p->mainloop, 1, NULL) < 0) {
- if (perror)
- *perror = PA_ERROR_INTERNAL;
+ if (rerror)
+ *rerror = PA_ERROR_INTERNAL;
return -1;
}
- if (check_error(p, perror) < 0)
+ if (check_error(p, rerror) < 0)
return -1;
} while (pa_context_is_pending(p->context));
@@ -103,34 +103,34 @@ static int iterate(struct pa_simple *p, int block, int *perror) {
while (pa_mainloop_deferred_pending(p->mainloop)) {
if (pa_mainloop_iterate(p->mainloop, 0, NULL) < 0) {
- if (perror)
- *perror = PA_ERROR_INTERNAL;
+ if (rerror)
+ *rerror = PA_ERROR_INTERNAL;
return -1;
}
- if (check_error(p, perror) < 0)
+ if (check_error(p, rerror) < 0)
return -1;
}
return 0;
}
-struct pa_simple* pa_simple_new(
+pa_simple* pa_simple_new(
const char *server,
const char *name,
- enum pa_stream_direction dir,
+ pa_stream_direction dir,
const char *dev,
const char *stream_name,
- const struct pa_sample_spec *ss,
- const struct pa_buffer_attr *attr,
+ const pa_sample_spec *ss,
+ const pa_buffer_attr *attr,
pa_volume_t volume,
- int *perror) {
+ int *rerror) {
- struct pa_simple *p;
+ pa_simple *p;
int error = PA_ERROR_INTERNAL;
assert(ss && (dir == PA_STREAM_PLAYBACK || dir == PA_STREAM_RECORD));
- p = pa_xmalloc(sizeof(struct pa_simple));
+ p = pa_xmalloc(sizeof(pa_simple));
p->context = NULL;
p->stream = NULL;
p->mainloop = pa_mainloop_new();
@@ -171,13 +171,13 @@ struct pa_simple* pa_simple_new(
return p;
fail:
- if (perror)
- *perror = error;
+ if (rerror)
+ *rerror = error;
pa_simple_free(p);
return NULL;
}
-void pa_simple_free(struct pa_simple *s) {
+void pa_simple_free(pa_simple *s) {
assert(s);
pa_xfree(s->read_data);
@@ -194,12 +194,12 @@ void pa_simple_free(struct pa_simple *s) {
pa_xfree(s);
}
-int pa_simple_write(struct pa_simple *p, const void*data, size_t length, int *perror) {
+int pa_simple_write(pa_simple *p, const void*data, size_t length, int *rerror) {
assert(p && data && p->direction == PA_STREAM_PLAYBACK);
if (p->dead) {
- if (perror)
- *perror = pa_context_errno(p->context);
+ if (rerror)
+ *rerror = pa_context_errno(p->context);
return -1;
}
@@ -208,26 +208,26 @@ int pa_simple_write(struct pa_simple *p, const void*data, size_t length, int *pe
size_t l;
while (!(l = pa_stream_writable_size(p->stream)))
- if (iterate(p, 1, perror) < 0)
+ if (iterate(p, 1, rerror) < 0)
return -1;
if (l > length)
l = length;
pa_stream_write(p->stream, data, l, NULL, 0);
- data = (uint8_t*) data + l;
+ data = (const uint8_t*) data + l;
length -= l;
}
/* Make sure that no data is pending for write */
- if (iterate(p, 0, perror) < 0)
+ if (iterate(p, 0, rerror) < 0)
return -1;
return 0;
}
-static void read_callback(struct pa_stream *s, const void*data, size_t length, void *userdata) {
- struct pa_simple *p = userdata;
+static void read_callback(pa_stream *s, const void*data, size_t length, void *userdata) {
+ pa_simple *p = userdata;
assert(s && data && length && p);
if (p->read_data) {
@@ -239,12 +239,12 @@ static void read_callback(struct pa_stream *s, const void*data, size_t length, v
p->read_index = 0;
}
-int pa_simple_read(struct pa_simple *p, void*data, size_t length, int *perror) {
+int pa_simple_read(pa_simple *p, void*data, size_t length, int *rerror) {
assert(p && data && p->direction == PA_STREAM_RECORD);
if (p->dead) {
- if (perror)
- *perror = pa_context_errno(p->context);
+ if (rerror)
+ *rerror = pa_context_errno(p->context);
return -1;
}
@@ -276,27 +276,27 @@ int pa_simple_read(struct pa_simple *p, void*data, size_t length, int *perror) {
assert(!p->read_data);
}
- if (iterate(p, 1, perror) < 0)
+ if (iterate(p, 1, rerror) < 0)
return -1;
}
return 0;
}
-static void drain_or_flush_complete(struct pa_stream *s, int success, void *userdata) {
- struct pa_simple *p = userdata;
+static void drain_or_flush_complete(pa_stream *s, int success, void *userdata) {
+ pa_simple *p = userdata;
assert(s && p);
if (!success)
p->dead = 1;
}
-int pa_simple_drain(struct pa_simple *p, int *perror) {
- struct pa_operation *o;
+int pa_simple_drain(pa_simple *p, int *rerror) {
+ pa_operation *o;
assert(p && p->direction == PA_STREAM_PLAYBACK);
if (p->dead) {
- if (perror)
- *perror = pa_context_errno(p->context);
+ if (rerror)
+ *rerror = pa_context_errno(p->context);
return -1;
}
@@ -304,7 +304,7 @@ int pa_simple_drain(struct pa_simple *p, int *perror) {
o = pa_stream_drain(p->stream, drain_or_flush_complete, p);
while (pa_operation_get_state(o) == PA_OPERATION_RUNNING) {
- if (iterate(p, 1, perror) < 0) {
+ if (iterate(p, 1, rerror) < 0) {
pa_operation_cancel(o);
pa_operation_unref(o);
return -1;
@@ -313,14 +313,14 @@ int pa_simple_drain(struct pa_simple *p, int *perror) {
pa_operation_unref(o);
- if (p->dead && perror)
- *perror = pa_context_errno(p->context);
+ if (p->dead && rerror)
+ *rerror = pa_context_errno(p->context);
return p->dead ? -1 : 0;
}
-static void latency_complete(struct pa_stream *s, const struct pa_latency_info *l, void *userdata) {
- struct pa_simple *p = userdata;
+static void latency_complete(pa_stream *s, const pa_latency_info *l, void *userdata) {
+ pa_simple *p = userdata;
assert(s && p);
if (!l)
@@ -333,13 +333,13 @@ static void latency_complete(struct pa_stream *s, const struct pa_latency_info *
}
}
-pa_usec_t pa_simple_get_playback_latency(struct pa_simple *p, int *perror) {
- struct pa_operation *o;
+pa_usec_t pa_simple_get_playback_latency(pa_simple *p, int *rerror) {
+ pa_operation *o;
assert(p && p->direction == PA_STREAM_PLAYBACK);
if (p->dead) {
- if (perror)
- *perror = pa_context_errno(p->context);
+ if (rerror)
+ *rerror = pa_context_errno(p->context);
return (pa_usec_t) -1;
}
@@ -349,7 +349,7 @@ pa_usec_t pa_simple_get_playback_latency(struct pa_simple *p, int *perror) {
while (pa_operation_get_state(o) == PA_OPERATION_RUNNING) {
- if (iterate(p, 1, perror) < 0) {
+ if (iterate(p, 1, rerror) < 0) {
pa_operation_cancel(o);
pa_operation_unref(o);
return -1;
@@ -358,19 +358,19 @@ pa_usec_t pa_simple_get_playback_latency(struct pa_simple *p, int *perror) {
pa_operation_unref(o);
- if (p->dead && perror)
- *perror = pa_context_errno(p->context);
+ if (p->dead && rerror)
+ *rerror = pa_context_errno(p->context);
return p->dead ? (pa_usec_t) -1 : p->latency;
}
-int pa_simple_flush(struct pa_simple *p, int *perror) {
- struct pa_operation *o;
+int pa_simple_flush(pa_simple *p, int *rerror) {
+ pa_operation *o;
assert(p && p->direction == PA_STREAM_PLAYBACK);
if (p->dead) {
- if (perror)
- *perror = pa_context_errno(p->context);
+ if (rerror)
+ *rerror = pa_context_errno(p->context);
return -1;
}
@@ -378,7 +378,7 @@ int pa_simple_flush(struct pa_simple *p, int *perror) {
o = pa_stream_flush(p->stream, drain_or_flush_complete, p);
while (pa_operation_get_state(o) == PA_OPERATION_RUNNING) {
- if (iterate(p, 1, perror) < 0) {
+ if (iterate(p, 1, rerror) < 0) {
pa_operation_cancel(o);
pa_operation_unref(o);
return -1;
@@ -387,8 +387,8 @@ int pa_simple_flush(struct pa_simple *p, int *perror) {
pa_operation_unref(o);
- if (p->dead && perror)
- *perror = pa_context_errno(p->context);
+ if (p->dead && rerror)
+ *rerror = pa_context_errno(p->context);
return p->dead ? -1 : 0;
}
diff --git a/polyp/polyplib-simple.h b/polyp/polyplib-simple.h
index 9abef3fa..d1589115 100644
--- a/polyp/polyplib-simple.h
+++ b/polyp/polyplib-simple.h
@@ -41,40 +41,40 @@
PA_C_DECL_BEGIN
-/** \struct pa_simple
+/** \pa_simple
* An opaque simple connection object */
-struct pa_simple;
+typedef struct pa_simple pa_simple;
/** Create a new connection to the server */
-struct pa_simple* pa_simple_new(
+pa_simple* pa_simple_new(
const char *server, /**< Server name, or NULL for default */
const char *name, /**< A descriptive name for this client (application name, ...) */
- enum pa_stream_direction dir, /**< Open this stream for recording or playback? */
+ pa_stream_direction dir, /**< Open this stream for recording or playback? */
const char *dev, /**< Sink (resp. source) name, or NULL for default */
const char *stream_name, /**< A descriptive name for this client (application name, song title, ...) */
- const struct pa_sample_spec *ss, /**< The sample type to use */
- const struct pa_buffer_attr *attr, /**< Buffering attributes, or NULL for default */
+ const pa_sample_spec *ss, /**< The sample type to use */
+ const pa_buffer_attr *attr, /**< Buffering attributes, or NULL for default */
pa_volume_t volume, /**< Initial volume. Only for playback streams. \since 0.5 */
int *error /**< A pointer where the error code is stored when the routine returns NULL. It is OK to pass NULL here. */
);
/** Close and free the connection to the server. The connection objects becomes invalid when this is called. */
-void pa_simple_free(struct pa_simple *s);
+void pa_simple_free(pa_simple *s);
/** Write some data to the server */
-int pa_simple_write(struct pa_simple *s, const void*data, size_t length, int *error);
+int pa_simple_write(pa_simple *s, const void*data, size_t length, int *error);
/** Wait until all data already written is played by the daemon */
-int pa_simple_drain(struct pa_simple *s, int *error);
+int pa_simple_drain(pa_simple *s, int *error);
/** Read some data from the server */
-int pa_simple_read(struct pa_simple *s, void*data, size_t length, int *error);
+int pa_simple_read(pa_simple *s, void*data, size_t length, int *error);
/** Return the playback latency. \since 0.5 */
-pa_usec_t pa_simple_get_playback_latency(struct pa_simple *s, int *perror);
+pa_usec_t pa_simple_get_playback_latency(pa_simple *s, int *error);
/** Flush the playback buffer. \since 0.5 */
-int pa_simple_flush(struct pa_simple *s, int *perror);
+int pa_simple_flush(pa_simple *s, int *error);
PA_C_DECL_END
diff --git a/polyp/polyplib-stream.c b/polyp/polyplib-stream.c
index b6a091b3..6c8ed9c5 100644
--- a/polyp/polyplib-stream.c
+++ b/polyp/polyplib-stream.c
@@ -36,11 +36,11 @@
#define LATENCY_IPOL_INTERVAL_USEC (10000L)
-struct pa_stream *pa_stream_new(struct pa_context *c, const char *name, const struct pa_sample_spec *ss) {
- struct pa_stream *s;
+pa_stream *pa_stream_new(pa_context *c, const char *name, const pa_sample_spec *ss) {
+ pa_stream *s;
assert(c && ss);
- s = pa_xmalloc(sizeof(struct pa_stream));
+ s = pa_xmalloc(sizeof(pa_stream));
s->ref = 1;
s->context = c;
s->mainloop = c->mainloop;
@@ -76,12 +76,12 @@ struct pa_stream *pa_stream_new(struct pa_context *c, const char *name, const st
s->ipol_event = NULL;
s->ipol_requested = 0;
- PA_LLIST_PREPEND(struct pa_stream, c->streams, s);
+ PA_LLIST_PREPEND(pa_stream, c->streams, s);
return pa_stream_ref(s);
}
-static void stream_free(struct pa_stream *s) {
+static void stream_free(pa_stream *s) {
assert(s);
if (s->ipol_event) {
@@ -95,35 +95,35 @@ static void stream_free(struct pa_stream *s) {
pa_xfree(s);
}
-void pa_stream_unref(struct pa_stream *s) {
+void pa_stream_unref(pa_stream *s) {
assert(s && s->ref >= 1);
if (--(s->ref) == 0)
stream_free(s);
}
-struct pa_stream* pa_stream_ref(struct pa_stream *s) {
+pa_stream* pa_stream_ref(pa_stream *s) {
assert(s && s->ref >= 1);
s->ref++;
return s;
}
-enum pa_stream_state pa_stream_get_state(struct pa_stream *s) {
+pa_stream_state pa_stream_get_state(pa_stream *s) {
assert(s && s->ref >= 1);
return s->state;
}
-struct pa_context* pa_stream_get_context(struct pa_stream *s) {
+pa_context* pa_stream_get_context(pa_stream *s) {
assert(s && s->ref >= 1);
return s->context;
}
-uint32_t pa_stream_get_index(struct pa_stream *s) {
+uint32_t pa_stream_get_index(pa_stream *s) {
assert(s && s->ref >= 1);
return s->device_index;
}
-void pa_stream_set_state(struct pa_stream *s, enum pa_stream_state st) {
+void pa_stream_set_state(pa_stream *s, pa_stream_state st) {
assert(s && s->ref >= 1);
if (s->state == st)
@@ -137,7 +137,7 @@ void pa_stream_set_state(struct pa_stream *s, enum pa_stream_state st) {
if (s->channel_valid)
pa_dynarray_put((s->direction == PA_STREAM_PLAYBACK) ? s->context->playback_streams : s->context->record_streams, s->channel, NULL);
- PA_LLIST_REMOVE(struct pa_stream, s->context->streams, s);
+ PA_LLIST_REMOVE(pa_stream, s->context->streams, s);
pa_stream_unref(s);
}
@@ -147,9 +147,9 @@ void pa_stream_set_state(struct pa_stream *s, enum pa_stream_state st) {
pa_stream_unref(s);
}
-void pa_command_stream_killed(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
- struct pa_context *c = userdata;
- struct pa_stream *s;
+void pa_command_stream_killed(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED uint32_t tag, pa_tagstruct *t, void *userdata) {
+ pa_context *c = userdata;
+ pa_stream *s;
uint32_t channel;
assert(pd && (command == PA_COMMAND_PLAYBACK_STREAM_KILLED || command == PA_COMMAND_RECORD_STREAM_KILLED) && t && c);
@@ -171,9 +171,9 @@ finish:
pa_context_unref(c);
}
-void pa_command_request(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
- struct pa_stream *s;
- struct pa_context *c = userdata;
+void pa_command_request(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED uint32_t tag, pa_tagstruct *t, void *userdata) {
+ pa_stream *s;
+ pa_context *c = userdata;
uint32_t bytes, channel;
assert(pd && command == PA_COMMAND_REQUEST && t && c);
@@ -205,9 +205,9 @@ finish:
pa_context_unref(c);
}
-static void ipol_callback(struct pa_mainloop_api *m, struct pa_time_event *e, const struct timeval *tv, void *userdata) {
+static void ipol_callback(pa_mainloop_api *m, pa_time_event *e, PA_GCC_UNUSED const struct timeval *tv, void *userdata) {
struct timeval tv2;
- struct pa_stream *s = userdata;
+ pa_stream *s = userdata;
pa_stream_ref(s);
@@ -227,8 +227,8 @@ static void ipol_callback(struct pa_mainloop_api *m, struct pa_time_event *e, co
}
-void pa_create_stream_callback(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
- struct pa_stream *s = userdata;
+void pa_create_stream_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED uint32_t tag, pa_tagstruct *t, void *userdata) {
+ pa_stream *s = userdata;
assert(pd && s && s->state == PA_STREAM_CREATING);
pa_stream_ref(s);
@@ -271,8 +271,8 @@ finish:
pa_stream_unref(s);
}
-static void create_stream(struct pa_stream *s, const char *dev, const struct pa_buffer_attr *attr, enum pa_stream_flags flags, pa_volume_t volume) {
- struct pa_tagstruct *t;
+static void create_stream(pa_stream *s, const char *dev, const pa_buffer_attr *attr, pa_stream_flags flags, pa_volume_t volume) {
+ pa_tagstruct *t;
uint32_t tag;
assert(s && s->ref >= 1 && s->state == PA_STREAM_DISCONNECTED);
@@ -326,20 +326,20 @@ static void create_stream(struct pa_stream *s, const char *dev, const struct pa_
pa_stream_unref(s);
}
-void pa_stream_connect_playback(struct pa_stream *s, const char *dev, const struct pa_buffer_attr *attr, enum pa_stream_flags flags, pa_volume_t volume) {
+void pa_stream_connect_playback(pa_stream *s, const char *dev, const pa_buffer_attr *attr, pa_stream_flags flags, pa_volume_t volume) {
assert(s && s->context->state == PA_CONTEXT_READY && s->ref >= 1);
s->direction = PA_STREAM_PLAYBACK;
create_stream(s, dev, attr, flags, volume);
}
-void pa_stream_connect_record(struct pa_stream *s, const char *dev, const struct pa_buffer_attr *attr, enum pa_stream_flags flags) {
+void pa_stream_connect_record(pa_stream *s, const char *dev, const pa_buffer_attr *attr, pa_stream_flags flags) {
assert(s && s->context->state == PA_CONTEXT_READY && s->ref >= 1);
s->direction = PA_STREAM_RECORD;
create_stream(s, dev, attr, flags, 0);
}
-void pa_stream_write(struct pa_stream *s, const void *data, size_t length, void (*free_cb)(void *p), size_t delta) {
- struct pa_memchunk chunk;
+void pa_stream_write(pa_stream *s, const void *data, size_t length, void (*free_cb)(void *p), size_t delta) {
+ pa_memchunk chunk;
assert(s && s->context && data && length && s->state == PA_STREAM_READY && s->ref >= 1);
if (free_cb) {
@@ -364,20 +364,20 @@ void pa_stream_write(struct pa_stream *s, const void *data, size_t length, void
s->counter += length;
}
-size_t pa_stream_writable_size(struct pa_stream *s) {
+size_t pa_stream_writable_size(pa_stream *s) {
assert(s && s->ref >= 1);
return s->state == PA_STREAM_READY ? s->requested_bytes : 0;
}
-struct pa_operation * pa_stream_drain(struct pa_stream *s, void (*cb) (struct pa_stream*s, int success, void *userdata), void *userdata) {
- struct pa_operation *o;
- struct pa_tagstruct *t;
+pa_operation * pa_stream_drain(pa_stream *s, void (*cb) (pa_stream*s, int success, void *userdata), void *userdata) {
+ pa_operation *o;
+ pa_tagstruct *t;
uint32_t tag;
assert(s && s->ref >= 1 && s->state == PA_STREAM_READY);
o = pa_operation_new(s->context, s);
assert(o);
- o->callback = cb;
+ o->callback = (pa_operation_callback) cb;
o->userdata = userdata;
t = pa_tagstruct_new(NULL, 0);
@@ -391,9 +391,9 @@ struct pa_operation * pa_stream_drain(struct pa_stream *s, void (*cb) (struct pa
return pa_operation_ref(o);
}
-static void stream_get_latency_info_callback(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
- struct pa_operation *o = userdata;
- struct pa_latency_info i, *p = NULL;
+static void stream_get_latency_info_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED uint32_t tag, pa_tagstruct *t, void *userdata) {
+ pa_operation *o = userdata;
+ pa_latency_info i, *p = NULL;
struct timeval local, remote, now;
assert(pd && o && o->stream && o->context);
@@ -444,7 +444,7 @@ static void stream_get_latency_info_callback(struct pa_pdispatch *pd, uint32_t c
}
if (o->callback) {
- void (*cb)(struct pa_stream *s, const struct pa_latency_info *i, void *userdata) = o->callback;
+ void (*cb)(pa_stream *s, const pa_latency_info *_i, void *_userdata) = (void (*)(pa_stream *s, const pa_latency_info *_i, void *_userdata)) o->callback;
cb(o->stream, p, o->userdata);
}
@@ -453,16 +453,16 @@ finish:
pa_operation_unref(o);
}
-struct pa_operation* pa_stream_get_latency_info(struct pa_stream *s, void (*cb)(struct pa_stream *p, const struct pa_latency_info*i, void *userdata), void *userdata) {
+pa_operation* pa_stream_get_latency_info(pa_stream *s, void (*cb)(pa_stream *p, const pa_latency_info*i, void *userdata), void *userdata) {
uint32_t tag;
- struct pa_operation *o;
- struct pa_tagstruct *t;
+ pa_operation *o;
+ pa_tagstruct *t;
struct timeval now;
assert(s && s->direction != PA_STREAM_UPLOAD);
o = pa_operation_new(s->context, s);
assert(o);
- o->callback = cb;
+ o->callback = (pa_operation_callback) cb;
o->userdata = userdata;
t = pa_tagstruct_new(NULL, 0);
@@ -481,8 +481,8 @@ struct pa_operation* pa_stream_get_latency_info(struct pa_stream *s, void (*cb)(
return pa_operation_ref(o);
}
-void pa_stream_disconnect_callback(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
- struct pa_stream *s = userdata;
+void pa_stream_disconnect_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED uint32_t tag, pa_tagstruct *t, void *userdata) {
+ pa_stream *s = userdata;
assert(pd && s && s->ref >= 1);
pa_stream_ref(s);
@@ -504,8 +504,8 @@ finish:
pa_stream_unref(s);
}
-void pa_stream_disconnect(struct pa_stream *s) {
- struct pa_tagstruct *t;
+void pa_stream_disconnect(pa_stream *s) {
+ pa_tagstruct *t;
uint32_t tag;
assert(s && s->ref >= 1);
@@ -527,26 +527,26 @@ void pa_stream_disconnect(struct pa_stream *s) {
pa_stream_unref(s);
}
-void pa_stream_set_read_callback(struct pa_stream *s, void (*cb)(struct pa_stream *p, const void*data, size_t length, void *userdata), void *userdata) {
+void pa_stream_set_read_callback(pa_stream *s, void (*cb)(pa_stream *p, const void*data, size_t length, void *userdata), void *userdata) {
assert(s && s->ref >= 1);
s->read_callback = cb;
s->read_userdata = userdata;
}
-void pa_stream_set_write_callback(struct pa_stream *s, void (*cb)(struct pa_stream *p, size_t length, void *userdata), void *userdata) {
+void pa_stream_set_write_callback(pa_stream *s, void (*cb)(pa_stream *p, size_t length, void *userdata), void *userdata) {
assert(s && s->ref >= 1);
s->write_callback = cb;
s->write_userdata = userdata;
}
-void pa_stream_set_state_callback(struct pa_stream *s, void (*cb)(struct pa_stream *s, void *userdata), void *userdata) {
+void pa_stream_set_state_callback(pa_stream *s, void (*cb)(pa_stream *s, void *userdata), void *userdata) {
assert(s && s->ref >= 1);
s->state_callback = cb;
s->state_userdata = userdata;
}
-void pa_stream_simple_ack_callback(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
- struct pa_operation *o = userdata;
+void pa_stream_simple_ack_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED uint32_t tag, pa_tagstruct *t, void *userdata) {
+ pa_operation *o = userdata;
int success = 1;
assert(pd && o && o->context && o->ref >= 1);
@@ -561,7 +561,7 @@ void pa_stream_simple_ack_callback(struct pa_pdispatch *pd, uint32_t command, ui
}
if (o->callback) {
- void (*cb)(struct pa_stream *s, int success, void *userdata) = o->callback;
+ void (*cb)(pa_stream *s, int _success, void *_userdata) = (void (*)(pa_stream *s, int _success, void *_userdata)) o->callback;
cb(o->stream, success, o->userdata);
}
@@ -570,9 +570,9 @@ finish:
pa_operation_unref(o);
}
-struct pa_operation* pa_stream_cork(struct pa_stream *s, int b, void (*cb) (struct pa_stream*s, int success, void *userdata), void *userdata) {
- struct pa_operation *o;
- struct pa_tagstruct *t;
+pa_operation* pa_stream_cork(pa_stream *s, int b, void (*cb) (pa_stream*s, int success, void *userdata), void *userdata) {
+ pa_operation *o;
+ pa_tagstruct *t;
uint32_t tag;
assert(s && s->ref >= 1 && s->state == PA_STREAM_READY);
@@ -589,7 +589,7 @@ struct pa_operation* pa_stream_cork(struct pa_stream *s, int b, void (*cb) (stru
o = pa_operation_new(s->context, s);
assert(o);
- o->callback = cb;
+ o->callback = (pa_operation_callback) cb;
o->userdata = userdata;
t = pa_tagstruct_new(NULL, 0);
@@ -606,14 +606,14 @@ struct pa_operation* pa_stream_cork(struct pa_stream *s, int b, void (*cb) (stru
return pa_operation_ref(o);
}
-struct pa_operation* pa_stream_send_simple_command(struct pa_stream *s, uint32_t command, void (*cb)(struct pa_stream *s, int success, void *userdata), void *userdata) {
- struct pa_tagstruct *t;
- struct pa_operation *o;
+static pa_operation* stream_send_simple_command(pa_stream *s, uint32_t command, void (*cb)(pa_stream *s, int success, void *userdata), void *userdata) {
+ pa_tagstruct *t;
+ pa_operation *o;
uint32_t tag;
assert(s && s->ref >= 1 && s->state == PA_STREAM_READY);
o = pa_operation_new(s->context, s);
- o->callback = cb;
+ o->callback = (pa_operation_callback) cb;
o->userdata = userdata;
t = pa_tagstruct_new(NULL, 0);
@@ -626,36 +626,36 @@ struct pa_operation* pa_stream_send_simple_command(struct pa_stream *s, uint32_t
return pa_operation_ref(o);
}
-struct pa_operation* pa_stream_flush(struct pa_stream *s, void (*cb)(struct pa_stream *s, int success, void *userdata), void *userdata) {
- struct pa_operation *o;
- o = pa_stream_send_simple_command(s, s->direction == PA_STREAM_PLAYBACK ? PA_COMMAND_FLUSH_PLAYBACK_STREAM : PA_COMMAND_FLUSH_RECORD_STREAM, cb, userdata);
+pa_operation* pa_stream_flush(pa_stream *s, void (*cb)(pa_stream *s, int success, void *userdata), void *userdata) {
+ pa_operation *o;
+ o = stream_send_simple_command(s, s->direction == PA_STREAM_PLAYBACK ? PA_COMMAND_FLUSH_PLAYBACK_STREAM : PA_COMMAND_FLUSH_RECORD_STREAM, cb, userdata);
pa_operation_unref(pa_stream_get_latency_info(s, NULL, NULL));
return o;
}
-struct pa_operation* pa_stream_prebuf(struct pa_stream *s, void (*cb)(struct pa_stream *s, int success, void *userdata), void *userdata) {
- struct pa_operation *o;
- o = pa_stream_send_simple_command(s, PA_COMMAND_PREBUF_PLAYBACK_STREAM, cb, userdata);
+pa_operation* pa_stream_prebuf(pa_stream *s, void (*cb)(pa_stream *s, int success, void *userdata), void *userdata) {
+ pa_operation *o;
+ o = stream_send_simple_command(s, PA_COMMAND_PREBUF_PLAYBACK_STREAM, cb, userdata);
pa_operation_unref(pa_stream_get_latency_info(s, NULL, NULL));
return o;
}
-struct pa_operation* pa_stream_trigger(struct pa_stream *s, void (*cb)(struct pa_stream *s, int success, void *userdata), void *userdata) {
- struct pa_operation *o;
- o = pa_stream_send_simple_command(s, PA_COMMAND_TRIGGER_PLAYBACK_STREAM, cb, userdata);
+pa_operation* pa_stream_trigger(pa_stream *s, void (*cb)(pa_stream *s, int success, void *userdata), void *userdata) {
+ pa_operation *o;
+ o = stream_send_simple_command(s, PA_COMMAND_TRIGGER_PLAYBACK_STREAM, cb, userdata);
pa_operation_unref(pa_stream_get_latency_info(s, NULL, NULL));
return o;
}
-struct pa_operation* pa_stream_set_name(struct pa_stream *s, const char *name, void(*cb)(struct pa_stream*c, int success, void *userdata), void *userdata) {
- struct pa_operation *o;
- struct pa_tagstruct *t;
+pa_operation* pa_stream_set_name(pa_stream *s, const char *name, void(*cb)(pa_stream*c, int success, void *userdata), void *userdata) {
+ pa_operation *o;
+ pa_tagstruct *t;
uint32_t tag;
assert(s && s->ref >= 1 && s->state == PA_STREAM_READY && name && s->direction != PA_STREAM_UPLOAD);
o = pa_operation_new(s->context, s);
assert(o);
- o->callback = cb;
+ o->callback = (pa_operation_callback) cb;
o->userdata = userdata;
t = pa_tagstruct_new(NULL, 0);
@@ -670,12 +670,12 @@ struct pa_operation* pa_stream_set_name(struct pa_stream *s, const char *name, v
return pa_operation_ref(o);
}
-uint64_t pa_stream_get_counter(struct pa_stream *s) {
+uint64_t pa_stream_get_counter(pa_stream *s) {
assert(s);
return s->counter;
}
-pa_usec_t pa_stream_get_time(struct pa_stream *s, const struct pa_latency_info *i) {
+pa_usec_t pa_stream_get_time(pa_stream *s, const pa_latency_info *i) {
pa_usec_t usec;
assert(s);
@@ -707,7 +707,7 @@ pa_usec_t pa_stream_get_time(struct pa_stream *s, const struct pa_latency_info *
return usec;
}
-static pa_usec_t time_counter_diff(struct pa_stream *s, pa_usec_t t, pa_usec_t c, int *negative) {
+static pa_usec_t time_counter_diff(pa_stream *s, pa_usec_t t, pa_usec_t c, int *negative) {
assert(s);
if (negative)
@@ -725,7 +725,7 @@ static pa_usec_t time_counter_diff(struct pa_stream *s, pa_usec_t t, pa_usec_t c
return c-t;
}
-pa_usec_t pa_stream_get_latency(struct pa_stream *s, const struct pa_latency_info *i, int *negative) {
+pa_usec_t pa_stream_get_latency(pa_stream *s, const pa_latency_info *i, int *negative) {
pa_usec_t t, c;
assert(s && i);
@@ -735,12 +735,12 @@ pa_usec_t pa_stream_get_latency(struct pa_stream *s, const struct pa_latency_inf
return time_counter_diff(s, t, c, negative);
}
-const struct pa_sample_spec* pa_stream_get_sample_spec(struct pa_stream *s) {
+const pa_sample_spec* pa_stream_get_sample_spec(pa_stream *s) {
assert(s);
return &s->sample_spec;
}
-void pa_stream_trash_ipol(struct pa_stream *s) {
+void pa_stream_trash_ipol(pa_stream *s) {
assert(s);
if (!s->interpolate)
@@ -750,7 +750,7 @@ void pa_stream_trash_ipol(struct pa_stream *s) {
s->ipol_usec = 0;
}
-pa_usec_t pa_stream_get_interpolated_time(struct pa_stream *s) {
+pa_usec_t pa_stream_get_interpolated_time(pa_stream *s) {
pa_usec_t usec;
assert(s && s->interpolate);
@@ -771,7 +771,7 @@ pa_usec_t pa_stream_get_interpolated_time(struct pa_stream *s) {
return usec;
}
-pa_usec_t pa_stream_get_interpolated_latency(struct pa_stream *s, int *negative) {
+pa_usec_t pa_stream_get_interpolated_latency(pa_stream *s, int *negative) {
pa_usec_t t, c;
assert(s && s->interpolate);
diff --git a/polyp/polyplib-stream.h b/polyp/polyplib-stream.h
index 939b2ae6..806579f5 100644
--- a/polyp/polyplib-stream.h
+++ b/polyp/polyplib-stream.h
@@ -34,43 +34,43 @@
PA_C_DECL_BEGIN
-/** \struct pa_stream
+/** \pa_stream
* An opaque stream for playback or recording */
-struct pa_stream;
+typedef struct pa_stream pa_stream;
/** Create a new, unconnected stream with the specified name and sample type */
-struct pa_stream* pa_stream_new(struct pa_context *c, const char *name, const struct pa_sample_spec *ss);
+pa_stream* pa_stream_new(pa_context *c, const char *name, const pa_sample_spec *ss);
/** Decrease the reference counter by one */
-void pa_stream_unref(struct pa_stream *s);
+void pa_stream_unref(pa_stream *s);
/** Increase the reference counter by one */
-struct pa_stream *pa_stream_ref(struct pa_stream *s);
+pa_stream *pa_stream_ref(pa_stream *s);
/** Return the current state of the stream */
-enum pa_stream_state pa_stream_get_state(struct pa_stream *p);
+pa_stream_state pa_stream_get_state(pa_stream *p);
/** Return the context this stream is attached to */
-struct pa_context* pa_stream_get_context(struct pa_stream *p);
+pa_context* pa_stream_get_context(pa_stream *p);
/** Return the device (sink input or source output) index this stream is connected to */
-uint32_t pa_stream_get_index(struct pa_stream *s);
+uint32_t pa_stream_get_index(pa_stream *s);
/** Connect the stream to a sink */
-void pa_stream_connect_playback(struct pa_stream *s, const char *dev, const struct pa_buffer_attr *attr, enum pa_stream_flags flags, pa_volume_t volume);
+void pa_stream_connect_playback(pa_stream *s, const char *dev, const pa_buffer_attr *attr, pa_stream_flags flags, pa_volume_t volume);
/** Connect the stream to a source */
-void pa_stream_connect_record(struct pa_stream *s, const char *dev, const struct pa_buffer_attr *attr, enum pa_stream_flags flags);
+void pa_stream_connect_record(pa_stream *s, const char *dev, const pa_buffer_attr *attr, pa_stream_flags flags);
/** Disconnect a stream from a source/sink */
-void pa_stream_disconnect(struct pa_stream *s);
+void pa_stream_disconnect(pa_stream *s);
/** Write some data to the server (for playback sinks), if free_cb is
* non-NULL this routine is called when all data has been written out
* and an internal reference to the specified data is kept, the data
* is not copied. If NULL, the data is copied into an internal
* buffer. */
-void pa_stream_write(struct pa_stream *p /**< The stream to use */,
+void pa_stream_write(pa_stream *p /**< The stream to use */,
const void *data /**< The data to write */,
size_t length /**< The length of the data to write */,
void (*free_cb)(void *p) /**< A cleanup routine for the data or NULL to request an internal copy */,
@@ -96,74 +96,74 @@ void pa_stream_write(struct pa_stream *p /**< The stream to use */,
upload streams. */);
/** Return the amount of bytes that may be written using pa_stream_write() */
-size_t pa_stream_writable_size(struct pa_stream *p);
+size_t pa_stream_writable_size(pa_stream *p);
/** Drain a playback stream */
-struct pa_operation* pa_stream_drain(struct pa_stream *s, void (*cb) (struct pa_stream*s, int success, void *userdata), void *userdata);
+pa_operation* pa_stream_drain(pa_stream *s, void (*cb) (pa_stream*s, int success, void *userdata), void *userdata);
/** Get the playback latency of a stream */
-struct pa_operation* pa_stream_get_latency_info(struct pa_stream *p, void (*cb)(struct pa_stream *p, const struct pa_latency_info *i, void *userdata), void *userdata);
+pa_operation* pa_stream_get_latency_info(pa_stream *p, void (*cb)(pa_stream *p, const pa_latency_info *i, void *userdata), void *userdata);
/** Set the callback function that is called whenever the state of the stream changes */
-void pa_stream_set_state_callback(struct pa_stream *s, void (*cb)(struct pa_stream *s, void *userdata), void *userdata);
+void pa_stream_set_state_callback(pa_stream *s, void (*cb)(pa_stream *s, void *userdata), void *userdata);
/** Set the callback function that is called when new data may be
* written to the stream. */
-void pa_stream_set_write_callback(struct pa_stream *p, void (*cb)(struct pa_stream *p, size_t length, void *userdata), void *userdata);
+void pa_stream_set_write_callback(pa_stream *p, void (*cb)(pa_stream *p, size_t length, void *userdata), void *userdata);
/** Set the callback function that is called when new data is available from the stream */
-void pa_stream_set_read_callback(struct pa_stream *p, void (*cb)(struct pa_stream *p, const void*data, size_t length, void *userdata), void *userdata);
+void pa_stream_set_read_callback(pa_stream *p, void (*cb)(pa_stream *p, const void*data, size_t length, void *userdata), void *userdata);
/** Pause (or resume) playback of this stream temporarily. Available on both playback and recording streams. \since 0.3 */
-struct pa_operation* pa_stream_cork(struct pa_stream *s, int b, void (*cb) (struct pa_stream*s, int success, void *userdata), void *userdata);
+pa_operation* pa_stream_cork(pa_stream *s, int b, void (*cb) (pa_stream*s, int success, void *userdata), void *userdata);
/** Flush the playback buffer of this stream. Most of the time you're
* better off using the parameter delta of pa_stream_write() instead of this
* function. Available on both playback and recording streams. \since 0.3 */
-struct pa_operation* pa_stream_flush(struct pa_stream *s, void (*cb)(struct pa_stream *s, int success, void *userdata), void *userdata);
+pa_operation* pa_stream_flush(pa_stream *s, void (*cb)(pa_stream *s, int success, void *userdata), void *userdata);
/** Reenable prebuffering. Available for playback streams only. \since 0.6 */
-struct pa_operation* pa_stream_prebuf(struct pa_stream *s, void (*cb)(struct pa_stream *s, int success, void *userdata), void *userdata);
+pa_operation* pa_stream_prebuf(pa_stream *s, void (*cb)(pa_stream *s, int success, void *userdata), void *userdata);
/** Request immediate start of playback on this stream. This disables
* prebuffering as specified in the pa_buffer_attr structure. Available for playback streams only. \since
* 0.3 */
-struct pa_operation* pa_stream_trigger(struct pa_stream *s, void (*cb)(struct pa_stream *s, int success, void *userdata), void *userdata);
+pa_operation* pa_stream_trigger(pa_stream *s, void (*cb)(pa_stream *s, int success, void *userdata), void *userdata);
/** Rename the stream. \since 0.5 */
-struct pa_operation* pa_stream_set_name(struct pa_stream *s, const char *name, void(*cb)(struct pa_stream*c, int success, void *userdata), void *userdata);
+pa_operation* pa_stream_set_name(pa_stream *s, const char *name, void(*cb)(pa_stream*c, int success, void *userdata), void *userdata);
/** Return the total number of bytes written to/read from the
* stream. This counter is not reset on pa_stream_flush(), you may do
* this yourself using pa_stream_reset_counter(). \since 0.6 */
-uint64_t pa_stream_get_counter(struct pa_stream *s);
+uint64_t pa_stream_get_counter(pa_stream *s);
/** Return the current playback/recording time. This is based on the
* counter accessible with pa_stream_get_counter(). This function
* requires a pa_latency_info structure as argument, which should be
* acquired using pa_stream_get_latency(). \since 0.6 */
-pa_usec_t pa_stream_get_time(struct pa_stream *s, const struct pa_latency_info *i);
+pa_usec_t pa_stream_get_time(pa_stream *s, const pa_latency_info *i);
/** Return the total stream latency. Thus function requires a
* pa_latency_info structure as argument, which should be aquired
* using pa_stream_get_latency(). In case the stream is a monitoring
* stream the result can be negative, i.e. the captured samples are
* not yet played. In this case *negative is set to 1. \since 0.6 */
-pa_usec_t pa_stream_get_latency(struct pa_stream *s, const struct pa_latency_info *i, int *negative);
+pa_usec_t pa_stream_get_latency(pa_stream *s, const pa_latency_info *i, int *negative);
/** Return the interpolated playback/recording time. Requires the
* PA_STREAM_INTERPOLATE_LATENCY bit set when creating the stream. In
* contrast to pa_stream_get_latency() this function doesn't require
* a whole roundtrip for response. \since 0.6 */
-pa_usec_t pa_stream_get_interpolated_time(struct pa_stream *s);
+pa_usec_t pa_stream_get_interpolated_time(pa_stream *s);
/** Return the interpolated playback/recording latency. Requires the
* PA_STREAM_INTERPOLATE_LATENCY bit set when creating the
* stream. \since 0.6 */
-pa_usec_t pa_stream_get_interpolated_latency(struct pa_stream *s, int *negative);
+pa_usec_t pa_stream_get_interpolated_latency(pa_stream *s, int *negative);
/** Return a pointer to the streams sample specification. \since 0.6 */
-const struct pa_sample_spec* pa_stream_get_sample_spec(struct pa_stream *s);
+const pa_sample_spec* pa_stream_get_sample_spec(pa_stream *s);
PA_C_DECL_END
diff --git a/polyp/polyplib-subscribe.c b/polyp/polyplib-subscribe.c
index d7e8e7c1..69ae588f 100644
--- a/polyp/polyplib-subscribe.c
+++ b/polyp/polyplib-subscribe.c
@@ -29,10 +29,11 @@
#include "polyplib-subscribe.h"
#include "polyplib-internal.h"
#include "pstream-util.h"
+#include "gccmacro.h"
-void pa_command_subscribe_event(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
- struct pa_context *c = userdata;
- enum pa_subscription_event_type e;
+void pa_command_subscribe_event(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED uint32_t tag, pa_tagstruct *t, void *userdata) {
+ pa_context *c = userdata;
+ pa_subscription_event_type e;
uint32_t index;
assert(pd && command == PA_COMMAND_SUBSCRIBE_EVENT && t && c);
@@ -53,14 +54,14 @@ finish:
}
-struct pa_operation* pa_context_subscribe(struct pa_context *c, enum pa_subscription_mask m, void (*cb)(struct pa_context *c, int success, void *userdata), void *userdata) {
- struct pa_operation *o;
- struct pa_tagstruct *t;
+pa_operation* pa_context_subscribe(pa_context *c, pa_subscription_mask m, void (*cb)(pa_context *c, int success, void *userdata), void *userdata) {
+ pa_operation *o;
+ pa_tagstruct *t;
uint32_t tag;
assert(c);
o = pa_operation_new(c, NULL);
- o->callback = cb;
+ o->callback = (pa_operation_callback) cb;
o->userdata = userdata;
t = pa_tagstruct_new(NULL, 0);
@@ -73,7 +74,7 @@ struct pa_operation* pa_context_subscribe(struct pa_context *c, enum pa_subscrip
return pa_operation_ref(o);
}
-void pa_context_set_subscribe_callback(struct pa_context *c, void (*cb)(struct pa_context *c, enum pa_subscription_event_type t, uint32_t index, void *userdata), void *userdata) {
+void pa_context_set_subscribe_callback(pa_context *c, void (*cb)(pa_context *c, pa_subscription_event_type t, uint32_t index, void *userdata), void *userdata) {
assert(c);
c->subscribe_callback = cb;
c->subscribe_userdata = userdata;
diff --git a/polyp/polyplib-subscribe.h b/polyp/polyplib-subscribe.h
index 5c697b71..f2760ee6 100644
--- a/polyp/polyplib-subscribe.h
+++ b/polyp/polyplib-subscribe.h
@@ -37,10 +37,10 @@
PA_C_DECL_BEGIN
/** Enable event notification */
-struct pa_operation* pa_context_subscribe(struct pa_context *c, enum pa_subscription_mask m, void (*cb)(struct pa_context *c, int success, void *userdata), void *userdata);
+pa_operation* pa_context_subscribe(pa_context *c, pa_subscription_mask m, void (*cb)(pa_context *c, int success, void *userdata), void *userdata);
/** Set the context specific call back function that is called whenever the state of the daemon changes */
-void pa_context_set_subscribe_callback(struct pa_context *c, void (*cb)(struct pa_context *c, enum pa_subscription_event_type t, uint32_t index, void *userdata), void *userdata);
+void pa_context_set_subscribe_callback(pa_context *c, void (*cb)(pa_context *c, pa_subscription_event_type t, uint32_t index, void *userdata), void *userdata);
PA_C_DECL_END
diff --git a/polyp/props.c b/polyp/props.c
index 1046551b..df748c1e 100644
--- a/polyp/props.c
+++ b/polyp/props.c
@@ -25,17 +25,17 @@
#include "props.h"
#include "log.h"
-struct pa_property {
+typedef struct pa_property {
char *name; /* Points to memory allocated by the property subsystem */
void *data; /* Points to memory maintained by the caller */
-};
+} pa_property;
/* Allocate a new property object */
-static struct pa_property* property_new(const char *name, void *data) {
- struct pa_property* p;
+static pa_property* property_new(const char *name, void *data) {
+ pa_property* p;
assert(name && data);
- p = pa_xmalloc(sizeof(struct pa_property));
+ p = pa_xmalloc(sizeof(pa_property));
p->name = pa_xstrdup(name);
p->data = data;
@@ -43,15 +43,15 @@ static struct pa_property* property_new(const char *name, void *data) {
}
/* Free a property object */
-static void property_free(struct pa_property *p) {
+static void property_free(pa_property *p) {
assert(p);
pa_xfree(p->name);
pa_xfree(p);
}
-void* pa_property_get(struct pa_core *c, const char *name) {
- struct pa_property *p;
+void* pa_property_get(pa_core *c, const char *name) {
+ pa_property *p;
assert(c && name && c->properties);
if (!(p = pa_hashmap_get(c->properties, name)))
@@ -60,8 +60,8 @@ void* pa_property_get(struct pa_core *c, const char *name) {
return p->data;
}
-int pa_property_set(struct pa_core *c, const char *name, void *data) {
- struct pa_property *p;
+int pa_property_set(pa_core *c, const char *name, void *data) {
+ pa_property *p;
assert(c && name && data && c->properties);
if (pa_hashmap_get(c->properties, name))
@@ -72,8 +72,8 @@ int pa_property_set(struct pa_core *c, const char *name, void *data) {
return 0;
}
-int pa_property_remove(struct pa_core *c, const char *name) {
- struct pa_property *p;
+int pa_property_remove(pa_core *c, const char *name) {
+ pa_property *p;
assert(c && name && c->properties);
if (!(p = pa_hashmap_remove(c->properties, name)))
@@ -83,35 +83,35 @@ int pa_property_remove(struct pa_core *c, const char *name) {
return 0;
}
-void pa_property_init(struct pa_core *c) {
+void pa_property_init(pa_core *c) {
assert(c);
c->properties = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
}
-void pa_property_cleanup(struct pa_core *c) {
+void pa_property_cleanup(pa_core *c) {
assert(c);
if (!c->properties)
return;
- assert(!pa_hashmap_ncontents(c->properties));
+ assert(!pa_hashmap_size(c->properties));
pa_hashmap_free(c->properties, NULL, NULL);
c->properties = NULL;
}
-void pa_property_dump(struct pa_core *c, struct pa_strbuf *s) {
+void pa_property_dump(pa_core *c, pa_strbuf *s) {
void *state = NULL;
- struct pa_property *p;
+ pa_property *p;
assert(c && s);
while ((p = pa_hashmap_iterate(c->properties, &state, NULL)))
pa_strbuf_printf(s, "[%s] -> [%p]\n", p->name, p->data);
}
-int pa_property_replace(struct pa_core *c, const char *name, void *data) {
+int pa_property_replace(pa_core *c, const char *name, void *data) {
assert(c && name);
pa_property_remove(c, name);
diff --git a/polyp/props.h b/polyp/props.h
index 9b379cf1..5abf8787 100644
--- a/polyp/props.h
+++ b/polyp/props.h
@@ -33,26 +33,26 @@
* reference counting themselves. */
/* Return a pointer to the value of the specified property. */
-void* pa_property_get(struct pa_core *c, const char *name);
+void* pa_property_get(pa_core *c, const char *name);
/* Set the property 'name' to 'data'. This function fails in case a
* property by this name already exists. The property data is not
* copied or reference counted. This is the caller's job. */
-int pa_property_set(struct pa_core *c, const char *name, void *data);
+int pa_property_set(pa_core *c, const char *name, void *data);
/* Remove the specified property. Return non-zero on failure */
-int pa_property_remove(struct pa_core *c, const char *name);
+int pa_property_remove(pa_core *c, const char *name);
/* A combination of pa_property_remove() and pa_property_set() */
-int pa_property_replace(struct pa_core *c, const char *name, void *data);
+int pa_property_replace(pa_core *c, const char *name, void *data);
/* Free all memory used by the property system */
-void pa_property_cleanup(struct pa_core *c);
+void pa_property_cleanup(pa_core *c);
/* Initialize the properties subsystem */
-void pa_property_init(struct pa_core *c);
+void pa_property_init(pa_core *c);
/* Dump the current set of properties */
-void pa_property_dump(struct pa_core *c, struct pa_strbuf *s);
+void pa_property_dump(pa_core *c, pa_strbuf *s);
#endif
diff --git a/polyp/protocol-cli.c b/polyp/protocol-cli.c
index 107acb19..d2d73550 100644
--- a/polyp/protocol-cli.c
+++ b/polyp/protocol-cli.c
@@ -35,25 +35,25 @@
#define MAX_CONNECTIONS 25
struct pa_protocol_cli {
- struct pa_module *module;
- struct pa_core *core;
- struct pa_socket_server*server;
- struct pa_idxset *connections;
+ pa_module *module;
+ pa_core *core;
+ pa_socket_server*server;
+ pa_idxset *connections;
};
-static void cli_eof_cb(struct pa_cli*c, void*userdata) {
- struct pa_protocol_cli *p = userdata;
+static void cli_eof_cb(pa_cli*c, void*userdata) {
+ pa_protocol_cli *p = userdata;
assert(p);
pa_idxset_remove_by_data(p->connections, c, NULL);
pa_cli_free(c);
}
-static void on_connection(struct pa_socket_server*s, struct pa_iochannel *io, void *userdata) {
- struct pa_protocol_cli *p = userdata;
- struct pa_cli *c;
+static void on_connection(pa_socket_server*s, pa_iochannel *io, void *userdata) {
+ pa_protocol_cli *p = userdata;
+ pa_cli *c;
assert(s && io && p);
- if (pa_idxset_ncontents(p->connections)+1 > MAX_CONNECTIONS) {
+ if (pa_idxset_size(p->connections)+1 > MAX_CONNECTIONS) {
pa_log(__FILE__": Warning! Too many connections (%u), dropping incoming connection.\n", MAX_CONNECTIONS);
pa_iochannel_free(io);
return;
@@ -66,11 +66,11 @@ static void on_connection(struct pa_socket_server*s, struct pa_iochannel *io, vo
pa_idxset_put(p->connections, c, NULL);
}
-struct pa_protocol_cli* pa_protocol_cli_new(struct pa_core *core, struct pa_socket_server *server, struct pa_module *m, struct pa_modargs *ma) {
- struct pa_protocol_cli* p;
+pa_protocol_cli* pa_protocol_cli_new(pa_core *core, pa_socket_server *server, pa_module *m, PA_GCC_UNUSED pa_modargs *ma) {
+ pa_protocol_cli* p;
assert(core && server);
- p = pa_xmalloc(sizeof(struct pa_protocol_cli));
+ p = pa_xmalloc(sizeof(pa_protocol_cli));
p->module = m;
p->core = core;
p->server = server;
@@ -81,12 +81,12 @@ struct pa_protocol_cli* pa_protocol_cli_new(struct pa_core *core, struct pa_sock
return p;
}
-static void free_connection(void *p, void *userdata) {
+static void free_connection(void *p, PA_GCC_UNUSED void *userdata) {
assert(p);
pa_cli_free(p);
}
-void pa_protocol_cli_free(struct pa_protocol_cli *p) {
+void pa_protocol_cli_free(pa_protocol_cli *p) {
assert(p);
pa_idxset_free(p->connections, free_connection, NULL);
diff --git a/polyp/protocol-cli.h b/polyp/protocol-cli.h
index e0fe4bc1..aed733c1 100644
--- a/polyp/protocol-cli.h
+++ b/polyp/protocol-cli.h
@@ -27,9 +27,9 @@
#include "module.h"
#include "modargs.h"
-struct pa_protocol_cli;
+typedef struct pa_protocol_cli pa_protocol_cli;
-struct pa_protocol_cli* pa_protocol_cli_new(struct pa_core *core, struct pa_socket_server *server, struct pa_module *m, struct pa_modargs *ma);
-void pa_protocol_cli_free(struct pa_protocol_cli *n);
+pa_protocol_cli* pa_protocol_cli_new(pa_core *core, pa_socket_server *server, pa_module *m, pa_modargs *ma);
+void pa_protocol_cli_free(pa_protocol_cli *n);
#endif
diff --git a/polyp/protocol-esound.c b/polyp/protocol-esound.c
index 18ecb0ac..a97bc25c 100644
--- a/polyp/protocol-esound.c
+++ b/polyp/protocol-esound.c
@@ -45,6 +45,7 @@
#include "namereg.h"
#include "xmalloc.h"
#include "log.h"
+#include "util.h"
/* Don't accept more connection than this */
#define MAX_CONNECTIONS 10
@@ -70,9 +71,9 @@
struct connection {
uint32_t index;
int dead;
- struct pa_protocol_esound *protocol;
- struct pa_iochannel *io;
- struct pa_client *client;
+ pa_protocol_esound *protocol;
+ pa_iochannel *io;
+ pa_client *client;
int authorized, swap_byte_order;
void *write_data;
size_t write_data_alloc, write_data_index, write_data_length;
@@ -80,31 +81,31 @@ struct connection {
size_t read_data_alloc, read_data_length;
esd_proto_t request;
esd_client_state_t state;
- struct pa_sink_input *sink_input;
- struct pa_source_output *source_output;
- struct pa_memblockq *input_memblockq, *output_memblockq;
- struct pa_defer_event *defer_event;
+ pa_sink_input *sink_input;
+ pa_source_output *source_output;
+ pa_memblockq *input_memblockq, *output_memblockq;
+ pa_defer_event *defer_event;
struct {
- struct pa_memblock *current_memblock;
+ pa_memblock *current_memblock;
size_t memblock_index, fragment_size;
} playback;
struct {
- struct pa_memchunk memchunk;
+ pa_memchunk memchunk;
char *name;
- struct pa_sample_spec sample_spec;
+ pa_sample_spec sample_spec;
} scache;
- struct pa_time_event *auth_timeout_event;
+ pa_time_event *auth_timeout_event;
};
struct pa_protocol_esound {
int public;
- struct pa_module *module;
- struct pa_core *core;
- struct pa_socket_server *server;
- struct pa_idxset *connections;
+ pa_module *module;
+ pa_core *core;
+ pa_socket_server *server;
+ pa_idxset *connections;
char *sink_name, *source_name;
unsigned n_player;
uint8_t esd_key[ESD_KEY_LEN];
@@ -116,14 +117,14 @@ typedef struct proto_handler {
const char *description;
} esd_proto_handler_info_t;
-static void sink_input_drop_cb(struct pa_sink_input *i, const struct pa_memchunk *chunk, size_t length);
-static int sink_input_peek_cb(struct pa_sink_input *i, struct pa_memchunk *chunk);
-static void sink_input_kill_cb(struct pa_sink_input *i);
-static pa_usec_t sink_input_get_latency_cb(struct pa_sink_input *i);
-static pa_usec_t source_output_get_latency_cb(struct pa_source_output *o);
+static void sink_input_drop_cb(pa_sink_input *i, const pa_memchunk *chunk, size_t length);
+static int sink_input_peek_cb(pa_sink_input *i, pa_memchunk *chunk);
+static void sink_input_kill_cb(pa_sink_input *i);
+static pa_usec_t sink_input_get_latency_cb(pa_sink_input *i);
+static pa_usec_t source_output_get_latency_cb(pa_source_output *o);
-static void source_output_push_cb(struct pa_source_output *o, const struct pa_memchunk *chunk);
-static void source_output_kill_cb(struct pa_source_output *o);
+static void source_output_push_cb(pa_source_output *o, const pa_memchunk *chunk);
+static void source_output_kill_cb(pa_source_output *o);
static int esd_proto_connect(struct connection *c, esd_proto_t request, const void *data, size_t length);
static int esd_proto_stream_play(struct connection *c, esd_proto_t request, const void *data, size_t length);
@@ -239,7 +240,7 @@ static void* connection_write(struct connection *c, size_t length) {
return (uint8_t*) c->write_data+i;
}
-static void format_esd2native(int format, int swap_bytes, struct pa_sample_spec *ss) {
+static void format_esd2native(int format, int swap_bytes, pa_sample_spec *ss) {
assert(ss);
ss->channels = ((format & ESD_MASK_CHAN) == ESD_STEREO) ? 2 : 1;
@@ -249,7 +250,7 @@ static void format_esd2native(int format, int swap_bytes, struct pa_sample_spec
ss->format = PA_SAMPLE_U8;
}
-static int format_native2esd(struct pa_sample_spec *ss) {
+static int format_native2esd(pa_sample_spec *ss) {
int format = 0;
format = (ss->format == PA_SAMPLE_U8) ? ESD_BITS8 : ESD_BITS16;
@@ -260,7 +261,7 @@ static int format_native2esd(struct pa_sample_spec *ss) {
/*** esound commands ***/
-static int esd_proto_connect(struct connection *c, esd_proto_t request, const void *data, size_t length) {
+static int esd_proto_connect(struct connection *c, PA_GCC_UNUSED esd_proto_t request, const void *data, size_t length) {
uint32_t ekey;
int *ok;
assert(length == (ESD_KEY_LEN + sizeof(uint32_t)));
@@ -278,7 +279,7 @@ static int esd_proto_connect(struct connection *c, esd_proto_t request, const vo
}
}
- ekey = *(uint32_t*)((uint8_t*) data+ESD_KEY_LEN);
+ ekey = *(const uint32_t*)((const uint8_t*) data+ESD_KEY_LEN);
if (ekey == ESD_ENDIAN_KEY)
c->swap_byte_order = 0;
else if (ekey == ESD_SWAP_ENDIAN_KEY)
@@ -294,16 +295,16 @@ static int esd_proto_connect(struct connection *c, esd_proto_t request, const vo
return 0;
}
-static int esd_proto_stream_play(struct connection *c, esd_proto_t request, const void *data, size_t length) {
+static int esd_proto_stream_play(struct connection *c, PA_GCC_UNUSED esd_proto_t request, const void *data, size_t length) {
char name[ESD_NAME_MAX];
int format, rate;
- struct pa_sink *sink;
- struct pa_sample_spec ss;
+ pa_sink *sink;
+ pa_sample_spec ss;
size_t l;
assert(c && length == (sizeof(int)*2+ESD_NAME_MAX));
- format = maybe_swap_endian_32(c->swap_byte_order, *(int*)data);
- rate = maybe_swap_endian_32(c->swap_byte_order, *((int*)data + 1));
+ format = maybe_swap_endian_32(c->swap_byte_order, *(const int*)data);
+ rate = maybe_swap_endian_32(c->swap_byte_order, *((const int*)data + 1));
ss.rate = rate;
format_esd2native(format, c->swap_byte_order, &ss);
@@ -318,7 +319,7 @@ static int esd_proto_stream_play(struct connection *c, esd_proto_t request, cons
return -1;
}
- strncpy(name, (char*) data + sizeof(int)*2, sizeof(name));
+ strncpy(name, (const char*) data + sizeof(int)*2, sizeof(name));
name[sizeof(name)-1] = 0;
pa_client_set_name(c->client, name);
@@ -353,13 +354,13 @@ static int esd_proto_stream_play(struct connection *c, esd_proto_t request, cons
static int esd_proto_stream_record(struct connection *c, esd_proto_t request, const void *data, size_t length) {
char name[ESD_NAME_MAX];
int format, rate;
- struct pa_source *source;
- struct pa_sample_spec ss;
+ pa_source *source;
+ pa_sample_spec ss;
size_t l;
assert(c && length == (sizeof(int)*2+ESD_NAME_MAX));
- format = maybe_swap_endian_32(c->swap_byte_order, *(int*)data);
- rate = maybe_swap_endian_32(c->swap_byte_order, *((int*)data + 1));
+ format = maybe_swap_endian_32(c->swap_byte_order, *(const int*)data);
+ rate = maybe_swap_endian_32(c->swap_byte_order, *((const int*)data + 1));
ss.rate = rate;
format_esd2native(format, c->swap_byte_order, &ss);
@@ -370,7 +371,7 @@ static int esd_proto_stream_record(struct connection *c, esd_proto_t request, co
}
if (request == ESD_PROTO_STREAM_MON) {
- struct pa_sink* sink;
+ pa_sink* sink;
if (!(sink = pa_namereg_get(c->protocol->core, c->protocol->sink_name, PA_NAMEREG_SINK, 1))) {
pa_log(__FILE__": no such sink.\n");
@@ -390,7 +391,7 @@ static int esd_proto_stream_record(struct connection *c, esd_proto_t request, co
}
}
- strncpy(name, (char*) data + sizeof(int)*2, sizeof(name));
+ strncpy(name, (const char*) data + sizeof(int)*2, sizeof(name));
name[sizeof(name)-1] = 0;
pa_client_set_name(c->client, name);
@@ -420,8 +421,8 @@ static int esd_proto_stream_record(struct connection *c, esd_proto_t request, co
return 0;
}
-static int esd_proto_get_latency(struct connection *c, esd_proto_t request, const void *data, size_t length) {
- struct pa_sink *sink;
+static int esd_proto_get_latency(struct connection *c, PA_GCC_UNUSED esd_proto_t request, const void *data, size_t length) {
+ pa_sink *sink;
int latency, *lag;
assert(c && !data && length == 0);
@@ -438,10 +439,10 @@ static int esd_proto_get_latency(struct connection *c, esd_proto_t request, cons
return 0;
}
-static int esd_proto_server_info(struct connection *c, esd_proto_t request, const void *data, size_t length) {
+static int esd_proto_server_info(struct connection *c, PA_GCC_UNUSED esd_proto_t request, const void *data, size_t length) {
int rate = 44100, format = ESD_STEREO|ESD_BITS16;
int *response;
- struct pa_sink *sink;
+ pa_sink *sink;
assert(c && data && length == sizeof(int));
if ((sink = pa_namereg_get(c->protocol->core, c->protocol->sink_name, PA_NAMEREG_SINK, 1))) {
@@ -461,7 +462,7 @@ static int esd_proto_all_info(struct connection *c, esd_proto_t request, const v
uint8_t *response;
size_t t, k, s;
struct connection *conn;
- size_t index = PA_IDXSET_INVALID;
+ size_t idx = PA_IDXSET_INVALID;
unsigned nsamples;
assert(c && data && length == sizeof(int));
@@ -470,11 +471,11 @@ static int esd_proto_all_info(struct connection *c, esd_proto_t request, const v
k = sizeof(int)*5+ESD_NAME_MAX;
s = sizeof(int)*6+ESD_NAME_MAX;
- nsamples = c->protocol->core->scache ? pa_idxset_ncontents(c->protocol->core->scache) : 0;
+ nsamples = c->protocol->core->scache ? pa_idxset_size(c->protocol->core->scache) : 0;
response = connection_write(c, (t = s*(nsamples+1) + k*(c->protocol->n_player+1)));
assert(k);
- for (conn = pa_idxset_first(c->protocol->connections, &index); conn; conn = pa_idxset_next(c->protocol->connections, &index)) {
+ for (conn = pa_idxset_first(c->protocol->connections, &idx); conn; conn = pa_idxset_next(c->protocol->connections, &idx)) {
int format = ESD_BITS16 | ESD_STEREO, rate = 44100, volume = 0xFF;
if (conn->state != ESD_STREAMING_DATA)
@@ -522,10 +523,10 @@ static int esd_proto_all_info(struct connection *c, esd_proto_t request, const v
t -= k;
if (nsamples) {
- struct pa_scache_entry *ce;
+ pa_scache_entry *ce;
- index = PA_IDXSET_INVALID;
- for (ce = pa_idxset_first(c->protocol->core->scache, &index); ce; ce = pa_idxset_next(c->protocol->core->scache, &index)) {
+ idx = PA_IDXSET_INVALID;
+ for (ce = pa_idxset_first(c->protocol->core->scache, &idx); ce; ce = pa_idxset_next(c->protocol->core->scache, &idx)) {
assert(t >= s*2);
/* id */
@@ -569,20 +570,20 @@ static int esd_proto_all_info(struct connection *c, esd_proto_t request, const v
return 0;
}
-static int esd_proto_stream_pan(struct connection *c, esd_proto_t request, const void *data, size_t length) {
+static int esd_proto_stream_pan(struct connection *c, PA_GCC_UNUSED esd_proto_t request, const void *data, size_t length) {
int *ok;
- uint32_t index, volume;
+ uint32_t idx, volume;
struct connection *conn;
assert(c && data && length == sizeof(int)*3);
- index = (uint32_t) maybe_swap_endian_32(c->swap_byte_order, *(int*)data)-1;
- volume = (uint32_t) maybe_swap_endian_32(c->swap_byte_order, *((int*)data + 1));
+ idx = (uint32_t) maybe_swap_endian_32(c->swap_byte_order, *(const int*)data)-1;
+ volume = (uint32_t) maybe_swap_endian_32(c->swap_byte_order, *((const int*)data + 1));
volume = (volume*0x100)/0xFF;
ok = connection_write(c, sizeof(int));
assert(ok);
- if ((conn = pa_idxset_get_by_index(c->protocol->connections, index))) {
+ if ((conn = pa_idxset_get_by_index(c->protocol->connections, idx))) {
assert(conn->sink_input);
conn->sink_input->volume = volume;
*ok = 1;
@@ -592,28 +593,28 @@ static int esd_proto_stream_pan(struct connection *c, esd_proto_t request, const
return 0;
}
-static int esd_proto_sample_cache(struct connection *c, esd_proto_t request, const void *data, size_t length) {
- struct pa_sample_spec ss;
+static int esd_proto_sample_cache(struct connection *c, PA_GCC_UNUSED esd_proto_t request, const void *data, size_t length) {
+ pa_sample_spec ss;
int format, rate;
size_t sc_length;
- uint32_t index;
+ uint32_t idx;
int *ok;
char name[ESD_NAME_MAX+sizeof(SCACHE_PREFIX)-1];
assert(c && data && length == (ESD_NAME_MAX+3*sizeof(int)));
- format = maybe_swap_endian_32(c->swap_byte_order, *(int*)data);
- rate = maybe_swap_endian_32(c->swap_byte_order, *((int*)data + 1));
+ format = maybe_swap_endian_32(c->swap_byte_order, *(const int*)data);
+ rate = maybe_swap_endian_32(c->swap_byte_order, *((const int*)data + 1));
ss.rate = rate;
format_esd2native(format, c->swap_byte_order, &ss);
- sc_length = (size_t) maybe_swap_endian_32(c->swap_byte_order, (*((int*)data + 2)));
+ sc_length = (size_t) maybe_swap_endian_32(c->swap_byte_order, (*((const int*)data + 2)));
if (sc_length >= MAX_CACHE_SAMPLE_SIZE)
return -1;
strcpy(name, SCACHE_PREFIX);
- strncpy(name+sizeof(SCACHE_PREFIX)-1, (char*) data+3*sizeof(int), ESD_NAME_MAX);
+ strncpy(name+sizeof(SCACHE_PREFIX)-1, (const char*) data+3*sizeof(int), ESD_NAME_MAX);
name[sizeof(name)-1] = 0;
assert(!c->scache.memchunk.memblock);
@@ -626,19 +627,19 @@ static int esd_proto_sample_cache(struct connection *c, esd_proto_t request, con
c->state = ESD_CACHING_SAMPLE;
- pa_scache_add_item(c->protocol->core, c->scache.name, NULL, NULL, &index);
+ pa_scache_add_item(c->protocol->core, c->scache.name, NULL, NULL, &idx);
ok = connection_write(c, sizeof(int));
assert(ok);
- *ok = index+1;
+ *ok = idx+1;
return 0;
}
-static int esd_proto_sample_get_id(struct connection *c, esd_proto_t request, const void *data, size_t length) {
+static int esd_proto_sample_get_id(struct connection *c, PA_GCC_UNUSED esd_proto_t request, const void *data, size_t length) {
int *ok;
- uint32_t index;
+ uint32_t idx;
char name[ESD_NAME_MAX+sizeof(SCACHE_PREFIX)-1];
assert(c && data && length == ESD_NAME_MAX);
@@ -651,8 +652,8 @@ static int esd_proto_sample_get_id(struct connection *c, esd_proto_t request, co
strncpy(name+sizeof(SCACHE_PREFIX)-1, data, ESD_NAME_MAX);
name[sizeof(name)-1] = 0;
- if ((index = pa_scache_get_id_by_name(c->protocol->core, name)) != PA_IDXSET_INVALID)
- *ok = (int) index +1;
+ if ((idx = pa_scache_get_id_by_name(c->protocol->core, name)) != PA_IDXSET_INVALID)
+ *ok = (int) idx +1;
return 0;
}
@@ -660,35 +661,35 @@ static int esd_proto_sample_get_id(struct connection *c, esd_proto_t request, co
static int esd_proto_sample_free_or_play(struct connection *c, esd_proto_t request, const void *data, size_t length) {
int *ok;
const char *name;
- uint32_t index;
+ uint32_t idx;
assert(c && data && length == sizeof(int));
- index = (uint32_t) maybe_swap_endian_32(c->swap_byte_order, *(int*)data)-1;
+ idx = (uint32_t) maybe_swap_endian_32(c->swap_byte_order, *(const int*)data)-1;
ok = connection_write(c, sizeof(int));
assert(ok);
*ok = 0;
- if ((name = pa_scache_get_name_by_id(c->protocol->core, index))) {
+ if ((name = pa_scache_get_name_by_id(c->protocol->core, idx))) {
if (request == ESD_PROTO_SAMPLE_PLAY) {
- struct pa_sink *sink;
+ pa_sink *sink;
if ((sink = pa_namereg_get(c->protocol->core, c->protocol->sink_name, PA_NAMEREG_SINK, 1)))
if (pa_scache_play_item(c->protocol->core, name, sink, PA_VOLUME_NORM) >= 0)
- *ok = (int) index+1;
+ *ok = (int) idx+1;
} else {
assert(request == ESD_PROTO_SAMPLE_FREE);
if (pa_scache_remove_item(c->protocol->core, name) >= 0)
- *ok = (int) index+1;
+ *ok = (int) idx+1;
}
}
return 0;
}
-static int esd_proto_standby_or_resume(struct connection *c, esd_proto_t request, const void *data, size_t length) {
+static int esd_proto_standby_or_resume(struct connection *c, PA_GCC_UNUSED esd_proto_t request, PA_GCC_UNUSED const void *data, PA_GCC_UNUSED size_t length) {
int *ok;
ok = connection_write(c, sizeof(int)*2);
assert(ok);
@@ -699,7 +700,7 @@ static int esd_proto_standby_or_resume(struct connection *c, esd_proto_t request
/*** client callbacks ***/
-static void client_kill_cb(struct pa_client *c) {
+static void client_kill_cb(pa_client *c) {
assert(c && c->userdata);
connection_free(c->userdata);
}
@@ -796,11 +797,11 @@ static int do_read(struct connection *c) {
assert(c->scache.memchunk.index <= c->scache.memchunk.length);
if (c->scache.memchunk.index == c->scache.memchunk.length) {
- uint32_t index;
+ uint32_t idx;
int *ok;
c->scache.memchunk.index = 0;
- pa_scache_add_item(c->protocol->core, c->scache.name, &c->scache.sample_spec, &c->scache.memchunk, &index);
+ pa_scache_add_item(c->protocol->core, c->scache.name, &c->scache.sample_spec, &c->scache.memchunk, &idx);
pa_memblock_unref(c->scache.memchunk.memblock);
c->scache.memchunk.memblock = NULL;
@@ -813,11 +814,11 @@ static int do_read(struct connection *c) {
ok = connection_write(c, sizeof(int));
assert(ok);
- *ok = index+1;
+ *ok = idx+1;
}
} else if (c->state == ESD_STREAMING_DATA && c->sink_input) {
- struct pa_memchunk chunk;
+ pa_memchunk chunk;
ssize_t r;
size_t l;
@@ -886,7 +887,7 @@ static int do_write(struct connection *c) {
c->write_data_length = c->write_data_index = 0;
} else if (c->state == ESD_STREAMING_DATA && c->source_output) {
- struct pa_memchunk chunk;
+ pa_memchunk chunk;
ssize_t r;
assert(c->output_memblockq);
@@ -945,7 +946,7 @@ fail:
connection_free(c);
}
-static void io_callback(struct pa_iochannel*io, void *userdata) {
+static void io_callback(pa_iochannel*io, void *userdata) {
struct connection *c = userdata;
assert(io && c && c->io == io);
@@ -956,7 +957,7 @@ static void io_callback(struct pa_iochannel*io, void *userdata) {
/*** defer callback ***/
-static void defer_callback(struct pa_mainloop_api*a, struct pa_defer_event *e, void *userdata) {
+static void defer_callback(pa_mainloop_api*a, pa_defer_event *e, void *userdata) {
struct connection *c = userdata;
assert(a && c && c->defer_event == e);
@@ -967,7 +968,7 @@ static void defer_callback(struct pa_mainloop_api*a, struct pa_defer_event *e, v
/*** sink_input callbacks ***/
-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 connection*c;
assert(i && i->userdata && chunk);
c = i->userdata;
@@ -983,7 +984,7 @@ static int sink_input_peek_cb(struct pa_sink_input *i, struct pa_memchunk *chunk
return 0;
}
-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 connection*c = i->userdata;
assert(i && c && length);
@@ -1000,12 +1001,12 @@ static void sink_input_drop_cb(struct pa_sink_input *i, const struct pa_memchunk
/* assert(pa_memblockq_get_length(c->input_memblockq) > 2048); */
}
-static void sink_input_kill_cb(struct pa_sink_input *i) {
+static void sink_input_kill_cb(pa_sink_input *i) {
assert(i && i->userdata);
connection_free((struct connection *) i->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 connection*c = i->userdata;
assert(i && c);
return pa_bytes_to_usec(pa_memblockq_get_length(c->input_memblockq), &c->sink_input->sample_spec);
@@ -1013,7 +1014,7 @@ static pa_usec_t sink_input_get_latency_cb(struct pa_sink_input *i) {
/*** source_output callbacks ***/
-static void source_output_push_cb(struct pa_source_output *o, const struct pa_memchunk *chunk) {
+static void source_output_push_cb(pa_source_output *o, const pa_memchunk *chunk) {
struct connection *c = o->userdata;
assert(o && c && chunk);
@@ -1026,12 +1027,12 @@ static void source_output_push_cb(struct pa_source_output *o, const struct pa_me
c->protocol->core->mainloop->defer_enable(c->defer_event, 1);
}
-static void source_output_kill_cb(struct pa_source_output *o) {
+static void source_output_kill_cb(pa_source_output *o) {
assert(o && o->userdata);
connection_free((struct connection *) o->userdata);
}
-static pa_usec_t source_output_get_latency_cb(struct pa_source_output *o) {
+static pa_usec_t source_output_get_latency_cb(pa_source_output *o) {
struct connection*c = o->userdata;
assert(o && c);
return pa_bytes_to_usec(pa_memblockq_get_length(c->output_memblockq), &c->source_output->sample_spec);
@@ -1039,7 +1040,7 @@ static pa_usec_t source_output_get_latency_cb(struct pa_source_output *o) {
/*** socket server callback ***/
-static void auth_timeout(struct pa_mainloop_api*m, struct pa_time_event *e, const struct timeval *tv, void *userdata) {
+static void auth_timeout(pa_mainloop_api*m, pa_time_event *e, const struct timeval *tv, void *userdata) {
struct connection *c = userdata;
assert(m && tv && c && c->auth_timeout_event == e);
@@ -1047,13 +1048,13 @@ static void auth_timeout(struct pa_mainloop_api*m, struct pa_time_event *e, cons
connection_free(c);
}
-static void on_connection(struct pa_socket_server*s, struct pa_iochannel *io, void *userdata) {
+static void on_connection(pa_socket_server*s, pa_iochannel *io, void *userdata) {
struct connection *c;
- struct pa_protocol_esound *p = userdata;
+ pa_protocol_esound *p = userdata;
char cname[256];
assert(s && io && p);
- if (pa_idxset_ncontents(p->connections)+1 > MAX_CONNECTIONS) {
+ if (pa_idxset_size(p->connections)+1 > MAX_CONNECTIONS) {
pa_log(__FILE__": Warning! Too many connections (%u), dropping incoming connection.\n", MAX_CONNECTIONS);
pa_iochannel_free(io);
return;
@@ -1116,12 +1117,12 @@ static void on_connection(struct pa_socket_server*s, struct pa_iochannel *io, vo
/*** entry points ***/
-struct pa_protocol_esound* pa_protocol_esound_new(struct pa_core*core, struct pa_socket_server *server, struct pa_module *m, struct pa_modargs *ma) {
- struct pa_protocol_esound *p;
+pa_protocol_esound* pa_protocol_esound_new(pa_core*core, pa_socket_server *server, pa_module *m, pa_modargs *ma) {
+ pa_protocol_esound *p;
int public = 0;
assert(core && server && ma);
- p = pa_xmalloc(sizeof(struct pa_protocol_esound));
+ p = pa_xmalloc(sizeof(pa_protocol_esound));
if (pa_modargs_get_value_boolean(ma, "public", &public) < 0) {
pa_log(__FILE__": public= expects a boolean argument.\n");
@@ -1148,7 +1149,7 @@ struct pa_protocol_esound* pa_protocol_esound_new(struct pa_core*core, struct pa
return p;
}
-void pa_protocol_esound_free(struct pa_protocol_esound *p) {
+void pa_protocol_esound_free(pa_protocol_esound *p) {
struct connection *c;
assert(p);
diff --git a/polyp/protocol-esound.h b/polyp/protocol-esound.h
index dda6977d..71d58464 100644
--- a/polyp/protocol-esound.h
+++ b/polyp/protocol-esound.h
@@ -27,9 +27,9 @@
#include "module.h"
#include "modargs.h"
-struct pa_protocol_esound;
+typedef struct pa_protocol_esound pa_protocol_esound;
-struct pa_protocol_esound* pa_protocol_esound_new(struct pa_core*core, struct pa_socket_server *server, struct pa_module *m, struct pa_modargs *ma);
-void pa_protocol_esound_free(struct pa_protocol_esound *p);
+pa_protocol_esound* pa_protocol_esound_new(pa_core*core, pa_socket_server *server, pa_module *m, pa_modargs *ma);
+void pa_protocol_esound_free(pa_protocol_esound *p);
#endif
diff --git a/polyp/protocol-http.c b/polyp/protocol-http.c
index 64e6dadf..3e55df03 100644
--- a/polyp/protocol-http.c
+++ b/polyp/protocol-http.c
@@ -45,17 +45,17 @@
#define URL_STATUS "/status"
struct connection {
- struct pa_protocol_http *protocol;
- struct pa_ioline *line;
+ pa_protocol_http *protocol;
+ pa_ioline *line;
enum { REQUEST_LINE, MIME_HEADER, DATA } state;
char *url;
};
struct pa_protocol_http {
- struct pa_module *module;
- struct pa_core *core;
- struct pa_socket_server*server;
- struct pa_idxset *connections;
+ pa_module *module;
+ pa_core *core;
+ pa_socket_server*server;
+ pa_idxset *connections;
};
static void http_response(struct connection *c, int code, const char *msg, const char *mime) {
@@ -109,7 +109,7 @@ static void connection_free(struct connection *c, int del) {
pa_xfree(c);
}
-static void line_callback(struct pa_ioline *line, const char *s, void *userdata) {
+static void line_callback(pa_ioline *line, const char *s, void *userdata) {
struct connection *c = userdata;
assert(line);
assert(c);
@@ -191,12 +191,12 @@ static void line_callback(struct pa_ioline *line, const char *s, void *userdata)
pa_ioline_defer_close(c->line);
} else if (!strcmp(c->url, URL_STATUS)) {
- char *s;
+ char *r;
http_response(c, 200, "OK", "text/plain");
- s = pa_full_status_string(c->protocol->core);
- pa_ioline_puts(c->line, s);
- pa_xfree(s);
+ r = pa_full_status_string(c->protocol->core);
+ pa_ioline_puts(c->line, r);
+ pa_xfree(r);
pa_ioline_defer_close(c->line);
} else
@@ -215,12 +215,12 @@ fail:
internal_server_error(c);
}
-static void on_connection(struct pa_socket_server*s, struct pa_iochannel *io, void *userdata) {
- struct pa_protocol_http *p = userdata;
+static void on_connection(pa_socket_server*s, pa_iochannel *io, void *userdata) {
+ pa_protocol_http *p = userdata;
struct connection *c;
assert(s && io && p);
- if (pa_idxset_ncontents(p->connections)+1 > MAX_CONNECTIONS) {
+ if (pa_idxset_size(p->connections)+1 > MAX_CONNECTIONS) {
pa_log_warn(__FILE__": Warning! Too many connections (%u), dropping incoming connection.\n", MAX_CONNECTIONS);
pa_iochannel_free(io);
return;
@@ -236,11 +236,11 @@ static void on_connection(struct pa_socket_server*s, struct pa_iochannel *io, vo
pa_idxset_put(p->connections, c, NULL);
}
-struct pa_protocol_http* pa_protocol_http_new(struct pa_core *core, struct pa_socket_server *server, struct pa_module *m, struct pa_modargs *ma) {
- struct pa_protocol_http* p;
+pa_protocol_http* pa_protocol_http_new(pa_core *core, pa_socket_server *server, pa_module *m, PA_GCC_UNUSED pa_modargs *ma) {
+ pa_protocol_http* p;
assert(core && server);
- p = pa_xmalloc(sizeof(struct pa_protocol_http));
+ p = pa_xmalloc(sizeof(pa_protocol_http));
p->module = m;
p->core = core;
p->server = server;
@@ -251,12 +251,12 @@ struct pa_protocol_http* pa_protocol_http_new(struct pa_core *core, struct pa_so
return p;
}
-static void free_connection(void *p, void *userdata) {
+static void free_connection(void *p, PA_GCC_UNUSED void *userdata) {
assert(p);
connection_free(p, 0);
}
-void pa_protocol_http_free(struct pa_protocol_http *p) {
+void pa_protocol_http_free(pa_protocol_http *p) {
assert(p);
pa_idxset_free(p->connections, free_connection, NULL);
diff --git a/polyp/protocol-http.h b/polyp/protocol-http.h
index 3c9b8d76..0a1855e9 100644
--- a/polyp/protocol-http.h
+++ b/polyp/protocol-http.h
@@ -27,9 +27,9 @@
#include "module.h"
#include "modargs.h"
-struct pa_protocol_http;
+typedef struct pa_protocol_http pa_protocol_http;
-struct pa_protocol_http* pa_protocol_http_new(struct pa_core *core, struct pa_socket_server *server, struct pa_module *m, struct pa_modargs *ma);
-void pa_protocol_http_free(struct pa_protocol_http *n);
+pa_protocol_http* pa_protocol_http_new(pa_core *core, pa_socket_server *server, pa_module *m, pa_modargs *ma);
+void pa_protocol_http_free(pa_protocol_http *n);
#endif
diff --git a/polyp/protocol-native.c b/polyp/protocol-native.c
index 90dbdaf5..b19d30d9 100644
--- a/polyp/protocol-native.c
+++ b/polyp/protocol-native.c
@@ -64,8 +64,8 @@ struct pa_protocol_native;
struct record_stream {
struct connection *connection;
uint32_t index;
- struct pa_source_output *source_output;
- struct pa_memblockq *memblockq;
+ pa_source_output *source_output;
+ pa_memblockq *memblockq;
size_t fragment_size;
};
@@ -73,8 +73,8 @@ struct playback_stream {
int type;
struct connection *connection;
uint32_t index;
- struct pa_sink_input *sink_input;
- struct pa_memblockq *memblockq;
+ pa_sink_input *sink_input;
+ pa_memblockq *memblockq;
size_t requested_bytes;
int drain_request;
uint32_t drain_tag;
@@ -84,10 +84,10 @@ struct upload_stream {
int type;
struct connection *connection;
uint32_t index;
- struct pa_memchunk memchunk;
+ pa_memchunk memchunk;
size_t length;
char *name;
- struct pa_sample_spec sample_spec;
+ pa_sample_spec sample_spec;
};
struct output_stream {
@@ -101,141 +101,141 @@ enum {
struct connection {
int authorized;
- struct pa_protocol_native *protocol;
- struct pa_client *client;
- struct pa_pstream *pstream;
- struct pa_pdispatch *pdispatch;
- struct pa_idxset *record_streams, *output_streams;
+ pa_protocol_native *protocol;
+ pa_client *client;
+ pa_pstream *pstream;
+ pa_pdispatch *pdispatch;
+ pa_idxset *record_streams, *output_streams;
uint32_t rrobin_index;
- struct pa_subscription *subscription;
- struct pa_time_event *auth_timeout_event;
+ pa_subscription *subscription;
+ pa_time_event *auth_timeout_event;
};
struct pa_protocol_native {
- struct pa_module *module;
+ pa_module *module;
int public;
- struct pa_core *core;
- struct pa_socket_server *server;
- struct pa_idxset *connections;
+ pa_core *core;
+ pa_socket_server *server;
+ pa_idxset *connections;
uint8_t auth_cookie[PA_NATIVE_COOKIE_LENGTH];
int auth_cookie_in_property;
};
-static int sink_input_peek_cb(struct pa_sink_input *i, struct pa_memchunk *chunk);
-static void sink_input_drop_cb(struct pa_sink_input *i, const struct pa_memchunk *chunk, size_t length);
-static void sink_input_kill_cb(struct pa_sink_input *i);
-static pa_usec_t sink_input_get_latency_cb(struct pa_sink_input *i);
+static int sink_input_peek_cb(pa_sink_input *i, pa_memchunk *chunk);
+static void sink_input_drop_cb(pa_sink_input *i, const pa_memchunk *chunk, size_t length);
+static void sink_input_kill_cb(pa_sink_input *i);
+static pa_usec_t sink_input_get_latency_cb(pa_sink_input *i);
static void request_bytes(struct playback_stream*s);
-static void source_output_kill_cb(struct pa_source_output *o);
-static void source_output_push_cb(struct pa_source_output *o, const struct pa_memchunk *chunk);
-static pa_usec_t source_output_get_latency_cb(struct pa_source_output *o);
-
-static void command_exit(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
-static void command_create_playback_stream(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
-static void command_drain_playback_stream(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
-static void command_create_record_stream(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
-static void command_delete_stream(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
-static void command_auth(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
-static void command_set_client_name(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
-static void command_lookup(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
-static void command_stat(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
-static void command_get_playback_latency(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
-static void command_get_record_latency(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
-static void command_create_upload_stream(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
-static void command_finish_upload_stream(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
-static void command_play_sample(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
-static void command_remove_sample(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
-static void command_get_info(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
-static void command_get_info_list(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
-static void command_get_server_info(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
-static void command_subscribe(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
-static void command_set_volume(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
-static void command_cork_playback_stream(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
-static void command_flush_or_trigger_playback_stream(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
-static void command_set_default_sink_or_source(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
-static void command_set_stream_name(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
-static void command_kill(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
-static void command_load_module(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
-static void command_unload_module(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
-static void command_add_autoload(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
-static void command_remove_autoload(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
-static void command_get_autoload_info(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
-static void command_get_autoload_info_list(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
-static void command_cork_record_stream(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
-static void command_flush_record_stream(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata);
-
-static const struct pa_pdispatch_command command_table[PA_COMMAND_MAX] = {
- [PA_COMMAND_ERROR] = { NULL },
- [PA_COMMAND_TIMEOUT] = { NULL },
- [PA_COMMAND_REPLY] = { NULL },
- [PA_COMMAND_CREATE_PLAYBACK_STREAM] = { command_create_playback_stream },
- [PA_COMMAND_DELETE_PLAYBACK_STREAM] = { command_delete_stream },
- [PA_COMMAND_DRAIN_PLAYBACK_STREAM] = { command_drain_playback_stream },
- [PA_COMMAND_CREATE_RECORD_STREAM] = { command_create_record_stream },
- [PA_COMMAND_DELETE_RECORD_STREAM] = { command_delete_stream },
- [PA_COMMAND_AUTH] = { command_auth },
- [PA_COMMAND_REQUEST] = { NULL },
- [PA_COMMAND_EXIT] = { command_exit },
- [PA_COMMAND_SET_CLIENT_NAME] = { command_set_client_name },
- [PA_COMMAND_LOOKUP_SINK] = { command_lookup },
- [PA_COMMAND_LOOKUP_SOURCE] = { command_lookup },
- [PA_COMMAND_STAT] = { command_stat },
- [PA_COMMAND_GET_PLAYBACK_LATENCY] = { command_get_playback_latency },
- [PA_COMMAND_GET_RECORD_LATENCY] = { command_get_record_latency },
- [PA_COMMAND_CREATE_UPLOAD_STREAM] = { command_create_upload_stream },
- [PA_COMMAND_DELETE_UPLOAD_STREAM] = { command_delete_stream },
- [PA_COMMAND_FINISH_UPLOAD_STREAM] = { command_finish_upload_stream },
- [PA_COMMAND_PLAY_SAMPLE] = { command_play_sample },
- [PA_COMMAND_REMOVE_SAMPLE] = { command_remove_sample },
- [PA_COMMAND_GET_SINK_INFO] = { command_get_info },
- [PA_COMMAND_GET_SOURCE_INFO] = { command_get_info },
- [PA_COMMAND_GET_CLIENT_INFO] = { command_get_info },
- [PA_COMMAND_GET_MODULE_INFO] = { command_get_info },
- [PA_COMMAND_GET_SINK_INPUT_INFO] = { command_get_info },
- [PA_COMMAND_GET_SOURCE_OUTPUT_INFO] = { command_get_info },
- [PA_COMMAND_GET_SAMPLE_INFO] = { command_get_info },
- [PA_COMMAND_GET_SINK_INFO_LIST] = { command_get_info_list },
- [PA_COMMAND_GET_SOURCE_INFO_LIST] = { command_get_info_list },
- [PA_COMMAND_GET_MODULE_INFO_LIST] = { command_get_info_list },
- [PA_COMMAND_GET_CLIENT_INFO_LIST] = { command_get_info_list },
- [PA_COMMAND_GET_SINK_INPUT_INFO_LIST] = { command_get_info_list },
- [PA_COMMAND_GET_SOURCE_OUTPUT_INFO_LIST] = { command_get_info_list },
- [PA_COMMAND_GET_SAMPLE_INFO_LIST] = { command_get_info_list },
- [PA_COMMAND_GET_SERVER_INFO] = { command_get_server_info },
- [PA_COMMAND_SUBSCRIBE] = { command_subscribe },
-
- [PA_COMMAND_SET_SINK_VOLUME] = { command_set_volume },
- [PA_COMMAND_SET_SINK_INPUT_VOLUME] = { command_set_volume },
+static void source_output_kill_cb(pa_source_output *o);
+static void source_output_push_cb(pa_source_output *o, const pa_memchunk *chunk);
+static pa_usec_t source_output_get_latency_cb(pa_source_output *o);
+
+static void command_exit(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
+static void command_create_playback_stream(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
+static void command_drain_playback_stream(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
+static void command_create_record_stream(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
+static void command_delete_stream(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
+static void command_auth(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
+static void command_set_client_name(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
+static void command_lookup(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
+static void command_stat(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
+static void command_get_playback_latency(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
+static void command_get_record_latency(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
+static void command_create_upload_stream(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
+static void command_finish_upload_stream(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
+static void command_play_sample(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
+static void command_remove_sample(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
+static void command_get_info(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
+static void command_get_info_list(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
+static void command_get_server_info(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
+static void command_subscribe(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
+static void command_set_volume(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
+static void command_cork_playback_stream(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
+static void command_flush_or_trigger_playback_stream(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
+static void command_set_default_sink_or_source(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
+static void command_set_stream_name(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
+static void command_kill(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
+static void command_load_module(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
+static void command_unload_module(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
+static void command_add_autoload(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
+static void command_remove_autoload(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
+static void command_get_autoload_info(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
+static void command_get_autoload_info_list(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
+static void command_cork_record_stream(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
+static void command_flush_record_stream(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
+
+static const pa_pdispatch_callback command_table[PA_COMMAND_MAX] = {
+ [PA_COMMAND_ERROR] = NULL,
+ [PA_COMMAND_TIMEOUT] = NULL,
+ [PA_COMMAND_REPLY] = NULL,
+ [PA_COMMAND_CREATE_PLAYBACK_STREAM] = command_create_playback_stream,
+ [PA_COMMAND_DELETE_PLAYBACK_STREAM] = command_delete_stream,
+ [PA_COMMAND_DRAIN_PLAYBACK_STREAM] = command_drain_playback_stream,
+ [PA_COMMAND_CREATE_RECORD_STREAM] = command_create_record_stream,
+ [PA_COMMAND_DELETE_RECORD_STREAM] = command_delete_stream,
+ [PA_COMMAND_AUTH] = command_auth,
+ [PA_COMMAND_REQUEST] = NULL,
+ [PA_COMMAND_EXIT] = command_exit,
+ [PA_COMMAND_SET_CLIENT_NAME] = command_set_client_name,
+ [PA_COMMAND_LOOKUP_SINK] = command_lookup,
+ [PA_COMMAND_LOOKUP_SOURCE] = command_lookup,
+ [PA_COMMAND_STAT] = command_stat,
+ [PA_COMMAND_GET_PLAYBACK_LATENCY] = command_get_playback_latency,
+ [PA_COMMAND_GET_RECORD_LATENCY] = command_get_record_latency,
+ [PA_COMMAND_CREATE_UPLOAD_STREAM] = command_create_upload_stream,
+ [PA_COMMAND_DELETE_UPLOAD_STREAM] = command_delete_stream,
+ [PA_COMMAND_FINISH_UPLOAD_STREAM] = command_finish_upload_stream,
+ [PA_COMMAND_PLAY_SAMPLE] = command_play_sample,
+ [PA_COMMAND_REMOVE_SAMPLE] = command_remove_sample,
+ [PA_COMMAND_GET_SINK_INFO] = command_get_info,
+ [PA_COMMAND_GET_SOURCE_INFO] = command_get_info,
+ [PA_COMMAND_GET_CLIENT_INFO] = command_get_info,
+ [PA_COMMAND_GET_MODULE_INFO] = command_get_info,
+ [PA_COMMAND_GET_SINK_INPUT_INFO] = command_get_info,
+ [PA_COMMAND_GET_SOURCE_OUTPUT_INFO] = command_get_info,
+ [PA_COMMAND_GET_SAMPLE_INFO] = command_get_info,
+ [PA_COMMAND_GET_SINK_INFO_LIST] = command_get_info_list,
+ [PA_COMMAND_GET_SOURCE_INFO_LIST] = command_get_info_list,
+ [PA_COMMAND_GET_MODULE_INFO_LIST] = command_get_info_list,
+ [PA_COMMAND_GET_CLIENT_INFO_LIST] = command_get_info_list,
+ [PA_COMMAND_GET_SINK_INPUT_INFO_LIST] = command_get_info_list,
+ [PA_COMMAND_GET_SOURCE_OUTPUT_INFO_LIST] = command_get_info_list,
+ [PA_COMMAND_GET_SAMPLE_INFO_LIST] = command_get_info_list,
+ [PA_COMMAND_GET_SERVER_INFO] = command_get_server_info,
+ [PA_COMMAND_SUBSCRIBE] = command_subscribe,
+
+ [PA_COMMAND_SET_SINK_VOLUME] = command_set_volume,
+ [PA_COMMAND_SET_SINK_INPUT_VOLUME] = command_set_volume,
- [PA_COMMAND_CORK_PLAYBACK_STREAM] = { command_cork_playback_stream },
- [PA_COMMAND_FLUSH_PLAYBACK_STREAM] = { command_flush_or_trigger_playback_stream },
- [PA_COMMAND_TRIGGER_PLAYBACK_STREAM] = { command_flush_or_trigger_playback_stream },
- [PA_COMMAND_PREBUF_PLAYBACK_STREAM] = { command_flush_or_trigger_playback_stream },
+ [PA_COMMAND_CORK_PLAYBACK_STREAM] = command_cork_playback_stream,
+ [PA_COMMAND_FLUSH_PLAYBACK_STREAM] = command_flush_or_trigger_playback_stream,
+ [PA_COMMAND_TRIGGER_PLAYBACK_STREAM] = command_flush_or_trigger_playback_stream,
+ [PA_COMMAND_PREBUF_PLAYBACK_STREAM] = command_flush_or_trigger_playback_stream,
- [PA_COMMAND_CORK_RECORD_STREAM] = { command_cork_record_stream },
- [PA_COMMAND_FLUSH_RECORD_STREAM] = { command_flush_record_stream },
+ [PA_COMMAND_CORK_RECORD_STREAM] = command_cork_record_stream,
+ [PA_COMMAND_FLUSH_RECORD_STREAM] = command_flush_record_stream,
- [PA_COMMAND_SET_DEFAULT_SINK] = { command_set_default_sink_or_source },
- [PA_COMMAND_SET_DEFAULT_SOURCE] = { command_set_default_sink_or_source },
- [PA_COMMAND_SET_PLAYBACK_STREAM_NAME] = { command_set_stream_name },
- [PA_COMMAND_SET_RECORD_STREAM_NAME] = { command_set_stream_name },
- [PA_COMMAND_KILL_CLIENT] = { command_kill },
- [PA_COMMAND_KILL_SINK_INPUT] = { command_kill },
- [PA_COMMAND_KILL_SOURCE_OUTPUT] = { command_kill },
- [PA_COMMAND_LOAD_MODULE] = { command_load_module },
- [PA_COMMAND_UNLOAD_MODULE] = { command_unload_module },
- [PA_COMMAND_GET_AUTOLOAD_INFO] = { command_get_autoload_info },
- [PA_COMMAND_GET_AUTOLOAD_INFO_LIST] = { command_get_autoload_info_list },
- [PA_COMMAND_ADD_AUTOLOAD] = { command_add_autoload },
- [PA_COMMAND_REMOVE_AUTOLOAD] = { command_remove_autoload },
+ [PA_COMMAND_SET_DEFAULT_SINK] = command_set_default_sink_or_source,
+ [PA_COMMAND_SET_DEFAULT_SOURCE] = command_set_default_sink_or_source,
+ [PA_COMMAND_SET_PLAYBACK_STREAM_NAME] = command_set_stream_name,
+ [PA_COMMAND_SET_RECORD_STREAM_NAME] = command_set_stream_name,
+ [PA_COMMAND_KILL_CLIENT] = command_kill,
+ [PA_COMMAND_KILL_SINK_INPUT] = command_kill,
+ [PA_COMMAND_KILL_SOURCE_OUTPUT] = command_kill,
+ [PA_COMMAND_LOAD_MODULE] = command_load_module,
+ [PA_COMMAND_UNLOAD_MODULE] = command_unload_module,
+ [PA_COMMAND_GET_AUTOLOAD_INFO] = command_get_autoload_info,
+ [PA_COMMAND_GET_AUTOLOAD_INFO_LIST] = command_get_autoload_info_list,
+ [PA_COMMAND_ADD_AUTOLOAD] = command_add_autoload,
+ [PA_COMMAND_REMOVE_AUTOLOAD] = command_remove_autoload,
};
/* structure management */
-static struct upload_stream* upload_stream_new(struct connection *c, const struct pa_sample_spec *ss, const char *name, size_t length) {
+static struct upload_stream* upload_stream_new(struct connection *c, const pa_sample_spec *ss, const char *name, size_t length) {
struct upload_stream *s;
assert(c && ss && name && length);
@@ -268,9 +268,9 @@ static void upload_stream_free(struct upload_stream *o) {
pa_xfree(o);
}
-static struct record_stream* record_stream_new(struct connection *c, struct pa_source *source, const struct pa_sample_spec *ss, const char *name, size_t maxlength, size_t fragment_size) {
+static struct record_stream* record_stream_new(struct connection *c, pa_source *source, const pa_sample_spec *ss, const char *name, size_t maxlength, size_t fragment_size) {
struct record_stream *s;
- struct pa_source_output *source_output;
+ pa_source_output *source_output;
size_t base;
assert(c && source && ss && name && maxlength);
@@ -308,14 +308,14 @@ static void record_stream_free(struct record_stream* r) {
pa_xfree(r);
}
-static struct playback_stream* playback_stream_new(struct connection *c, struct pa_sink *sink, const struct pa_sample_spec *ss, const char *name,
+static struct playback_stream* playback_stream_new(struct connection *c, pa_sink *sink, const pa_sample_spec *ss, const char *name,
size_t maxlength,
size_t tlength,
size_t prebuf,
size_t minreq,
pa_volume_t volume) {
struct playback_stream *s;
- struct pa_sink_input *sink_input;
+ pa_sink_input *sink_input;
assert(c && sink && ss && name && maxlength);
if (!(sink_input = pa_sink_input_new(sink, PA_TYPEID_NATIVE, name, ss, 0, -1)))
@@ -391,7 +391,7 @@ static void connection_free(struct connection *c) {
}
static void request_bytes(struct playback_stream *s) {
- struct pa_tagstruct *t;
+ pa_tagstruct *t;
size_t l;
assert(s);
@@ -425,7 +425,7 @@ static void send_memblock(struct connection *c) {
start = PA_IDXSET_INVALID;
for (;;) {
- struct pa_memchunk chunk;
+ pa_memchunk chunk;
if (!(r = pa_idxset_rrobin(c->record_streams, &c->rrobin_index)))
return;
@@ -436,7 +436,7 @@ static void send_memblock(struct connection *c) {
return;
if (pa_memblockq_peek(r->memblockq, &chunk) >= 0) {
- struct pa_memchunk schunk = chunk;
+ pa_memchunk schunk = chunk;
if (schunk.length > r->fragment_size)
schunk.length = r->fragment_size;
@@ -451,7 +451,7 @@ static void send_memblock(struct connection *c) {
}
static void send_playback_stream_killed(struct playback_stream *p) {
- struct pa_tagstruct *t;
+ pa_tagstruct *t;
assert(p);
t = pa_tagstruct_new(NULL, 0);
@@ -463,7 +463,7 @@ static void send_playback_stream_killed(struct playback_stream *p) {
}
static void send_record_stream_killed(struct record_stream *r) {
- struct pa_tagstruct *t;
+ pa_tagstruct *t;
assert(r);
t = pa_tagstruct_new(NULL, 0);
@@ -476,7 +476,7 @@ static void send_record_stream_killed(struct record_stream *r) {
/*** sinkinput callbacks ***/
-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 playback_stream *s;
assert(i && i->userdata && chunk);
s = i->userdata;
@@ -487,7 +487,7 @@ static int sink_input_peek_cb(struct pa_sink_input *i, struct pa_memchunk *chunk
return 0;
}
-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 playback_stream *s;
assert(i && i->userdata && length);
s = i->userdata;
@@ -503,13 +503,13 @@ static void sink_input_drop_cb(struct pa_sink_input *i, const struct pa_memchunk
/* pa_log(__FILE__": after_drop: %u\n", pa_memblockq_get_length(s->memblockq)); */
}
-static void sink_input_kill_cb(struct pa_sink_input *i) {
+static void sink_input_kill_cb(pa_sink_input *i) {
assert(i && i->userdata);
send_playback_stream_killed((struct playback_stream *) i->userdata);
playback_stream_free((struct playback_stream *) i->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 playback_stream *s;
assert(i && i->userdata);
s = i->userdata;
@@ -521,7 +521,7 @@ static pa_usec_t sink_input_get_latency_cb(struct pa_sink_input *i) {
/*** source_output callbacks ***/
-static void source_output_push_cb(struct pa_source_output *o, const struct pa_memchunk *chunk) {
+static void source_output_push_cb(pa_source_output *o, const pa_memchunk *chunk) {
struct record_stream *s;
assert(o && o->userdata && chunk);
s = o->userdata;
@@ -531,13 +531,13 @@ static void source_output_push_cb(struct pa_source_output *o, const struct pa_me
send_memblock(s->connection);
}
-static void source_output_kill_cb(struct pa_source_output *o) {
+static void source_output_kill_cb(pa_source_output *o) {
assert(o && o->userdata);
send_record_stream_killed((struct record_stream *) o->userdata);
record_stream_free((struct record_stream *) o->userdata);
}
-static pa_usec_t source_output_get_latency_cb(struct pa_source_output *o) {
+static pa_usec_t source_output_get_latency_cb(pa_source_output *o) {
struct record_stream *s;
assert(o && o->userdata);
s = o->userdata;
@@ -554,15 +554,15 @@ static void protocol_error(struct connection *c) {
connection_free(c);
}
-static void command_create_playback_stream(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
+static void command_create_playback_stream(PA_GCC_UNUSED pa_pdispatch *pd, PA_GCC_UNUSED uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
struct connection *c = userdata;
struct playback_stream *s;
size_t maxlength, tlength, prebuf, minreq;
uint32_t sink_index;
const char *name, *sink_name;
- struct pa_sample_spec ss;
- struct pa_tagstruct *reply;
- struct pa_sink *sink;
+ pa_sample_spec ss;
+ pa_tagstruct *reply;
+ pa_sink *sink;
pa_volume_t volume;
int corked;
assert(c && t && c->protocol && c->protocol->core);
@@ -618,7 +618,7 @@ static void command_create_playback_stream(struct pa_pdispatch *pd, uint32_t com
request_bytes(s);
}
-static void command_delete_stream(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
+static void command_delete_stream(PA_GCC_UNUSED pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
struct connection *c = userdata;
uint32_t channel;
assert(c && t);
@@ -664,15 +664,15 @@ static void command_delete_stream(struct pa_pdispatch *pd, uint32_t command, uin
pa_pstream_send_simple_ack(c->pstream, tag);
}
-static void command_create_record_stream(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
+static void command_create_record_stream(PA_GCC_UNUSED pa_pdispatch *pd, PA_GCC_UNUSED uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
struct connection *c = userdata;
struct record_stream *s;
size_t maxlength, fragment_size;
uint32_t source_index;
const char *name, *source_name;
- struct pa_sample_spec ss;
- struct pa_tagstruct *reply;
- struct pa_source *source;
+ pa_sample_spec ss;
+ pa_tagstruct *reply;
+ pa_source *source;
int corked;
assert(c && t && c->protocol && c->protocol->core);
@@ -720,7 +720,7 @@ static void command_create_record_stream(struct pa_pdispatch *pd, uint32_t comma
pa_pstream_send_tagstruct(c->pstream, reply);
}
-static void command_exit(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
+static void command_exit(PA_GCC_UNUSED pa_pdispatch *pd, PA_GCC_UNUSED uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
struct connection *c = userdata;
assert(c && t);
@@ -740,7 +740,7 @@ static void command_exit(struct pa_pdispatch *pd, uint32_t command, uint32_t tag
return;
}
-static void command_auth(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
+static void command_auth(PA_GCC_UNUSED pa_pdispatch *pd, PA_GCC_UNUSED uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
struct connection *c = userdata;
const void*cookie;
assert(c && t);
@@ -769,7 +769,7 @@ static void command_auth(struct pa_pdispatch *pd, uint32_t command, uint32_t tag
return;
}
-static void command_set_client_name(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
+static void command_set_client_name(PA_GCC_UNUSED pa_pdispatch *pd, PA_GCC_UNUSED uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
struct connection *c = userdata;
const char *name;
assert(c && t);
@@ -785,10 +785,10 @@ static void command_set_client_name(struct pa_pdispatch *pd, uint32_t command, u
return;
}
-static void command_lookup(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
+static void command_lookup(PA_GCC_UNUSED pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
struct connection *c = userdata;
const char *name;
- uint32_t index = PA_IDXSET_INVALID;
+ uint32_t idx = PA_IDXSET_INVALID;
assert(c && t);
if (pa_tagstruct_gets(t, &name) < 0 || !name ||
@@ -803,36 +803,36 @@ static void command_lookup(struct pa_pdispatch *pd, uint32_t command, uint32_t t
}
if (command == PA_COMMAND_LOOKUP_SINK) {
- struct pa_sink *sink;
+ pa_sink *sink;
if ((sink = pa_namereg_get(c->protocol->core, name, PA_NAMEREG_SINK, 1)))
- index = sink->index;
+ idx = sink->index;
} else {
- struct pa_source *source;
+ pa_source *source;
assert(command == PA_COMMAND_LOOKUP_SOURCE);
if ((source = pa_namereg_get(c->protocol->core, name, PA_NAMEREG_SOURCE, 1)))
- index = source->index;
+ idx = source->index;
}
- if (index == PA_IDXSET_INVALID)
+ if (idx == PA_IDXSET_INVALID)
pa_pstream_send_error(c->pstream, tag, PA_ERROR_NOENTITY);
else {
- struct pa_tagstruct *reply;
+ pa_tagstruct *reply;
reply = pa_tagstruct_new(NULL, 0);
assert(reply);
pa_tagstruct_putu32(reply, PA_COMMAND_REPLY);
pa_tagstruct_putu32(reply, tag);
- pa_tagstruct_putu32(reply, index);
+ pa_tagstruct_putu32(reply, idx);
pa_pstream_send_tagstruct(c->pstream, reply);
}
}
-static void command_drain_playback_stream(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
+static void command_drain_playback_stream(PA_GCC_UNUSED pa_pdispatch *pd, PA_GCC_UNUSED uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
struct connection *c = userdata;
- uint32_t index;
+ uint32_t idx;
struct playback_stream *s;
assert(c && t);
- if (pa_tagstruct_getu32(t, &index) < 0 ||
+ if (pa_tagstruct_getu32(t, &idx) < 0 ||
!pa_tagstruct_eof(t)) {
protocol_error(c);
return;
@@ -843,7 +843,7 @@ static void command_drain_playback_stream(struct pa_pdispatch *pd, uint32_t comm
return;
}
- if (!(s = pa_idxset_get_by_index(c->output_streams, index)) || s->type != PLAYBACK_STREAM) {
+ if (!(s = pa_idxset_get_by_index(c->output_streams, idx)) || s->type != PLAYBACK_STREAM) {
pa_pstream_send_error(c->pstream, tag, PA_ERROR_NOENTITY);
return;
}
@@ -864,9 +864,9 @@ static void command_drain_playback_stream(struct pa_pdispatch *pd, uint32_t comm
}
}
-static void command_stat(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
+static void command_stat(PA_GCC_UNUSED pa_pdispatch *pd, PA_GCC_UNUSED uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
struct connection *c = userdata;
- struct pa_tagstruct *reply;
+ pa_tagstruct *reply;
assert(c && t);
if (!pa_tagstruct_eof(t)) {
@@ -891,16 +891,16 @@ static void command_stat(struct pa_pdispatch *pd, uint32_t command, uint32_t tag
pa_pstream_send_tagstruct(c->pstream, reply);
}
-static void command_get_playback_latency(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
+static void command_get_playback_latency(PA_GCC_UNUSED pa_pdispatch *pd, PA_GCC_UNUSED uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
struct connection *c = userdata;
- struct pa_tagstruct *reply;
+ pa_tagstruct *reply;
struct playback_stream *s;
struct timeval tv, now;
uint64_t counter;
- uint32_t index;
+ uint32_t idx;
assert(c && t);
- if (pa_tagstruct_getu32(t, &index) < 0 ||
+ if (pa_tagstruct_getu32(t, &idx) < 0 ||
pa_tagstruct_get_timeval(t, &tv) < 0 ||
pa_tagstruct_getu64(t, &counter) < 0 ||
!pa_tagstruct_eof(t)) {
@@ -913,7 +913,7 @@ static void command_get_playback_latency(struct pa_pdispatch *pd, uint32_t comma
return;
}
- if (!(s = pa_idxset_get_by_index(c->output_streams, index)) || s->type != PLAYBACK_STREAM) {
+ if (!(s = pa_idxset_get_by_index(c->output_streams, idx)) || s->type != PLAYBACK_STREAM) {
pa_pstream_send_error(c->pstream, tag, PA_ERROR_NOENTITY);
return;
}
@@ -934,16 +934,16 @@ static void command_get_playback_latency(struct pa_pdispatch *pd, uint32_t comma
pa_pstream_send_tagstruct(c->pstream, reply);
}
-static void command_get_record_latency(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
+static void command_get_record_latency(PA_GCC_UNUSED pa_pdispatch *pd, PA_GCC_UNUSED uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
struct connection *c = userdata;
- struct pa_tagstruct *reply;
+ pa_tagstruct *reply;
struct record_stream *s;
struct timeval tv, now;
uint64_t counter;
- uint32_t index;
+ uint32_t idx;
assert(c && t);
- if (pa_tagstruct_getu32(t, &index) < 0 ||
+ if (pa_tagstruct_getu32(t, &idx) < 0 ||
pa_tagstruct_get_timeval(t, &tv) < 0 ||
pa_tagstruct_getu64(t, &counter) < 0 ||
!pa_tagstruct_eof(t)) {
@@ -956,7 +956,7 @@ static void command_get_record_latency(struct pa_pdispatch *pd, uint32_t command
return;
}
- if (!(s = pa_idxset_get_by_index(c->record_streams, index))) {
+ if (!(s = pa_idxset_get_by_index(c->record_streams, idx))) {
pa_pstream_send_error(c->pstream, tag, PA_ERROR_NOENTITY);
return;
}
@@ -978,13 +978,13 @@ static void command_get_record_latency(struct pa_pdispatch *pd, uint32_t command
}
-static void command_create_upload_stream(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
+static void command_create_upload_stream(PA_GCC_UNUSED pa_pdispatch *pd, PA_GCC_UNUSED uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
struct connection *c = userdata;
struct upload_stream *s;
size_t length;
const char *name;
- struct pa_sample_spec ss;
- struct pa_tagstruct *reply;
+ pa_sample_spec ss;
+ pa_tagstruct *reply;
assert(c && t && c->protocol && c->protocol->core);
if (pa_tagstruct_gets(t, &name) < 0 || !name ||
@@ -1019,11 +1019,11 @@ static void command_create_upload_stream(struct pa_pdispatch *pd, uint32_t comma
pa_pstream_send_tagstruct(c->pstream, reply);
}
-static void command_finish_upload_stream(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
+static void command_finish_upload_stream(PA_GCC_UNUSED pa_pdispatch *pd, PA_GCC_UNUSED uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
struct connection *c = userdata;
uint32_t channel;
struct upload_stream *s;
- uint32_t index;
+ uint32_t idx;
assert(c && t);
if (pa_tagstruct_getu32(t, &channel) < 0 ||
@@ -1042,15 +1042,15 @@ static void command_finish_upload_stream(struct pa_pdispatch *pd, uint32_t comma
return;
}
- pa_scache_add_item(c->protocol->core, s->name, &s->sample_spec, &s->memchunk, &index);
+ pa_scache_add_item(c->protocol->core, s->name, &s->sample_spec, &s->memchunk, &idx);
pa_pstream_send_simple_ack(c->pstream, tag);
upload_stream_free(s);
}
-static void command_play_sample(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
+static void command_play_sample(PA_GCC_UNUSED pa_pdispatch *pd, PA_GCC_UNUSED uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
struct connection *c = userdata;
uint32_t sink_index, volume;
- struct pa_sink *sink;
+ pa_sink *sink;
const char *name, *sink_name;
assert(c && t);
@@ -1086,7 +1086,7 @@ static void command_play_sample(struct pa_pdispatch *pd, uint32_t command, uint3
pa_pstream_send_simple_ack(c->pstream, tag);
}
-static void command_remove_sample(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
+static void command_remove_sample(PA_GCC_UNUSED pa_pdispatch *pd, PA_GCC_UNUSED uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
struct connection *c = userdata;
const char *name;
assert(c && t);
@@ -1110,7 +1110,7 @@ static void command_remove_sample(struct pa_pdispatch *pd, uint32_t command, uin
pa_pstream_send_simple_ack(c->pstream, tag);
}
-static void sink_fill_tagstruct(struct pa_tagstruct *t, struct pa_sink *sink) {
+static void sink_fill_tagstruct(pa_tagstruct *t, pa_sink *sink) {
assert(t && sink);
pa_tagstruct_putu32(t, sink->index);
pa_tagstruct_puts(t, sink->name);
@@ -1124,7 +1124,7 @@ static void sink_fill_tagstruct(struct pa_tagstruct *t, struct pa_sink *sink) {
pa_tagstruct_putu32(t, sink->typeid);
}
-static void source_fill_tagstruct(struct pa_tagstruct *t, struct pa_source *source) {
+static void source_fill_tagstruct(pa_tagstruct *t, pa_source *source) {
assert(t && source);
pa_tagstruct_putu32(t, source->index);
pa_tagstruct_puts(t, source->name);
@@ -1137,7 +1137,7 @@ static void source_fill_tagstruct(struct pa_tagstruct *t, struct pa_source *sour
pa_tagstruct_putu32(t, source->typeid);
}
-static void client_fill_tagstruct(struct pa_tagstruct *t, struct pa_client *client) {
+static void client_fill_tagstruct(pa_tagstruct *t, pa_client *client) {
assert(t && client);
pa_tagstruct_putu32(t, client->index);
pa_tagstruct_puts(t, client->name);
@@ -1145,7 +1145,7 @@ static void client_fill_tagstruct(struct pa_tagstruct *t, struct pa_client *clie
pa_tagstruct_putu32(t, client->typeid);
}
-static void module_fill_tagstruct(struct pa_tagstruct *t, struct pa_module *module) {
+static void module_fill_tagstruct(pa_tagstruct *t, pa_module *module) {
assert(t && module);
pa_tagstruct_putu32(t, module->index);
pa_tagstruct_puts(t, module->name);
@@ -1154,7 +1154,7 @@ static void module_fill_tagstruct(struct pa_tagstruct *t, struct pa_module *modu
pa_tagstruct_put_boolean(t, module->auto_unload);
}
-static void sink_input_fill_tagstruct(struct pa_tagstruct *t, struct pa_sink_input *s) {
+static void sink_input_fill_tagstruct(pa_tagstruct *t, pa_sink_input *s) {
assert(t && s);
pa_tagstruct_putu32(t, s->index);
pa_tagstruct_puts(t, s->name);
@@ -1169,7 +1169,7 @@ static void sink_input_fill_tagstruct(struct pa_tagstruct *t, struct pa_sink_inp
pa_tagstruct_putu32(t, s->typeid);
}
-static void source_output_fill_tagstruct(struct pa_tagstruct *t, struct pa_source_output *s) {
+static void source_output_fill_tagstruct(pa_tagstruct *t, pa_source_output *s) {
assert(t && s);
pa_tagstruct_putu32(t, s->index);
pa_tagstruct_puts(t, s->name);
@@ -1183,7 +1183,7 @@ static void source_output_fill_tagstruct(struct pa_tagstruct *t, struct pa_sourc
pa_tagstruct_putu32(t, s->typeid);
}
-static void scache_fill_tagstruct(struct pa_tagstruct *t, struct pa_scache_entry *e) {
+static void scache_fill_tagstruct(pa_tagstruct *t, pa_scache_entry *e) {
assert(t && e);
pa_tagstruct_putu32(t, e->index);
pa_tagstruct_puts(t, e->name);
@@ -1195,22 +1195,22 @@ static void scache_fill_tagstruct(struct pa_tagstruct *t, struct pa_scache_entry
pa_tagstruct_puts(t, e->filename);
}
-static void command_get_info(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
+static void command_get_info(PA_GCC_UNUSED pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
struct connection *c = userdata;
- uint32_t index;
- struct pa_sink *sink = NULL;
- struct pa_source *source = NULL;
- struct pa_client *client = NULL;
- struct pa_module *module = NULL;
- struct pa_sink_input *si = NULL;
- struct pa_source_output *so = NULL;
- struct pa_scache_entry *sce = NULL;
+ uint32_t idx;
+ pa_sink *sink = NULL;
+ pa_source *source = NULL;
+ pa_client *client = NULL;
+ pa_module *module = NULL;
+ pa_sink_input *si = NULL;
+ pa_source_output *so = NULL;
+ pa_scache_entry *sce = NULL;
const char *name;
- struct pa_tagstruct *reply;
+ pa_tagstruct *reply;
assert(c && t);
- if (pa_tagstruct_getu32(t, &index) < 0 ||
+ if (pa_tagstruct_getu32(t, &idx) < 0 ||
(command != PA_COMMAND_GET_CLIENT_INFO &&
command != PA_COMMAND_GET_MODULE_INFO &&
command != PA_COMMAND_GET_SINK_INPUT_INFO &&
@@ -1227,27 +1227,27 @@ static void command_get_info(struct pa_pdispatch *pd, uint32_t command, uint32_t
}
if (command == PA_COMMAND_GET_SINK_INFO) {
- if (index != (uint32_t) -1)
- sink = pa_idxset_get_by_index(c->protocol->core->sinks, index);
+ if (idx != (uint32_t) -1)
+ sink = pa_idxset_get_by_index(c->protocol->core->sinks, idx);
else
sink = pa_namereg_get(c->protocol->core, name, PA_NAMEREG_SINK, 1);
} else if (command == PA_COMMAND_GET_SOURCE_INFO) {
- if (index != (uint32_t) -1)
- source = pa_idxset_get_by_index(c->protocol->core->sources, index);
+ if (idx != (uint32_t) -1)
+ source = pa_idxset_get_by_index(c->protocol->core->sources, idx);
else
source = pa_namereg_get(c->protocol->core, name, PA_NAMEREG_SOURCE, 1);
} else if (command == PA_COMMAND_GET_CLIENT_INFO)
- client = pa_idxset_get_by_index(c->protocol->core->clients, index);
+ client = pa_idxset_get_by_index(c->protocol->core->clients, idx);
else if (command == PA_COMMAND_GET_MODULE_INFO)
- module = pa_idxset_get_by_index(c->protocol->core->modules, index);
+ module = pa_idxset_get_by_index(c->protocol->core->modules, idx);
else if (command == PA_COMMAND_GET_SINK_INPUT_INFO)
- si = pa_idxset_get_by_index(c->protocol->core->sink_inputs, index);
+ si = pa_idxset_get_by_index(c->protocol->core->sink_inputs, idx);
else if (command == PA_COMMAND_GET_SOURCE_OUTPUT_INFO)
- so = pa_idxset_get_by_index(c->protocol->core->source_outputs, index);
+ so = pa_idxset_get_by_index(c->protocol->core->source_outputs, idx);
else {
assert(command == PA_COMMAND_GET_SAMPLE_INFO);
- if (index != (uint32_t) -1)
- sce = pa_idxset_get_by_index(c->protocol->core->scache, index);
+ if (idx != (uint32_t) -1)
+ sce = pa_idxset_get_by_index(c->protocol->core->scache, idx);
else
sce = pa_namereg_get(c->protocol->core, name, PA_NAMEREG_SAMPLE, 0);
}
@@ -1278,12 +1278,12 @@ static void command_get_info(struct pa_pdispatch *pd, uint32_t command, uint32_t
pa_pstream_send_tagstruct(c->pstream, reply);
}
-static void command_get_info_list(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
+static void command_get_info_list(PA_GCC_UNUSED pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
struct connection *c = userdata;
- struct pa_idxset *i;
- uint32_t index;
+ pa_idxset *i;
+ uint32_t idx;
void *p;
- struct pa_tagstruct *reply;
+ pa_tagstruct *reply;
assert(c && t);
if (!pa_tagstruct_eof(t)) {
@@ -1319,7 +1319,7 @@ static void command_get_info_list(struct pa_pdispatch *pd, uint32_t command, uin
}
if (i) {
- for (p = pa_idxset_first(i, &index); p; p = pa_idxset_next(i, &index)) {
+ for (p = pa_idxset_first(i, &idx); p; p = pa_idxset_next(i, &idx)) {
if (command == PA_COMMAND_GET_SINK_INFO_LIST)
sink_fill_tagstruct(reply, p);
else if (command == PA_COMMAND_GET_SOURCE_INFO_LIST)
@@ -1342,9 +1342,9 @@ static void command_get_info_list(struct pa_pdispatch *pd, uint32_t command, uin
pa_pstream_send_tagstruct(c->pstream, reply);
}
-static void command_get_server_info(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
+static void command_get_server_info(PA_GCC_UNUSED pa_pdispatch *pd, PA_GCC_UNUSED uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
struct connection *c = userdata;
- struct pa_tagstruct *reply;
+ pa_tagstruct *reply;
char txt[256];
const char *n;
assert(c && t);
@@ -1379,8 +1379,8 @@ static void command_get_server_info(struct pa_pdispatch *pd, uint32_t command, u
pa_pstream_send_tagstruct(c->pstream, reply);
}
-static void subscription_cb(struct pa_core *core, enum pa_subscription_event_type e, uint32_t index, void *userdata) {
- struct pa_tagstruct *t;
+static void subscription_cb(pa_core *core, pa_subscription_event_type e, uint32_t idx, void *userdata) {
+ pa_tagstruct *t;
struct connection *c = userdata;
assert(c && core);
@@ -1389,13 +1389,13 @@ static void subscription_cb(struct pa_core *core, enum pa_subscription_event_typ
pa_tagstruct_putu32(t, PA_COMMAND_SUBSCRIBE_EVENT);
pa_tagstruct_putu32(t, (uint32_t) -1);
pa_tagstruct_putu32(t, e);
- pa_tagstruct_putu32(t, index);
+ pa_tagstruct_putu32(t, idx);
pa_pstream_send_tagstruct(c->pstream, t);
}
-static void command_subscribe(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
+static void command_subscribe(PA_GCC_UNUSED pa_pdispatch *pd, PA_GCC_UNUSED uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
struct connection *c = userdata;
- enum pa_subscription_mask m;
+ pa_subscription_mask m;
assert(c && t);
if (pa_tagstruct_getu32(t, &m) < 0 ||
@@ -1421,15 +1421,15 @@ static void command_subscribe(struct pa_pdispatch *pd, uint32_t command, uint32_
pa_pstream_send_simple_ack(c->pstream, tag);
}
-static void command_set_volume(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
+static void command_set_volume(PA_GCC_UNUSED pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
struct connection *c = userdata;
- uint32_t index, volume;
- struct pa_sink *sink = NULL;
- struct pa_sink_input *si = NULL;
+ uint32_t idx, volume;
+ pa_sink *sink = NULL;
+ pa_sink_input *si = NULL;
const char *name = NULL;
assert(c && t);
- if (pa_tagstruct_getu32(t, &index) < 0 ||
+ if (pa_tagstruct_getu32(t, &idx) < 0 ||
(command == PA_COMMAND_SET_SINK_VOLUME && pa_tagstruct_gets(t, &name) < 0) ||
pa_tagstruct_getu32(t, &volume) ||
!pa_tagstruct_eof(t)) {
@@ -1443,13 +1443,13 @@ static void command_set_volume(struct pa_pdispatch *pd, uint32_t command, uint32
}
if (command == PA_COMMAND_SET_SINK_VOLUME) {
- if (index != (uint32_t) -1)
- sink = pa_idxset_get_by_index(c->protocol->core->sinks, index);
+ if (idx != (uint32_t) -1)
+ sink = pa_idxset_get_by_index(c->protocol->core->sinks, idx);
else
sink = pa_namereg_get(c->protocol->core, name, PA_NAMEREG_SINK, 1);
} else {
assert(command == PA_COMMAND_SET_SINK_INPUT_VOLUME);
- si = pa_idxset_get_by_index(c->protocol->core->sink_inputs, index);
+ si = pa_idxset_get_by_index(c->protocol->core->sink_inputs, idx);
}
if (!si && !sink) {
@@ -1465,14 +1465,14 @@ static void command_set_volume(struct pa_pdispatch *pd, uint32_t command, uint32
pa_pstream_send_simple_ack(c->pstream, tag);
}
-static void command_cork_playback_stream(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
+static void command_cork_playback_stream(PA_GCC_UNUSED pa_pdispatch *pd, PA_GCC_UNUSED uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
struct connection *c = userdata;
- uint32_t index;
+ uint32_t idx;
int b;
struct playback_stream *s;
assert(c && t);
- if (pa_tagstruct_getu32(t, &index) < 0 ||
+ if (pa_tagstruct_getu32(t, &idx) < 0 ||
pa_tagstruct_get_boolean(t, &b) < 0 ||
!pa_tagstruct_eof(t)) {
protocol_error(c);
@@ -1484,7 +1484,7 @@ static void command_cork_playback_stream(struct pa_pdispatch *pd, uint32_t comma
return;
}
- if (!(s = pa_idxset_get_by_index(c->output_streams, index)) || s->type != PLAYBACK_STREAM) {
+ if (!(s = pa_idxset_get_by_index(c->output_streams, idx)) || s->type != PLAYBACK_STREAM) {
pa_pstream_send_error(c->pstream, tag, PA_ERROR_NOENTITY);
return;
}
@@ -1493,13 +1493,13 @@ static void command_cork_playback_stream(struct pa_pdispatch *pd, uint32_t comma
pa_pstream_send_simple_ack(c->pstream, tag);
}
-static void command_flush_or_trigger_playback_stream(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
+static void command_flush_or_trigger_playback_stream(PA_GCC_UNUSED pa_pdispatch *pd, PA_GCC_UNUSED uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
struct connection *c = userdata;
- uint32_t index;
+ uint32_t idx;
struct playback_stream *s;
assert(c && t);
- if (pa_tagstruct_getu32(t, &index) < 0 ||
+ if (pa_tagstruct_getu32(t, &idx) < 0 ||
!pa_tagstruct_eof(t)) {
protocol_error(c);
return;
@@ -1510,7 +1510,7 @@ static void command_flush_or_trigger_playback_stream(struct pa_pdispatch *pd, ui
return;
}
- if (!(s = pa_idxset_get_by_index(c->output_streams, index)) || s->type != PLAYBACK_STREAM) {
+ if (!(s = pa_idxset_get_by_index(c->output_streams, idx)) || s->type != PLAYBACK_STREAM) {
pa_pstream_send_error(c->pstream, tag, PA_ERROR_NOENTITY);
return;
}
@@ -1530,14 +1530,14 @@ static void command_flush_or_trigger_playback_stream(struct pa_pdispatch *pd, ui
request_bytes(s);
}
-static void command_cork_record_stream(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
+static void command_cork_record_stream(PA_GCC_UNUSED pa_pdispatch *pd, PA_GCC_UNUSED uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
struct connection *c = userdata;
- uint32_t index;
+ uint32_t idx;
struct record_stream *s;
int b;
assert(c && t);
- if (pa_tagstruct_getu32(t, &index) < 0 ||
+ if (pa_tagstruct_getu32(t, &idx) < 0 ||
pa_tagstruct_get_boolean(t, &b) < 0 ||
!pa_tagstruct_eof(t)) {
protocol_error(c);
@@ -1549,7 +1549,7 @@ static void command_cork_record_stream(struct pa_pdispatch *pd, uint32_t command
return;
}
- if (!(s = pa_idxset_get_by_index(c->record_streams, index))) {
+ if (!(s = pa_idxset_get_by_index(c->record_streams, idx))) {
pa_pstream_send_error(c->pstream, tag, PA_ERROR_NOENTITY);
return;
}
@@ -1558,13 +1558,13 @@ static void command_cork_record_stream(struct pa_pdispatch *pd, uint32_t command
pa_pstream_send_simple_ack(c->pstream, tag);
}
-static void command_flush_record_stream(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
+static void command_flush_record_stream(PA_GCC_UNUSED pa_pdispatch *pd, PA_GCC_UNUSED uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
struct connection *c = userdata;
- uint32_t index;
+ uint32_t idx;
struct record_stream *s;
assert(c && t);
- if (pa_tagstruct_getu32(t, &index) < 0 ||
+ if (pa_tagstruct_getu32(t, &idx) < 0 ||
!pa_tagstruct_eof(t)) {
protocol_error(c);
return;
@@ -1575,7 +1575,7 @@ static void command_flush_record_stream(struct pa_pdispatch *pd, uint32_t comman
return;
}
- if (!(s = pa_idxset_get_by_index(c->record_streams, index))) {
+ if (!(s = pa_idxset_get_by_index(c->record_streams, idx))) {
pa_pstream_send_error(c->pstream, tag, PA_ERROR_NOENTITY);
return;
}
@@ -1584,13 +1584,13 @@ static void command_flush_record_stream(struct pa_pdispatch *pd, uint32_t comman
pa_pstream_send_simple_ack(c->pstream, tag);
}
-static void command_set_default_sink_or_source(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
+static void command_set_default_sink_or_source(PA_GCC_UNUSED pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
struct connection *c = userdata;
- uint32_t index;
+ uint32_t idx;
const char *s;
assert(c && t);
- if (pa_tagstruct_getu32(t, &index) < 0 ||
+ if (pa_tagstruct_getu32(t, &idx) < 0 ||
pa_tagstruct_gets(t, &s) < 0 || !s ||
!pa_tagstruct_eof(t)) {
protocol_error(c);
@@ -1606,13 +1606,13 @@ static void command_set_default_sink_or_source(struct pa_pdispatch *pd, uint32_t
pa_pstream_send_simple_ack(c->pstream, tag);
}
-static void command_set_stream_name(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
+static void command_set_stream_name(PA_GCC_UNUSED pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
struct connection *c = userdata;
- uint32_t index;
+ uint32_t idx;
const char *name;
assert(c && t);
- if (pa_tagstruct_getu32(t, &index) < 0 ||
+ if (pa_tagstruct_getu32(t, &idx) < 0 ||
pa_tagstruct_gets(t, &name) < 0 || !name ||
!pa_tagstruct_eof(t)) {
protocol_error(c);
@@ -1627,7 +1627,7 @@ static void command_set_stream_name(struct pa_pdispatch *pd, uint32_t command, u
if (command == PA_COMMAND_SET_PLAYBACK_STREAM_NAME) {
struct playback_stream *s;
- if (!(s = pa_idxset_get_by_index(c->output_streams, index)) || s->type != PLAYBACK_STREAM) {
+ if (!(s = pa_idxset_get_by_index(c->output_streams, idx)) || s->type != PLAYBACK_STREAM) {
pa_pstream_send_error(c->pstream, tag, PA_ERROR_NOENTITY);
return;
}
@@ -1637,7 +1637,7 @@ static void command_set_stream_name(struct pa_pdispatch *pd, uint32_t command, u
} else {
struct record_stream *s;
- if (!(s = pa_idxset_get_by_index(c->record_streams, index))) {
+ if (!(s = pa_idxset_get_by_index(c->record_streams, idx))) {
pa_pstream_send_error(c->pstream, tag, PA_ERROR_NOENTITY);
return;
}
@@ -1648,12 +1648,12 @@ static void command_set_stream_name(struct pa_pdispatch *pd, uint32_t command, u
pa_pstream_send_simple_ack(c->pstream, tag);
}
-static void command_kill(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
+static void command_kill(PA_GCC_UNUSED pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
struct connection *c = userdata;
- uint32_t index;
+ uint32_t idx;
assert(c && t);
- if (pa_tagstruct_getu32(t, &index) < 0 ||
+ if (pa_tagstruct_getu32(t, &idx) < 0 ||
!pa_tagstruct_eof(t)) {
protocol_error(c);
return;
@@ -1665,29 +1665,29 @@ static void command_kill(struct pa_pdispatch *pd, uint32_t command, uint32_t tag
}
if (command == PA_COMMAND_KILL_CLIENT) {
- struct pa_client *client;
+ pa_client *client;
- if (!(client = pa_idxset_get_by_index(c->protocol->core->clients, index))) {
+ if (!(client = pa_idxset_get_by_index(c->protocol->core->clients, idx))) {
pa_pstream_send_error(c->pstream, tag, PA_ERROR_NOENTITY);
return;
}
pa_client_kill(client);
} else if (command == PA_COMMAND_KILL_SINK_INPUT) {
- struct pa_sink_input *s;
+ pa_sink_input *s;
- if (!(s = pa_idxset_get_by_index(c->protocol->core->sink_inputs, index))) {
+ if (!(s = pa_idxset_get_by_index(c->protocol->core->sink_inputs, idx))) {
pa_pstream_send_error(c->pstream, tag, PA_ERROR_NOENTITY);
return;
}
pa_sink_input_kill(s);
} else {
- struct pa_source_output *s;
+ pa_source_output *s;
assert(command == PA_COMMAND_KILL_SOURCE_OUTPUT);
- if (!(s = pa_idxset_get_by_index(c->protocol->core->source_outputs, index))) {
+ if (!(s = pa_idxset_get_by_index(c->protocol->core->source_outputs, idx))) {
pa_pstream_send_error(c->pstream, tag, PA_ERROR_NOENTITY);
return;
}
@@ -1698,11 +1698,11 @@ static void command_kill(struct pa_pdispatch *pd, uint32_t command, uint32_t tag
pa_pstream_send_simple_ack(c->pstream, tag);
}
-static void command_load_module(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
+static void command_load_module(PA_GCC_UNUSED pa_pdispatch *pd, PA_GCC_UNUSED uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
struct connection *c = userdata;
- struct pa_module *m;
+ pa_module *m;
const char *name, *argument;
- struct pa_tagstruct *reply;
+ pa_tagstruct *reply;
assert(c && t);
if (pa_tagstruct_gets(t, &name) < 0 || !name ||
@@ -1729,13 +1729,13 @@ static void command_load_module(struct pa_pdispatch *pd, uint32_t command, uint3
pa_pstream_send_tagstruct(c->pstream, reply);
}
-static void command_unload_module(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
+static void command_unload_module(PA_GCC_UNUSED pa_pdispatch *pd, PA_GCC_UNUSED uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
struct connection *c = userdata;
- uint32_t index;
- struct pa_module *m;
+ uint32_t idx;
+ pa_module *m;
assert(c && t);
- if (pa_tagstruct_getu32(t, &index) < 0 ||
+ if (pa_tagstruct_getu32(t, &idx) < 0 ||
!pa_tagstruct_eof(t)) {
protocol_error(c);
return;
@@ -1746,7 +1746,7 @@ static void command_unload_module(struct pa_pdispatch *pd, uint32_t command, uin
return;
}
- if (!(m = pa_idxset_get_by_index(c->protocol->core->modules, index))) {
+ if (!(m = pa_idxset_get_by_index(c->protocol->core->modules, idx))) {
pa_pstream_send_error(c->pstream, tag, PA_ERROR_NOENTITY);
return;
}
@@ -1755,12 +1755,12 @@ static void command_unload_module(struct pa_pdispatch *pd, uint32_t command, uin
pa_pstream_send_simple_ack(c->pstream, tag);
}
-static void command_add_autoload(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
+static void command_add_autoload(PA_GCC_UNUSED pa_pdispatch *pd, PA_GCC_UNUSED uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
struct connection *c = userdata;
const char *name, *module, *argument;
uint32_t type;
- uint32_t index;
- struct pa_tagstruct *reply;
+ uint32_t idx;
+ pa_tagstruct *reply;
assert(c && t);
if (pa_tagstruct_gets(t, &name) < 0 || !name ||
@@ -1777,7 +1777,7 @@ static void command_add_autoload(struct pa_pdispatch *pd, uint32_t command, uint
return;
}
- if (pa_autoload_add(c->protocol->core, name, type == 0 ? PA_NAMEREG_SINK : PA_NAMEREG_SOURCE, module, argument, &index) < 0) {
+ if (pa_autoload_add(c->protocol->core, name, type == 0 ? PA_NAMEREG_SINK : PA_NAMEREG_SOURCE, module, argument, &idx) < 0) {
pa_pstream_send_error(c->pstream, tag, PA_ERROR_EXIST);
return;
}
@@ -1785,21 +1785,21 @@ static void command_add_autoload(struct pa_pdispatch *pd, uint32_t command, uint
reply = pa_tagstruct_new(NULL, 0);
pa_tagstruct_putu32(reply, PA_COMMAND_REPLY);
pa_tagstruct_putu32(reply, tag);
- pa_tagstruct_putu32(reply, index);
+ pa_tagstruct_putu32(reply, idx);
pa_pstream_send_tagstruct(c->pstream, reply);
}
-static void command_remove_autoload(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
+static void command_remove_autoload(PA_GCC_UNUSED pa_pdispatch *pd, PA_GCC_UNUSED uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
struct connection *c = userdata;
const char *name = NULL;
- uint32_t type, index = PA_IDXSET_INVALID;
+ uint32_t type, idx = PA_IDXSET_INVALID;
int r;
assert(c && t);
- if ((pa_tagstruct_getu32(t, &index) < 0 &&
+ if ((pa_tagstruct_getu32(t, &idx) < 0 &&
(pa_tagstruct_gets(t, &name) < 0 ||
pa_tagstruct_getu32(t, &type) < 0)) ||
- (!name && index == PA_IDXSET_INVALID) ||
+ (!name && idx == PA_IDXSET_INVALID) ||
(name && type > 1) ||
!pa_tagstruct_eof(t)) {
protocol_error(c);
@@ -1814,7 +1814,7 @@ static void command_remove_autoload(struct pa_pdispatch *pd, uint32_t command, u
if (name)
r = pa_autoload_remove_by_name(c->protocol->core, name, type == 0 ? PA_NAMEREG_SINK : PA_NAMEREG_SOURCE);
else
- r = pa_autoload_remove_by_index(c->protocol->core, index);
+ r = pa_autoload_remove_by_index(c->protocol->core, idx);
if (r < 0) {
pa_pstream_send_error(c->pstream, tag, PA_ERROR_NOENTITY);
@@ -1824,7 +1824,7 @@ static void command_remove_autoload(struct pa_pdispatch *pd, uint32_t command, u
pa_pstream_send_simple_ack(c->pstream, tag);
}
-static void autoload_fill_tagstruct(struct pa_tagstruct *t, const struct pa_autoload_entry *e) {
+static void autoload_fill_tagstruct(pa_tagstruct *t, const pa_autoload_entry *e) {
assert(t && e);
pa_tagstruct_putu32(t, e->index);
@@ -1834,18 +1834,18 @@ static void autoload_fill_tagstruct(struct pa_tagstruct *t, const struct pa_auto
pa_tagstruct_puts(t, e->argument);
}
-static void command_get_autoload_info(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
+static void command_get_autoload_info(PA_GCC_UNUSED pa_pdispatch *pd, PA_GCC_UNUSED uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
struct connection *c = userdata;
- const struct pa_autoload_entry *a = NULL;
- uint32_t type, index;
+ const pa_autoload_entry *a = NULL;
+ uint32_t type, idx;
const char *name;
- struct pa_tagstruct *reply;
+ pa_tagstruct *reply;
assert(c && t);
- if ((pa_tagstruct_getu32(t, &index) < 0 &&
+ if ((pa_tagstruct_getu32(t, &idx) < 0 &&
(pa_tagstruct_gets(t, &name) < 0 ||
pa_tagstruct_getu32(t, &type) < 0)) ||
- (!name && index == PA_IDXSET_INVALID) ||
+ (!name && idx == PA_IDXSET_INVALID) ||
(name && type > 1) ||
!pa_tagstruct_eof(t)) {
protocol_error(c);
@@ -1861,7 +1861,7 @@ static void command_get_autoload_info(struct pa_pdispatch *pd, uint32_t command,
if (name)
a = pa_autoload_get_by_name(c->protocol->core, name, type == 0 ? PA_NAMEREG_SINK : PA_NAMEREG_SOURCE);
else
- a = pa_autoload_get_by_index(c->protocol->core, index);
+ a = pa_autoload_get_by_index(c->protocol->core, idx);
if (!a) {
pa_pstream_send_error(c->pstream, tag, PA_ERROR_NOENTITY);
@@ -1876,9 +1876,9 @@ static void command_get_autoload_info(struct pa_pdispatch *pd, uint32_t command,
pa_pstream_send_tagstruct(c->pstream, reply);
}
-static void command_get_autoload_info_list(struct pa_pdispatch *pd, uint32_t command, uint32_t tag, struct pa_tagstruct *t, void *userdata) {
+static void command_get_autoload_info_list(PA_GCC_UNUSED pa_pdispatch *pd, PA_GCC_UNUSED uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
struct connection *c = userdata;
- struct pa_tagstruct *reply;
+ pa_tagstruct *reply;
assert(c && t);
if (!pa_tagstruct_eof(t)) {
@@ -1896,7 +1896,7 @@ static void command_get_autoload_info_list(struct pa_pdispatch *pd, uint32_t com
pa_tagstruct_putu32(reply, tag);
if (c->protocol->core->autoload_hashmap) {
- struct pa_autoload_entry *a;
+ pa_autoload_entry *a;
void *state = NULL;
while ((a = pa_hashmap_iterate(c->protocol->core->autoload_hashmap, &state, NULL)))
@@ -1908,7 +1908,7 @@ static void command_get_autoload_info_list(struct pa_pdispatch *pd, uint32_t com
/*** pstream callbacks ***/
-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 connection *c = userdata;
assert(p && packet && packet->data && c);
@@ -1918,7 +1918,7 @@ static void pstream_packet_callback(struct pa_pstream *p, struct pa_packet *pack
}
}
-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 connection *c = userdata;
struct output_stream *stream;
assert(p && chunk && userdata);
@@ -1930,17 +1930,17 @@ static void pstream_memblock_callback(struct pa_pstream *p, uint32_t channel, ui
}
if (stream->type == PLAYBACK_STREAM) {
- struct playback_stream *p = (struct playback_stream*) stream;
- if (chunk->length >= p->requested_bytes)
- p->requested_bytes = 0;
+ struct playback_stream *ps = (struct playback_stream*) stream;
+ if (chunk->length >= ps->requested_bytes)
+ ps->requested_bytes = 0;
else
- p->requested_bytes -= chunk->length;
+ ps->requested_bytes -= chunk->length;
- pa_memblockq_push_align(p->memblockq, chunk, delta);
- assert(p->sink_input);
+ pa_memblockq_push_align(ps->memblockq, chunk, delta);
+ assert(ps->sink_input);
/* pa_log(__FILE__": after_recv: %u\n", pa_memblockq_get_length(p->memblockq)); */
- pa_sink_notify(p->sink_input->sink);
+ pa_sink_notify(ps->sink_input->sink);
/* pa_log(__FILE__": Recieved %u bytes.\n", chunk->length); */
} else {
@@ -1974,7 +1974,7 @@ static void pstream_memblock_callback(struct pa_pstream *p, uint32_t channel, ui
}
}
-static void pstream_die_callback(struct pa_pstream *p, void *userdata) {
+static void pstream_die_callback(pa_pstream *p, void *userdata) {
struct connection *c = userdata;
assert(p && c);
connection_free(c);
@@ -1983,7 +1983,7 @@ static void pstream_die_callback(struct pa_pstream *p, void *userdata) {
}
-static void pstream_drain_callback(struct pa_pstream *p, void *userdata) {
+static void pstream_drain_callback(pa_pstream *p, void *userdata) {
struct connection *c = userdata;
assert(p && c);
@@ -1992,14 +1992,14 @@ static void pstream_drain_callback(struct pa_pstream *p, void *userdata) {
/*** client callbacks ***/
-static void client_kill_cb(struct pa_client *c) {
+static void client_kill_cb(pa_client *c) {
assert(c && c->userdata);
connection_free(c->userdata);
}
/*** socket server callbacks ***/
-static void auth_timeout(struct pa_mainloop_api*m, struct pa_time_event *e, const struct timeval *tv, void *userdata) {
+static void auth_timeout(pa_mainloop_api*m, pa_time_event *e, const struct timeval *tv, void *userdata) {
struct connection *c = userdata;
assert(m && tv && c && c->auth_timeout_event == e);
@@ -2007,12 +2007,12 @@ static void auth_timeout(struct pa_mainloop_api*m, struct pa_time_event *e, cons
connection_free(c);
}
-static void on_connection(struct pa_socket_server*s, struct pa_iochannel *io, void *userdata) {
- struct pa_protocol_native *p = userdata;
+static void on_connection(PA_GCC_UNUSED pa_socket_server*s, pa_iochannel *io, void *userdata) {
+ pa_protocol_native *p = userdata;
struct connection *c;
assert(io && p);
- if (pa_idxset_ncontents(p->connections)+1 > MAX_CONNECTIONS) {
+ if (pa_idxset_size(p->connections)+1 > MAX_CONNECTIONS) {
pa_log_warn(__FILE__": Warning! Too many connections (%u), dropping incoming connection.\n", MAX_CONNECTIONS);
pa_iochannel_free(io);
return;
@@ -2061,7 +2061,7 @@ static void on_connection(struct pa_socket_server*s, struct pa_iochannel *io, vo
/*** module entry points ***/
-static int load_key(struct pa_protocol_native*p, const char*fn) {
+static int load_key(pa_protocol_native*p, const char*fn) {
assert(p);
p->auth_cookie_in_property = 0;
@@ -2087,8 +2087,8 @@ static int load_key(struct pa_protocol_native*p, const char*fn) {
return 0;
}
-static struct pa_protocol_native* protocol_new_internal(struct pa_core *c, struct pa_module *m, struct pa_modargs *ma) {
- struct pa_protocol_native *p;
+static pa_protocol_native* protocol_new_internal(pa_core *c, pa_module *m, pa_modargs *ma) {
+ pa_protocol_native *p;
int public = 0;
assert(c && ma);
@@ -2097,7 +2097,7 @@ static struct pa_protocol_native* protocol_new_internal(struct pa_core *c, struc
return NULL;
}
- p = pa_xmalloc(sizeof(struct pa_protocol_native));
+ p = pa_xmalloc(sizeof(pa_protocol_native));
p->core = c;
p->module = m;
p->public = public;
@@ -2114,9 +2114,9 @@ static struct pa_protocol_native* protocol_new_internal(struct pa_core *c, struc
return p;
}
-struct pa_protocol_native* pa_protocol_native_new(struct pa_core *core, struct pa_socket_server *server, struct pa_module *m, struct pa_modargs *ma) {
+pa_protocol_native* pa_protocol_native_new(pa_core *core, pa_socket_server *server, pa_module *m, pa_modargs *ma) {
char t[256];
- struct pa_protocol_native *p;
+ pa_protocol_native *p;
if (!(p = protocol_new_internal(core, m, ma)))
return NULL;
@@ -2125,7 +2125,7 @@ struct pa_protocol_native* pa_protocol_native_new(struct pa_core *core, struct p
pa_socket_server_set_callback(p->server, on_connection, p);
if (pa_socket_server_get_address(p->server, t, sizeof(t))) {
- struct pa_strlist *l;
+ pa_strlist *l;
l = pa_property_get(core, PA_NATIVE_SERVER_PROPERTY_NAME);
l = pa_strlist_prepend(l, t);
pa_property_replace(core, PA_NATIVE_SERVER_PROPERTY_NAME, l);
@@ -2134,7 +2134,7 @@ struct pa_protocol_native* pa_protocol_native_new(struct pa_core *core, struct p
return p;
}
-void pa_protocol_native_free(struct pa_protocol_native *p) {
+void pa_protocol_native_free(pa_protocol_native *p) {
struct connection *c;
assert(p);
@@ -2146,7 +2146,7 @@ void pa_protocol_native_free(struct pa_protocol_native *p) {
char t[256];
if (pa_socket_server_get_address(p->server, t, sizeof(t))) {
- struct pa_strlist *l;
+ pa_strlist *l;
l = pa_property_get(p->core, PA_NATIVE_SERVER_PROPERTY_NAME);
l = pa_strlist_remove(l, t);
@@ -2165,8 +2165,8 @@ void pa_protocol_native_free(struct pa_protocol_native *p) {
pa_xfree(p);
}
-struct pa_protocol_native* pa_protocol_native_new_iochannel(struct pa_core*core, struct pa_iochannel *io, struct pa_module *m, struct pa_modargs *ma) {
- struct pa_protocol_native *p;
+pa_protocol_native* pa_protocol_native_new_iochannel(pa_core*core, pa_iochannel *io, pa_module *m, pa_modargs *ma) {
+ pa_protocol_native *p;
if (!(p = protocol_new_internal(core, m, ma)))
return NULL;
diff --git a/polyp/protocol-native.h b/polyp/protocol-native.h
index 57c29e38..12e85d0b 100644
--- a/polyp/protocol-native.h
+++ b/polyp/protocol-native.h
@@ -27,11 +27,11 @@
#include "module.h"
#include "modargs.h"
-struct pa_protocol_native;
+typedef struct pa_protocol_native pa_protocol_native;
-struct pa_protocol_native* pa_protocol_native_new(struct pa_core*core, struct pa_socket_server *server, struct pa_module *m, struct pa_modargs *ma);
-void pa_protocol_native_free(struct pa_protocol_native *n);
+pa_protocol_native* pa_protocol_native_new(pa_core*core, pa_socket_server *server, pa_module *m, pa_modargs *ma);
+void pa_protocol_native_free(pa_protocol_native *n);
-struct pa_protocol_native* pa_protocol_native_new_iochannel(struct pa_core*core, struct pa_iochannel *io, struct pa_module *m, struct pa_modargs *ma);
+pa_protocol_native* pa_protocol_native_new_iochannel(pa_core*core, pa_iochannel *io, pa_module *m, pa_modargs *ma);
#endif
diff --git a/polyp/protocol-simple.c b/polyp/protocol-simple.c
index 8d05a7fa..a3d7099c 100644
--- a/polyp/protocol-simple.c
+++ b/polyp/protocol-simple.c
@@ -45,31 +45,31 @@
#define PA_TYPEID_SIMPLE PA_TYPEID_MAKE('S', 'M', 'P', 'L')
struct connection {
- struct pa_protocol_simple *protocol;
- struct pa_iochannel *io;
- struct pa_sink_input *sink_input;
- struct pa_source_output *source_output;
- struct pa_client *client;
- struct pa_memblockq *input_memblockq, *output_memblockq;
- struct pa_defer_event *defer_event;
+ pa_protocol_simple *protocol;
+ pa_iochannel *io;
+ pa_sink_input *sink_input;
+ pa_source_output *source_output;
+ pa_client *client;
+ pa_memblockq *input_memblockq, *output_memblockq;
+ pa_defer_event *defer_event;
struct {
- struct pa_memblock *current_memblock;
+ pa_memblock *current_memblock;
size_t memblock_index, fragment_size;
} playback;
};
struct pa_protocol_simple {
- struct pa_module *module;
- struct pa_core *core;
- struct pa_socket_server*server;
- struct pa_idxset *connections;
+ pa_module *module;
+ pa_core *core;
+ pa_socket_server*server;
+ pa_idxset *connections;
enum {
RECORD = 1,
PLAYBACK = 2,
DUPLEX = 3
} mode;
- struct pa_sample_spec sample_spec;
+ pa_sample_spec sample_spec;
char *source_name, *sink_name;
};
@@ -107,7 +107,7 @@ static void connection_free(struct connection *c) {
}
static int do_read(struct connection *c) {
- struct pa_memchunk chunk;
+ pa_memchunk chunk;
ssize_t r;
size_t l;
@@ -151,7 +151,7 @@ static int do_read(struct connection *c) {
}
static int do_write(struct connection *c) {
- struct pa_memchunk chunk;
+ pa_memchunk chunk;
ssize_t r;
if (!c->source_output)
@@ -201,7 +201,7 @@ fail:
/*** sink_input callbacks ***/
-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 connection*c;
assert(i && i->userdata && chunk);
c = i->userdata;
@@ -212,7 +212,7 @@ static int sink_input_peek_cb(struct pa_sink_input *i, struct pa_memchunk *chunk
return 0;
}
-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 connection*c = i->userdata;
assert(i && c && length);
@@ -223,13 +223,13 @@ static void sink_input_drop_cb(struct pa_sink_input *i, const struct pa_memchunk
c->protocol->core->mainloop->defer_enable(c->defer_event, 1);
}
-static void sink_input_kill_cb(struct pa_sink_input *i) {
+static void sink_input_kill_cb(pa_sink_input *i) {
assert(i && i->userdata);
connection_free((struct connection *) i->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 connection*c = i->userdata;
assert(i && c);
return pa_bytes_to_usec(pa_memblockq_get_length(c->input_memblockq), &c->sink_input->sample_spec);
@@ -237,7 +237,7 @@ static pa_usec_t sink_input_get_latency_cb(struct pa_sink_input *i) {
/*** source_output callbacks ***/
-static void source_output_push_cb(struct pa_source_output *o, const struct pa_memchunk *chunk) {
+static void source_output_push_cb(pa_source_output *o, const pa_memchunk *chunk) {
struct connection *c = o->userdata;
assert(o && c && chunk);
@@ -248,12 +248,12 @@ static void source_output_push_cb(struct pa_source_output *o, const struct pa_me
c->protocol->core->mainloop->defer_enable(c->defer_event, 1);
}
-static void source_output_kill_cb(struct pa_source_output *o) {
+static void source_output_kill_cb(pa_source_output *o) {
assert(o && o->userdata);
connection_free((struct connection *) o->userdata);
}
-static pa_usec_t source_output_get_latency_cb(struct pa_source_output *o) {
+static pa_usec_t source_output_get_latency_cb(pa_source_output *o) {
struct connection*c = o->userdata;
assert(o && c);
return pa_bytes_to_usec(pa_memblockq_get_length(c->output_memblockq), &c->source_output->sample_spec);
@@ -261,14 +261,14 @@ static pa_usec_t source_output_get_latency_cb(struct pa_source_output *o) {
/*** client callbacks ***/
-static void client_kill_cb(struct pa_client *c) {
+static void client_kill_cb(pa_client *c) {
assert(c && c->userdata);
connection_free((struct connection *) c->userdata);
}
/*** pa_iochannel callbacks ***/
-static void io_callback(struct pa_iochannel*io, void *userdata) {
+static void io_callback(pa_iochannel*io, void *userdata) {
struct connection *c = userdata;
assert(io && c && c->io == io);
@@ -277,7 +277,7 @@ static void io_callback(struct pa_iochannel*io, void *userdata) {
/*** fixed callback ***/
-static void defer_callback(struct pa_mainloop_api*a, struct pa_defer_event *e, void *userdata) {
+static void defer_callback(pa_mainloop_api*a, pa_defer_event *e, void *userdata) {
struct connection *c = userdata;
assert(a && c && c->defer_event == e);
@@ -286,13 +286,13 @@ static void defer_callback(struct pa_mainloop_api*a, struct pa_defer_event *e, v
/*** socket_server callbacks ***/
-static void on_connection(struct pa_socket_server*s, struct pa_iochannel *io, void *userdata) {
- struct pa_protocol_simple *p = userdata;
+static void on_connection(pa_socket_server*s, pa_iochannel *io, void *userdata) {
+ pa_protocol_simple *p = userdata;
struct connection *c = NULL;
char cname[256];
assert(s && io && p);
- if (pa_idxset_ncontents(p->connections)+1 > MAX_CONNECTIONS) {
+ if (pa_idxset_size(p->connections)+1 > MAX_CONNECTIONS) {
pa_log(__FILE__": Warning! Too many connections (%u), dropping incoming connection.\n", MAX_CONNECTIONS);
pa_iochannel_free(io);
return;
@@ -317,7 +317,7 @@ static void on_connection(struct pa_socket_server*s, struct pa_iochannel *io, vo
c->client->userdata = c;
if (p->mode & PLAYBACK) {
- struct pa_sink *sink;
+ pa_sink *sink;
size_t l;
if (!(sink = pa_namereg_get(p->core, p->sink_name, PA_NAMEREG_SINK, 1))) {
@@ -347,7 +347,7 @@ static void on_connection(struct pa_socket_server*s, struct pa_iochannel *io, vo
}
if (p->mode & RECORD) {
- struct pa_source *source;
+ pa_source *source;
size_t l;
if (!(source = pa_namereg_get(p->core, p->source_name, PA_NAMEREG_SOURCE, 1))) {
@@ -387,12 +387,12 @@ fail:
connection_free(c);
}
-struct pa_protocol_simple* pa_protocol_simple_new(struct pa_core *core, struct pa_socket_server *server, struct pa_module *m, struct pa_modargs *ma) {
- struct pa_protocol_simple* p = NULL;
+pa_protocol_simple* pa_protocol_simple_new(pa_core *core, pa_socket_server *server, pa_module *m, pa_modargs *ma) {
+ pa_protocol_simple* p = NULL;
int enable;
assert(core && server && ma);
- p = pa_xmalloc0(sizeof(struct pa_protocol_simple));
+ p = pa_xmalloc0(sizeof(pa_protocol_simple));
p->module = m;
p->core = core;
p->server = server;
@@ -437,7 +437,7 @@ fail:
}
-void pa_protocol_simple_free(struct pa_protocol_simple *p) {
+void pa_protocol_simple_free(pa_protocol_simple *p) {
struct connection *c;
assert(p);
diff --git a/polyp/protocol-simple.h b/polyp/protocol-simple.h
index 7b15ffcd..63455a53 100644
--- a/polyp/protocol-simple.h
+++ b/polyp/protocol-simple.h
@@ -27,9 +27,9 @@
#include "core.h"
#include "modargs.h"
-struct pa_protocol_simple;
+typedef struct pa_protocol_simple pa_protocol_simple;
-struct pa_protocol_simple* pa_protocol_simple_new(struct pa_core *core, struct pa_socket_server *server, struct pa_module *m, struct pa_modargs *ma);
-void pa_protocol_simple_free(struct pa_protocol_simple *n);
+pa_protocol_simple* pa_protocol_simple_new(pa_core *core, pa_socket_server *server, pa_module *m, pa_modargs *ma);
+void pa_protocol_simple_free(pa_protocol_simple *n);
#endif
diff --git a/polyp/pstream-util.c b/polyp/pstream-util.c
index 8526f29c..ecd63d15 100644
--- a/polyp/pstream-util.c
+++ b/polyp/pstream-util.c
@@ -28,10 +28,10 @@
#include "native-common.h"
#include "pstream-util.h"
-void pa_pstream_send_tagstruct(struct pa_pstream *p, struct pa_tagstruct *t) {
+void pa_pstream_send_tagstruct(pa_pstream *p, pa_tagstruct *t) {
size_t length;
uint8_t *data;
- struct pa_packet *packet;
+ pa_packet *packet;
assert(p);
assert(t);
@@ -43,8 +43,8 @@ void pa_pstream_send_tagstruct(struct pa_pstream *p, struct pa_tagstruct *t) {
pa_packet_unref(packet);
}
-void pa_pstream_send_error(struct pa_pstream *p, uint32_t tag, uint32_t error) {
- struct pa_tagstruct *t = pa_tagstruct_new(NULL, 0);
+void pa_pstream_send_error(pa_pstream *p, uint32_t tag, uint32_t error) {
+ pa_tagstruct *t = pa_tagstruct_new(NULL, 0);
assert(t);
pa_tagstruct_putu32(t, PA_COMMAND_ERROR);
pa_tagstruct_putu32(t, tag);
@@ -52,8 +52,8 @@ void pa_pstream_send_error(struct pa_pstream *p, uint32_t tag, uint32_t error) {
pa_pstream_send_tagstruct(p, t);
}
-void pa_pstream_send_simple_ack(struct pa_pstream *p, uint32_t tag) {
- struct pa_tagstruct *t = pa_tagstruct_new(NULL, 0);
+void pa_pstream_send_simple_ack(pa_pstream *p, uint32_t tag) {
+ pa_tagstruct *t = pa_tagstruct_new(NULL, 0);
assert(t);
pa_tagstruct_putu32(t, PA_COMMAND_REPLY);
pa_tagstruct_putu32(t, tag);
diff --git a/polyp/pstream-util.h b/polyp/pstream-util.h
index 9560bfe7..601a9e99 100644
--- a/polyp/pstream-util.h
+++ b/polyp/pstream-util.h
@@ -27,9 +27,9 @@
#include "tagstruct.h"
/* The tagstruct is freed!*/
-void pa_pstream_send_tagstruct(struct pa_pstream *p, struct pa_tagstruct *t);
+void pa_pstream_send_tagstruct(pa_pstream *p, pa_tagstruct *t);
-void pa_pstream_send_error(struct pa_pstream *p, uint32_t tag, uint32_t error);
-void pa_pstream_send_simple_ack(struct pa_pstream *p, uint32_t tag);
+void pa_pstream_send_error(pa_pstream *p, uint32_t tag, uint32_t error);
+void pa_pstream_send_simple_ack(pa_pstream *p, uint32_t tag);
#endif
diff --git a/polyp/pstream.c b/polyp/pstream.c
index 6f983289..bd00ba4f 100644
--- a/polyp/pstream.c
+++ b/polyp/pstream.c
@@ -39,12 +39,12 @@
#include "xmalloc.h"
#include "log.h"
-enum pa_pstream_descriptor_index {
+typedef enum pa_pstream_descriptor_index {
PA_PSTREAM_DESCRIPTOR_LENGTH,
PA_PSTREAM_DESCRIPTOR_CHANNEL,
PA_PSTREAM_DESCRIPTOR_DELTA,
PA_PSTREAM_DESCRIPTOR_MAX
-};
+} pa_pstream_descriptor_index;
typedef uint32_t pa_pstream_descriptor[PA_PSTREAM_DESCRIPTOR_MAX];
@@ -55,24 +55,24 @@ struct item_info {
enum { PA_PSTREAM_ITEM_PACKET, PA_PSTREAM_ITEM_MEMBLOCK } type;
/* memblock info */
- struct pa_memchunk chunk;
+ pa_memchunk chunk;
uint32_t channel;
uint32_t delta;
/* packet info */
- struct pa_packet *packet;
+ pa_packet *packet;
};
struct pa_pstream {
int ref;
- struct pa_mainloop_api *mainloop;
- struct pa_defer_event *defer_event;
- struct pa_iochannel *io;
- struct pa_queue *send_queue;
+ pa_mainloop_api *mainloop;
+ pa_defer_event *defer_event;
+ pa_iochannel *io;
+ pa_queue *send_queue;
int dead;
- void (*die_callback) (struct pa_pstream *p, void *userdata);
+ void (*die_callback) (pa_pstream *p, void *userdata);
void *die_callback_userdata;
struct {
@@ -83,29 +83,29 @@ struct pa_pstream {
} write;
struct {
- struct pa_memblock *memblock;
- struct pa_packet *packet;
+ pa_memblock *memblock;
+ pa_packet *packet;
pa_pstream_descriptor descriptor;
void *data;
size_t index;
} read;
- void (*recieve_packet_callback) (struct pa_pstream *p, struct pa_packet *packet, void *userdata);
+ void (*recieve_packet_callback) (pa_pstream *p, pa_packet *packet, void *userdata);
void *recieve_packet_callback_userdata;
- void (*recieve_memblock_callback) (struct pa_pstream *p, uint32_t channel, uint32_t delta, const struct pa_memchunk *chunk, void *userdata);
+ void (*recieve_memblock_callback) (pa_pstream *p, uint32_t channel, uint32_t delta, const pa_memchunk *chunk, void *userdata);
void *recieve_memblock_callback_userdata;
- void (*drain_callback)(struct pa_pstream *p, void *userdata);
+ void (*drain_callback)(pa_pstream *p, void *userdata);
void *drain_userdata;
- struct pa_memblock_stat *memblock_stat;
+ pa_memblock_stat *memblock_stat;
};
-static void do_write(struct pa_pstream *p);
-static void do_read(struct pa_pstream *p);
+static void do_write(pa_pstream *p);
+static void do_read(pa_pstream *p);
-static void do_something(struct pa_pstream *p) {
+static void do_something(pa_pstream *p) {
assert(p);
p->mainloop->defer_enable(p->defer_event, 0);
@@ -127,23 +127,23 @@ static void do_something(struct pa_pstream *p) {
pa_pstream_unref(p);
}
-static void io_callback(struct pa_iochannel*io, void *userdata) {
- struct pa_pstream *p = userdata;
+static void io_callback(pa_iochannel*io, void *userdata) {
+ pa_pstream *p = userdata;
assert(p && p->io == io);
do_something(p);
}
-static void defer_callback(struct pa_mainloop_api *m, struct pa_defer_event *e, void*userdata) {
- struct pa_pstream *p = userdata;
+static void defer_callback(pa_mainloop_api *m, pa_defer_event *e, void*userdata) {
+ pa_pstream *p = userdata;
assert(p && p->defer_event == e && p->mainloop == m);
do_something(p);
}
-struct pa_pstream *pa_pstream_new(struct pa_mainloop_api *m, struct pa_iochannel *io, struct pa_memblock_stat *s) {
- struct pa_pstream *p;
+pa_pstream *pa_pstream_new(pa_mainloop_api *m, pa_iochannel *io, pa_memblock_stat *s) {
+ pa_pstream *p;
assert(io);
- p = pa_xmalloc(sizeof(struct pa_pstream));
+ p = pa_xmalloc(sizeof(pa_pstream));
p->ref = 1;
p->io = io;
pa_iochannel_set_callback(io, io_callback, p);
@@ -183,7 +183,7 @@ struct pa_pstream *pa_pstream_new(struct pa_mainloop_api *m, struct pa_iochannel
return p;
}
-static void item_free(void *item, void *p) {
+static void item_free(void *item, PA_GCC_UNUSED void *p) {
struct item_info *i = item;
assert(i);
@@ -199,7 +199,7 @@ static void item_free(void *item, void *p) {
pa_xfree(i);
}
-static void pstream_free(struct pa_pstream *p) {
+static void pstream_free(pa_pstream *p) {
assert(p);
pa_pstream_close(p);
@@ -218,7 +218,7 @@ static void pstream_free(struct pa_pstream *p) {
pa_xfree(p);
}
-void pa_pstream_send_packet(struct pa_pstream*p, struct pa_packet *packet) {
+void pa_pstream_send_packet(pa_pstream*p, pa_packet *packet) {
struct item_info *i;
assert(p && packet && p->ref >= 1);
@@ -235,7 +235,7 @@ void pa_pstream_send_packet(struct pa_pstream*p, struct pa_packet *packet) {
p->mainloop->defer_enable(p->defer_event, 1);
}
-void pa_pstream_send_memblock(struct pa_pstream*p, uint32_t channel, uint32_t delta, const struct pa_memchunk *chunk) {
+void pa_pstream_send_memblock(pa_pstream*p, uint32_t channel, uint32_t delta, const pa_memchunk *chunk) {
struct item_info *i;
assert(p && channel != (uint32_t) -1 && chunk && p->ref >= 1);
@@ -256,21 +256,21 @@ void pa_pstream_send_memblock(struct pa_pstream*p, uint32_t channel, uint32_t de
p->mainloop->defer_enable(p->defer_event, 1);
}
-void pa_pstream_set_recieve_packet_callback(struct pa_pstream *p, void (*callback) (struct pa_pstream *p, struct pa_packet *packet, void *userdata), void *userdata) {
+void pa_pstream_set_recieve_packet_callback(pa_pstream *p, void (*callback) (pa_pstream *p, pa_packet *packet, void *userdata), void *userdata) {
assert(p && callback);
p->recieve_packet_callback = callback;
p->recieve_packet_callback_userdata = userdata;
}
-void pa_pstream_set_recieve_memblock_callback(struct pa_pstream *p, void (*callback) (struct pa_pstream *p, uint32_t channel, uint32_t delta, const struct pa_memchunk *chunk, void *userdata), void *userdata) {
+void pa_pstream_set_recieve_memblock_callback(pa_pstream *p, void (*callback) (pa_pstream *p, uint32_t channel, uint32_t delta, const pa_memchunk *chunk, void *userdata), void *userdata) {
assert(p && callback);
p->recieve_memblock_callback = callback;
p->recieve_memblock_callback_userdata = userdata;
}
-static void prepare_next_write_item(struct pa_pstream *p) {
+static void prepare_next_write_item(pa_pstream *p) {
assert(p);
if (!(p->write.current = pa_queue_pop(p->send_queue)))
@@ -295,7 +295,7 @@ static void prepare_next_write_item(struct pa_pstream *p) {
}
}
-static void do_write(struct pa_pstream *p) {
+static void do_write(pa_pstream *p) {
void *d;
size_t l;
ssize_t r;
@@ -339,9 +339,9 @@ die:
p->die_callback(p, p->die_callback_userdata);
}
-static void do_read(struct pa_pstream *p) {
+static void do_read(pa_pstream *p) {
void *d;
- size_t l;
+ size_t l;
ssize_t r;
assert(p);
@@ -386,12 +386,10 @@ static void do_read(struct pa_pstream *p) {
/* Frame payload available */
if (p->read.memblock && p->recieve_memblock_callback) { /* Is this memblock data? Than pass it to the user */
- size_t l;
-
l = (p->read.index - r) < PA_PSTREAM_DESCRIPTOR_SIZE ? p->read.index - PA_PSTREAM_DESCRIPTOR_SIZE : (size_t) r;
if (l > 0) {
- struct pa_memchunk chunk;
+ pa_memchunk chunk;
chunk.memblock = p->read.memblock;
chunk.index = p->read.index - PA_PSTREAM_DESCRIPTOR_SIZE - l;
@@ -437,13 +435,13 @@ die:
}
-void pa_pstream_set_die_callback(struct pa_pstream *p, void (*callback)(struct pa_pstream *p, void *userdata), void *userdata) {
+void pa_pstream_set_die_callback(pa_pstream *p, void (*callback)(pa_pstream *p, void *userdata), void *userdata) {
assert(p && callback);
p->die_callback = callback;
p->die_callback_userdata = userdata;
}
-int pa_pstream_is_pending(struct pa_pstream *p) {
+int pa_pstream_is_pending(pa_pstream *p) {
assert(p);
if (p->dead)
@@ -452,27 +450,27 @@ int pa_pstream_is_pending(struct pa_pstream *p) {
return p->write.current || !pa_queue_is_empty(p->send_queue);
}
-void pa_pstream_set_drain_callback(struct pa_pstream *p, void (*cb)(struct pa_pstream *p, void *userdata), void *userdata) {
+void pa_pstream_set_drain_callback(pa_pstream *p, void (*cb)(pa_pstream *p, void *userdata), void *userdata) {
assert(p);
p->drain_callback = cb;
p->drain_userdata = userdata;
}
-void pa_pstream_unref(struct pa_pstream*p) {
+void pa_pstream_unref(pa_pstream*p) {
assert(p && p->ref >= 1);
if (!(--(p->ref)))
pstream_free(p);
}
-struct pa_pstream* pa_pstream_ref(struct pa_pstream*p) {
+pa_pstream* pa_pstream_ref(pa_pstream*p) {
assert(p && p->ref >= 1);
p->ref++;
return p;
}
-void pa_pstream_close(struct pa_pstream *p) {
+void pa_pstream_close(pa_pstream *p) {
assert(p);
p->dead = 1;
diff --git a/polyp/pstream.h b/polyp/pstream.h
index 8fa62f06..77c92802 100644
--- a/polyp/pstream.h
+++ b/polyp/pstream.h
@@ -30,23 +30,23 @@
#include "mainloop-api.h"
#include "memchunk.h"
-struct pa_pstream;
+typedef struct pa_pstream pa_pstream;
-struct pa_pstream* pa_pstream_new(struct pa_mainloop_api *m, struct pa_iochannel *io, struct pa_memblock_stat *s);
-void pa_pstream_unref(struct pa_pstream*p);
-struct pa_pstream* pa_pstream_ref(struct pa_pstream*p);
+pa_pstream* pa_pstream_new(pa_mainloop_api *m, pa_iochannel *io, pa_memblock_stat *s);
+void pa_pstream_unref(pa_pstream*p);
+pa_pstream* pa_pstream_ref(pa_pstream*p);
-void pa_pstream_send_packet(struct pa_pstream*p, struct pa_packet *packet);
-void pa_pstream_send_memblock(struct pa_pstream*p, uint32_t channel, uint32_t delta, const struct pa_memchunk *chunk);
+void pa_pstream_send_packet(pa_pstream*p, pa_packet *packet);
+void pa_pstream_send_memblock(pa_pstream*p, uint32_t channel, uint32_t delta, const pa_memchunk *chunk);
-void pa_pstream_set_recieve_packet_callback(struct pa_pstream *p, void (*callback) (struct pa_pstream *p, struct pa_packet *packet, void *userdata), void *userdata);
-void pa_pstream_set_recieve_memblock_callback(struct pa_pstream *p, void (*callback) (struct pa_pstream *p, uint32_t channel, uint32_t delta, const struct pa_memchunk *chunk, void *userdata), void *userdata);
-void pa_pstream_set_drain_callback(struct pa_pstream *p, void (*cb)(struct pa_pstream *p, void *userdata), void *userdata);
+void pa_pstream_set_recieve_packet_callback(pa_pstream *p, void (*callback) (pa_pstream *p, pa_packet *packet, void *userdata), void *userdata);
+void pa_pstream_set_recieve_memblock_callback(pa_pstream *p, void (*callback) (pa_pstream *p, uint32_t channel, uint32_t delta, const pa_memchunk *chunk, void *userdata), void *userdata);
+void pa_pstream_set_drain_callback(pa_pstream *p, void (*cb)(pa_pstream *p, void *userdata), void *userdata);
-void pa_pstream_set_die_callback(struct pa_pstream *p, void (*callback)(struct pa_pstream *p, void *userdata), void *userdata);
+void pa_pstream_set_die_callback(pa_pstream *p, void (*callback)(pa_pstream *p, void *userdata), void *userdata);
-int pa_pstream_is_pending(struct pa_pstream *p);
+int pa_pstream_is_pending(pa_pstream *p);
-void pa_pstream_close(struct pa_pstream *p);
+void pa_pstream_close(pa_pstream *p);
#endif
diff --git a/polyp/queue.c b/polyp/queue.c
index e0a06ae1..80ec0068 100644
--- a/polyp/queue.c
+++ b/polyp/queue.c
@@ -39,14 +39,14 @@ struct pa_queue {
unsigned length;
};
-struct pa_queue* pa_queue_new(void) {
- struct pa_queue *q = pa_xmalloc(sizeof(struct pa_queue));
+pa_queue* pa_queue_new(void) {
+ pa_queue *q = pa_xnew(pa_queue, 1);
q->front = q->back = NULL;
q->length = 0;
return q;
}
-void pa_queue_free(struct pa_queue* q, void (*destroy)(void *p, void *userdata), void *userdata) {
+void pa_queue_free(pa_queue* q, void (*destroy)(void *p, void *userdata), void *userdata) {
struct queue_entry *e;
assert(q);
@@ -64,10 +64,10 @@ void pa_queue_free(struct pa_queue* q, void (*destroy)(void *p, void *userdata),
pa_xfree(q);
}
-void pa_queue_push(struct pa_queue *q, void *p) {
+void pa_queue_push(pa_queue *q, void *p) {
struct queue_entry *e;
- e = pa_xmalloc(sizeof(struct queue_entry));
+ e = pa_xnew(struct queue_entry, 1);
e->data = p;
e->next = NULL;
@@ -82,7 +82,7 @@ void pa_queue_push(struct pa_queue *q, void *p) {
q->length++;
}
-void* pa_queue_pop(struct pa_queue *q) {
+void* pa_queue_pop(pa_queue *q) {
void *p;
struct queue_entry *e;
assert(q);
@@ -102,7 +102,7 @@ void* pa_queue_pop(struct pa_queue *q) {
return p;
}
-int pa_queue_is_empty(struct pa_queue *q) {
+int pa_queue_is_empty(pa_queue *q) {
assert(q);
return q->length == 0;
}
diff --git a/polyp/queue.h b/polyp/queue.h
index a739ab74..3edcfb63 100644
--- a/polyp/queue.h
+++ b/polyp/queue.h
@@ -22,19 +22,19 @@
USA.
***/
-struct pa_queue;
+typedef struct pa_queue pa_queue;
/* A simple implementation of the abstract data type queue. Stores
* pointers as members. The memory has to be managed by the caller. */
-struct pa_queue* pa_queue_new(void);
+pa_queue* pa_queue_new(void);
/* Free the queue and run the specified callback function for every remaining entry. The callback function may be NULL. */
-void pa_queue_free(struct pa_queue* q, void (*destroy)(void *p, void *userdata), void *userdata);
+void pa_queue_free(pa_queue* q, void (*destroy)(void *p, void *userdata), void *userdata);
-void pa_queue_push(struct pa_queue *q, void *p);
-void* pa_queue_pop(struct pa_queue *q);
+void pa_queue_push(pa_queue *q, void *p);
+void* pa_queue_pop(pa_queue *q);
-int pa_queue_is_empty(struct pa_queue *q);
+int pa_queue_is_empty(pa_queue *q);
#endif
diff --git a/polyp/resampler.c b/polyp/resampler.c
index 28e49209..96a1678f 100644
--- a/polyp/resampler.c
+++ b/polyp/resampler.c
@@ -34,16 +34,16 @@
#include "log.h"
struct pa_resampler {
- struct pa_sample_spec i_ss, o_ss;
+ pa_sample_spec i_ss, o_ss;
size_t i_fz, o_fz;
- struct pa_memblock_stat *memblock_stat;
+ pa_memblock_stat *memblock_stat;
void *impl_data;
int channels;
- enum pa_resample_method resample_method;
+ pa_resample_method resample_method;
- void (*impl_free)(struct pa_resampler *r);
- void (*impl_set_input_rate)(struct pa_resampler *r, uint32_t rate);
- void (*impl_run)(struct pa_resampler *r, const struct pa_memchunk *in, struct pa_memchunk *out);
+ void (*impl_free)(pa_resampler *r);
+ void (*impl_set_input_rate)(pa_resampler *r, uint32_t rate);
+ void (*impl_run)(pa_resampler *r, const pa_memchunk *in, pa_memchunk *out);
};
struct impl_libsamplerate {
@@ -59,17 +59,17 @@ struct impl_trivial {
unsigned i_counter;
};
-static int libsamplerate_init(struct pa_resampler*r);
-static int trivial_init(struct pa_resampler*r);
+static int libsamplerate_init(pa_resampler*r);
+static int trivial_init(pa_resampler*r);
-struct pa_resampler* pa_resampler_new(const struct pa_sample_spec *a, const struct pa_sample_spec *b, struct pa_memblock_stat *s, enum pa_resample_method resample_method) {
- struct pa_resampler *r = NULL;
+pa_resampler* pa_resampler_new(const pa_sample_spec *a, const pa_sample_spec *b, pa_memblock_stat *s, pa_resample_method resample_method) {
+ pa_resampler *r = NULL;
assert(a && b && pa_sample_spec_valid(a) && pa_sample_spec_valid(b) && resample_method != PA_RESAMPLER_INVALID);
if (a->channels != b->channels && a->channels != 1 && b->channels != 1)
goto fail;
- r = pa_xmalloc(sizeof(struct pa_resampler));
+ r = pa_xmalloc(sizeof(pa_resampler));
r->impl_data = NULL;
r->memblock_stat = s;
r->resample_method = resample_method;
@@ -113,7 +113,7 @@ fail:
return NULL;
}
-void pa_resampler_free(struct pa_resampler *r) {
+void pa_resampler_free(pa_resampler *r) {
assert(r);
if (r->impl_free)
@@ -122,7 +122,7 @@ void pa_resampler_free(struct pa_resampler *r) {
pa_xfree(r);
}
-void pa_resampler_set_input_rate(struct pa_resampler *r, uint32_t rate) {
+void pa_resampler_set_input_rate(pa_resampler *r, uint32_t rate) {
assert(r && rate);
r->i_ss.rate = rate;
@@ -130,24 +130,24 @@ void pa_resampler_set_input_rate(struct pa_resampler *r, uint32_t rate) {
r->impl_set_input_rate(r, rate);
}
-void pa_resampler_run(struct pa_resampler *r, const struct pa_memchunk *in, struct pa_memchunk *out) {
+void pa_resampler_run(pa_resampler *r, const pa_memchunk *in, pa_memchunk *out) {
assert(r && in && out && r->impl_run);
r->impl_run(r, in, out);
}
-size_t pa_resampler_request(struct pa_resampler *r, size_t out_length) {
+size_t pa_resampler_request(pa_resampler *r, size_t out_length) {
assert(r && (out_length % r->o_fz) == 0);
return (((out_length / r->o_fz)*r->i_ss.rate)/r->o_ss.rate) * r->i_fz;
}
-enum pa_resample_method pa_resampler_get_method(struct pa_resampler *r) {
+pa_resample_method pa_resampler_get_method(pa_resampler *r) {
assert(r);
return r->resample_method;
}
/* Parse a libsamplrate compatible resampling implementation */
-enum pa_resample_method pa_parse_resample_method(const char *string) {
+pa_resample_method pa_parse_resample_method(const char *string) {
assert(string);
if (!strcmp(string, "src-sinc-best-quality"))
@@ -168,7 +168,7 @@ enum pa_resample_method pa_parse_resample_method(const char *string) {
/*** libsamplerate based implementation ***/
-static void libsamplerate_free(struct pa_resampler *r) {
+static void libsamplerate_free(pa_resampler *r) {
struct impl_libsamplerate *i;
assert(r && r->impl_data);
i = r->impl_data;
@@ -181,7 +181,7 @@ static void libsamplerate_free(struct pa_resampler *r) {
pa_xfree(i);
}
-static void libsamplerate_run(struct pa_resampler *r, const struct pa_memchunk *in, struct pa_memchunk *out) {
+static void libsamplerate_run(pa_resampler *r, const pa_memchunk *in, pa_memchunk *out) {
unsigned i_nchannels, o_nchannels, ins, ons, eff_ins, eff_ons;
float *cbuf;
struct impl_libsamplerate *i;
@@ -267,7 +267,7 @@ static void libsamplerate_run(struct pa_resampler *r, const struct pa_memchunk *
}
}
-static void libsamplerate_set_input_rate(struct pa_resampler *r, uint32_t rate) {
+static void libsamplerate_set_input_rate(pa_resampler *r, uint32_t rate) {
int ret;
struct impl_libsamplerate *i;
assert(r && rate > 0 && r->impl_data);
@@ -277,7 +277,7 @@ static void libsamplerate_set_input_rate(struct pa_resampler *r, uint32_t rate)
assert(ret == 0);
}
-static int libsamplerate_init(struct pa_resampler *r) {
+static int libsamplerate_init(pa_resampler *r) {
struct impl_libsamplerate *i = NULL;
int err;
@@ -308,7 +308,7 @@ fail:
/* Trivial implementation */
-static void trivial_run(struct pa_resampler *r, const struct pa_memchunk *in, struct pa_memchunk *out) {
+static void trivial_run(pa_resampler *r, const pa_memchunk *in, pa_memchunk *out) {
size_t fz;
unsigned nframes;
struct impl_trivial *i;
@@ -367,12 +367,12 @@ static void trivial_run(struct pa_resampler *r, const struct pa_memchunk *in, st
}
}
-static void trivial_free(struct pa_resampler *r) {
+static void trivial_free(pa_resampler *r) {
assert(r);
pa_xfree(r->impl_data);
}
-static void trivial_set_input_rate(struct pa_resampler *r, uint32_t rate) {
+static void trivial_set_input_rate(pa_resampler *r, uint32_t rate) {
struct impl_trivial *i;
assert(r && rate > 0 && r->impl_data);
i = r->impl_data;
@@ -381,7 +381,7 @@ static void trivial_set_input_rate(struct pa_resampler *r, uint32_t rate) {
i->o_counter = 0;
}
-static int trivial_init(struct pa_resampler*r) {
+static int trivial_init(pa_resampler*r) {
struct impl_trivial *i;
assert(r && r->i_ss.format == r->o_ss.format && r->i_ss.channels == r->o_ss.channels);
@@ -395,7 +395,7 @@ static int trivial_init(struct pa_resampler*r) {
return 0;
}
-const char *pa_resample_method_to_string(enum pa_resample_method m) {
+const char *pa_resample_method_to_string(pa_resample_method m) {
static const char * const resample_methods[] = {
"src-sinc-best-quality",
"src-sinc-medium-quality",
diff --git a/polyp/resampler.h b/polyp/resampler.h
index 0109e790..358c872a 100644
--- a/polyp/resampler.h
+++ b/polyp/resampler.h
@@ -28,9 +28,9 @@
#include "memblock.h"
#include "memchunk.h"
-struct pa_resampler;
+typedef struct pa_resampler pa_resampler;
-enum pa_resample_method {
+typedef enum pa_resample_method {
PA_RESAMPLER_INVALID = -1,
PA_RESAMPLER_SRC_SINC_BEST_QUALITY = SRC_SINC_BEST_QUALITY,
PA_RESAMPLER_SRC_SINC_MEDIUM_QUALITY = SRC_SINC_MEDIUM_QUALITY,
@@ -39,27 +39,27 @@ enum pa_resample_method {
PA_RESAMPLER_SRC_LINEAR = SRC_LINEAR,
PA_RESAMPLER_TRIVIAL,
PA_RESAMPLER_MAX
-};
+} pa_resample_method;
-struct pa_resampler* pa_resampler_new(const struct pa_sample_spec *a, const struct pa_sample_spec *b, struct pa_memblock_stat *s, int resample_method);
-void pa_resampler_free(struct pa_resampler *r);
+pa_resampler* pa_resampler_new(const pa_sample_spec *a, const pa_sample_spec *b, pa_memblock_stat *s, int resample_method);
+void pa_resampler_free(pa_resampler *r);
/* Returns the size of an input memory block which is required to return the specified amount of output data */
-size_t pa_resampler_request(struct pa_resampler *r, size_t out_length);
+size_t pa_resampler_request(pa_resampler *r, size_t out_length);
/* Pass the specified memory chunk to the resampler and return the newly resampled data */
-void pa_resampler_run(struct pa_resampler *r, const struct pa_memchunk *in, struct pa_memchunk *out);
+void pa_resampler_run(pa_resampler *r, const pa_memchunk *in, pa_memchunk *out);
/* Change the input rate of the resampler object */
-void pa_resampler_set_input_rate(struct pa_resampler *r, uint32_t rate);
+void pa_resampler_set_input_rate(pa_resampler *r, uint32_t rate);
/* Return the resampling method of the resampler object */
-enum pa_resample_method pa_resampler_get_method(struct pa_resampler *r);
+pa_resample_method pa_resampler_get_method(pa_resampler *r);
/* Try to parse the resampler method */
-enum pa_resample_method pa_parse_resample_method(const char *string);
+pa_resample_method pa_parse_resample_method(const char *string);
/* return a human readable string for the specified resampling method. Inverse of pa_parse_resample_method() */
-const char *pa_resample_method_to_string(enum pa_resample_method m);
+const char *pa_resample_method_to_string(pa_resample_method m);
#endif
diff --git a/polyp/sample-util.c b/polyp/sample-util.c
index bf8be34e..cb5dd1c3 100644
--- a/polyp/sample-util.c
+++ b/polyp/sample-util.c
@@ -30,18 +30,18 @@
#include "sample-util.h"
-struct pa_memblock *pa_silence_memblock(struct pa_memblock* b, const struct pa_sample_spec *spec) {
+pa_memblock *pa_silence_memblock(pa_memblock* b, const pa_sample_spec *spec) {
assert(b && b->data && spec);
pa_silence_memory(b->data, b->length, spec);
return b;
}
-void pa_silence_memchunk(struct pa_memchunk *c, const struct pa_sample_spec *spec) {
+void pa_silence_memchunk(pa_memchunk *c, const pa_sample_spec *spec) {
assert(c && c->memblock && c->memblock->data && spec && c->length);
pa_silence_memory((uint8_t*) c->memblock->data+c->index, c->length, spec);
}
-void pa_silence_memory(void *p, size_t length, const struct pa_sample_spec *spec) {
+void pa_silence_memory(void *p, size_t length, const pa_sample_spec *spec) {
uint8_t c = 0;
assert(p && length && spec);
@@ -65,7 +65,7 @@ void pa_silence_memory(void *p, size_t length, const struct pa_sample_spec *spec
memset(p, c, length);
}
-size_t pa_mix(struct pa_mix_info channels[], unsigned nchannels, void *data, size_t length, const struct pa_sample_spec *spec, pa_volume_t volume) {
+size_t pa_mix(pa_mix_info channels[], unsigned nchannels, void *data, size_t length, const pa_sample_spec *spec, pa_volume_t volume) {
assert(channels && data && length && spec);
if (spec->format == PA_SAMPLE_S16NE) {
@@ -161,7 +161,7 @@ size_t pa_mix(struct pa_mix_info channels[], unsigned nchannels, void *data, siz
size_t d;
for (d = 0;; d += sizeof(float)) {
- pa_volume_t sum = 0;
+ float sum = 0;
unsigned c;
if (d >= length)
@@ -203,7 +203,7 @@ size_t pa_mix(struct pa_mix_info channels[], unsigned nchannels, void *data, siz
}
-void pa_volume_memchunk(struct pa_memchunk*c, const struct pa_sample_spec *spec, pa_volume_t volume) {
+void pa_volume_memchunk(pa_memchunk*c, const pa_sample_spec *spec, pa_volume_t volume) {
assert(c && spec && (c->length % pa_frame_size(spec) == 0));
if (volume == PA_VOLUME_NORM)
diff --git a/polyp/sample-util.h b/polyp/sample-util.h
index aafdda63..eaebe91d 100644
--- a/polyp/sample-util.h
+++ b/polyp/sample-util.h
@@ -27,18 +27,18 @@
#include "memchunk.h"
-struct pa_memblock *pa_silence_memblock(struct pa_memblock* b, const struct pa_sample_spec *spec);
-void pa_silence_memchunk(struct pa_memchunk *c, const struct pa_sample_spec *spec);
-void pa_silence_memory(void *p, size_t length, const struct pa_sample_spec *spec);
+pa_memblock *pa_silence_memblock(pa_memblock* b, const pa_sample_spec *spec);
+void pa_silence_memchunk(pa_memchunk *c, const pa_sample_spec *spec);
+void pa_silence_memory(void *p, size_t length, const pa_sample_spec *spec);
-struct pa_mix_info {
- struct pa_memchunk chunk;
+typedef struct pa_mix_info {
+ pa_memchunk chunk;
pa_volume_t volume;
void *userdata;
-};
+} pa_mix_info ;
-size_t pa_mix(struct pa_mix_info channels[], unsigned nchannels, void *data, size_t length, const struct pa_sample_spec *spec, pa_volume_t volume);
+size_t pa_mix(pa_mix_info channels[], unsigned nchannels, void *data, size_t length, const pa_sample_spec *spec, pa_volume_t volume);
-void pa_volume_memchunk(struct pa_memchunk*c, const struct pa_sample_spec *spec, pa_volume_t volume);
+void pa_volume_memchunk(pa_memchunk*c, const pa_sample_spec *spec, pa_volume_t volume);
#endif
diff --git a/polyp/sample.c b/polyp/sample.c
index f9d0c458..37ab96a0 100644
--- a/polyp/sample.c
+++ b/polyp/sample.c
@@ -30,7 +30,7 @@
#include "sample.h"
-size_t pa_frame_size(const struct pa_sample_spec *spec) {
+size_t pa_frame_size(const pa_sample_spec *spec) {
size_t b = 1;
assert(spec);
@@ -55,18 +55,18 @@ size_t pa_frame_size(const struct pa_sample_spec *spec) {
return b * spec->channels;
}
-size_t pa_bytes_per_second(const struct pa_sample_spec *spec) {
+size_t pa_bytes_per_second(const pa_sample_spec *spec) {
assert(spec);
return spec->rate*pa_frame_size(spec);
}
-pa_usec_t pa_bytes_to_usec(uint64_t length, const struct pa_sample_spec *spec) {
+pa_usec_t pa_bytes_to_usec(uint64_t length, const pa_sample_spec *spec) {
assert(spec);
return (pa_usec_t) (((double) length/pa_frame_size(spec)*1000000)/spec->rate);
}
-int pa_sample_spec_valid(const struct pa_sample_spec *spec) {
+int pa_sample_spec_valid(const pa_sample_spec *spec) {
assert(spec);
if (spec->rate <= 0 || spec->channels <= 0)
@@ -78,13 +78,13 @@ int pa_sample_spec_valid(const struct pa_sample_spec *spec) {
return 1;
}
-int pa_sample_spec_equal(const struct pa_sample_spec*a, const struct pa_sample_spec*b) {
+int pa_sample_spec_equal(const pa_sample_spec*a, const pa_sample_spec*b) {
assert(a && b);
return (a->format == b->format) && (a->rate == b->rate) && (a->channels == b->channels);
}
-const char *pa_sample_format_to_string(enum pa_sample_format f) {
+const char *pa_sample_format_to_string(pa_sample_format f) {
static const char* const table[]= {
[PA_SAMPLE_U8] = "U8",
[PA_SAMPLE_ALAW] = "ALAW",
@@ -101,7 +101,7 @@ const char *pa_sample_format_to_string(enum pa_sample_format f) {
return table[f];
}
-char *pa_sample_spec_snprint(char *s, size_t l, const struct pa_sample_spec *spec) {
+char *pa_sample_spec_snprint(char *s, size_t l, const pa_sample_spec *spec) {
assert(s && l && spec);
if (!pa_sample_spec_valid(spec))
@@ -161,7 +161,7 @@ void pa_bytes_snprint(char *s, size_t l, unsigned v) {
snprintf(s, l, "%u B", (unsigned) v);
}
-enum pa_sample_format pa_parse_sample_format(const char *format) {
+pa_sample_format pa_parse_sample_format(const char *format) {
if (strcasecmp(format, "s16le") == 0)
return PA_SAMPLE_S16LE;
diff --git a/polyp/sample.h b/polyp/sample.h
index 82c14615..739cb337 100644
--- a/polyp/sample.h
+++ b/polyp/sample.h
@@ -34,7 +34,7 @@
PA_C_DECL_BEGIN
/** Sample format */
-enum pa_sample_format {
+typedef enum pa_sample_format {
PA_SAMPLE_U8, /**< Unsigned 8 Bit PCM */
PA_SAMPLE_ALAW, /**< 8 Bit a-Law */
PA_SAMPLE_ULAW, /**< 8 Bit mu-Law */
@@ -44,7 +44,7 @@ enum pa_sample_format {
PA_SAMPLE_FLOAT32BE, /**< 32 Bit IEEE floating point, big endian, range -1..1 */
PA_SAMPLE_MAX, /**< Upper limit of valid sample types */
PA_SAMPLE_INVALID = -1 /**< An invalid value */
-};
+} pa_sample_format;
#ifdef WORDS_BIGENDIAN
/** Signed 16 Bit PCM, native endian */
@@ -70,38 +70,38 @@ enum pa_sample_format {
#define PA_SAMPLE_FLOAT32 PA_SAMPLE_FLOAT32NE
/** A sample format and attribute specification */
-struct pa_sample_spec {
- enum pa_sample_format format; /**< The sample format */
+typedef struct pa_sample_spec {
+ pa_sample_format format; /**< The sample format */
uint32_t rate; /**< The sample rate. (e.g. 44100) */
uint8_t channels; /**< Audio channels. (1 for mono, 2 for stereo, ...) */
-};
+} pa_sample_spec;
/** Type for usec specifications (unsigned). May be either 32 or 64 bit, depending on the architecture */
typedef uint64_t pa_usec_t;
/** Return the amount of bytes playback of a second of audio with the specified sample type takes */
-size_t pa_bytes_per_second(const struct pa_sample_spec *spec);
+size_t pa_bytes_per_second(const pa_sample_spec *spec);
/** Return the size of a frame with the specific sample type */
-size_t pa_frame_size(const struct pa_sample_spec *spec);
+size_t pa_frame_size(const pa_sample_spec *spec);
/** Calculate the time the specified bytes take to play with the specified sample type */
-pa_usec_t pa_bytes_to_usec(uint64_t length, const struct pa_sample_spec *spec);
+pa_usec_t pa_bytes_to_usec(uint64_t length, const pa_sample_spec *spec);
/** Return non-zero when the sample type specification is valid */
-int pa_sample_spec_valid(const struct pa_sample_spec *spec);
+int pa_sample_spec_valid(const pa_sample_spec *spec);
/** Return non-zero when the two sample type specifications match */
-int pa_sample_spec_equal(const struct pa_sample_spec*a, const struct pa_sample_spec*b);
+int pa_sample_spec_equal(const pa_sample_spec*a, const pa_sample_spec*b);
/* Return a descriptive string for the specified sample format. \since 0.8 */
-const char *pa_sample_format_to_string(enum pa_sample_format f);
+const char *pa_sample_format_to_string(pa_sample_format f);
/** Maximum required string length for pa_sample_spec_snprint() */
#define PA_SAMPLE_SPEC_SNPRINT_MAX 32
/** Pretty print a sample type specification to a string */
-char* pa_sample_spec_snprint(char *s, size_t l, const struct pa_sample_spec *spec);
+char* pa_sample_spec_snprint(char *s, size_t l, const pa_sample_spec *spec);
/** Volume specification: 0: silence; < 256: diminished volume; 256: normal volume; > 256 amplified volume */
typedef uint32_t pa_volume_t;
@@ -138,7 +138,7 @@ pa_volume_t pa_volume_from_user(double v);
void pa_bytes_snprint(char *s, size_t l, unsigned v);
/** Parse a sample format text. Inverse of pa_sample_format_to_string() */
-enum pa_sample_format pa_parse_sample_format(const char *format);
+pa_sample_format pa_parse_sample_format(const char *format);
PA_C_DECL_END
diff --git a/polyp/scache.c b/polyp/scache.c
index 2953145d..32c89a99 100644
--- a/polyp/scache.c
+++ b/polyp/scache.c
@@ -55,8 +55,8 @@
#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->scache_auto_unload_event == e);
@@ -67,7 +67,7 @@ static void timeout_callback(struct pa_mainloop_api *m, struct pa_time_event*e,
m->time_restart(e, &ntv);
}
-static void free_entry(struct pa_scache_entry *e) {
+static void free_entry(pa_scache_entry *e) {
assert(e);
pa_namereg_unregister(e->core, e->name);
pa_subscription_post(e->core, PA_SUBSCRIPTION_EVENT_SAMPLE_CACHE|PA_SUBSCRIPTION_EVENT_REMOVE, e->index);
@@ -78,8 +78,8 @@ static void free_entry(struct pa_scache_entry *e) {
pa_xfree(e);
}
-static struct pa_scache_entry* scache_add_item(struct pa_core *c, const char *name) {
- struct pa_scache_entry *e;
+static pa_scache_entry* scache_add_item(pa_core *c, const char *name) {
+ pa_scache_entry *e;
assert(c && name);
if ((e = pa_namereg_get(c, name, PA_NAMEREG_SAMPLE, 0))) {
@@ -92,7 +92,7 @@ static struct pa_scache_entry* scache_add_item(struct pa_core *c, const char *na
pa_subscription_post(c, PA_SUBSCRIPTION_EVENT_SAMPLE_CACHE|PA_SUBSCRIPTION_EVENT_CHANGE, e->index);
} else {
- e = pa_xmalloc(sizeof(struct pa_scache_entry));
+ e = pa_xmalloc(sizeof(pa_scache_entry));
if (!pa_namereg_register(c, name, PA_NAMEREG_SAMPLE, e, 1)) {
pa_xfree(e);
@@ -120,13 +120,13 @@ static struct pa_scache_entry* scache_add_item(struct pa_core *c, const char *na
e->lazy = 0;
e->last_used_time = 0;
- memset(&e->sample_spec, 0, sizeof(struct pa_sample_spec));
+ memset(&e->sample_spec, 0, sizeof(pa_sample_spec));
return e;
}
-int pa_scache_add_item(struct pa_core *c, const char *name, struct pa_sample_spec *ss, struct pa_memchunk *chunk, uint32_t *index) {
- struct pa_scache_entry *e;
+int pa_scache_add_item(pa_core *c, const char *name, pa_sample_spec *ss, pa_memchunk *chunk, uint32_t *idx) {
+ pa_scache_entry *e;
assert(c && name);
if (!(e = scache_add_item(c, name)))
@@ -140,15 +140,15 @@ int pa_scache_add_item(struct pa_core *c, const char *name, struct pa_sample_spe
pa_memblock_ref(e->memchunk.memblock);
}
- if (index)
- *index = e->index;
+ if (idx)
+ *idx = e->index;
return 0;
}
-int pa_scache_add_file(struct pa_core *c, const char *name, const char *filename, uint32_t *index) {
- struct pa_sample_spec ss;
- struct pa_memchunk chunk;
+int pa_scache_add_file(pa_core *c, const char *name, const char *filename, uint32_t *idx) {
+ pa_sample_spec ss;
+ pa_memchunk chunk;
int r;
#ifdef OS_IS_WIN32
@@ -161,14 +161,14 @@ int pa_scache_add_file(struct pa_core *c, const char *name, const char *filename
if (pa_sound_file_load(filename, &ss, &chunk, c->memblock_stat) < 0)
return -1;
- r = pa_scache_add_item(c, name, &ss, &chunk, index);
+ r = pa_scache_add_item(c, name, &ss, &chunk, idx);
pa_memblock_unref(chunk.memblock);
return r;
}
-int pa_scache_add_file_lazy(struct pa_core *c, const char *name, const char *filename, uint32_t *index) {
- struct pa_scache_entry *e;
+int pa_scache_add_file_lazy(pa_core *c, const char *name, const char *filename, uint32_t *idx) {
+ pa_scache_entry *e;
#ifdef OS_IS_WIN32
char buf[MAX_PATH];
@@ -192,11 +192,14 @@ int pa_scache_add_file_lazy(struct pa_core *c, const char *name, const char *fil
c->scache_auto_unload_event = c->mainloop->time_new(c->mainloop, &ntv, timeout_callback, c);
}
+ if (idx)
+ *idx = e->index;
+
return 0;
}
-int pa_scache_remove_item(struct pa_core *c, const char *name) {
- struct pa_scache_entry *e;
+int pa_scache_remove_item(pa_core *c, const char *name) {
+ pa_scache_entry *e;
assert(c && name);
if (!(e = pa_namereg_get(c, name, PA_NAMEREG_SAMPLE, 0)))
@@ -209,13 +212,13 @@ int pa_scache_remove_item(struct pa_core *c, const char *name) {
return 0;
}
-static void free_cb(void *p, void *userdata) {
- struct pa_scache_entry *e = p;
+static void free_cb(void *p, PA_GCC_UNUSED void *userdata) {
+ pa_scache_entry *e = p;
assert(e);
free_entry(e);
}
-void pa_scache_free(struct pa_core *c) {
+void pa_scache_free(pa_core *c) {
assert(c);
if (c->scache) {
@@ -227,8 +230,8 @@ void pa_scache_free(struct pa_core *c) {
c->mainloop->time_free(c->scache_auto_unload_event);
}
-int pa_scache_play_item(struct pa_core *c, const char *name, struct pa_sink *sink, uint32_t volume) {
- struct pa_scache_entry *e;
+int pa_scache_play_item(pa_core *c, const char *name, pa_sink *sink, uint32_t volume) {
+ pa_scache_entry *e;
char *t;
assert(c && name && sink);
@@ -259,8 +262,8 @@ int pa_scache_play_item(struct pa_core *c, const char *name, struct pa_sink *sin
return 0;
}
-const char * pa_scache_get_name_by_id(struct pa_core *c, uint32_t id) {
- struct pa_scache_entry *e;
+const char * pa_scache_get_name_by_id(pa_core *c, uint32_t id) {
+ pa_scache_entry *e;
assert(c && id != PA_IDXSET_INVALID);
if (!c->scache || !(e = pa_idxset_get_by_index(c->scache, id)))
@@ -269,8 +272,8 @@ const char * pa_scache_get_name_by_id(struct pa_core *c, uint32_t id) {
return e->name;
}
-uint32_t pa_scache_get_id_by_name(struct pa_core *c, const char *name) {
- struct pa_scache_entry *e;
+uint32_t pa_scache_get_id_by_name(pa_core *c, const char *name) {
+ pa_scache_entry *e;
assert(c && name);
if (!(e = pa_namereg_get(c, name, PA_NAMEREG_SAMPLE, 0)))
@@ -279,33 +282,33 @@ uint32_t pa_scache_get_id_by_name(struct pa_core *c, const char *name) {
return e->index;
}
-uint32_t pa_scache_total_size(struct pa_core *c) {
- struct pa_scache_entry *e;
- uint32_t index, sum = 0;
+uint32_t pa_scache_total_size(pa_core *c) {
+ pa_scache_entry *e;
+ uint32_t idx, sum = 0;
assert(c);
- if (!c->scache || !pa_idxset_ncontents(c->scache))
+ if (!c->scache || !pa_idxset_size(c->scache))
return 0;
- 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))
if (e->memchunk.memblock)
sum += e->memchunk.length;
return sum;
}
-void pa_scache_unload_unused(struct pa_core *c) {
- struct pa_scache_entry *e;
+void pa_scache_unload_unused(pa_core *c) {
+ pa_scache_entry *e;
time_t now;
- uint32_t index;
+ uint32_t idx;
assert(c);
- if (!c->scache || !pa_idxset_ncontents(c->scache))
+ if (!c->scache || !pa_idxset_size(c->scache))
return;
time(&now);
- 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)) {
if (!e->lazy || !e->memchunk.memblock)
continue;
@@ -321,7 +324,7 @@ void pa_scache_unload_unused(struct pa_core *c) {
}
}
-static void add_file(struct pa_core *c, const char *pathname) {
+static void add_file(pa_core *c, const char *pathname) {
struct stat st;
const char *e;
@@ -338,7 +341,7 @@ static void add_file(struct pa_core *c, const char *pathname) {
pa_scache_add_file_lazy(c, e, pathname, NULL);
}
-int pa_scache_add_directory_lazy(struct pa_core *c, const char *pathname) {
+int pa_scache_add_directory_lazy(pa_core *c, const char *pathname) {
DIR *dir;
assert(c && pathname);
diff --git a/polyp/scache.h b/polyp/scache.h
index f7043f16..c23e33de 100644
--- a/polyp/scache.h
+++ b/polyp/scache.h
@@ -26,36 +26,36 @@
#include "memchunk.h"
#include "sink.h"
-struct pa_scache_entry {
- struct pa_core *core;
+typedef struct pa_scache_entry {
+ pa_core *core;
uint32_t index;
char *name;
uint32_t volume;
- struct pa_sample_spec sample_spec;
- struct pa_memchunk memchunk;
+ pa_sample_spec sample_spec;
+ pa_memchunk memchunk;
char *filename;
int lazy;
time_t last_used_time;
-};
+} pa_scache_entry;
-int pa_scache_add_item(struct pa_core *c, const char *name, struct pa_sample_spec *ss, struct pa_memchunk *chunk, uint32_t *index);
-int pa_scache_add_file(struct pa_core *c, const char *name, const char *filename, uint32_t *index);
-int pa_scache_add_file_lazy(struct pa_core *c, const char *name, const char *filename, uint32_t *index);
+int pa_scache_add_item(pa_core *c, const char *name, pa_sample_spec *ss, pa_memchunk *chunk, uint32_t *idx);
+int pa_scache_add_file(pa_core *c, const char *name, const char *filename, uint32_t *idx);
+int pa_scache_add_file_lazy(pa_core *c, const char *name, const char *filename, uint32_t *idx);
-int pa_scache_add_directory_lazy(struct pa_core *c, const char *pathname);
+int pa_scache_add_directory_lazy(pa_core *c, const char *pathname);
-int pa_scache_remove_item(struct pa_core *c, const char *name);
-int pa_scache_play_item(struct pa_core *c, const char *name, struct pa_sink *sink, uint32_t volume);
-void pa_scache_free(struct pa_core *c);
+int pa_scache_remove_item(pa_core *c, const char *name);
+int pa_scache_play_item(pa_core *c, const char *name, pa_sink *sink, uint32_t volume);
+void pa_scache_free(pa_core *c);
-const char *pa_scache_get_name_by_id(struct pa_core *c, uint32_t id);
-uint32_t pa_scache_get_id_by_name(struct pa_core *c, const char *name);
+const char *pa_scache_get_name_by_id(pa_core *c, uint32_t id);
+uint32_t pa_scache_get_id_by_name(pa_core *c, const char *name);
-uint32_t pa_scache_total_size(struct pa_core *c);
+uint32_t pa_scache_total_size(pa_core *c);
-void pa_scache_unload_unused(struct pa_core *c);
+void pa_scache_unload_unused(pa_core *c);
#endif
diff --git a/polyp/sconv-s16be.c b/polyp/sconv-s16be.c
index 54efc78c..3880b043 100644
--- a/polyp/sconv-s16be.c
+++ b/polyp/sconv-s16be.c
@@ -23,12 +23,11 @@
#include <config.h>
#endif
-#include "sconv-s16be.h"
-
#define INT16_FROM INT16_FROM_BE
#define INT16_TO INT16_TO_BE
#define pa_sconv_s16le_to_float32ne pa_sconv_s16be_to_float32ne
#define pa_sconv_s16le_from_float32ne pa_sconv_s16be_from_float32ne
+#include "sconv-s16le.h"
#include "sconv-s16le.c"
diff --git a/polyp/sconv-s16le.c b/polyp/sconv-s16le.c
index 49c47461..c9682fff 100644
--- a/polyp/sconv-s16le.c
+++ b/polyp/sconv-s16le.c
@@ -28,6 +28,7 @@
#include "endianmacros.h"
#include "sconv.h"
+#include "sconv-s16le.h"
#include "log.h"
#ifndef INT16_FROM
diff --git a/polyp/sconv.c b/polyp/sconv.c
index a404f432..223df5d9 100644
--- a/polyp/sconv.c
+++ b/polyp/sconv.c
@@ -115,7 +115,7 @@ static void ulaw_to_float32ne(unsigned n, const void *a, unsigned an, float *b)
float sum = 0;
for (i = 0; i < an; i++)
- sum += (float) st_ulaw2linear16(*ca++) / 0x7FFF;
+ sum += st_ulaw2linear16(*ca++) * 1.0F / 0x7FFF;
if (sum > 1)
sum = 1;
@@ -156,7 +156,7 @@ static void alaw_to_float32ne(unsigned n, const void *a, unsigned an, float *b)
float sum = 0;
for (i = 0; i < an; i++)
- sum += (float) st_alaw2linear16(*ca++) / 0x7FFF;
+ sum += st_alaw2linear16(*ca++) * 1.0F / 0x7FFF;
if (sum > 1)
sum = 1;
@@ -190,7 +190,7 @@ static void alaw_from_float32ne(unsigned n, const float *a, void *b, unsigned bn
}
-pa_convert_to_float32ne_func_t pa_get_convert_to_float32ne_function(enum pa_sample_format f) {
+pa_convert_to_float32ne_func_t pa_get_convert_to_float32ne_function(pa_sample_format f) {
switch(f) {
case PA_SAMPLE_U8:
return u8_to_float32ne;
@@ -209,7 +209,7 @@ pa_convert_to_float32ne_func_t pa_get_convert_to_float32ne_function(enum pa_samp
}
}
-pa_convert_from_float32ne_func_t pa_get_convert_from_float32ne_function(enum pa_sample_format f) {
+pa_convert_from_float32ne_func_t pa_get_convert_from_float32ne_function(pa_sample_format f) {
switch(f) {
case PA_SAMPLE_U8:
return u8_from_float32ne;
diff --git a/polyp/sconv.h b/polyp/sconv.h
index 71517ec2..2866fd41 100644
--- a/polyp/sconv.h
+++ b/polyp/sconv.h
@@ -27,7 +27,7 @@
typedef void (*pa_convert_to_float32ne_func_t)(unsigned n, const void *a, unsigned an, float *b);
typedef void (*pa_convert_from_float32ne_func_t)(unsigned n, const float *a, void *b, unsigned bn);
-pa_convert_to_float32ne_func_t pa_get_convert_to_float32ne_function(enum pa_sample_format f);
-pa_convert_from_float32ne_func_t pa_get_convert_from_float32ne_function(enum pa_sample_format f);
+pa_convert_to_float32ne_func_t pa_get_convert_to_float32ne_function(pa_sample_format f);
+pa_convert_from_float32ne_func_t pa_get_convert_from_float32ne_function(pa_sample_format f);
#endif
diff --git a/polyp/sink-input.c b/polyp/sink-input.c
index 3e7fdf7b..682b3222 100644
--- a/polyp/sink-input.c
+++ b/polyp/sink-input.c
@@ -36,14 +36,14 @@
#define CONVERT_BUFFER_LENGTH 4096
-struct pa_sink_input* pa_sink_input_new(struct pa_sink *s, pa_typeid_t typeid, const char *name, const struct pa_sample_spec *spec, int variable_rate, int resample_method) {
- struct pa_sink_input *i;
- struct pa_resampler *resampler = NULL;
+pa_sink_input* pa_sink_input_new(pa_sink *s, pa_typeid_t typeid, const char *name, const pa_sample_spec *spec, int variable_rate, int resample_method) {
+ pa_sink_input *i;
+ pa_resampler *resampler = NULL;
int r;
char st[256];
assert(s && spec && s->state == PA_SINK_RUNNING);
- if (pa_idxset_ncontents(s->inputs) >= PA_MAX_INPUTS_PER_SINK) {
+ if (pa_idxset_size(s->inputs) >= PA_MAX_INPUTS_PER_SINK) {
pa_log(__FILE__": Failed to create sink input: too many inputs per sink.\n");
return NULL;
}
@@ -55,7 +55,7 @@ struct pa_sink_input* pa_sink_input_new(struct pa_sink *s, pa_typeid_t typeid, c
if (!(resampler = pa_resampler_new(spec, &s->sample_spec, s->core->memblock_stat, resample_method)))
return NULL;
- i = pa_xmalloc(sizeof(struct pa_sink_input));
+ i = pa_xmalloc(sizeof(pa_sink_input));
i->ref = 1;
i->state = PA_SINK_INPUT_RUNNING;
i->name = pa_xstrdup(name);
@@ -93,7 +93,7 @@ struct pa_sink_input* pa_sink_input_new(struct pa_sink *s, pa_typeid_t typeid, c
return i;
}
-void pa_sink_input_disconnect(struct pa_sink_input *i) {
+void pa_sink_input_disconnect(pa_sink_input *i) {
assert(i && i->state != PA_SINK_INPUT_DISCONNECTED && i->sink && i->sink->core);
pa_idxset_remove_by_data(i->sink->core->sink_inputs, i, NULL);
@@ -110,7 +110,7 @@ void pa_sink_input_disconnect(struct pa_sink_input *i) {
i->state = PA_SINK_INPUT_DISCONNECTED;
}
-static void sink_input_free(struct pa_sink_input* i) {
+static void sink_input_free(pa_sink_input* i) {
assert(i);
if (i->state != PA_SINK_INPUT_DISCONNECTED)
@@ -127,27 +127,27 @@ static void sink_input_free(struct pa_sink_input* i) {
pa_xfree(i);
}
-void pa_sink_input_unref(struct pa_sink_input *i) {
+void pa_sink_input_unref(pa_sink_input *i) {
assert(i && i->ref >= 1);
if (!(--i->ref))
sink_input_free(i);
}
-struct pa_sink_input* pa_sink_input_ref(struct pa_sink_input *i) {
+pa_sink_input* pa_sink_input_ref(pa_sink_input *i) {
assert(i && i->ref >= 1);
i->ref++;
return i;
}
-void pa_sink_input_kill(struct pa_sink_input*i) {
+void pa_sink_input_kill(pa_sink_input*i) {
assert(i && i->ref >= 1);
if (i->kill)
i->kill(i);
}
-pa_usec_t pa_sink_input_get_latency(struct pa_sink_input *i) {
+pa_usec_t pa_sink_input_get_latency(pa_sink_input *i) {
pa_usec_t r = 0;
assert(i && i->ref >= 1);
@@ -160,7 +160,7 @@ pa_usec_t pa_sink_input_get_latency(struct pa_sink_input *i) {
return r;
}
-int pa_sink_input_peek(struct pa_sink_input *i, struct pa_memchunk *chunk) {
+int pa_sink_input_peek(pa_sink_input *i, pa_memchunk *chunk) {
int ret = -1;
assert(i && chunk && i->ref >= 1);
@@ -175,7 +175,7 @@ int pa_sink_input_peek(struct pa_sink_input *i, struct pa_memchunk *chunk) {
}
while (!i->resampled_chunk.memblock) {
- struct pa_memchunk tchunk;
+ pa_memchunk tchunk;
size_t l;
if ((ret = i->peek(i, &tchunk)) < 0)
@@ -213,7 +213,7 @@ finish:
return ret;
}
-void pa_sink_input_drop(struct pa_sink_input *i, const struct pa_memchunk *chunk, size_t length) {
+void pa_sink_input_drop(pa_sink_input *i, const pa_memchunk *chunk, size_t length) {
assert(i && length && i->ref >= 1);
if (!i->resampler) {
@@ -234,7 +234,7 @@ void pa_sink_input_drop(struct pa_sink_input *i, const struct pa_memchunk *chunk
}
}
-void pa_sink_input_set_volume(struct pa_sink_input *i, pa_volume_t volume) {
+void pa_sink_input_set_volume(pa_sink_input *i, pa_volume_t volume) {
assert(i && i->sink && i->sink->core && i->ref >= 1);
if (i->volume != volume) {
@@ -243,7 +243,7 @@ void pa_sink_input_set_volume(struct pa_sink_input *i, pa_volume_t volume) {
}
}
-void pa_sink_input_cork(struct pa_sink_input *i, int b) {
+void pa_sink_input_cork(pa_sink_input *i, int b) {
int n;
assert(i && i->ref >= 1);
@@ -257,7 +257,7 @@ void pa_sink_input_cork(struct pa_sink_input *i, int b) {
pa_sink_notify(i->sink);
}
-void pa_sink_input_set_rate(struct pa_sink_input *i, uint32_t rate) {
+void pa_sink_input_set_rate(pa_sink_input *i, uint32_t rate) {
assert(i && i->resampler && i->ref >= 1);
if (i->sample_spec.rate == rate)
@@ -267,7 +267,7 @@ void pa_sink_input_set_rate(struct pa_sink_input *i, uint32_t rate) {
pa_resampler_set_input_rate(i->resampler, rate);
}
-void pa_sink_input_set_name(struct pa_sink_input *i, const char *name) {
+void pa_sink_input_set_name(pa_sink_input *i, const char *name) {
assert(i && i->ref >= 1);
pa_xfree(i->name);
@@ -276,7 +276,7 @@ void pa_sink_input_set_name(struct pa_sink_input *i, const char *name) {
pa_subscription_post(i->sink->core, PA_SUBSCRIPTION_EVENT_SINK_INPUT|PA_SUBSCRIPTION_EVENT_CHANGE, i->index);
}
-enum pa_resample_method pa_sink_input_get_resample_method(struct pa_sink_input *i) {
+pa_resample_method pa_sink_input_get_resample_method(pa_sink_input *i) {
assert(i && i->ref >= 1);
if (!i->resampler)
diff --git a/polyp/sink-input.h b/polyp/sink-input.h
index 83abe537..b4c3ec7f 100644
--- a/polyp/sink-input.h
+++ b/polyp/sink-input.h
@@ -24,6 +24,8 @@
#include <inttypes.h>
+typedef struct pa_sink_input pa_sink_input;
+
#include "sink.h"
#include "sample.h"
#include "memblockq.h"
@@ -31,63 +33,63 @@
#include "module.h"
#include "client.h"
-enum pa_sink_input_state {
+typedef enum {
PA_SINK_INPUT_RUNNING,
PA_SINK_INPUT_CORKED,
PA_SINK_INPUT_DISCONNECTED
-};
+} pa_sink_input_state ;
struct pa_sink_input {
int ref;
- enum pa_sink_input_state state;
+ pa_sink_input_state state;
uint32_t index;
pa_typeid_t typeid;
char *name;
- struct pa_module *owner;
- struct pa_client *client;
- struct pa_sink *sink;
- struct pa_sample_spec sample_spec;
+ pa_module *owner;
+ pa_client *client;
+ pa_sink *sink;
+ pa_sample_spec sample_spec;
uint32_t volume;
- int (*peek) (struct pa_sink_input *i, struct pa_memchunk *chunk);
- void (*drop) (struct pa_sink_input *i, const struct pa_memchunk *chunk, size_t length);
- void (*kill) (struct pa_sink_input *i);
- pa_usec_t (*get_latency) (struct pa_sink_input *i);
- void (*underrun) (struct pa_sink_input *i);
+ int (*peek) (pa_sink_input *i, pa_memchunk *chunk);
+ void (*drop) (pa_sink_input *i, const pa_memchunk *chunk, size_t length);
+ void (*kill) (pa_sink_input *i);
+ pa_usec_t (*get_latency) (pa_sink_input *i);
+ void (*underrun) (pa_sink_input *i);
void *userdata;
int playing;
- struct pa_memchunk resampled_chunk;
- struct pa_resampler *resampler;
+ pa_memchunk resampled_chunk;
+ pa_resampler *resampler;
};
-struct pa_sink_input* pa_sink_input_new(struct pa_sink *s, pa_typeid_t typeid, const char *name, const struct pa_sample_spec *spec, int variable_rate, int resample_method);
-void pa_sink_input_unref(struct pa_sink_input* i);
-struct pa_sink_input* pa_sink_input_ref(struct pa_sink_input* i);
+pa_sink_input* pa_sink_input_new(pa_sink *s, pa_typeid_t typeid, const char *name, const pa_sample_spec *spec, int variable_rate, int resample_method);
+void pa_sink_input_unref(pa_sink_input* i);
+pa_sink_input* pa_sink_input_ref(pa_sink_input* i);
/* To be called by the implementing module only */
-void pa_sink_input_disconnect(struct pa_sink_input* i);
+void pa_sink_input_disconnect(pa_sink_input* i);
/* External code may request disconnection with this funcion */
-void pa_sink_input_kill(struct pa_sink_input*i);
+void pa_sink_input_kill(pa_sink_input*i);
-pa_usec_t pa_sink_input_get_latency(struct pa_sink_input *i);
+pa_usec_t pa_sink_input_get_latency(pa_sink_input *i);
-int pa_sink_input_peek(struct pa_sink_input *i, struct pa_memchunk *chunk);
-void pa_sink_input_drop(struct pa_sink_input *i, const struct pa_memchunk *chunk, size_t length);
+int pa_sink_input_peek(pa_sink_input *i, pa_memchunk *chunk);
+void pa_sink_input_drop(pa_sink_input *i, const pa_memchunk *chunk, size_t length);
-void pa_sink_input_set_volume(struct pa_sink_input *i, pa_volume_t volume);
+void pa_sink_input_set_volume(pa_sink_input *i, pa_volume_t volume);
-void pa_sink_input_cork(struct pa_sink_input *i, int b);
+void pa_sink_input_cork(pa_sink_input *i, int b);
-void pa_sink_input_set_rate(struct pa_sink_input *i, uint32_t rate);
+void pa_sink_input_set_rate(pa_sink_input *i, uint32_t rate);
-void pa_sink_input_set_name(struct pa_sink_input *i, const char *name);
+void pa_sink_input_set_name(pa_sink_input *i, const char *name);
-enum pa_resample_method pa_sink_input_get_resample_method(struct pa_sink_input *i);
+pa_resample_method pa_sink_input_get_resample_method(pa_sink_input *i);
#endif
diff --git a/polyp/sink.c b/polyp/sink.c
index 481e5cf7..aac90c04 100644
--- a/polyp/sink.c
+++ b/polyp/sink.c
@@ -36,17 +36,18 @@
#include "xmalloc.h"
#include "subscribe.h"
#include "log.h"
+#include "polyplib-introspect.h"
#define MAX_MIX_CHANNELS 32
-struct pa_sink* pa_sink_new(struct pa_core *core, pa_typeid_t typeid, const char *name, int fail, const struct pa_sample_spec *spec) {
- struct pa_sink *s;
+pa_sink* pa_sink_new(pa_core *core, pa_typeid_t typeid, const char *name, int fail, const pa_sample_spec *spec) {
+ pa_sink *s;
char *n = NULL;
char st[256];
int r;
assert(core && name && *name && spec);
- s = pa_xmalloc(sizeof(struct pa_sink));
+ s = pa_xmalloc(sizeof(pa_sink));
if (!(name = pa_namereg_register(core, name, PA_NAMEREG_SINK, s, fail))) {
pa_xfree(s);
@@ -89,8 +90,8 @@ struct pa_sink* pa_sink_new(struct pa_core *core, pa_typeid_t typeid, const char
return s;
}
-void pa_sink_disconnect(struct pa_sink* s) {
- struct pa_sink_input *i, *j = NULL;
+void pa_sink_disconnect(pa_sink* s) {
+ pa_sink_input *i, *j = NULL;
assert(s && s->state == PA_SINK_RUNNING);
pa_namereg_unregister(s->core, s->name);
@@ -112,7 +113,7 @@ void pa_sink_disconnect(struct pa_sink* s) {
s->state = PA_SINK_DISCONNECTED;
}
-static void sink_free(struct pa_sink *s) {
+static void sink_free(pa_sink *s) {
assert(s && s->ref == 0);
if (s->state != PA_SINK_DISCONNECTED)
@@ -130,34 +131,34 @@ static void sink_free(struct pa_sink *s) {
pa_xfree(s);
}
-void pa_sink_unref(struct pa_sink*s) {
+void pa_sink_unref(pa_sink*s) {
assert(s && s->ref >= 1);
if (!(--s->ref))
sink_free(s);
}
-struct pa_sink* pa_sink_ref(struct pa_sink *s) {
+pa_sink* pa_sink_ref(pa_sink *s) {
assert(s && s->ref >= 1);
s->ref++;
return s;
}
-void pa_sink_notify(struct pa_sink*s) {
+void pa_sink_notify(pa_sink*s) {
assert(s && s->ref >= 1);
if (s->notify)
s->notify(s);
}
-static unsigned fill_mix_info(struct pa_sink *s, struct pa_mix_info *info, unsigned maxinfo) {
- uint32_t index = PA_IDXSET_INVALID;
- struct pa_sink_input *i;
+static unsigned fill_mix_info(pa_sink *s, pa_mix_info *info, unsigned maxinfo) {
+ uint32_t idx = PA_IDXSET_INVALID;
+ pa_sink_input *i;
unsigned n = 0;
assert(s && s->ref >= 1 && info);
- for (i = pa_idxset_first(s->inputs, &index); maxinfo > 0 && i; i = pa_idxset_next(s->inputs, &index)) {
+ for (i = pa_idxset_first(s->inputs, &idx); maxinfo > 0 && i; i = pa_idxset_next(s->inputs, &idx)) {
pa_sink_input_ref(i);
if (pa_sink_input_peek(i, &info->chunk) < 0) {
@@ -178,11 +179,11 @@ static unsigned fill_mix_info(struct pa_sink *s, struct pa_mix_info *info, unsig
return n;
}
-static void inputs_drop(struct pa_sink *s, struct pa_mix_info *info, unsigned maxinfo, size_t length) {
+static void inputs_drop(pa_sink *s, pa_mix_info *info, unsigned maxinfo, size_t length) {
assert(s && s->ref >= 1 && info);
for (; maxinfo > 0; maxinfo--, info++) {
- struct pa_sink_input *i = info->userdata;
+ pa_sink_input *i = info->userdata;
assert(i && info->chunk.memblock);
pa_sink_input_drop(i, &info->chunk, length);
@@ -193,8 +194,8 @@ static void inputs_drop(struct pa_sink *s, struct pa_mix_info *info, unsigned ma
}
}
-int pa_sink_render(struct pa_sink*s, size_t length, struct pa_memchunk *result) {
- struct pa_mix_info info[MAX_MIX_CHANNELS];
+int pa_sink_render(pa_sink*s, size_t length, pa_memchunk *result) {
+ pa_mix_info info[MAX_MIX_CHANNELS];
unsigned n;
size_t l;
int r = -1;
@@ -212,7 +213,7 @@ int pa_sink_render(struct pa_sink*s, size_t length, struct pa_memchunk *result)
if (n == 1) {
uint32_t volume = PA_VOLUME_NORM;
- struct pa_sink_input *i = info[0].userdata;
+ pa_sink_input *i = info[0].userdata;
assert(i);
*result = info[0].chunk;
pa_memblock_ref(result->memblock);
@@ -252,8 +253,8 @@ finish:
return r;
}
-int pa_sink_render_into(struct pa_sink*s, struct pa_memchunk *target) {
- struct pa_mix_info info[MAX_MIX_CHANNELS];
+int pa_sink_render_into(pa_sink*s, pa_memchunk *target) {
+ pa_mix_info info[MAX_MIX_CHANNELS];
unsigned n;
size_t l;
int r = -1;
@@ -268,8 +269,6 @@ int pa_sink_render_into(struct pa_sink*s, struct pa_memchunk *target) {
if (n == 1) {
uint32_t volume = PA_VOLUME_NORM;
- struct pa_sink_info *i = info[0].userdata;
- assert(i);
l = target->length;
if (l > info[0].chunk.length)
@@ -300,8 +299,8 @@ finish:
return r;
}
-void pa_sink_render_into_full(struct pa_sink *s, struct pa_memchunk *target) {
- struct pa_memchunk chunk;
+void pa_sink_render_into_full(pa_sink *s, pa_memchunk *target) {
+ pa_memchunk chunk;
size_t l, d;
assert(s && s->ref >= 1 && target && target->memblock && target->length && target->memblock->data);
@@ -331,7 +330,7 @@ void pa_sink_render_into_full(struct pa_sink *s, struct pa_memchunk *target) {
pa_sink_unref(s);
}
-void pa_sink_render_full(struct pa_sink *s, size_t length, struct pa_memchunk *result) {
+void pa_sink_render_full(pa_sink *s, size_t length, pa_memchunk *result) {
assert(s && s->ref >= 1 && length && result);
/*** This needs optimization ***/
@@ -342,7 +341,7 @@ void pa_sink_render_full(struct pa_sink *s, size_t length, struct pa_memchunk *r
pa_sink_render_into_full(s, result);
}
-pa_usec_t pa_sink_get_latency(struct pa_sink *s) {
+pa_usec_t pa_sink_get_latency(pa_sink *s) {
assert(s && s->ref >= 1);
if (!s->get_latency)
@@ -351,7 +350,7 @@ pa_usec_t pa_sink_get_latency(struct pa_sink *s) {
return s->get_latency(s);
}
-void pa_sink_set_owner(struct pa_sink *s, struct pa_module *m) {
+void pa_sink_set_owner(pa_sink *s, pa_module *m) {
assert(s && s->ref >= 1);
s->owner = m;
@@ -360,7 +359,7 @@ void pa_sink_set_owner(struct pa_sink *s, struct pa_module *m) {
pa_source_set_owner(s->monitor_source, m);
}
-void pa_sink_set_volume(struct pa_sink *s, pa_volume_t volume) {
+void pa_sink_set_volume(pa_sink *s, pa_volume_t volume) {
assert(s && s->ref >= 1);
if (s->volume != volume) {
diff --git a/polyp/sink.h b/polyp/sink.h
index 844af964..22d90858 100644
--- a/polyp/sink.h
+++ b/polyp/sink.h
@@ -22,61 +22,62 @@
USA.
***/
-struct pa_sink;
-
#include <inttypes.h>
+typedef struct pa_sink pa_sink;
+
#include "core.h"
#include "sample.h"
#include "idxset.h"
#include "source.h"
#include "typeid.h"
+#include "module.h"
#define PA_MAX_INPUTS_PER_SINK 6
-enum pa_sink_state {
+typedef enum pa_sink_state {
PA_SINK_RUNNING,
PA_SINK_DISCONNECTED
-};
+} pa_sink_state;
struct pa_sink {
int ref;
- enum pa_sink_state state;
+ pa_sink_state state;
uint32_t index;
pa_typeid_t typeid;
char *name, *description;
- struct pa_module *owner;
- struct pa_core *core;
- struct pa_sample_spec sample_spec;
- struct pa_idxset *inputs;
+ pa_module *owner;
+ pa_core *core;
+ pa_sample_spec sample_spec;
+ pa_idxset *inputs;
- struct pa_source *monitor_source;
+ pa_source *monitor_source;
pa_volume_t volume;
- void (*notify)(struct pa_sink*sink);
- pa_usec_t (*get_latency)(struct pa_sink *s);
+ void (*notify)(pa_sink*sink);
+ pa_usec_t (*get_latency)(pa_sink *s);
void *userdata;
};
-struct pa_sink* pa_sink_new(struct pa_core *core, pa_typeid_t typeid, const char *name, int fail, const struct pa_sample_spec *spec);
-void pa_sink_disconnect(struct pa_sink* s);
-void pa_sink_unref(struct pa_sink*s);
-struct pa_sink* pa_sink_ref(struct pa_sink *s);
+pa_sink* pa_sink_new(pa_core *core, pa_typeid_t typeid, const char *name, int fail, const pa_sample_spec *spec);
+void pa_sink_disconnect(pa_sink* s);
+void pa_sink_unref(pa_sink*s);
+pa_sink* pa_sink_ref(pa_sink *s);
-int pa_sink_render(struct pa_sink*s, size_t length, struct pa_memchunk *result);
-void pa_sink_render_full(struct pa_sink *s, size_t length, struct pa_memchunk *result);
-int pa_sink_render_into(struct pa_sink*s, struct pa_memchunk *target);
-void pa_sink_render_into_full(struct pa_sink *s, struct pa_memchunk *target);
+int pa_sink_render(pa_sink*s, size_t length, pa_memchunk *result);
+void pa_sink_render_full(pa_sink *s, size_t length, pa_memchunk *result);
+int pa_sink_render_into(pa_sink*s, pa_memchunk *target);
+void pa_sink_render_into_full(pa_sink *s, pa_memchunk *target);
-pa_usec_t pa_sink_get_latency(struct pa_sink *s);
+pa_usec_t pa_sink_get_latency(pa_sink *s);
-void pa_sink_notify(struct pa_sink*s);
+void pa_sink_notify(pa_sink*s);
-void pa_sink_set_owner(struct pa_sink *sink, struct pa_module *m);
+void pa_sink_set_owner(pa_sink *sink, pa_module *m);
-void pa_sink_set_volume(struct pa_sink *sink, pa_volume_t volume);
+void pa_sink_set_volume(pa_sink *sink, pa_volume_t volume);
#endif
diff --git a/polyp/socket-client.c b/polyp/socket-client.c
index 51134b84..a884aa61 100644
--- a/polyp/socket-client.c
+++ b/polyp/socket-client.c
@@ -65,26 +65,26 @@
struct pa_socket_client {
int ref;
- struct pa_mainloop_api *mainloop;
+ pa_mainloop_api *mainloop;
int fd;
- struct pa_io_event *io_event;
- struct pa_time_event *timeout_event;
- struct pa_defer_event *defer_event;
- void (*callback)(struct pa_socket_client*c, struct pa_iochannel *io, void *userdata);
+ pa_io_event *io_event;
+ pa_time_event *timeout_event;
+ pa_defer_event *defer_event;
+ void (*callback)(pa_socket_client*c, pa_iochannel *io, void *userdata);
void *userdata;
int local;
#ifdef HAVE_LIBASYNCNS
asyncns_t *asyncns;
asyncns_query_t * asyncns_query;
- struct pa_io_event *asyncns_io_event;
+ pa_io_event *asyncns_io_event;
#endif
};
-static struct pa_socket_client*pa_socket_client_new(struct pa_mainloop_api *m) {
- struct pa_socket_client *c;
+static pa_socket_client*pa_socket_client_new(pa_mainloop_api *m) {
+ pa_socket_client *c;
assert(m);
- c = pa_xmalloc(sizeof(struct pa_socket_client));
+ c = pa_xmalloc(sizeof(pa_socket_client));
c->ref = 1;
c->mainloop = m;
c->fd = -1;
@@ -104,7 +104,7 @@ static struct pa_socket_client*pa_socket_client_new(struct pa_mainloop_api *m) {
return c;
}
-static void free_events(struct pa_socket_client *c) {
+static void free_events(pa_socket_client *c) {
assert(c);
if (c->io_event) {
@@ -123,8 +123,8 @@ static void free_events(struct pa_socket_client *c) {
}
}
-static void do_call(struct pa_socket_client *c) {
- struct pa_iochannel *io = NULL;
+static void do_call(pa_socket_client *c) {
+ pa_iochannel *io = NULL;
int error;
socklen_t lerror;
assert(c && c->callback);
@@ -167,19 +167,19 @@ finish:
pa_socket_client_unref(c);
}
-static void connect_fixed_cb(struct pa_mainloop_api *m, struct pa_defer_event *e, void *userdata) {
- struct pa_socket_client *c = userdata;
+static void connect_fixed_cb(pa_mainloop_api *m, pa_defer_event *e, void *userdata) {
+ pa_socket_client *c = userdata;
assert(m && c && c->defer_event == e);
do_call(c);
}
-static void connect_io_cb(struct pa_mainloop_api*m, struct pa_io_event *e, int fd, enum pa_io_event_flags f, void *userdata) {
- struct pa_socket_client *c = userdata;
+static void connect_io_cb(pa_mainloop_api*m, pa_io_event *e, int fd, PA_GCC_UNUSED pa_io_event_flags f, void *userdata) {
+ pa_socket_client *c = userdata;
assert(m && c && c->io_event == e && fd >= 0);
do_call(c);
}
-static int do_connect(struct pa_socket_client *c, const struct sockaddr *sa, socklen_t len) {
+static int do_connect(pa_socket_client *c, const struct sockaddr *sa, socklen_t len) {
int r;
assert(c && sa && len);
@@ -201,7 +201,7 @@ static int do_connect(struct pa_socket_client *c, const struct sockaddr *sa, soc
return 0;
}
-struct pa_socket_client* pa_socket_client_new_ipv4(struct pa_mainloop_api *m, uint32_t address, uint16_t port) {
+pa_socket_client* pa_socket_client_new_ipv4(pa_mainloop_api *m, uint32_t address, uint16_t port) {
struct sockaddr_in sa;
assert(m && port > 0);
@@ -215,7 +215,7 @@ struct pa_socket_client* pa_socket_client_new_ipv4(struct pa_mainloop_api *m, ui
#ifdef HAVE_SYS_UN_H
-struct pa_socket_client* pa_socket_client_new_unix(struct pa_mainloop_api *m, const char *filename) {
+pa_socket_client* pa_socket_client_new_unix(pa_mainloop_api *m, const char *filename) {
struct sockaddr_un sa;
assert(m && filename);
@@ -229,13 +229,13 @@ struct pa_socket_client* pa_socket_client_new_unix(struct pa_mainloop_api *m, co
#else /* HAVE_SYS_UN_H */
-struct pa_socket_client* pa_socket_client_new_unix(struct pa_mainloop_api *m, const char *filename) {
+pa_socket_client* pa_socket_client_new_unix(pa_mainloop_api *m, const char *filename) {
return NULL;
}
#endif /* HAVE_SYS_UN_H */
-static int sockaddr_prepare(struct pa_socket_client *c, const struct sockaddr *sa, size_t salen) {
+static int sockaddr_prepare(pa_socket_client *c, const struct sockaddr *sa, size_t salen) {
assert(c);
assert(sa);
assert(salen);
@@ -274,8 +274,8 @@ static int sockaddr_prepare(struct pa_socket_client *c, const struct sockaddr *s
return 0;
}
-struct pa_socket_client* pa_socket_client_new_sockaddr(struct pa_mainloop_api *m, const struct sockaddr *sa, size_t salen) {
- struct pa_socket_client *c;
+pa_socket_client* pa_socket_client_new_sockaddr(pa_mainloop_api *m, const struct sockaddr *sa, size_t salen) {
+ pa_socket_client *c;
assert(m && sa);
c = pa_socket_client_new(m);
assert(c);
@@ -291,7 +291,7 @@ fail:
}
-void socket_client_free(struct pa_socket_client *c) {
+static void socket_client_free(pa_socket_client *c) {
assert(c && c->mainloop);
@@ -312,26 +312,26 @@ void socket_client_free(struct pa_socket_client *c) {
pa_xfree(c);
}
-void pa_socket_client_unref(struct pa_socket_client *c) {
+void pa_socket_client_unref(pa_socket_client *c) {
assert(c && c->ref >= 1);
if (!(--(c->ref)))
socket_client_free(c);
}
-struct pa_socket_client* pa_socket_client_ref(struct pa_socket_client *c) {
+pa_socket_client* pa_socket_client_ref(pa_socket_client *c) {
assert(c && c->ref >= 1);
c->ref++;
return c;
}
-void pa_socket_client_set_callback(struct pa_socket_client *c, void (*on_connection)(struct pa_socket_client *c, struct pa_iochannel*io, void *userdata), void *userdata) {
+void pa_socket_client_set_callback(pa_socket_client *c, void (*on_connection)(pa_socket_client *c, pa_iochannel*io, void *userdata), void *userdata) {
assert(c);
c->callback = on_connection;
c->userdata = userdata;
}
-struct pa_socket_client* pa_socket_client_new_ipv6(struct pa_mainloop_api *m, uint8_t address[16], uint16_t port) {
+pa_socket_client* pa_socket_client_new_ipv6(pa_mainloop_api *m, uint8_t address[16], uint16_t port) {
struct sockaddr_in6 sa;
memset(&sa, 0, sizeof(sa));
@@ -344,8 +344,8 @@ struct pa_socket_client* pa_socket_client_new_ipv6(struct pa_mainloop_api *m, ui
#ifdef HAVE_LIBASYNCNS
-static void asyncns_cb(struct pa_mainloop_api*m, struct pa_io_event *e, int fd, enum pa_io_event_flags f, void *userdata) {
- struct pa_socket_client *c = userdata;
+static void asyncns_cb(pa_mainloop_api*m, pa_io_event *e, int fd, PA_GCC_UNUSED pa_io_event_flags f, void *userdata) {
+ pa_socket_client *c = userdata;
struct addrinfo *res = NULL;
int ret;
assert(m && c && c->asyncns_io_event == e && fd >= 0);
@@ -381,8 +381,8 @@ finish:
#endif
-static void timeout_cb(struct pa_mainloop_api *m, struct pa_time_event *e, const struct timeval *tv, void *userdata) {
- struct pa_socket_client *c = userdata;
+static void timeout_cb(pa_mainloop_api *m, pa_time_event *e, const struct timeval *tv, void *userdata) {
+ pa_socket_client *c = userdata;
assert(m);
assert(e);
assert(tv);
@@ -397,7 +397,7 @@ static void timeout_cb(struct pa_mainloop_api *m, struct pa_time_event *e, const
do_call(c);
}
-static void start_timeout(struct pa_socket_client *c) {
+static void start_timeout(pa_socket_client *c) {
struct timeval tv;
assert(c);
assert(!c->timeout_event);
@@ -407,9 +407,9 @@ static void start_timeout(struct pa_socket_client *c) {
c->timeout_event = c->mainloop->time_new(c->mainloop, &tv, timeout_cb, c);
}
-struct pa_socket_client* pa_socket_client_new_string(struct pa_mainloop_api *m, const char*name, uint16_t default_port) {
- struct pa_socket_client *c = NULL;
- struct pa_parsed_address a;
+pa_socket_client* pa_socket_client_new_string(pa_mainloop_api *m, const char*name, uint16_t default_port) {
+ pa_socket_client *c = NULL;
+ pa_parsed_address a;
assert(m && name);
if (pa_parse_address(name, &a) < 0)
@@ -507,7 +507,7 @@ finish:
/* Return non-zero when the target sockaddr is considered
local. "local" means UNIX socket or TCP socket on localhost. Other
local IP addresses are not considered local. */
-int pa_socket_client_is_local(struct pa_socket_client *c) {
+int pa_socket_client_is_local(pa_socket_client *c) {
assert(c);
return c->local;
}
diff --git a/polyp/socket-client.h b/polyp/socket-client.h
index b8c73ed8..40e9629a 100644
--- a/polyp/socket-client.h
+++ b/polyp/socket-client.h
@@ -29,19 +29,19 @@
struct sockaddr;
-struct pa_socket_client;
+typedef struct pa_socket_client pa_socket_client;
-struct pa_socket_client* pa_socket_client_new_ipv4(struct pa_mainloop_api *m, uint32_t address, uint16_t port);
-struct pa_socket_client* pa_socket_client_new_ipv6(struct pa_mainloop_api *m, uint8_t address[16], uint16_t port);
-struct pa_socket_client* pa_socket_client_new_unix(struct pa_mainloop_api *m, const char *filename);
-struct pa_socket_client* pa_socket_client_new_sockaddr(struct pa_mainloop_api *m, const struct sockaddr *sa, size_t salen);
-struct pa_socket_client* pa_socket_client_new_string(struct pa_mainloop_api *m, const char *a, uint16_t default_port);
+pa_socket_client* pa_socket_client_new_ipv4(pa_mainloop_api *m, uint32_t address, uint16_t port);
+pa_socket_client* pa_socket_client_new_ipv6(pa_mainloop_api *m, uint8_t address[16], uint16_t port);
+pa_socket_client* pa_socket_client_new_unix(pa_mainloop_api *m, const char *filename);
+pa_socket_client* pa_socket_client_new_sockaddr(pa_mainloop_api *m, const struct sockaddr *sa, size_t salen);
+pa_socket_client* pa_socket_client_new_string(pa_mainloop_api *m, const char *a, uint16_t default_port);
-void pa_socket_client_unref(struct pa_socket_client *c);
-struct pa_socket_client* pa_socket_client_ref(struct pa_socket_client *c);
+void pa_socket_client_unref(pa_socket_client *c);
+pa_socket_client* pa_socket_client_ref(pa_socket_client *c);
-void pa_socket_client_set_callback(struct pa_socket_client *c, void (*on_connection)(struct pa_socket_client *c, struct pa_iochannel*io, void *userdata), void *userdata);
+void pa_socket_client_set_callback(pa_socket_client *c, void (*on_connection)(pa_socket_client *c, pa_iochannel*io, void *userdata), void *userdata);
-int pa_socket_client_is_local(struct pa_socket_client *c);
+int pa_socket_client_is_local(pa_socket_client *c);
#endif
diff --git a/polyp/socket-server.c b/polyp/socket-server.c
index a78f04cd..6f1794bc 100644
--- a/polyp/socket-server.c
+++ b/polyp/socket-server.c
@@ -70,17 +70,17 @@ struct pa_socket_server {
char *filename;
char *tcpwrap_service;
- void (*on_connection)(struct pa_socket_server*s, struct pa_iochannel *io, void *userdata);
+ void (*on_connection)(pa_socket_server*s, pa_iochannel *io, void *userdata);
void *userdata;
- struct pa_io_event *io_event;
- struct pa_mainloop_api *mainloop;
+ pa_io_event *io_event;
+ pa_mainloop_api *mainloop;
enum { SOCKET_SERVER_GENERIC, SOCKET_SERVER_IPV4, SOCKET_SERVER_UNIX, SOCKET_SERVER_IPV6 } type;
};
-static void callback(struct pa_mainloop_api *mainloop, struct pa_io_event *e, int fd, enum pa_io_event_flags f, void *userdata) {
- struct pa_socket_server *s = userdata;
- struct pa_iochannel *io;
+static void callback(pa_mainloop_api *mainloop, pa_io_event *e, int fd, PA_GCC_UNUSED pa_io_event_flags f, void *userdata) {
+ pa_socket_server *s = userdata;
+ pa_iochannel *io;
int nfd;
assert(s && s->mainloop == mainloop && s->io_event == e && e && fd >= 0 && fd == s->fd);
@@ -129,11 +129,11 @@ finish:
pa_socket_server_unref(s);
}
-struct pa_socket_server* pa_socket_server_new(struct pa_mainloop_api *m, int fd) {
- struct pa_socket_server *s;
+pa_socket_server* pa_socket_server_new(pa_mainloop_api *m, int fd) {
+ pa_socket_server *s;
assert(m && fd >= 0);
- s = pa_xmalloc(sizeof(struct pa_socket_server));
+ s = pa_xmalloc(sizeof(pa_socket_server));
s->ref = 1;
s->fd = fd;
s->filename = NULL;
@@ -150,7 +150,7 @@ struct pa_socket_server* pa_socket_server_new(struct pa_mainloop_api *m, int fd)
return s;
}
-struct pa_socket_server* pa_socket_server_ref(struct pa_socket_server *s) {
+pa_socket_server* pa_socket_server_ref(pa_socket_server *s) {
assert(s && s->ref >= 1);
s->ref++;
return s;
@@ -158,10 +158,10 @@ struct pa_socket_server* pa_socket_server_ref(struct pa_socket_server *s) {
#ifdef HAVE_SYS_UN_H
-struct pa_socket_server* pa_socket_server_new_unix(struct pa_mainloop_api *m, const char *filename) {
+pa_socket_server* pa_socket_server_new_unix(pa_mainloop_api *m, const char *filename) {
int fd = -1;
struct sockaddr_un sa;
- struct pa_socket_server *s;
+ pa_socket_server *s;
assert(m && filename);
@@ -205,14 +205,14 @@ fail:
#else /* HAVE_SYS_UN_H */
-struct pa_socket_server* pa_socket_server_new_unix(struct pa_mainloop_api *m, const char *filename) {
+pa_socket_server* pa_socket_server_new_unix(pa_mainloop_api *m, const char *filename) {
return NULL;
}
#endif /* HAVE_SYS_UN_H */
-struct pa_socket_server* pa_socket_server_new_ipv4(struct pa_mainloop_api *m, uint32_t address, uint16_t port, const char *tcpwrap_service) {
- struct pa_socket_server *ss;
+pa_socket_server* pa_socket_server_new_ipv4(pa_mainloop_api *m, uint32_t address, uint16_t port, const char *tcpwrap_service) {
+ pa_socket_server *ss;
int fd = -1;
struct sockaddr_in sa;
int on = 1;
@@ -260,8 +260,8 @@ fail:
return NULL;
}
-struct pa_socket_server* pa_socket_server_new_ipv6(struct pa_mainloop_api *m, uint8_t address[16], uint16_t port) {
- struct pa_socket_server *ss;
+pa_socket_server* pa_socket_server_new_ipv6(pa_mainloop_api *m, const uint8_t address[16], uint16_t port) {
+ pa_socket_server *ss;
int fd = -1;
struct sockaddr_in6 sa;
int on = 1;
@@ -307,7 +307,7 @@ fail:
return NULL;
}
-static void socket_server_free(struct pa_socket_server*s) {
+static void socket_server_free(pa_socket_server*s) {
assert(s);
close(s->fd);
@@ -322,14 +322,14 @@ static void socket_server_free(struct pa_socket_server*s) {
pa_xfree(s);
}
-void pa_socket_server_unref(struct pa_socket_server *s) {
+void pa_socket_server_unref(pa_socket_server *s) {
assert(s && s->ref >= 1);
if (!(--(s->ref)))
socket_server_free(s);
}
-void pa_socket_server_set_callback(struct pa_socket_server*s, void (*on_connection)(struct pa_socket_server*s, struct pa_iochannel *io, void *userdata), void *userdata) {
+void pa_socket_server_set_callback(pa_socket_server*s, void (*on_connection)(pa_socket_server*s, pa_iochannel *io, void *userdata), void *userdata) {
assert(s && s->ref >= 1);
s->on_connection = on_connection;
@@ -337,7 +337,7 @@ void pa_socket_server_set_callback(struct pa_socket_server*s, void (*on_connecti
}
-char *pa_socket_server_get_address(struct pa_socket_server *s, char *c, size_t l) {
+char *pa_socket_server_get_address(pa_socket_server *s, char *c, size_t l) {
assert(s && c && l > 0);
switch (s->type) {
diff --git a/polyp/socket-server.h b/polyp/socket-server.h
index dbd82518..6c5d7bac 100644
--- a/polyp/socket-server.h
+++ b/polyp/socket-server.h
@@ -28,18 +28,18 @@
/* It is safe to destroy the calling socket_server object from the callback */
-struct pa_socket_server;
+typedef struct pa_socket_server pa_socket_server;
-struct pa_socket_server* pa_socket_server_new(struct pa_mainloop_api *m, int fd);
-struct pa_socket_server* pa_socket_server_new_unix(struct pa_mainloop_api *m, const char *filename);
-struct pa_socket_server* pa_socket_server_new_ipv4(struct pa_mainloop_api *m, uint32_t address, uint16_t port, const char *tcpwrap_service);
-struct pa_socket_server* pa_socket_server_new_ipv6(struct pa_mainloop_api *m, uint8_t address[16], uint16_t port);
+pa_socket_server* pa_socket_server_new(pa_mainloop_api *m, int fd);
+pa_socket_server* pa_socket_server_new_unix(pa_mainloop_api *m, const char *filename);
+pa_socket_server* pa_socket_server_new_ipv4(pa_mainloop_api *m, uint32_t address, uint16_t port, const char *tcpwrap_service);
+pa_socket_server* pa_socket_server_new_ipv6(pa_mainloop_api *m, const uint8_t address[16], uint16_t port);
-void pa_socket_server_unref(struct pa_socket_server*s);
-struct pa_socket_server* pa_socket_server_ref(struct pa_socket_server *s);
+void pa_socket_server_unref(pa_socket_server*s);
+pa_socket_server* pa_socket_server_ref(pa_socket_server *s);
-void pa_socket_server_set_callback(struct pa_socket_server*s, void (*on_connection)(struct pa_socket_server*s, struct pa_iochannel *io, void *userdata), void *userdata);
+void pa_socket_server_set_callback(pa_socket_server*s, void (*on_connection)(pa_socket_server*s, pa_iochannel *io, void *userdata), void *userdata);
-char *pa_socket_server_get_address(struct pa_socket_server *s, char *c, size_t l);
+char *pa_socket_server_get_address(pa_socket_server *s, char *c, size_t l);
#endif
diff --git a/polyp/sound-file-stream.c b/polyp/sound-file-stream.c
index 621c3ed9..a277eb25 100644
--- a/polyp/sound-file-stream.c
+++ b/polyp/sound-file-stream.c
@@ -40,8 +40,8 @@
struct userdata {
SNDFILE *sndfile;
- struct pa_sink_input *sink_input;
- struct pa_memchunk memchunk;
+ pa_sink_input *sink_input;
+ pa_memchunk memchunk;
sf_count_t (*readf_function)(SNDFILE *sndfile, void *ptr, sf_count_t frames);
};
@@ -60,16 +60,16 @@ static void free_userdata(struct userdata *u) {
pa_xfree(u);
}
-static void sink_input_kill(struct pa_sink_input *i) {
+static void sink_input_kill(pa_sink_input *i) {
assert(i && i->userdata);
free_userdata(i->userdata);
}
-static void si_kill(struct pa_mainloop_api *m, void *i) {
+static void si_kill(PA_GCC_UNUSED pa_mainloop_api *m, void *i) {
sink_input_kill(i);
}
-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;
@@ -98,7 +98,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;
@@ -116,10 +116,10 @@ static void sink_input_drop(struct pa_sink_input *i, const struct pa_memchunk*ch
}
}
-int pa_play_file(struct pa_sink *sink, const char *fname, pa_volume_t volume) {
+int pa_play_file(pa_sink *sink, const char *fname, pa_volume_t volume) {
struct userdata *u = NULL;
SF_INFO sfinfo;
- struct pa_sample_spec ss;
+ pa_sample_spec ss;
assert(sink && fname);
if (volume <= 0)
diff --git a/polyp/sound-file-stream.h b/polyp/sound-file-stream.h
index f5ab8e2c..0b383f96 100644
--- a/polyp/sound-file-stream.h
+++ b/polyp/sound-file-stream.h
@@ -24,6 +24,6 @@
#include "sink.h"
-int pa_play_file(struct pa_sink *sink, const char *fname, pa_volume_t volume);
+int pa_play_file(pa_sink *sink, const char *fname, pa_volume_t volume);
#endif
diff --git a/polyp/sound-file.c b/polyp/sound-file.c
index 326ddd8b..0048ed74 100644
--- a/polyp/sound-file.c
+++ b/polyp/sound-file.c
@@ -34,7 +34,7 @@
#define MAX_FILE_SIZE (1024*1024)
-int pa_sound_file_load(const char *fname, struct pa_sample_spec *ss, struct pa_memchunk *chunk, struct pa_memblock_stat *s) {
+int pa_sound_file_load(const char *fname, pa_sample_spec *ss, pa_memchunk *chunk, pa_memblock_stat *s) {
SNDFILE*sf = NULL;
SF_INFO sfinfo;
int ret = -1;
@@ -106,7 +106,7 @@ finish:
int pa_sound_file_too_big_to_cache(const char *fname) {
SNDFILE*sf = NULL;
SF_INFO sfinfo;
- struct pa_sample_spec ss;
+ pa_sample_spec ss;
if (!(sf = sf_open(fname, SFM_READ, &sfinfo))) {
pa_log(__FILE__": Failed to open file %s\n", fname);
diff --git a/polyp/sound-file.h b/polyp/sound-file.h
index 855e6883..e0534275 100644
--- a/polyp/sound-file.h
+++ b/polyp/sound-file.h
@@ -25,7 +25,7 @@
#include "memchunk.h"
#include "sample.h"
-int pa_sound_file_load(const char *fname, struct pa_sample_spec *ss, struct pa_memchunk *chunk, struct pa_memblock_stat *s);
+int pa_sound_file_load(const char *fname, pa_sample_spec *ss, pa_memchunk *chunk, pa_memblock_stat *s);
int pa_sound_file_too_big_to_cache(const char *fname);
diff --git a/polyp/source-output.c b/polyp/source-output.c
index f954c23f..7a540633 100644
--- a/polyp/source-output.c
+++ b/polyp/source-output.c
@@ -33,14 +33,14 @@
#include "subscribe.h"
#include "log.h"
-struct pa_source_output* pa_source_output_new(struct pa_source *s, pa_typeid_t typeid, const char *name, const struct pa_sample_spec *spec, int resample_method) {
- struct pa_source_output *o;
- struct pa_resampler *resampler = NULL;
+pa_source_output* pa_source_output_new(pa_source *s, pa_typeid_t typeid, const char *name, const pa_sample_spec *spec, int resample_method) {
+ pa_source_output *o;
+ pa_resampler *resampler = NULL;
int r;
char st[256];
assert(s && spec);
- if (pa_idxset_ncontents(s->outputs) >= PA_MAX_OUTPUTS_PER_SOURCE) {
+ if (pa_idxset_size(s->outputs) >= PA_MAX_OUTPUTS_PER_SOURCE) {
pa_log(__FILE__": Failed to create source output: too many outputs per source.\n");
return NULL;
}
@@ -52,7 +52,7 @@ struct pa_source_output* pa_source_output_new(struct pa_source *s, pa_typeid_t t
if (!(resampler = pa_resampler_new(&s->sample_spec, spec, s->core->memblock_stat, resample_method)))
return NULL;
- o = pa_xmalloc(sizeof(struct pa_source_output));
+ o = pa_xmalloc(sizeof(pa_source_output));
o->ref = 1;
o->state = PA_SOURCE_OUTPUT_RUNNING;
o->name = pa_xstrdup(name);
@@ -84,7 +84,7 @@ struct pa_source_output* pa_source_output_new(struct pa_source *s, pa_typeid_t t
return o;
}
-void pa_source_output_disconnect(struct pa_source_output*o) {
+void pa_source_output_disconnect(pa_source_output*o) {
assert(o && o->state != PA_SOURCE_OUTPUT_DISCONNECTED && o->source && o->source->core);
pa_idxset_remove_by_data(o->source->core->source_outputs, o, NULL);
@@ -100,7 +100,7 @@ void pa_source_output_disconnect(struct pa_source_output*o) {
o->state = PA_SOURCE_OUTPUT_DISCONNECTED;
}
-static void source_output_free(struct pa_source_output* o) {
+static void source_output_free(pa_source_output* o) {
assert(o);
if (o->state != PA_SOURCE_OUTPUT_DISCONNECTED)
@@ -116,29 +116,29 @@ static void source_output_free(struct pa_source_output* o) {
}
-void pa_source_output_unref(struct pa_source_output* o) {
+void pa_source_output_unref(pa_source_output* o) {
assert(o && o->ref >= 1);
if (!(--o->ref))
source_output_free(o);
}
-struct pa_source_output* pa_source_output_ref(struct pa_source_output *o) {
+pa_source_output* pa_source_output_ref(pa_source_output *o) {
assert(o && o->ref >= 1);
o->ref++;
return o;
}
-void pa_source_output_kill(struct pa_source_output*o) {
+void pa_source_output_kill(pa_source_output*o) {
assert(o && o->ref >= 1);
if (o->kill)
o->kill(o);
}
-void pa_source_output_push(struct pa_source_output *o, const struct pa_memchunk *chunk) {
- struct pa_memchunk rchunk;
+void pa_source_output_push(pa_source_output *o, const pa_memchunk *chunk) {
+ pa_memchunk rchunk;
assert(o && chunk && chunk->length && o->push);
if (o->state == PA_SOURCE_OUTPUT_CORKED)
@@ -158,7 +158,7 @@ void pa_source_output_push(struct pa_source_output *o, const struct pa_memchunk
pa_memblock_unref(rchunk.memblock);
}
-void pa_source_output_set_name(struct pa_source_output *o, const char *name) {
+void pa_source_output_set_name(pa_source_output *o, const char *name) {
assert(o && o->ref >= 1);
pa_xfree(o->name);
o->name = pa_xstrdup(name);
@@ -166,7 +166,7 @@ void pa_source_output_set_name(struct pa_source_output *o, const char *name) {
pa_subscription_post(o->source->core, PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT|PA_SUBSCRIPTION_EVENT_CHANGE, o->index);
}
-pa_usec_t pa_source_output_get_latency(struct pa_source_output *o) {
+pa_usec_t pa_source_output_get_latency(pa_source_output *o) {
assert(o && o->ref >= 1);
if (o->get_latency)
@@ -175,7 +175,7 @@ pa_usec_t pa_source_output_get_latency(struct pa_source_output *o) {
return 0;
}
-void pa_source_output_cork(struct pa_source_output *o, int b) {
+void pa_source_output_cork(pa_source_output *o, int b) {
assert(o && o->ref >= 1);
if (o->state == PA_SOURCE_OUTPUT_DISCONNECTED)
@@ -184,7 +184,7 @@ void pa_source_output_cork(struct pa_source_output *o, int b) {
o->state = b ? PA_SOURCE_OUTPUT_CORKED : PA_SOURCE_OUTPUT_RUNNING;
}
-enum pa_resample_method pa_source_output_get_resample_method(struct pa_source_output *o) {
+pa_resample_method pa_source_output_get_resample_method(pa_source_output *o) {
assert(o && o->ref >= 1);
if (!o->resampler)
diff --git a/polyp/source-output.h b/polyp/source-output.h
index f3187aa9..ef8f9fa9 100644
--- a/polyp/source-output.h
+++ b/polyp/source-output.h
@@ -24,6 +24,8 @@
#include <inttypes.h>
+typedef struct pa_source_output pa_source_output;
+
#include "source.h"
#include "sample.h"
#include "memblockq.h"
@@ -31,52 +33,52 @@
#include "module.h"
#include "client.h"
-enum pa_source_output_state {
+typedef enum {
PA_SOURCE_OUTPUT_RUNNING,
PA_SOURCE_OUTPUT_CORKED,
PA_SOURCE_OUTPUT_DISCONNECTED
-};
+} pa_source_output_state;
struct pa_source_output {
int ref;
- enum pa_source_output_state state;
+ pa_source_output_state state;
uint32_t index;
pa_typeid_t typeid;
char *name;
- struct pa_module *owner;
- struct pa_client *client;
- struct pa_source *source;
- struct pa_sample_spec sample_spec;
+ pa_module *owner;
+ pa_client *client;
+ pa_source *source;
+ pa_sample_spec sample_spec;
- void (*push)(struct pa_source_output *o, const struct pa_memchunk *chunk);
- void (*kill)(struct pa_source_output* o);
- pa_usec_t (*get_latency) (struct pa_source_output *i);
+ void (*push)(pa_source_output *o, const pa_memchunk *chunk);
+ void (*kill)(pa_source_output* o);
+ pa_usec_t (*get_latency) (pa_source_output *i);
- struct pa_resampler* resampler;
+ pa_resampler* resampler;
void *userdata;
};
-struct pa_source_output* pa_source_output_new(struct pa_source *s, pa_typeid_t typeid, const char *name, const struct pa_sample_spec *spec, int resample_method);
-void pa_source_output_unref(struct pa_source_output* o);
-struct pa_source_output* pa_source_output_ref(struct pa_source_output *o);
+pa_source_output* pa_source_output_new(pa_source *s, pa_typeid_t typeid, const char *name, const pa_sample_spec *spec, int resample_method);
+void pa_source_output_unref(pa_source_output* o);
+pa_source_output* pa_source_output_ref(pa_source_output *o);
/* To be called by the implementing module only */
-void pa_source_output_disconnect(struct pa_source_output*o);
+void pa_source_output_disconnect(pa_source_output*o);
/* External code may request disconnection with this funcion */
-void pa_source_output_kill(struct pa_source_output*o);
+void pa_source_output_kill(pa_source_output*o);
-void pa_source_output_push(struct pa_source_output *o, const struct pa_memchunk *chunk);
+void pa_source_output_push(pa_source_output *o, const pa_memchunk *chunk);
-void pa_source_output_set_name(struct pa_source_output *i, const char *name);
+void pa_source_output_set_name(pa_source_output *i, const char *name);
-pa_usec_t pa_source_output_get_latency(struct pa_source_output *i);
+pa_usec_t pa_source_output_get_latency(pa_source_output *i);
-void pa_source_output_cork(struct pa_source_output *i, int b);
+void pa_source_output_cork(pa_source_output *i, int b);
-enum pa_resample_method pa_source_output_get_resample_method(struct pa_source_output *o);
+pa_resample_method pa_source_output_get_resample_method(pa_source_output *o);
#endif
diff --git a/polyp/source.c b/polyp/source.c
index fc73272c..c287899e 100644
--- a/polyp/source.c
+++ b/polyp/source.c
@@ -35,13 +35,13 @@
#include "subscribe.h"
#include "log.h"
-struct pa_source* pa_source_new(struct pa_core *core, pa_typeid_t typeid, const char *name, int fail, const struct pa_sample_spec *spec) {
- struct pa_source *s;
+pa_source* pa_source_new(pa_core *core, pa_typeid_t typeid, const char *name, int fail, const pa_sample_spec *spec) {
+ pa_source *s;
char st[256];
int r;
assert(core && spec && name && *name);
- s = pa_xmalloc(sizeof(struct pa_source));
+ s = pa_xmalloc(sizeof(pa_source));
if (!(name = pa_namereg_register(core, name, PA_NAMEREG_SOURCE, s, fail))) {
pa_xfree(s);
@@ -76,8 +76,8 @@ struct pa_source* pa_source_new(struct pa_core *core, pa_typeid_t typeid, const
return s;
}
-void pa_source_disconnect(struct pa_source *s) {
- struct pa_source_output *o, *j = NULL;
+void pa_source_disconnect(pa_source *s) {
+ pa_source_output *o, *j = NULL;
assert(s && s->state == PA_SOURCE_RUNNING);
pa_namereg_unregister(s->core, s->name);
@@ -96,7 +96,7 @@ void pa_source_disconnect(struct pa_source *s) {
s->state = PA_SOURCE_DISCONNECTED;
}
-static void source_free(struct pa_source *s) {
+static void source_free(pa_source *s) {
assert(s && !s->ref);
if (s->state != PA_SOURCE_DISCONNECTED)
@@ -111,36 +111,36 @@ static void source_free(struct pa_source *s) {
pa_xfree(s);
}
-void pa_source_unref(struct pa_source *s) {
+void pa_source_unref(pa_source *s) {
assert(s && s->ref >= 1);
if (!(--s->ref))
source_free(s);
}
-struct pa_source* pa_source_ref(struct pa_source *s) {
+pa_source* pa_source_ref(pa_source *s) {
assert(s && s->ref >= 1);
s->ref++;
return s;
}
-void pa_source_notify(struct pa_source*s) {
+void pa_source_notify(pa_source*s) {
assert(s && s->ref >= 1);
if (s->notify)
s->notify(s);
}
-static int do_post(void *p, uint32_t index, int *del, void*userdata) {
- const struct pa_memchunk *chunk = userdata;
- struct pa_source_output *o = p;
+static int do_post(void *p, PA_GCC_UNUSED uint32_t idx, int *del, void*userdata) {
+ const pa_memchunk *chunk = userdata;
+ pa_source_output *o = p;
assert(o && o->push && del && chunk);
pa_source_output_push(o, chunk);
return 0;
}
-void pa_source_post(struct pa_source*s, const struct pa_memchunk *chunk) {
+void pa_source_post(pa_source*s, const pa_memchunk *chunk) {
assert(s && s->ref >= 1 && chunk);
pa_source_ref(s);
@@ -148,12 +148,12 @@ void pa_source_post(struct pa_source*s, const struct pa_memchunk *chunk) {
pa_source_unref(s);
}
-void pa_source_set_owner(struct pa_source *s, struct pa_module *m) {
+void pa_source_set_owner(pa_source *s, pa_module *m) {
assert(s);
s->owner = m;
}
-pa_usec_t pa_source_get_latency(struct pa_source *s) {
+pa_usec_t pa_source_get_latency(pa_source *s) {
assert(s && s->ref >= 1);
if (!s->get_latency)
diff --git a/polyp/source.h b/polyp/source.h
index 0fac2b34..c7f8d059 100644
--- a/polyp/source.h
+++ b/polyp/source.h
@@ -22,7 +22,7 @@
USA.
***/
-struct pa_source;
+typedef struct pa_source pa_source;
#include <inttypes.h>
#include "core.h"
@@ -32,45 +32,46 @@ struct pa_source;
#include "memchunk.h"
#include "sink.h"
#include "typeid.h"
+#include "module.h"
#define PA_MAX_OUTPUTS_PER_SOURCE 16
-enum pa_source_state {
+typedef enum pa_source_state {
PA_SOURCE_RUNNING,
PA_SOURCE_DISCONNECTED
-};
+} pa_source_state;
struct pa_source {
int ref;
- enum pa_source_state state;
+ pa_source_state state;
uint32_t index;
pa_typeid_t typeid;
char *name, *description;
- struct pa_module *owner;
- struct pa_core *core;
- struct pa_sample_spec sample_spec;
- struct pa_idxset *outputs;
- struct pa_sink *monitor_of;
+ pa_module *owner;
+ pa_core *core;
+ pa_sample_spec sample_spec;
+ pa_idxset *outputs;
+ pa_sink *monitor_of;
- void (*notify)(struct pa_source*source);
- pa_usec_t (*get_latency)(struct pa_source *s);
+ void (*notify)(pa_source*source);
+ pa_usec_t (*get_latency)(pa_source *s);
void *userdata;
};
-struct pa_source* pa_source_new(struct pa_core *core, pa_typeid_t typeid, const char *name, int fail, const struct pa_sample_spec *spec);
-void pa_source_disconnect(struct pa_source *s);
-void pa_source_unref(struct pa_source *s);
-struct pa_source* pa_source_ref(struct pa_source *c);
+pa_source* pa_source_new(pa_core *core, pa_typeid_t typeid, const char *name, int fail, const pa_sample_spec *spec);
+void pa_source_disconnect(pa_source *s);
+void pa_source_unref(pa_source *s);
+pa_source* pa_source_ref(pa_source *c);
/* Pass a new memory block to all output streams */
-void pa_source_post(struct pa_source*s, const struct pa_memchunk *b);
+void pa_source_post(pa_source*s, const pa_memchunk *b);
-void pa_source_notify(struct pa_source *s);
+void pa_source_notify(pa_source *s);
-void pa_source_set_owner(struct pa_source *s, struct pa_module *m);
+void pa_source_set_owner(pa_source *s, pa_module *m);
-pa_usec_t pa_source_get_latency(struct pa_source *s);
+pa_usec_t pa_source_get_latency(pa_source *s);
#endif
diff --git a/polyp/strbuf.c b/polyp/strbuf.c
index 1aa710ea..aa20218a 100644
--- a/polyp/strbuf.c
+++ b/polyp/strbuf.c
@@ -46,14 +46,14 @@ struct pa_strbuf {
struct chunk *head, *tail;
};
-struct pa_strbuf *pa_strbuf_new(void) {
- struct pa_strbuf *sb = pa_xmalloc(sizeof(struct pa_strbuf));
+pa_strbuf *pa_strbuf_new(void) {
+ pa_strbuf *sb = pa_xmalloc(sizeof(pa_strbuf));
sb->length = 0;
sb->head = sb->tail = NULL;
return sb;
}
-void pa_strbuf_free(struct pa_strbuf *sb) {
+void pa_strbuf_free(pa_strbuf *sb) {
assert(sb);
while (sb->head) {
struct chunk *c = sb->head;
@@ -66,7 +66,7 @@ void pa_strbuf_free(struct pa_strbuf *sb) {
/* Make a C string from the string buffer. The caller has to free
* string with pa_xfree(). */
-char *pa_strbuf_tostring(struct pa_strbuf *sb) {
+char *pa_strbuf_tostring(pa_strbuf *sb) {
char *t, *e;
struct chunk *c;
assert(sb);
@@ -88,7 +88,7 @@ char *pa_strbuf_tostring(struct pa_strbuf *sb) {
}
/* Combination of pa_strbuf_free() and pa_strbuf_tostring() */
-char *pa_strbuf_tostring_free(struct pa_strbuf *sb) {
+char *pa_strbuf_tostring_free(pa_strbuf *sb) {
char *t;
assert(sb);
t = pa_strbuf_tostring(sb);
@@ -97,13 +97,13 @@ char *pa_strbuf_tostring_free(struct pa_strbuf *sb) {
}
/* Append a string to the string buffer */
-void pa_strbuf_puts(struct pa_strbuf *sb, const char *t) {
+void pa_strbuf_puts(pa_strbuf *sb, const char *t) {
assert(sb && t);
pa_strbuf_putsn(sb, t, strlen(t));
}
/* Append a new chunk to the linked list */
-static void append(struct pa_strbuf *sb, struct chunk *c) {
+static void append(pa_strbuf *sb, struct chunk *c) {
assert(sb && c);
if (sb->tail) {
@@ -120,7 +120,7 @@ static void append(struct pa_strbuf *sb, struct chunk *c) {
}
/* Append up to l bytes of a string to the string buffer */
-void pa_strbuf_putsn(struct pa_strbuf *sb, const char *t, size_t l) {
+void pa_strbuf_putsn(pa_strbuf *sb, const char *t, size_t l) {
struct chunk *c;
assert(sb && t);
@@ -136,7 +136,7 @@ void pa_strbuf_putsn(struct pa_strbuf *sb, const char *t, size_t l) {
/* Append a printf() style formatted string to the string buffer. */
/* The following is based on an example from the GNU libc documentation */
-int pa_strbuf_printf(struct pa_strbuf *sb, const char *format, ...) {
+int pa_strbuf_printf(pa_strbuf *sb, const char *format, ...) {
int size = 100;
struct chunk *c = NULL;
diff --git a/polyp/strbuf.h b/polyp/strbuf.h
index 281eee1e..a88f5190 100644
--- a/polyp/strbuf.h
+++ b/polyp/strbuf.h
@@ -22,17 +22,17 @@
USA.
***/
-#include "gcc-printf.h"
+#include "gccmacro.h"
-struct pa_strbuf;
+typedef struct pa_strbuf pa_strbuf;
-struct pa_strbuf *pa_strbuf_new(void);
-void pa_strbuf_free(struct pa_strbuf *sb);
-char *pa_strbuf_tostring(struct pa_strbuf *sb);
-char *pa_strbuf_tostring_free(struct pa_strbuf *sb);
+pa_strbuf *pa_strbuf_new(void);
+void pa_strbuf_free(pa_strbuf *sb);
+char *pa_strbuf_tostring(pa_strbuf *sb);
+char *pa_strbuf_tostring_free(pa_strbuf *sb);
-int pa_strbuf_printf(struct pa_strbuf *sb, const char *format, ...) PA_GCC_PRINTF_ATTR(2,3);
-void pa_strbuf_puts(struct pa_strbuf *sb, const char *t);
-void pa_strbuf_putsn(struct pa_strbuf *sb, const char *t, size_t m);
+int pa_strbuf_printf(pa_strbuf *sb, const char *format, ...) PA_GCC_PRINTF_ATTR(2,3);
+void pa_strbuf_puts(pa_strbuf *sb, const char *t);
+void pa_strbuf_putsn(pa_strbuf *sb, const char *t, size_t m);
#endif
diff --git a/polyp/strlist-test.c b/polyp/strlist-test.c
index b68a0415..c670a105 100644
--- a/polyp/strlist-test.c
+++ b/polyp/strlist-test.c
@@ -2,10 +2,11 @@
#include "strlist.h"
#include "xmalloc.h"
+#include "gccmacro.h"
-int main(int argc, char* argv[]) {
+int main(PA_GCC_UNUSED int argc, PA_GCC_UNUSED char* argv[]) {
char *t, *u;
- struct pa_strlist *l = NULL;
+ pa_strlist *l = NULL;
l = pa_strlist_prepend(l, "e");
l = pa_strlist_prepend(l, "d");
diff --git a/polyp/strlist.c b/polyp/strlist.c
index 6dc865d1..09eb0c8a 100644
--- a/polyp/strlist.c
+++ b/polyp/strlist.c
@@ -32,22 +32,22 @@
#include "util.h"
struct pa_strlist {
- struct pa_strlist *next;
+ pa_strlist *next;
char *str;
};
-struct pa_strlist* pa_strlist_prepend(struct pa_strlist *l, const char *s) {
- struct pa_strlist *n;
+pa_strlist* pa_strlist_prepend(pa_strlist *l, const char *s) {
+ pa_strlist *n;
assert(s);
- n = pa_xmalloc(sizeof(struct pa_strlist));
+ n = pa_xmalloc(sizeof(pa_strlist));
n->str = pa_xstrdup(s);
n->next = l;
return n;
}
-char *pa_strlist_tostring(struct pa_strlist *l) {
+char *pa_strlist_tostring(pa_strlist *l) {
int first = 1;
- struct pa_strbuf *b;
+ pa_strbuf *b;
b = pa_strbuf_new();
for (; l; l = l->next) {
@@ -60,13 +60,13 @@ char *pa_strlist_tostring(struct pa_strlist *l) {
return pa_strbuf_tostring_free(b);
}
-struct pa_strlist* pa_strlist_remove(struct pa_strlist *l, const char *s) {
- struct pa_strlist *ret = l, *prev = NULL;
+pa_strlist* pa_strlist_remove(pa_strlist *l, const char *s) {
+ pa_strlist *ret = l, *prev = NULL;
assert(l && s);
while (l) {
if (!strcmp(l->str, s)) {
- struct pa_strlist *n = l->next;
+ pa_strlist *n = l->next;
if (!prev) {
assert(ret == l);
@@ -88,9 +88,9 @@ struct pa_strlist* pa_strlist_remove(struct pa_strlist *l, const char *s) {
return ret;
}
-void pa_strlist_free(struct pa_strlist *l) {
+void pa_strlist_free(pa_strlist *l) {
while (l) {
- struct pa_strlist *c = l;
+ pa_strlist *c = l;
l = l->next;
pa_xfree(c->str);
@@ -98,8 +98,8 @@ void pa_strlist_free(struct pa_strlist *l) {
}
}
-struct pa_strlist* pa_strlist_pop(struct pa_strlist *l, char **s) {
- struct pa_strlist *r;
+pa_strlist* pa_strlist_pop(pa_strlist *l, char **s) {
+ pa_strlist *r;
assert(s);
if (!l) {
@@ -113,15 +113,15 @@ struct pa_strlist* pa_strlist_pop(struct pa_strlist *l, char **s) {
return r;
}
-struct pa_strlist* pa_strlist_parse(const char *s) {
- struct pa_strlist *head = NULL, *p = NULL;
+pa_strlist* pa_strlist_parse(const char *s) {
+ pa_strlist *head = NULL, *p = NULL;
const char *state = NULL;
char *r;
while ((r = pa_split_spaces(s, &state))) {
- struct pa_strlist *n;
+ pa_strlist *n;
- n = pa_xmalloc(sizeof(struct pa_strlist));
+ n = pa_xmalloc(sizeof(pa_strlist));
n->str = r;
n->next = NULL;
diff --git a/polyp/strlist.h b/polyp/strlist.h
index 533f5533..2c54dc74 100644
--- a/polyp/strlist.h
+++ b/polyp/strlist.h
@@ -22,26 +22,26 @@
USA.
***/
-struct pa_strlist;
+typedef struct pa_strlist pa_strlist;
/* Add the specified server string to the list, return the new linked list head */
-struct pa_strlist* pa_strlist_prepend(struct pa_strlist *l, const char *s);
+pa_strlist* pa_strlist_prepend(pa_strlist *l, const char *s);
/* Remove the specified string from the list, return the new linked list head */
-struct pa_strlist* pa_strlist_remove(struct pa_strlist *l, const char *s);
+pa_strlist* pa_strlist_remove(pa_strlist *l, const char *s);
/* Make a whitespace separated string of all server stringes. Returned memory has to be freed with pa_xfree() */
-char *pa_strlist_tostring(struct pa_strlist *l);
+char *pa_strlist_tostring(pa_strlist *l);
/* Free the entire list */
-void pa_strlist_free(struct pa_strlist *l);
+void pa_strlist_free(pa_strlist *l);
/* Return the next entry in the list in *string and remove it from
* the list. Returns the new list head. The memory *string points to
* has to be freed with pa_xfree() */
-struct pa_strlist* pa_strlist_pop(struct pa_strlist *l, char **s);
+pa_strlist* pa_strlist_pop(pa_strlist *l, char **s);
/* Parse a whitespace separated server list */
-struct pa_strlist* pa_strlist_parse(const char *s);
+pa_strlist* pa_strlist_parse(const char *s);
#endif
diff --git a/polyp/subscribe.c b/polyp/subscribe.c
index ee6ef3aa..d3db90f7 100644
--- a/polyp/subscribe.c
+++ b/polyp/subscribe.c
@@ -39,28 +39,28 @@
* called from within the stack frame the entity was created in. */
struct pa_subscription {
- struct pa_core *core;
+ pa_core *core;
int dead;
- void (*callback)(struct pa_core *c, enum pa_subscription_event_type t, uint32_t index, void *userdata);
+ void (*callback)(pa_core *c, pa_subscription_event_type t, uint32_t index, void *userdata);
void *userdata;
- enum pa_subscription_mask mask;
+ pa_subscription_mask mask;
- struct pa_subscription *prev, *next;
+ pa_subscription *prev, *next;
};
struct pa_subscription_event {
- enum pa_subscription_event_type type;
+ pa_subscription_event_type type;
uint32_t index;
};
-static void sched_event(struct pa_core *c);
+static void sched_event(pa_core *c);
/* Allocate a new subscription object for the given subscription mask. Use the specified callback function and user data */
-struct pa_subscription* pa_subscription_new(struct pa_core *c, enum pa_subscription_mask m, void (*callback)(struct pa_core *c, enum pa_subscription_event_type t, uint32_t index, void *userdata), void *userdata) {
- struct pa_subscription *s;
+pa_subscription* pa_subscription_new(pa_core *c, pa_subscription_mask m, void (*callback)(pa_core *c, pa_subscription_event_type t, uint32_t index, void *userdata), void *userdata) {
+ pa_subscription *s;
assert(c);
- s = pa_xmalloc(sizeof(struct pa_subscription));
+ s = pa_xmalloc(sizeof(pa_subscription));
s->core = c;
s->dead = 0;
s->callback = callback;
@@ -75,13 +75,13 @@ struct pa_subscription* pa_subscription_new(struct pa_core *c, enum pa_subscript
}
/* Free a subscription object, effectively marking it for deletion */
-void pa_subscription_free(struct pa_subscription*s) {
+void pa_subscription_free(pa_subscription*s) {
assert(s && !s->dead);
s->dead = 1;
sched_event(s->core);
}
-static void free_item(struct pa_subscription *s) {
+static void free_item(pa_subscription *s) {
assert(s && s->core);
if (s->prev)
@@ -96,8 +96,8 @@ static void free_item(struct pa_subscription *s) {
}
/* Free all subscription objects */
-void pa_subscription_free_all(struct pa_core *c) {
- struct pa_subscription_event *e;
+void pa_subscription_free_all(pa_core *c) {
+ pa_subscription_event *e;
assert(c);
while (c->subscriptions)
@@ -117,7 +117,7 @@ void pa_subscription_free_all(struct pa_core *c) {
}
}
-/*static void dump_event(struct pa_subscription_event*e) {
+/*static void dump_event(pa_subscription_event*e) {
switch (e->type & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) {
case PA_SUBSCRIPTION_EVENT_SINK:
pa_log(__FILE__": SINK_EVENT");
@@ -161,10 +161,10 @@ void pa_subscription_free_all(struct pa_core *c) {
}*/
/* Deferred callback for dispatching subscirption events */
-static void defer_cb(struct pa_mainloop_api *m, struct pa_defer_event *e, void *userdata) {
- struct pa_core *c = userdata;
- struct pa_subscription *s;
- assert(c && c->subscription_defer_event == e && c->mainloop == m);
+static void defer_cb(pa_mainloop_api *m, pa_defer_event *de, void *userdata) {
+ pa_core *c = userdata;
+ pa_subscription *s;
+ assert(c && c->subscription_defer_event == de && c->mainloop == m);
c->mainloop->defer_enable(c->subscription_defer_event, 0);
@@ -172,10 +172,9 @@ static void defer_cb(struct pa_mainloop_api *m, struct pa_defer_event *e, void *
/* Dispatch queued events */
if (c->subscription_event_queue) {
- struct pa_subscription_event *e;
+ pa_subscription_event *e;
while ((e = pa_queue_pop(c->subscription_event_queue))) {
- struct pa_subscription *s;
for (s = c->subscriptions; s; s = s->next) {
@@ -191,7 +190,7 @@ static void defer_cb(struct pa_mainloop_api *m, struct pa_defer_event *e, void *
s = c->subscriptions;
while (s) {
- struct pa_subscription *n = s->next;
+ pa_subscription *n = s->next;
if (s->dead)
free_item(s);
s = n;
@@ -199,7 +198,7 @@ static void defer_cb(struct pa_mainloop_api *m, struct pa_defer_event *e, void *
}
/* Schedule an mainloop event so that a pending subscription event is dispatched */
-static void sched_event(struct pa_core *c) {
+static void sched_event(pa_core *c) {
assert(c);
if (!c->subscription_defer_event) {
@@ -211,11 +210,11 @@ static void sched_event(struct pa_core *c) {
}
/* Append a new subscription event to the subscription event queue and schedule a main loop event */
-void pa_subscription_post(struct pa_core *c, enum pa_subscription_event_type t, uint32_t index) {
- struct pa_subscription_event *e;
+void pa_subscription_post(pa_core *c, pa_subscription_event_type t, uint32_t index) {
+ pa_subscription_event *e;
assert(c);
- e = pa_xmalloc(sizeof(struct pa_subscription_event));
+ e = pa_xmalloc(sizeof(pa_subscription_event));
e->type = t;
e->index = index;
diff --git a/polyp/subscribe.h b/polyp/subscribe.h
index 38323faf..6980328f 100644
--- a/polyp/subscribe.h
+++ b/polyp/subscribe.h
@@ -22,16 +22,16 @@
USA.
***/
+typedef struct pa_subscription pa_subscription;
+typedef struct pa_subscription_event pa_subscription_event;
+
#include "core.h"
#include "native-common.h"
-struct pa_subscription;
-struct pa_subscription_event;
-
-struct pa_subscription* pa_subscription_new(struct pa_core *c, enum pa_subscription_mask m, void (*callback)(struct pa_core *c, enum pa_subscription_event_type t, uint32_t index, void *userdata), void *userdata);
-void pa_subscription_free(struct pa_subscription*s);
-void pa_subscription_free_all(struct pa_core *c);
+pa_subscription* pa_subscription_new(pa_core *c, pa_subscription_mask m, void (*callback)(pa_core *c, pa_subscription_event_type t, uint32_t index, void *userdata), void *userdata);
+void pa_subscription_free(pa_subscription*s);
+void pa_subscription_free_all(pa_core *c);
-void pa_subscription_post(struct pa_core *c, enum pa_subscription_event_type t, uint32_t index);
+void pa_subscription_post(pa_core *c, pa_subscription_event_type t, uint32_t idx);
#endif
diff --git a/polyp/tagstruct.c b/polyp/tagstruct.c
index 1ff09cd1..28b1afa6 100644
--- a/polyp/tagstruct.c
+++ b/polyp/tagstruct.c
@@ -65,12 +65,12 @@ struct pa_tagstruct {
int dynamic;
};
-struct pa_tagstruct *pa_tagstruct_new(const uint8_t* data, size_t length) {
- struct pa_tagstruct*t;
+pa_tagstruct *pa_tagstruct_new(const uint8_t* data, size_t length) {
+ pa_tagstruct*t;
assert(!data || (data && length));
- t = pa_xmalloc(sizeof(struct pa_tagstruct));
+ t = pa_xmalloc(sizeof(pa_tagstruct));
t->data = (uint8_t*) data;
t->allocated = t->length = data ? length : 0;
t->rindex = 0;
@@ -78,14 +78,14 @@ struct pa_tagstruct *pa_tagstruct_new(const uint8_t* data, size_t length) {
return t;
}
-void pa_tagstruct_free(struct pa_tagstruct*t) {
+void pa_tagstruct_free(pa_tagstruct*t) {
assert(t);
if (t->dynamic)
pa_xfree(t->data);
pa_xfree(t);
}
-uint8_t* pa_tagstruct_free_data(struct pa_tagstruct*t, size_t *l) {
+uint8_t* pa_tagstruct_free_data(pa_tagstruct*t, size_t *l) {
uint8_t *p;
assert(t && t->dynamic && l);
p = t->data;
@@ -94,7 +94,7 @@ uint8_t* pa_tagstruct_free_data(struct pa_tagstruct*t, size_t *l) {
return p;
}
-static void extend(struct pa_tagstruct*t, size_t l) {
+static void extend(pa_tagstruct*t, size_t l) {
assert(t && t->dynamic);
if (t->length+l <= t->allocated)
@@ -103,7 +103,7 @@ static void extend(struct pa_tagstruct*t, size_t l) {
t->data = pa_xrealloc(t->data, t->allocated = t->length+l+100);
}
-void pa_tagstruct_puts(struct pa_tagstruct*t, const char *s) {
+void pa_tagstruct_puts(pa_tagstruct*t, const char *s) {
size_t l;
assert(t);
if (s) {
@@ -119,7 +119,7 @@ void pa_tagstruct_puts(struct pa_tagstruct*t, const char *s) {
}
}
-void pa_tagstruct_putu32(struct pa_tagstruct*t, uint32_t i) {
+void pa_tagstruct_putu32(pa_tagstruct*t, uint32_t i) {
assert(t);
extend(t, 5);
t->data[t->length] = TAG_U32;
@@ -128,7 +128,7 @@ void pa_tagstruct_putu32(struct pa_tagstruct*t, uint32_t i) {
t->length += 5;
}
-void pa_tagstruct_putu8(struct pa_tagstruct*t, uint8_t c) {
+void pa_tagstruct_putu8(pa_tagstruct*t, uint8_t c) {
assert(t);
extend(t, 2);
t->data[t->length] = TAG_U8;
@@ -136,7 +136,7 @@ void pa_tagstruct_putu8(struct pa_tagstruct*t, uint8_t c) {
t->length += 2;
}
-void pa_tagstruct_put_sample_spec(struct pa_tagstruct *t, const struct pa_sample_spec *ss) {
+void pa_tagstruct_put_sample_spec(pa_tagstruct *t, const pa_sample_spec *ss) {
uint32_t rate;
assert(t && ss);
extend(t, 7);
@@ -148,7 +148,7 @@ void pa_tagstruct_put_sample_spec(struct pa_tagstruct *t, const struct pa_sample
t->length += 7;
}
-void pa_tagstruct_put_arbitrary(struct pa_tagstruct *t, const void *p, size_t length) {
+void pa_tagstruct_put_arbitrary(pa_tagstruct *t, const void *p, size_t length) {
uint32_t tmp;
assert(t && p);
@@ -161,14 +161,14 @@ void pa_tagstruct_put_arbitrary(struct pa_tagstruct *t, const void *p, size_t le
t->length += 5+length;
}
-void pa_tagstruct_put_boolean(struct pa_tagstruct*t, int b) {
+void pa_tagstruct_put_boolean(pa_tagstruct*t, int b) {
assert(t);
extend(t, 1);
t->data[t->length] = b ? TAG_BOOLEAN_TRUE : TAG_BOOLEAN_FALSE;
t->length += 1;
}
-void pa_tagstruct_put_timeval(struct pa_tagstruct*t, const struct timeval *tv) {
+void pa_tagstruct_put_timeval(pa_tagstruct*t, const struct timeval *tv) {
uint32_t tmp;
assert(t);
extend(t, 9);
@@ -180,7 +180,7 @@ void pa_tagstruct_put_timeval(struct pa_tagstruct*t, const struct timeval *tv) {
t->length += 9;
}
-void pa_tagstruct_put_usec(struct pa_tagstruct*t, pa_usec_t u) {
+void pa_tagstruct_put_usec(pa_tagstruct*t, pa_usec_t u) {
uint32_t tmp;
assert(t);
extend(t, 9);
@@ -192,7 +192,7 @@ void pa_tagstruct_put_usec(struct pa_tagstruct*t, pa_usec_t u) {
t->length += 9;
}
-void pa_tagstruct_putu64(struct pa_tagstruct*t, uint64_t u) {
+void pa_tagstruct_putu64(pa_tagstruct*t, uint64_t u) {
uint32_t tmp;
assert(t);
extend(t, 9);
@@ -204,7 +204,7 @@ void pa_tagstruct_putu64(struct pa_tagstruct*t, uint64_t u) {
t->length += 9;
}
-int pa_tagstruct_gets(struct pa_tagstruct*t, const char **s) {
+int pa_tagstruct_gets(pa_tagstruct*t, const char **s) {
int error = 0;
size_t n;
char *c;
@@ -241,7 +241,7 @@ int pa_tagstruct_gets(struct pa_tagstruct*t, const char **s) {
return 0;
}
-int pa_tagstruct_getu32(struct pa_tagstruct*t, uint32_t *i) {
+int pa_tagstruct_getu32(pa_tagstruct*t, uint32_t *i) {
assert(t && i);
if (t->rindex+5 > t->length)
@@ -256,7 +256,7 @@ int pa_tagstruct_getu32(struct pa_tagstruct*t, uint32_t *i) {
return 0;
}
-int pa_tagstruct_getu8(struct pa_tagstruct*t, uint8_t *c) {
+int pa_tagstruct_getu8(pa_tagstruct*t, uint8_t *c) {
assert(t && c);
if (t->rindex+2 > t->length)
@@ -270,7 +270,7 @@ int pa_tagstruct_getu8(struct pa_tagstruct*t, uint8_t *c) {
return 0;
}
-int pa_tagstruct_get_sample_spec(struct pa_tagstruct *t, struct pa_sample_spec *ss) {
+int pa_tagstruct_get_sample_spec(pa_tagstruct *t, pa_sample_spec *ss) {
assert(t && ss);
if (t->rindex+7 > t->length)
@@ -288,7 +288,7 @@ int pa_tagstruct_get_sample_spec(struct pa_tagstruct *t, struct pa_sample_spec *
return 0;
}
-int pa_tagstruct_get_arbitrary(struct pa_tagstruct *t, const void **p, size_t length) {
+int pa_tagstruct_get_arbitrary(pa_tagstruct *t, const void **p, size_t length) {
uint32_t len;
assert(t && p);
@@ -307,18 +307,18 @@ int pa_tagstruct_get_arbitrary(struct pa_tagstruct *t, const void **p, size_t le
return 0;
}
-int pa_tagstruct_eof(struct pa_tagstruct*t) {
+int pa_tagstruct_eof(pa_tagstruct*t) {
assert(t);
return t->rindex >= t->length;
}
-const uint8_t* pa_tagstruct_data(struct pa_tagstruct*t, size_t *l) {
+const uint8_t* pa_tagstruct_data(pa_tagstruct*t, size_t *l) {
assert(t && t->dynamic && l);
*l = t->length;
return t->data;
}
-int pa_tagstruct_get_boolean(struct pa_tagstruct*t, int *b) {
+int pa_tagstruct_get_boolean(pa_tagstruct*t, int *b) {
assert(t && b);
if (t->rindex+1 > t->length)
@@ -335,7 +335,7 @@ int pa_tagstruct_get_boolean(struct pa_tagstruct*t, int *b) {
return 0;
}
-int pa_tagstruct_get_timeval(struct pa_tagstruct*t, struct timeval *tv) {
+int pa_tagstruct_get_timeval(pa_tagstruct*t, struct timeval *tv) {
if (t->rindex+9 > t->length)
return -1;
@@ -352,7 +352,7 @@ int pa_tagstruct_get_timeval(struct pa_tagstruct*t, struct timeval *tv) {
}
-int pa_tagstruct_get_usec(struct pa_tagstruct*t, pa_usec_t *u) {
+int pa_tagstruct_get_usec(pa_tagstruct*t, pa_usec_t *u) {
uint32_t tmp;
assert(t && u);
@@ -370,7 +370,7 @@ int pa_tagstruct_get_usec(struct pa_tagstruct*t, pa_usec_t *u) {
return 0;
}
-int pa_tagstruct_getu64(struct pa_tagstruct*t, uint64_t *u) {
+int pa_tagstruct_getu64(pa_tagstruct*t, uint64_t *u) {
uint32_t tmp;
assert(t && u);
diff --git a/polyp/tagstruct.h b/polyp/tagstruct.h
index 135825e6..85b324b7 100644
--- a/polyp/tagstruct.h
+++ b/polyp/tagstruct.h
@@ -29,33 +29,33 @@
#include "sample.h"
-struct pa_tagstruct;
-
-struct pa_tagstruct *pa_tagstruct_new(const uint8_t* data, size_t length);
-void pa_tagstruct_free(struct pa_tagstruct*t);
-uint8_t* pa_tagstruct_free_data(struct pa_tagstruct*t, size_t *l);
-
-void pa_tagstruct_puts(struct pa_tagstruct*t, const char *s);
-void pa_tagstruct_putu8(struct pa_tagstruct*t, uint8_t c);
-void pa_tagstruct_putu32(struct pa_tagstruct*t, uint32_t i);
-void pa_tagstruct_putu64(struct pa_tagstruct*t, uint64_t i);
-void pa_tagstruct_put_sample_spec(struct pa_tagstruct *t, const struct pa_sample_spec *ss);
-void pa_tagstruct_put_arbitrary(struct pa_tagstruct*t, const void *p, size_t length);
-void pa_tagstruct_put_boolean(struct pa_tagstruct*t, int b);
-void pa_tagstruct_put_timeval(struct pa_tagstruct*t, const struct timeval *tv);
-void pa_tagstruct_put_usec(struct pa_tagstruct*t, pa_usec_t u);
-
-int pa_tagstruct_gets(struct pa_tagstruct*t, const char **s);
-int pa_tagstruct_getu8(struct pa_tagstruct*t, uint8_t *c);
-int pa_tagstruct_getu32(struct pa_tagstruct*t, uint32_t *i);
-int pa_tagstruct_getu64(struct pa_tagstruct*t, uint64_t *i);
-int pa_tagstruct_get_sample_spec(struct pa_tagstruct *t, struct pa_sample_spec *ss);
-int pa_tagstruct_get_arbitrary(struct pa_tagstruct *t, const void **p, size_t length);
-int pa_tagstruct_get_boolean(struct pa_tagstruct *t, int *b);
-int pa_tagstruct_get_timeval(struct pa_tagstruct*t, struct timeval *tv);
-int pa_tagstruct_get_usec(struct pa_tagstruct*t, pa_usec_t *u);
-
-int pa_tagstruct_eof(struct pa_tagstruct*t);
-const uint8_t* pa_tagstruct_data(struct pa_tagstruct*t, size_t *l);
+typedef struct pa_tagstruct pa_tagstruct;
+
+pa_tagstruct *pa_tagstruct_new(const uint8_t* data, size_t length);
+void pa_tagstruct_free(pa_tagstruct*t);
+uint8_t* pa_tagstruct_free_data(pa_tagstruct*t, size_t *l);
+
+void pa_tagstruct_puts(pa_tagstruct*t, const char *s);
+void pa_tagstruct_putu8(pa_tagstruct*t, uint8_t c);
+void pa_tagstruct_putu32(pa_tagstruct*t, uint32_t i);
+void pa_tagstruct_putu64(pa_tagstruct*t, uint64_t i);
+void pa_tagstruct_put_sample_spec(pa_tagstruct *t, const pa_sample_spec *ss);
+void pa_tagstruct_put_arbitrary(pa_tagstruct*t, const void *p, size_t length);
+void pa_tagstruct_put_boolean(pa_tagstruct*t, int b);
+void pa_tagstruct_put_timeval(pa_tagstruct*t, const struct timeval *tv);
+void pa_tagstruct_put_usec(pa_tagstruct*t, pa_usec_t u);
+
+int pa_tagstruct_gets(pa_tagstruct*t, const char **s);
+int pa_tagstruct_getu8(pa_tagstruct*t, uint8_t *c);
+int pa_tagstruct_getu32(pa_tagstruct*t, uint32_t *i);
+int pa_tagstruct_getu64(pa_tagstruct*t, uint64_t *i);
+int pa_tagstruct_get_sample_spec(pa_tagstruct *t, pa_sample_spec *ss);
+int pa_tagstruct_get_arbitrary(pa_tagstruct *t, const void **p, size_t length);
+int pa_tagstruct_get_boolean(pa_tagstruct *t, int *b);
+int pa_tagstruct_get_timeval(pa_tagstruct*t, struct timeval *tv);
+int pa_tagstruct_get_usec(pa_tagstruct*t, pa_usec_t *u);
+
+int pa_tagstruct_eof(pa_tagstruct*t);
+const uint8_t* pa_tagstruct_data(pa_tagstruct*t, size_t *l);
#endif
diff --git a/polyp/tokenizer.c b/polyp/tokenizer.c
index 8ccbc84f..5e0c1b16 100644
--- a/polyp/tokenizer.c
+++ b/polyp/tokenizer.c
@@ -30,16 +30,17 @@
#include "tokenizer.h"
#include "dynarray.h"
#include "xmalloc.h"
+#include "gccmacro.h"
struct pa_tokenizer {
- struct pa_dynarray *dynarray;
+ pa_dynarray *dynarray;
};
-static void token_free(void *p, void *userdata) {
+static void token_free(void *p, PA_GCC_UNUSED void *userdata) {
pa_xfree(p);
}
-static void parse(struct pa_dynarray*a, const char *s, unsigned args) {
+static void parse(pa_dynarray*a, const char *s, unsigned args) {
int infty = 0;
const char delimiter[] = " \t\n\r";
const char *p;
@@ -64,10 +65,10 @@ static void parse(struct pa_dynarray*a, const char *s, unsigned args) {
}
}
-struct pa_tokenizer* pa_tokenizer_new(const char *s, unsigned args) {
- struct pa_tokenizer *t;
+pa_tokenizer* pa_tokenizer_new(const char *s, unsigned args) {
+ pa_tokenizer *t;
- t = pa_xmalloc(sizeof(struct pa_tokenizer));
+ t = pa_xmalloc(sizeof(pa_tokenizer));
t->dynarray = pa_dynarray_new();
assert(t->dynarray);
@@ -75,13 +76,13 @@ struct pa_tokenizer* pa_tokenizer_new(const char *s, unsigned args) {
return t;
}
-void pa_tokenizer_free(struct pa_tokenizer *t) {
+void pa_tokenizer_free(pa_tokenizer *t) {
assert(t);
pa_dynarray_free(t->dynarray, token_free, NULL);
pa_xfree(t);
}
-const char *pa_tokenizer_get(struct pa_tokenizer *t, unsigned i) {
+const char *pa_tokenizer_get(pa_tokenizer *t, unsigned i) {
assert(t);
return pa_dynarray_get(t->dynarray, i);
}
diff --git a/polyp/tokenizer.h b/polyp/tokenizer.h
index 0b1c5022..bedacb8a 100644
--- a/polyp/tokenizer.h
+++ b/polyp/tokenizer.h
@@ -22,11 +22,11 @@
USA.
***/
-struct pa_tokenizer;
+typedef struct pa_tokenizer pa_tokenizer;
-struct pa_tokenizer* pa_tokenizer_new(const char *s, unsigned args);
-void pa_tokenizer_free(struct pa_tokenizer *t);
+pa_tokenizer* pa_tokenizer_new(const char *s, unsigned args);
+void pa_tokenizer_free(pa_tokenizer *t);
-const char *pa_tokenizer_get(struct pa_tokenizer *t, unsigned i);
+const char *pa_tokenizer_get(pa_tokenizer *t, unsigned i);
#endif
diff --git a/polyp/util.c b/polyp/util.c
index 26d71203..f9098704 100644
--- a/polyp/util.c
+++ b/polyp/util.c
@@ -219,7 +219,7 @@ ssize_t pa_loop_write(int fd, const void*data, size_t size) {
break;
ret += r;
- data = (uint8_t*) data + r;
+ data = (const uint8_t*) data + r;
size -= r;
}
@@ -767,13 +767,13 @@ finish:
/* Check the current user is member of the specified group */
int pa_uid_in_group(const char *name, gid_t *gid) {
- gid_t *gids, tgid;
- GETGROUPS_T n = sysconf(_SC_NGROUPS_MAX);
+ GETGROUPS_T *gids, tgid;
+ int n = sysconf(_SC_NGROUPS_MAX);
int r = -1, i;
assert(n > 0);
- gids = pa_xmalloc(sizeof(gid_t)*n);
+ gids = pa_xmalloc(sizeof(GETGROUPS_T)*n);
if ((n = getgroups(n, gids)) < 0) {
pa_log(__FILE__": getgroups() failed: %s\n", strerror(errno));
diff --git a/polyp/util.h b/polyp/util.h
index d9e18ddb..95e7b99b 100644
--- a/polyp/util.h
+++ b/polyp/util.h
@@ -27,7 +27,7 @@
#include <stdarg.h>
#include <stdio.h>
-#include "gcc-printf.h"
+#include "gccmacro.h"
#include "sample.h"
struct timeval;
diff --git a/polyp/voltest.c b/polyp/voltest.c
index d8d5c569..286334d0 100644
--- a/polyp/voltest.c
+++ b/polyp/voltest.c
@@ -3,8 +3,9 @@
#include <stdio.h>
#include <polyp/sample.h>
+#include "gccmacro.h"
-int main() {
+int main(PA_GCC_UNUSED int argc, PA_GCC_UNUSED char *argv[]) {
int p;
for (p = 0; p <= 200; p++) {
pa_volume_t v = pa_volume_from_user((double) p/100);
diff --git a/polyp/x11wrap.c b/polyp/x11wrap.c
index 4d8d6930..64923320 100644
--- a/polyp/x11wrap.c
+++ b/polyp/x11wrap.c
@@ -28,42 +28,42 @@
#include "log.h"
#include "props.h"
-struct pa_x11_client;
+typedef struct pa_x11_internal pa_x11_internal;
struct pa_x11_internal {
- PA_LLIST_FIELDS(struct pa_x11_internal);
- struct pa_x11_wrapper *wrapper;
- struct pa_io_event* io_event;
+ PA_LLIST_FIELDS(pa_x11_internal);
+ pa_x11_wrapper *wrapper;
+ pa_io_event* io_event;
int fd;
};
struct pa_x11_wrapper {
- struct pa_core *core;
+ pa_core *core;
int ref;
char *property_name;
Display *display;
- struct pa_defer_event* defer_event;
- struct pa_io_event* io_event;
+ pa_defer_event* defer_event;
+ pa_io_event* io_event;
- PA_LLIST_HEAD(struct pa_x11_client, clients);
- PA_LLIST_HEAD(struct pa_x11_internal, internals);
+ PA_LLIST_HEAD(pa_x11_client, clients);
+ PA_LLIST_HEAD(pa_x11_internal, internals);
};
struct pa_x11_client {
- PA_LLIST_FIELDS(struct pa_x11_client);
- struct pa_x11_wrapper *wrapper;
- int (*callback)(struct pa_x11_wrapper *w, XEvent *e, void *userdata);
+ PA_LLIST_FIELDS(pa_x11_client);
+ pa_x11_wrapper *wrapper;
+ int (*callback)(pa_x11_wrapper *w, XEvent *e, void *userdata);
void *userdata;
};
/* Dispatch all pending X11 events */
-static void work(struct pa_x11_wrapper *w) {
+static void work(pa_x11_wrapper *w) {
assert(w && w->ref >= 1);
while (XPending(w->display)) {
- struct pa_x11_client *c;
+ pa_x11_client *c;
XEvent e;
XNextEvent(w->display, &e);
@@ -76,63 +76,63 @@ static void work(struct pa_x11_wrapper *w) {
}
/* IO notification event for the X11 display connection */
-static void display_io_event(struct pa_mainloop_api *m, struct pa_io_event *e, int fd, enum pa_io_event_flags f, void *userdata) {
- struct pa_x11_wrapper *w = userdata;
+static void display_io_event(pa_mainloop_api *m, pa_io_event *e, int fd, PA_GCC_UNUSED pa_io_event_flags f, void *userdata) {
+ pa_x11_wrapper *w = userdata;
assert(m && e && fd >= 0 && w && w->ref >= 1);
work(w);
}
/* Deferred notification event. Called once each main loop iteration */
-static void defer_event(struct pa_mainloop_api *m, struct pa_defer_event *e, void *userdata) {
- struct pa_x11_wrapper *w = userdata;
+static void defer_event(pa_mainloop_api *m, pa_defer_event *e, void *userdata) {
+ pa_x11_wrapper *w = userdata;
assert(m && e && w && w->ref >= 1);
work(w);
}
/* IO notification event for X11 internal connections */
-static void internal_io_event(struct pa_mainloop_api *m, struct pa_io_event *e, int fd, enum pa_io_event_flags f, void *userdata) {
- struct pa_x11_wrapper *w = userdata;
+static void internal_io_event(pa_mainloop_api *m, pa_io_event *e, int fd, PA_GCC_UNUSED pa_io_event_flags f, void *userdata) {
+ pa_x11_wrapper *w = userdata;
assert(m && e && fd >= 0 && w && w->ref >= 1);
XProcessInternalConnection(w->display, fd);
}
/* Add a new IO source for the specified X11 internal connection */
-static struct pa_x11_internal* x11_internal_add(struct pa_x11_wrapper *w, int fd) {
- struct pa_x11_internal *i;
+static pa_x11_internal* x11_internal_add(pa_x11_wrapper *w, int fd) {
+ pa_x11_internal *i;
assert(i && fd >= 0);
- i = pa_xmalloc(sizeof(struct pa_x11_internal));
+ i = pa_xmalloc(sizeof(pa_x11_internal));
i->wrapper = w;
i->io_event = w->core->mainloop->io_new(w->core->mainloop, fd, PA_IO_EVENT_INPUT, internal_io_event, w);
i->fd = fd;
- PA_LLIST_PREPEND(struct pa_x11_internal, w->internals, i);
+ PA_LLIST_PREPEND(pa_x11_internal, w->internals, i);
return i;
}
/* Remove an IO source for an X11 internal connection */
-void x11_internal_remove(struct pa_x11_wrapper *w, struct pa_x11_internal *i) {
+static void x11_internal_remove(pa_x11_wrapper *w, pa_x11_internal *i) {
assert(i);
- PA_LLIST_REMOVE(struct pa_x11_internal, w->internals, i);
+ PA_LLIST_REMOVE(pa_x11_internal, w->internals, i);
w->core->mainloop->io_free(i->io_event);
pa_xfree(i);
}
/* Implementation of XConnectionWatchProc */
static void x11_watch(Display *display, XPointer userdata, int fd, Bool opening, XPointer *watch_data) {
- struct pa_x11_wrapper *w = (struct pa_x11_wrapper*) userdata;
+ pa_x11_wrapper *w = (pa_x11_wrapper*) userdata;
assert(display && w && fd >= 0);
if (opening)
*watch_data = (XPointer) x11_internal_add(w, fd);
else
- x11_internal_remove(w, (struct pa_x11_internal*) *watch_data);
+ x11_internal_remove(w, (pa_x11_internal*) *watch_data);
}
-static struct pa_x11_wrapper* x11_wrapper_new(struct pa_core *c, const char *name, const char *t) {
- struct pa_x11_wrapper*w;
+static pa_x11_wrapper* x11_wrapper_new(pa_core *c, const char *name, const char *t) {
+ pa_x11_wrapper*w;
Display *d;
int r;
@@ -141,14 +141,14 @@ static struct pa_x11_wrapper* x11_wrapper_new(struct pa_core *c, const char *nam
return NULL;
}
- w = pa_xmalloc(sizeof(struct pa_x11_wrapper));
+ w = pa_xmalloc(sizeof(pa_x11_wrapper));
w->core = c;
w->ref = 1;
w->property_name = pa_xstrdup(t);
w->display = d;
- PA_LLIST_HEAD_INIT(struct pa_x11_client, w->clients);
- PA_LLIST_HEAD_INIT(struct pa_x11_internal, w->internals);
+ PA_LLIST_HEAD_INIT(pa_x11_client, w->clients);
+ PA_LLIST_HEAD_INIT(pa_x11_internal, w->internals);
w->defer_event = c->mainloop->defer_new(c->mainloop, defer_event, w);
w->io_event = c->mainloop->io_new(c->mainloop, ConnectionNumber(d), PA_IO_EVENT_INPUT, display_io_event, w);
@@ -161,7 +161,7 @@ static struct pa_x11_wrapper* x11_wrapper_new(struct pa_core *c, const char *nam
return w;
}
-static void x11_wrapper_free(struct pa_x11_wrapper*w) {
+static void x11_wrapper_free(pa_x11_wrapper*w) {
int r;
assert(w);
@@ -183,9 +183,9 @@ static void x11_wrapper_free(struct pa_x11_wrapper*w) {
pa_xfree(w);
}
-struct pa_x11_wrapper* pa_x11_wrapper_get(struct pa_core *c, const char *name) {
+pa_x11_wrapper* pa_x11_wrapper_get(pa_core *c, const char *name) {
char t[256];
- struct pa_x11_wrapper *w;
+ pa_x11_wrapper *w;
assert(c);
snprintf(t, sizeof(t), "x11-wrapper%s%s", name ? "-" : "", name ? name : "");
@@ -195,41 +195,41 @@ struct pa_x11_wrapper* pa_x11_wrapper_get(struct pa_core *c, const char *name) {
return x11_wrapper_new(c, name, t);
}
-struct pa_x11_wrapper* pa_x11_wrapper_ref(struct pa_x11_wrapper *w) {
+pa_x11_wrapper* pa_x11_wrapper_ref(pa_x11_wrapper *w) {
assert(w && w->ref >= 1);
w->ref++;
return w;
}
-void pa_x11_wrapper_unref(struct pa_x11_wrapper* w) {
+void pa_x11_wrapper_unref(pa_x11_wrapper* w) {
assert(w && w->ref >= 1);
if (!(--w->ref))
x11_wrapper_free(w);
}
-Display *pa_x11_wrapper_get_display(struct pa_x11_wrapper *w) {
+Display *pa_x11_wrapper_get_display(pa_x11_wrapper *w) {
assert(w && w->ref >= 1);
return w->display;
}
-struct pa_x11_client* pa_x11_client_new(struct pa_x11_wrapper *w, int (*cb)(struct pa_x11_wrapper *w, XEvent *e, void *userdata), void *userdata) {
- struct pa_x11_client *c;
+pa_x11_client* pa_x11_client_new(pa_x11_wrapper *w, int (*cb)(pa_x11_wrapper *w, XEvent *e, void *userdata), void *userdata) {
+ pa_x11_client *c;
assert(w && w->ref >= 1);
- c = pa_xmalloc(sizeof(struct pa_x11_client));
+ c = pa_xmalloc(sizeof(pa_x11_client));
c->wrapper = w;
c->callback = cb;
c->userdata = userdata;
- PA_LLIST_PREPEND(struct pa_x11_client, w->clients, c);
+ PA_LLIST_PREPEND(pa_x11_client, w->clients, c);
return c;
}
-void pa_x11_client_free(struct pa_x11_client *c) {
+void pa_x11_client_free(pa_x11_client *c) {
assert(c && c->wrapper && c->wrapper->ref >= 1);
- PA_LLIST_REMOVE(struct pa_x11_client, c->wrapper->clients, c);
+ PA_LLIST_REMOVE(pa_x11_client, c->wrapper->clients, c);
pa_xfree(c);
}
diff --git a/polyp/x11wrap.h b/polyp/x11wrap.h
index 9ed690fe..15645168 100644
--- a/polyp/x11wrap.h
+++ b/polyp/x11wrap.h
@@ -26,27 +26,27 @@
#include "core.h"
-struct pa_x11_wrapper;
+typedef struct pa_x11_wrapper pa_x11_wrapper;
/* Return the X11 wrapper for this core. In case no wrapper was
existant before, allocate a new one */
-struct pa_x11_wrapper* pa_x11_wrapper_get(struct pa_core *c, const char *name);
+pa_x11_wrapper* pa_x11_wrapper_get(pa_core *c, const char *name);
/* Increase the wrapper's reference count by one */
-struct pa_x11_wrapper* pa_x11_wrapper_ref(struct pa_x11_wrapper *w);
+pa_x11_wrapper* pa_x11_wrapper_ref(pa_x11_wrapper *w);
/* Decrease the reference counter of an X11 wrapper object */
-void pa_x11_wrapper_unref(struct pa_x11_wrapper* w);
+void pa_x11_wrapper_unref(pa_x11_wrapper* w);
/* Return the X11 display object for this connection */
-Display *pa_x11_wrapper_get_display(struct pa_x11_wrapper *w);
+Display *pa_x11_wrapper_get_display(pa_x11_wrapper *w);
-struct pa_x11_client;
+typedef struct pa_x11_client pa_x11_client;
/* Register an X11 client, that is called for each X11 event */
-struct pa_x11_client* pa_x11_client_new(struct pa_x11_wrapper *w, int (*cb)(struct pa_x11_wrapper *w, XEvent *e, void *userdata), void *userdata);
+pa_x11_client* pa_x11_client_new(pa_x11_wrapper *w, int (*cb)(pa_x11_wrapper *w, XEvent *e, void *userdata), void *userdata);
/* Free an X11 client object */
-void pa_x11_client_free(struct pa_x11_client *c);
+void pa_x11_client_free(pa_x11_client *c);
#endif
diff --git a/polyp/xmalloc.c b/polyp/xmalloc.c
index f2751e52..bf366347 100644
--- a/polyp/xmalloc.c
+++ b/polyp/xmalloc.c
@@ -30,6 +30,8 @@
#include "memory.h"
#include "util.h"
+#include "xmalloc.h"
+#include "gccmacro.h"
/* Make sure not to allocate more than this much memory. */
#define MAX_ALLOC_SIZE (1024*1024*20) /* 20MB */
@@ -40,6 +42,8 @@
/* #undef strndup */
/* #undef strdup */
+static void oom(void) PA_GCC_NORETURN;
+
/** called in case of an OOM situation. Prints an error message and
* exits */
static void oom(void) {
diff --git a/polyp/xmalloc.h b/polyp/xmalloc.h
index b37ece90..2946011a 100644
--- a/polyp/xmalloc.h
+++ b/polyp/xmalloc.h
@@ -24,6 +24,8 @@
#include <sys/types.h>
#include <stdlib.h>
+#include <limits.h>
+#include <assert.h>
void* pa_xmalloc(size_t l);
void *pa_xmalloc0(size_t l);
@@ -35,4 +37,22 @@ char *pa_xstrndup(const char *s, size_t l);
void* pa_xmemdup(const void *p, size_t l);
+/** Internal helper for pa_xnew() */
+static inline void* pa_xnew_internal(unsigned n, size_t k) {
+ assert(n < INT_MAX/k);
+ return pa_xmalloc(n*k);
+}
+
+/** Allocate n new structures of the specified type. */
+#define pa_xnew(type, n) ((type*) pa_xnew_internal((n), sizeof(type)))
+
+/** Internal helper for pa_xnew0() */
+static inline void* pa_xnew0_internal(unsigned n, size_t k) {
+ assert(n < INT_MAX/k);
+ return pa_xmalloc0(n*k);
+}
+
+/** Same as pa_xnew() but set the memory to zero */
+#define pa_xnew0(type, n) ((type*) pa_xnew0_internal((n), sizeof(type)))
+
#endif