summaryrefslogtreecommitdiffstats
path: root/src/pulsecore/core.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pulsecore/core.c')
-rw-r--r--src/pulsecore/core.c73
1 files changed, 50 insertions, 23 deletions
diff --git a/src/pulsecore/core.c b/src/pulsecore/core.c
index 31b6c188..e9008833 100644
--- a/src/pulsecore/core.c
+++ b/src/pulsecore/core.c
@@ -27,7 +27,6 @@
#endif
#include <stdlib.h>
-#include <assert.h>
#include <stdio.h>
#include <signal.h>
@@ -45,12 +44,36 @@
#include <pulsecore/props.h>
#include <pulsecore/random.h>
#include <pulsecore/log.h>
+#include <pulsecore/macro.h>
#include "core.h"
+static PA_DEFINE_CHECK_TYPE(pa_core, pa_msgobject);
+
+static int core_process_msg(pa_msgobject *o, int code, void *userdata, int64_t offset, pa_memchunk *chunk) {
+ pa_core *c = PA_CORE(o);
+
+ pa_core_assert_ref(c);
+
+ switch (code) {
+
+ case PA_CORE_MESSAGE_UNLOAD_MODULE:
+ pa_module_unload(c, userdata);
+ return 0;
+
+ default:
+ return -1;
+ }
+}
+
+static void core_free(pa_object *o);
+
pa_core* pa_core_new(pa_mainloop_api *m, int shared) {
pa_core* c;
pa_mempool *pool;
+ int j;
+
+ pa_assert(m);
if (shared) {
if (!(pool = pa_mempool_new(shared))) {
@@ -66,7 +89,9 @@ pa_core* pa_core_new(pa_mainloop_api *m, int shared) {
}
}
- c = pa_xnew(pa_core, 1);
+ c = pa_msgobject_new(pa_core);
+ c->parent.parent.free = core_free;
+ c->parent.process_msg = core_process_msg;
c->mainloop = m;
c->clients = pa_idxset_new(NULL, NULL);
@@ -87,6 +112,8 @@ pa_core* pa_core_new(pa_mainloop_api *m, int shared) {
c->default_sample_spec.format = PA_SAMPLE_S16NE;
c->default_sample_spec.rate = 44100;
c->default_sample_spec.channels = 2;
+ c->default_n_fragments = 4;
+ c->default_fragment_size_msec = 25;
c->module_auto_unload_event = NULL;
c->module_defer_unload_event = NULL;
@@ -99,22 +126,21 @@ pa_core* pa_core_new(pa_mainloop_api *m, int shared) {
c->mempool = pool;
- c->disallow_module_loading = 0;
-
c->quit_event = NULL;
c->exit_idle_time = -1;
c->module_idle_time = 20;
c->scache_idle_time = 20;
- c->resample_method = PA_RESAMPLER_SRC_SINC_FASTEST;
+ c->resample_method = PA_RESAMPLER_SPEEX_FLOAT_BASE;
c->is_system_instance = 0;
+ c->disallow_module_loading = 0;
+ c->high_priority = 0;
+
- pa_hook_init(&c->hook_sink_input_new, c);
- pa_hook_init(&c->hook_sink_disconnect, c);
- pa_hook_init(&c->hook_source_output_new, c);
- pa_hook_init(&c->hook_source_disconnect, c);
+ for (j = 0; j < PA_CORE_HOOK_MAX; j++)
+ pa_hook_init(&c->hooks[j], c);
pa_property_init(c);
@@ -123,28 +149,31 @@ pa_core* pa_core_new(pa_mainloop_api *m, int shared) {
#ifdef SIGPIPE
pa_check_signal_is_blocked(SIGPIPE);
#endif
+
return c;
}
-void pa_core_free(pa_core *c) {
- assert(c);
+static void core_free(pa_object *o) {
+ pa_core *c = PA_CORE(o);
+ int j;
+ pa_assert(c);
pa_module_unload_all(c);
- assert(!c->modules);
+ pa_assert(!c->modules);
- assert(pa_idxset_isempty(c->clients));
+ pa_assert(pa_idxset_isempty(c->clients));
pa_idxset_free(c->clients, NULL, NULL);
- assert(pa_idxset_isempty(c->sinks));
+ pa_assert(pa_idxset_isempty(c->sinks));
pa_idxset_free(c->sinks, NULL, NULL);
- assert(pa_idxset_isempty(c->sources));
+ pa_assert(pa_idxset_isempty(c->sources));
pa_idxset_free(c->sources, NULL, NULL);
- assert(pa_idxset_isempty(c->source_outputs));
+ pa_assert(pa_idxset_isempty(c->source_outputs));
pa_idxset_free(c->source_outputs, NULL, NULL);
- assert(pa_idxset_isempty(c->sink_inputs));
+ pa_assert(pa_idxset_isempty(c->sink_inputs));
pa_idxset_free(c->sink_inputs, NULL, NULL);
pa_scache_free(c);
@@ -162,23 +191,21 @@ void pa_core_free(pa_core *c) {
pa_property_cleanup(c);
- pa_hook_free(&c->hook_sink_input_new);
- pa_hook_free(&c->hook_sink_disconnect);
- pa_hook_free(&c->hook_source_output_new);
- pa_hook_free(&c->hook_source_disconnect);
+ for (j = 0; j < PA_CORE_HOOK_MAX; j++)
+ pa_hook_free(&c->hooks[j]);
pa_xfree(c);
}
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);
+ pa_assert(c->quit_event == e);
m->quit(m, 0);
}
void pa_core_check_quit(pa_core *c) {
- assert(c);
+ pa_assert(c);
if (!c->quit_event && c->exit_idle_time >= 0 && pa_idxset_size(c->clients) == 0) {
struct timeval tv;