From f44ba092651aa75055e109e04b4164ea92ae7fdc Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 19 Jun 2006 21:53:48 +0000 Subject: big s/polyp/pulse/g git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1033 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/pulsecore/core.c | 160 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100644 src/pulsecore/core.c (limited to 'src/pulsecore/core.c') diff --git a/src/pulsecore/core.c b/src/pulsecore/core.c new file mode 100644 index 00000000..7c780ea8 --- /dev/null +++ b/src/pulsecore/core.c @@ -0,0 +1,160 @@ +/* $Id$ */ + +/*** + This file is part of PulseAudio. + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + USA. +***/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "core.h" + +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); + c->sinks = pa_idxset_new(NULL, NULL); + c->sources = pa_idxset_new(NULL, NULL); + c->source_outputs = pa_idxset_new(NULL, NULL); + c->sink_inputs = pa_idxset_new(NULL, NULL); + + c->default_source_name = c->default_sink_name = NULL; + + c->modules = NULL; + c->namereg = NULL; + c->scache = NULL; + c->autoload_idxset = NULL; + c->autoload_hashmap = NULL; + c->running_as_daemon = 0; + + c->default_sample_spec.format = PA_SAMPLE_S16NE; + c->default_sample_spec.rate = 44100; + c->default_sample_spec.channels = 2; + + c->module_auto_unload_event = NULL; + c->module_defer_unload_event = NULL; + c->scache_auto_unload_event = NULL; + + c->subscription_defer_event = NULL; + c->subscription_event_queue = NULL; + c->subscriptions = NULL; + + c->memblock_stat = pa_memblock_stat_new(); + + 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; + + pa_property_init(c); + + pa_random(&c->cookie, sizeof(c->cookie)); + +#ifdef SIGPIPE + pa_check_signal_is_blocked(SIGPIPE); +#endif + return c; +} + +void pa_core_free(pa_core *c) { + assert(c); + + pa_module_unload_all(c); + assert(!c->modules); + + assert(pa_idxset_isempty(c->clients)); + pa_idxset_free(c->clients, NULL, NULL); + + assert(pa_idxset_isempty(c->sinks)); + pa_idxset_free(c->sinks, NULL, NULL); + + assert(pa_idxset_isempty(c->sources)); + pa_idxset_free(c->sources, NULL, NULL); + + assert(pa_idxset_isempty(c->source_outputs)); + pa_idxset_free(c->source_outputs, NULL, NULL); + + assert(pa_idxset_isempty(c->sink_inputs)); + pa_idxset_free(c->sink_inputs, NULL, NULL); + + pa_scache_free(c); + pa_namereg_free(c); + pa_autoload_free(c); + pa_subscription_free_all(c); + + if (c->quit_event) + c->mainloop->time_free(c->quit_event); + + pa_xfree(c->default_source_name); + pa_xfree(c->default_sink_name); + + pa_memblock_stat_unref(c->memblock_stat); + + pa_property_cleanup(c); + + 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); + + m->quit(m, 0); +} + +void pa_core_check_quit(pa_core *c) { + assert(c); + + 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_size(c->clients) > 0) { + c->mainloop->time_free(c->quit_event); + c->quit_event = NULL; + } +} + -- cgit From 9c87a65ce91c38b60c19ae108a51a2e8ce46a85c Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 19 Jul 2006 17:44:19 +0000 Subject: * add new --system command line parameter to the daemon for running PulseAudio as system-wide instance * add PA_ prefixes to all global #defines * modify auth-by-creds: define a new group "pulse-access" which is used for authentication * add proper privilige dropping when running in --system mode * create runtime directory once on startup and not by each module seperately git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1105 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/pulsecore/core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/pulsecore/core.c') diff --git a/src/pulsecore/core.c b/src/pulsecore/core.c index 7c780ea8..d6af3ca9 100644 --- a/src/pulsecore/core.c +++ b/src/pulsecore/core.c @@ -46,7 +46,8 @@ pa_core* pa_core_new(pa_mainloop_api *m) { pa_core* c; - c = pa_xmalloc(sizeof(pa_core)); + + c = pa_xnew(pa_core, 1); c->mainloop = m; c->clients = pa_idxset_new(NULL, NULL); @@ -88,6 +89,8 @@ pa_core* pa_core_new(pa_mainloop_api *m) { c->resample_method = PA_RESAMPLER_SRC_SINC_FASTEST; + c->is_system_instance = 0; + pa_property_init(c); pa_random(&c->cookie, sizeof(c->cookie)); -- cgit From 47d009afd69612aa97fd368fd481734f1c52909a Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sat, 12 Aug 2006 02:18:24 +0000 Subject: rework subscription code: try to drop redundant queued events git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1211 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/pulsecore/core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/pulsecore/core.c') diff --git a/src/pulsecore/core.c b/src/pulsecore/core.c index d6af3ca9..710e00ad 100644 --- a/src/pulsecore/core.c +++ b/src/pulsecore/core.c @@ -74,8 +74,9 @@ pa_core* pa_core_new(pa_mainloop_api *m) { c->scache_auto_unload_event = NULL; c->subscription_defer_event = NULL; - c->subscription_event_queue = NULL; - c->subscriptions = NULL; + PA_LLIST_HEAD_INIT(pa_subscription, c->subscriptions); + PA_LLIST_HEAD_INIT(pa_subscription_event, c->subscription_event_queue); + c->subscription_event_last = NULL; c->memblock_stat = pa_memblock_stat_new(); -- cgit From a621d9028548723d13df64df06a4f4538504e7a3 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sun, 13 Aug 2006 16:19:56 +0000 Subject: allow hooking into the process of creating playback streams. To implement this I modified the pa_sink_input_new() signature to take a pa_sink_input_new_data structure instead of direct arguments. git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1237 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/pulsecore/core.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/pulsecore/core.c') diff --git a/src/pulsecore/core.c b/src/pulsecore/core.c index 710e00ad..24f835f7 100644 --- a/src/pulsecore/core.c +++ b/src/pulsecore/core.c @@ -92,6 +92,9 @@ pa_core* pa_core_new(pa_mainloop_api *m) { c->is_system_instance = 0; + pa_hook_init(&c->hook_sink_input_new, c); + pa_hook_init(&c->hook_sink_input_disconnect, c); + pa_property_init(c); pa_random(&c->cookie, sizeof(c->cookie)); @@ -137,6 +140,9 @@ void pa_core_free(pa_core *c) { pa_memblock_stat_unref(c->memblock_stat); pa_property_cleanup(c); + + pa_hook_free(&c->hook_sink_input_new); + pa_hook_free(&c->hook_sink_input_disconnect); pa_xfree(c); } -- cgit From 818083289882e8739bbfaefd1edb252ed5629771 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sun, 13 Aug 2006 17:33:32 +0000 Subject: properly implement a pa_sink_disconnect() hook git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1243 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/pulsecore/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/pulsecore/core.c') diff --git a/src/pulsecore/core.c b/src/pulsecore/core.c index 24f835f7..50d79fbf 100644 --- a/src/pulsecore/core.c +++ b/src/pulsecore/core.c @@ -93,7 +93,7 @@ pa_core* pa_core_new(pa_mainloop_api *m) { c->is_system_instance = 0; pa_hook_init(&c->hook_sink_input_new, c); - pa_hook_init(&c->hook_sink_input_disconnect, c); + pa_hook_init(&c->hook_sink_disconnect, c); pa_property_init(c); @@ -142,7 +142,7 @@ 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_input_disconnect); + pa_hook_free(&c->hook_sink_disconnect); pa_xfree(c); } -- cgit From 8f91b1f4c4b47997ce4bfd70dc4e0f7fffe58a35 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sun, 13 Aug 2006 19:52:43 +0000 Subject: define new hooks: hook_source_output_new, hook_source_disconnect git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1247 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/pulsecore/core.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/pulsecore/core.c') diff --git a/src/pulsecore/core.c b/src/pulsecore/core.c index 50d79fbf..7f2f0f60 100644 --- a/src/pulsecore/core.c +++ b/src/pulsecore/core.c @@ -94,6 +94,8 @@ pa_core* pa_core_new(pa_mainloop_api *m) { 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); pa_property_init(c); @@ -143,6 +145,8 @@ void pa_core_free(pa_core *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); pa_xfree(c); } -- cgit From 0e436a6926af56f37a74a03bb5e143e078ca0d55 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 18 Aug 2006 19:55:18 +0000 Subject: Rework memory management to allow shared memory data transfer. The central idea is to allocate all audio memory blocks from a per-process memory pool which is available as read-only SHM segment to other local processes. Then, instead of writing the actual audio data to the socket just write references to this shared memory pool. To work optimally all memory blocks should now be of type PA_MEMBLOCK_POOL or PA_MEMBLOCK_POOL_EXTERNAL. The function pa_memblock_new() now generates memory blocks of this type by default. git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1266 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/pulsecore/core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/pulsecore/core.c') diff --git a/src/pulsecore/core.c b/src/pulsecore/core.c index 7f2f0f60..5fdeab56 100644 --- a/src/pulsecore/core.c +++ b/src/pulsecore/core.c @@ -44,7 +44,7 @@ #include "core.h" -pa_core* pa_core_new(pa_mainloop_api *m) { +pa_core* pa_core_new(pa_mainloop_api *m, int shared) { pa_core* c; c = pa_xnew(pa_core, 1); @@ -78,7 +78,7 @@ pa_core* pa_core_new(pa_mainloop_api *m) { PA_LLIST_HEAD_INIT(pa_subscription_event, c->subscription_event_queue); c->subscription_event_last = NULL; - c->memblock_stat = pa_memblock_stat_new(); + c->mempool = pa_mempool_new(shared); c->disallow_module_loading = 0; @@ -139,7 +139,7 @@ void pa_core_free(pa_core *c) { pa_xfree(c->default_source_name); pa_xfree(c->default_sink_name); - pa_memblock_stat_unref(c->memblock_stat); + pa_mempool_free(c->mempool); pa_property_cleanup(c); -- cgit From 046bdd9b30d10a18d21890f7975a8ca268cdfeeb Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sat, 19 Aug 2006 01:15:48 +0000 Subject: deal properly with pa_mempool_new() failing git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1282 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/pulsecore/core.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/pulsecore/core.c') diff --git a/src/pulsecore/core.c b/src/pulsecore/core.c index 5fdeab56..c36a35bd 100644 --- a/src/pulsecore/core.c +++ b/src/pulsecore/core.c @@ -46,7 +46,11 @@ pa_core* pa_core_new(pa_mainloop_api *m, int shared) { pa_core* c; - + pa_mempool *pool; + + if (!(pool = pa_mempool_new(shared))) + return NULL; + c = pa_xnew(pa_core, 1); c->mainloop = m; @@ -78,7 +82,7 @@ pa_core* pa_core_new(pa_mainloop_api *m, int shared) { PA_LLIST_HEAD_INIT(pa_subscription_event, c->subscription_event_queue); c->subscription_event_last = NULL; - c->mempool = pa_mempool_new(shared); + c->mempool = pool; c->disallow_module_loading = 0; -- cgit From 26bfce6281f475d04f122dee6a711c7c00496614 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Tue, 22 Aug 2006 12:46:05 +0000 Subject: Improve error messages a bit. git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1320 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/pulsecore/core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/pulsecore/core.c') diff --git a/src/pulsecore/core.c b/src/pulsecore/core.c index c36a35bd..1a7382e5 100644 --- a/src/pulsecore/core.c +++ b/src/pulsecore/core.c @@ -41,6 +41,7 @@ #include #include #include +#include #include "core.h" @@ -48,8 +49,10 @@ pa_core* pa_core_new(pa_mainloop_api *m, int shared) { pa_core* c; pa_mempool *pool; - if (!(pool = pa_mempool_new(shared))) + if (!(pool = pa_mempool_new(shared))) { + pa_log("pa_mempool_new() failed."); return NULL; + } c = pa_xnew(pa_core, 1); -- cgit From 7bf25407789a99eec9d77ec8b9f9ece8abe49589 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Tue, 22 Aug 2006 12:51:29 +0000 Subject: Fall back to creating a "normal" memory pool if unable to get a shared one. git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1321 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/pulsecore/core.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/pulsecore/core.c') diff --git a/src/pulsecore/core.c b/src/pulsecore/core.c index 1a7382e5..3b6434d7 100644 --- a/src/pulsecore/core.c +++ b/src/pulsecore/core.c @@ -49,11 +49,20 @@ pa_core* pa_core_new(pa_mainloop_api *m, int shared) { pa_core* c; pa_mempool *pool; - if (!(pool = pa_mempool_new(shared))) { - pa_log("pa_mempool_new() failed."); - return NULL; + if (shared) { + if (!(pool = pa_mempool_new(shared))) { + pa_log_warn("failed to allocate shared memory pool. Falling back to a normal memory pool."); + shared = 0; + } + } + + if (!shared) { + if (!(pool = pa_mempool_new(shared))) { + pa_log("pa_mempool_new() failed."); + return NULL; + } } - + c = pa_xnew(pa_core, 1); c->mainloop = m; -- cgit From ead67cda48f58ad8d1f53ce2c32e3b500dfc5a19 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 6 Sep 2006 22:19:11 +0000 Subject: fix indentation git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1375 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/pulsecore/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/pulsecore/core.c') diff --git a/src/pulsecore/core.c b/src/pulsecore/core.c index 3b6434d7..63ee60ca 100644 --- a/src/pulsecore/core.c +++ b/src/pulsecore/core.c @@ -58,10 +58,10 @@ pa_core* pa_core_new(pa_mainloop_api *m, int shared) { if (!shared) { if (!(pool = pa_mempool_new(shared))) { - pa_log("pa_mempool_new() failed."); + pa_log("pa_mempool_new() failed."); return NULL; } - } + } c = pa_xnew(pa_core, 1); -- cgit From 521daf6f0ac4fa6a2fbfb5d523c0c743342dca2b Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Thu, 4 Jan 2007 13:43:45 +0000 Subject: Huge trailing whitespace cleanup. Let's keep the tree pure from here on, mmmkay? git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1418 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/pulsecore/core.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/pulsecore/core.c') diff --git a/src/pulsecore/core.c b/src/pulsecore/core.c index 63ee60ca..b19b1974 100644 --- a/src/pulsecore/core.c +++ b/src/pulsecore/core.c @@ -2,17 +2,17 @@ /*** This file is part of PulseAudio. - + PulseAudio is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + PulseAudio is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with PulseAudio; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -116,7 +116,7 @@ pa_core* pa_core_new(pa_mainloop_api *m, int shared) { pa_property_init(c); pa_random(&c->cookie, sizeof(c->cookie)); - + #ifdef SIGPIPE pa_check_signal_is_blocked(SIGPIPE); #endif @@ -131,16 +131,16 @@ void pa_core_free(pa_core *c) { assert(pa_idxset_isempty(c->clients)); pa_idxset_free(c->clients, NULL, NULL); - + assert(pa_idxset_isempty(c->sinks)); pa_idxset_free(c->sinks, NULL, NULL); assert(pa_idxset_isempty(c->sources)); pa_idxset_free(c->sources, NULL, NULL); - + assert(pa_idxset_isempty(c->source_outputs)); pa_idxset_free(c->source_outputs, NULL, NULL); - + assert(pa_idxset_isempty(c->sink_inputs)); pa_idxset_free(c->sink_inputs, NULL, NULL); @@ -163,8 +163,8 @@ void pa_core_free(pa_core *c) { pa_hook_free(&c->hook_sink_disconnect); pa_hook_free(&c->hook_source_output_new); pa_hook_free(&c->hook_source_disconnect); - - pa_xfree(c); + + pa_xfree(c); } static void quit_callback(pa_mainloop_api*m, pa_time_event *e, PA_GCC_UNUSED const struct timeval *tv, void *userdata) { -- cgit From 06211b7c8fd329137ae9003818543912a87d9898 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Tue, 13 Feb 2007 15:35:19 +0000 Subject: Add copyright notices to all relevant files. (based on svn log) git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1426 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/pulsecore/core.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/pulsecore/core.c') diff --git a/src/pulsecore/core.c b/src/pulsecore/core.c index b19b1974..31b6c188 100644 --- a/src/pulsecore/core.c +++ b/src/pulsecore/core.c @@ -3,6 +3,9 @@ /*** This file is part of PulseAudio. + Copyright 2004-2006 Lennart Poettering + Copyright 2006 Pierre Ossman for Cendio AB + PulseAudio is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, -- cgit From a67c21f093202f142438689d3f7cfbdf4ea82eea Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sun, 28 Oct 2007 19:13:50 +0000 Subject: merge 'lennart' branch back into trunk. git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1971 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/pulsecore/core.c | 73 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 50 insertions(+), 23 deletions(-) (limited to 'src/pulsecore/core.c') 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 -#include #include #include @@ -45,12 +44,36 @@ #include #include #include +#include #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; -- cgit From 1c0690776d45c50b90df037669b4dbfe0467ca8a Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 29 Oct 2007 08:34:30 +0000 Subject: make speex-float-3 the default resampler git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1973 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/pulsecore/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/pulsecore/core.c') diff --git a/src/pulsecore/core.c b/src/pulsecore/core.c index e9008833..e67f15b5 100644 --- a/src/pulsecore/core.c +++ b/src/pulsecore/core.c @@ -132,7 +132,7 @@ pa_core* pa_core_new(pa_mainloop_api *m, int shared) { c->module_idle_time = 20; c->scache_idle_time = 20; - c->resample_method = PA_RESAMPLER_SPEEX_FLOAT_BASE; + c->resample_method = PA_RESAMPLER_SPEEX_FLOAT_BASE + 3; c->is_system_instance = 0; c->disallow_module_loading = 0; -- cgit From 7bfd1b2f01613dd14b9ca478ae530c1641aa46a1 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 1 Nov 2007 02:58:26 +0000 Subject: make rtprio and nice level actually configurable git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@2014 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/pulsecore/core.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/pulsecore/core.c') diff --git a/src/pulsecore/core.c b/src/pulsecore/core.c index e67f15b5..9b420c94 100644 --- a/src/pulsecore/core.c +++ b/src/pulsecore/core.c @@ -107,7 +107,7 @@ pa_core* pa_core_new(pa_mainloop_api *m, int shared) { c->scache = NULL; c->autoload_idxset = NULL; c->autoload_hashmap = NULL; - c->running_as_daemon = 0; + c->running_as_daemon = FALSE; c->default_sample_spec.format = PA_SAMPLE_S16NE; c->default_sample_spec.rate = 44100; @@ -134,10 +134,10 @@ pa_core* pa_core_new(pa_mainloop_api *m, int shared) { c->resample_method = PA_RESAMPLER_SPEEX_FLOAT_BASE + 3; - c->is_system_instance = 0; - c->disallow_module_loading = 0; - c->high_priority = 0; - + c->is_system_instance = FALSE; + c->disallow_module_loading = FALSE; + c->realtime_scheduling = FALSE; + c->realtime_priority = 5; for (j = 0; j < PA_CORE_HOOK_MAX; j++) pa_hook_init(&c->hooks[j], c); @@ -217,4 +217,3 @@ void pa_core_check_quit(pa_core *c) { c->quit_event = NULL; } } - -- cgit From 14a9b80afbb0bddc216462b72156f14e032e1b5e Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 21 Nov 2007 01:30:40 +0000 Subject: - Check process name when dealing with PID files - Add new PA_STREAM_FIX_CHANNELS, FIX_RATE, FIX_FORMAT, DONT_MOVE, VARIABLE_RATES to pa_sream_flags_t adn implement it - Expose those flags in pacat - Add notifications about device suspend/resume to the protocol and expose them in libpulse - Allow changing of buffer_attr during playback - allow disabling for remixing globally - hookup polkit support git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@2067 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/pulsecore/core.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/pulsecore/core.c') diff --git a/src/pulsecore/core.c b/src/pulsecore/core.c index 9b420c94..cf018509 100644 --- a/src/pulsecore/core.c +++ b/src/pulsecore/core.c @@ -138,6 +138,7 @@ pa_core* pa_core_new(pa_mainloop_api *m, int shared) { c->disallow_module_loading = FALSE; c->realtime_scheduling = FALSE; c->realtime_priority = 5; + c->disable_remixing = FALSE; for (j = 0; j < PA_CORE_HOOK_MAX; j++) pa_hook_init(&c->hooks[j], c); -- cgit